Nevron Forum

Axes Issues

https://www.nevron.com/Forum/Topic7477.aspx

By Pedram . - Wednesday, February 20, 2013

I have a few questions with regards to Axes.

1) When is NAxis.IsUsed updated? For example, if I do Chart.Series.Clear() to clear all Series from the chart, I expect all the axes on the chart to immediately update and IsUsed == false. However it takes "time" for that to be updated, and if I have immediate code checking IsUsed==true. If I run this code "later", ie after a button press, they will be updated and IsUsed will correctly be false;.

ie

(assuming there is an axis with axis.axisid=5)
......
Chart.Series.Clear
List NotUsedAxes = new List();
foreach(NAxis axis in Chart.Axes)
{
if(!axis.IsUsed && axis.AxisId>4)
NotUsedAxes.Add(axis);
}

foreach(NAxis axis in NotUsedAxes)
Chart.Axes.Remove(axis);
.........

the expected result is that axis.axisId==5 should have axis.IsUsed = false; but is true and doesn't get removed.

2)

If I run the above code at a "later" time, and open the Chart Editor from the ChartCommandBar I get an exception, relating to Nevron.Chart.NSeriesBase.IsDisplayedOnAxis(Int32 axisId). I think there may be some coherence issue and I've included the stacktrace in the attached file.

In summary, what's the best way to remove an axis from the chart that may have a Series on it?
By Nevron Support - Thursday, February 21, 2013

Hi Pedram,

1. The axis IsUsed property is a calculated property and is not immediately updated - you can force the property to update by calling the chart control document Calculate method:
nChartControl1.Document.Calculate();

2. Most likely the control document is left damaged by this operation because you removed custom axes, but obviously there are series that scale on them. To correct the problem you also need to loop through the series and turn off their display on axis property for each removed axis id.

Hope this helps - let us know if you meet any problems...