1

I am using the MS Chart Control in a Windows application.

I am charting various series dynamically and the user can specify which charttype each series should be. This leads to situations where pie charts are combined with line/spline charts etc..

When at least one series is specified to be a pie chart, I am dynamically adding chartareas and legends to give each of these series their own chartarea, while all the "basic" charttypes (line(area)/spline(area)/etc.) are combined into a single chartarea.

The issue is that when adding 10+ series where the majority are pie charts, the charts are resized so small, they become useless. My thought was to dynamically increase the size of the chart control (thereby increasing the size of all chartareas within). My issue is, the width and height of the InnerPlotPosition are always zero unless I set them explicitly.

Is there any way to determine the size of the Plotting Area in pixels or percentage (which I could multiply by the chart controls size to get pixels), etc. even if not explicitly set? This would allow me to increase the chart controls size until some minimum ( and hopefully, readable) value was reached.

Jason Kibble
  • 2,647
  • 2
  • 18
  • 7

1 Answers1

1

I find that InnerPlotPosition is set at least in a PostPaint event callback. You may be checking that property before the Plot Area has been calculated.

This works:

var c = new Chart();
c.PostPaint += c_PostPaint;
// Do whatever to setup the chart
// Then in my case I'm saving the image which causes rendering
c.SaveImage(myFileName);


void c_PostPaint(object sender, ChartPaintEventArgs e)
{
    var ipp = e.Chart.ChartAreas[0].InnerPlotPosition; // Values populated here
}
Eric J.
  • 147,927
  • 63
  • 340
  • 553
  • This is exactly what I asked for, although it seems difficult to resize the control at this point in the rendering process and get it to redraw correctly. It is unfortunate that the Customize event (where I understand things like resizing are meant to happen) that the InnerPlotPosition is not yet determined. In any case, you answered my question. Thanks. – Jason Kibble Jun 11 '13 at 20:20