Jump to content
Software FX Community

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


Recommended Posts

additional info:

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

values.

- 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

news:gTNqMeYZCHA.3136@webserver1.softwarefx.com...

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

0.

> 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 post
Share on other sites

I tried the following:

chart1.AxisY.ResetScale();

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;}

chart1.CloseData(COD.Values);

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

problem

--

FP

Software FX, Inc.

Link to post
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.OpenData(SoftwareFX.ChartFX.COD.Values,1,5);

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;

chart1.CloseData(SoftwareFX.ChartFX.COD.Values);

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 post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...