locked
Side by side chart areas RRS feed

  • Question

  • I am trying to put two pie chart side by side but am having problems. I can set the x and y position of each chart Area but I cannot make the actual control the size I want without messing up the chart area size. Here is the steps I do. Start with two pie chart one on top of the other. I mess with the botom chart area x\y positon so it is right of the other. I now have the one which was on top, now the leftmost chart area and the one which was on the bottom, the now rightmost chart. Here I face the first problem the chart which I moved from the bottom to the right is now quite smaller the it's original size. How do I make both chart the same size? My second issue is the empty white space where the bottom chart used to be. If I try and resize the chart control it shrinks both pie charts. I need help in trying to figure this out. Thank you very much.
    Wednesday, February 25, 2009 6:50 AM

Answers

  • Setting ChartArea.Position property to the same Width and Height should produce Pie charts of the same size, unless you display labels and they are placed outside of the pie. In that case chart will shrink the Pie to alow more space for labels. The easiest solution is to place labels inside. As an alternative you can set the InnerPlotPosition but you will have to guess how much space labels will need and end up with overlapping labels.

    You can also try Align the plotting areas of the two Chart Areas. If you have to chart areas with names "Area1" and "Area2", here is the code you can use:


    chart.ChartArea["Area2"].AlignmentOrientation = AreaAlignmentOrientation.All;  
    chart.ChartArea["Area2"].AlignmentStyle = AreaAlignmentStyle.PlotPosition;  
    chart.ChartArea["Area2"].AlignWithChartArea = "Area1"


    Alex.
    http://blogs.msdn.com/alexgor
    Thursday, February 26, 2009 4:22 PM

All replies

  • Setting ChartArea.Position property to the same Width and Height should produce Pie charts of the same size, unless you display labels and they are placed outside of the pie. In that case chart will shrink the Pie to alow more space for labels. The easiest solution is to place labels inside. As an alternative you can set the InnerPlotPosition but you will have to guess how much space labels will need and end up with overlapping labels.

    You can also try Align the plotting areas of the two Chart Areas. If you have to chart areas with names "Area1" and "Area2", here is the code you can use:


    chart.ChartArea["Area2"].AlignmentOrientation = AreaAlignmentOrientation.All;  
    chart.ChartArea["Area2"].AlignmentStyle = AreaAlignmentStyle.PlotPosition;  
    chart.ChartArea["Area2"].AlignWithChartArea = "Area1"


    Alex.
    http://blogs.msdn.com/alexgor
    Thursday, February 26, 2009 4:22 PM
  • The problem I'm facing I think is related to the first pie chart (top) always want to be justified center. Thus if I palce the second (bottom) chart to the right it will resize to the width of the space between the top cahrt and its space to the right border. The other issue is I cannot remove the space at the bottom where the bottom chart used to be without affecting the size of both charts. Seems like the are anchored to the top or something. Thank you.
    Thursday, February 26, 2009 7:18 PM
  • I now have both charts side by side and same size. The problem now is that the chart control is huge and I cannot shrink it without affecting the chart's size. Wherever I put them when I shink the chart control it will shrink the chart areas as well.
    Thursday, February 26, 2009 7:50 PM
  • Got'er done! Here's a few tips from my experience unless you know something I don't. To start set the innerPlotPosition to w=100 h=100 x=0 y=0. Now you only have to deal with the chart area position. Now set the chart area background to a color diferent than your control back color. This will help you see wahts happening better. In my case I could see the chart only shrunk once the chart area was getting smaller then the chart itself. Hope this helps others.
    Thursday, February 26, 2009 8:58 PM