Divide by zero for empty series


If you drop an FNC Chart and a button on a form and then put the following code in the button on click event:

procedure TForm1.Button1Click(Sender: TObject);
 i : integer;
 Chart.Series[0].YValues.AutoUnits := false;
 Chart.Series[0].YValues.MajorUnitSpacing := 1.0; // not required to generate error
 for i := 0 to Chart.Series.Count-1 do

When you call Chart.EndUpdate you get a divide by zero error.
The error happens on line 4014 of VCL.TMSFNCChart.pas because "max" is zero
dv.ValueRadius := PointF((pr.Bottom - pr.Top) / max * JMax / 2, (pr.Bottom - pr.Top) / max * JMax / 2);

Changing the AutoUnits to true avoids the error so I can get around this but setting it to true when I clear and then back to false when I add a point is a bit clunky and causes me difficulties if it started false (i.e. I have to track for each series in each chart...)
Hope you can help/explain so I can get around this more eloquently.



We have tried to reproduce this issue here but are not able to.
Can you perhaps send us a full sample?

Hi Pieter,

Thanks for the quick response.  I have emailed the sample code to support@tmssoftware.com (I mention the title of the post in the subject line).

I look forward to hearing from you.