locked
Legend positioning RRS feed

  • Question

  • Hi,

    I have 14 Series in my graph for sales by type. The first group is the Facts, the second is the Prognosis. You can see it here:


    Q1: I should have to place the Legend somewhere out of this chart, because it always overlaps with the data.
    It only fits as a Table, If I try to place it to the bottom as a Row, it truncates the legend (the first 5 items are visible only)
    How can I move it outside of the columns-area?

    Q2: Is there any possibility to set the X axis to a "brake all texts on space" or "non-breaking-space" mode to have a nicer layout?

    Thanks,

    Balint
    Thursday, December 17, 2009 1:32 PM

Answers

  • Hi,

    I have 14 Series in my graph for sales by type. The first group is the Facts, the second is the Prognosis. You can see it here:


    Q1: I should have to place the Legend somewhere out of this chart, because it always overlaps with the data.
    It only fits as a Table, If I try to place it to the bottom as a Row, it truncates the legend (the first 5 items are visible only)
    How can I move it outside of the columns-area?

    Q2: Is there any possibility to set the X axis to a "brake all texts on space" or "non-breaking-space" mode to have a nicer layout?

    Thanks,

    Balint
    Hi Balint,

    Have you modified the legend's properties itself?  The Windows Forms Chart Control samples has some pretty good info on how to do this.  For instance, doing the following (from the "Legend Style and Auto Positioning" example) will move the legend outside the chart area:

    Chart1.Legends["Default"].InsideChartArea ="";

    You can dock the legend on the side by doing this:

    Chart1.Legends["Default"].Docking = Docking.Right;

    You can certainly manipulate a lot about the legend and the chart area's positioning, specifying how much space each gets and where they start by manipulating the X, Y, Width and Height  Positions properties.

    A cheap fix for getting the text to look nicer (I'm assuming you're talking about how sometimes the text under the column is on two lines and sometimes it is on one) is to manually insert a "\n" where you want that to happen.  Something like "January\nSales" will do the trick, though I suspect there is probably another and possibly better/cleaner way to do that.  But it worked for my test.

    Anyway, I hope I understood what you were asking and that it helped.

    Have a good one!
    Matt

    • Marked as answer by kbalint Saturday, December 19, 2009 8:47 PM
    Friday, December 18, 2009 12:39 PM

All replies

  • Hi,

    I have 14 Series in my graph for sales by type. The first group is the Facts, the second is the Prognosis. You can see it here:


    Q1: I should have to place the Legend somewhere out of this chart, because it always overlaps with the data.
    It only fits as a Table, If I try to place it to the bottom as a Row, it truncates the legend (the first 5 items are visible only)
    How can I move it outside of the columns-area?

    Q2: Is there any possibility to set the X axis to a "brake all texts on space" or "non-breaking-space" mode to have a nicer layout?

    Thanks,

    Balint
    Hi Balint,

    Have you modified the legend's properties itself?  The Windows Forms Chart Control samples has some pretty good info on how to do this.  For instance, doing the following (from the "Legend Style and Auto Positioning" example) will move the legend outside the chart area:

    Chart1.Legends["Default"].InsideChartArea ="";

    You can dock the legend on the side by doing this:

    Chart1.Legends["Default"].Docking = Docking.Right;

    You can certainly manipulate a lot about the legend and the chart area's positioning, specifying how much space each gets and where they start by manipulating the X, Y, Width and Height  Positions properties.

    A cheap fix for getting the text to look nicer (I'm assuming you're talking about how sometimes the text under the column is on two lines and sometimes it is on one) is to manually insert a "\n" where you want that to happen.  Something like "January\nSales" will do the trick, though I suspect there is probably another and possibly better/cleaner way to do that.  But it worked for my test.

    Anyway, I hope I understood what you were asking and that it helped.

    Have a good one!
    Matt

    • Marked as answer by kbalint Saturday, December 19, 2009 8:47 PM
    Friday, December 18, 2009 12:39 PM
  • Hi Matt,

    1) you were right: I've just copied a badly formatted <asp:ChartArea> all though my project with a wrongly set <position> node.
    2) thanks, I'm going with the \n version!

    b.
    Saturday, December 19, 2009 8:47 PM
  • You're welcome.
    Tuesday, December 22, 2009 11:55 AM