Jump to content
Software FX Community

How to handle a pie chart when the user enters all Zeros

User (Legacy)

Recommended Posts

additional info:

- This only happens for Pie charts, Bar charts are ok with all 0


- I tried the constant Chart.Hidden for the value if it is set to 0

but still blows up with the same exception listed below.

- When a data point value is updated by the user we always clear the

chart data and reload all the values.

"Bill Large" <largewi@wi.rr.com> wrote in message


> We are expereincing a problem with the chart when all the data points are


> The chart crashes with a "divide by zero" exception.


> We noticed that when using your data editor it works fine. We are using a

> custom data editor and do not understand why this is happening. Any

> suggestions?


> Thank you


> Bill Large

> Metavante



Link to comment
Share on other sites

I tried the following:


chart1.Gallery = Gallery.Pie;

chart1.OpenData(COD.Values | COD.AllocHidden,n1,n2);

for (j = 0; j < n2; j++) {

for (i = 0; i < n1; i++)

chart1.Value[i,j] = 0;}


And got no crash. Can you lease post/send some code that reproduces this




Software FX, Inc.

Link to comment
Share on other sites

Ok here is the code that causes this:

SoftwareFX.ChartFX.GalleryObj.Pie pie = null;

pie = (SoftwareFX.ChartFX.GalleryObj.Pie)chart1.GalleryObj;

pie.LabelsInside = false;

chart1.PointLabelMask = "%l";

chart1.PointLabels = true;


chart1.Value[0,0] =0;

chart1.Value[0,1] =0;

chart1.Value[0,2] =0;

chart1.Value[0,3] =0;

chart1.Value[0,4] =0;

chart1.Legend[0] = "1";

chart1.Legend[1] = "2";

chart1.Legend[2] = "3";

chart1.Legend[3] = "4";

chart1.Legend[4] = "5";

chart1.Point[0, 0].SeparateSlice = 0;

chart1.Point[0, 1].SeparateSlice = 0;

chart1.Point[0, 2].SeparateSlice = 0;

chart1.Point[0, 3].SeparateSlice = 0;

chart1.Point[0, 4].SeparateSlice = 0;

chart1.Point[0, 0].Color = Color.Black;

chart1.Point[0, 1].Color = Color.Wheat;

chart1.Point[0, 2].Color = Color.Blue;

chart1.Point[0, 3].Color = Color.Green;

chart1.Point[0, 4].Color = Color.Aqua;


MemoryStream stream = new MemoryStream();

chart1.Export(FileFormat.Bitmap, stream);

It appears that with PointLabels turned on and then trying to export the

chart to a stream causes it to blow up.

Link to comment
Share on other sites


This topic is now archived and is closed to further replies.

  • Create New...