I have added 8 Y Axes to my chart.
I want to give the user the ability to uncheck a certain series along with its Y axis.(when a series is in unchecked in the legend box, the corresponding Y axis should also disappear).
I'm using the following piece of code to do so:
Code: Select all
private void LegendBox_CheckBoxStateChanged(MouseItemBase series,bool isChecked)
{
SampleDataSeries s = (SampleDataSeries) series;
View.YAxes[s.AssignYAxisIndex].Visible=isChecked;
}
i tried to change my code to the following:
Code: Select all
private void LegendBox_CheckBoxStateChanged(MouseItemBase series,bool isChecked)
{
SampleDataSeries s = (SampleDataSeries) series;
if (isChecked)
{
View.YAxes.Add(YAxes[s.AssignYAxisIndex]);
}
else
{
View.YAxes.Remove(YAxes[s.AssignYAxisIndex]);
}
}
but i get the following exception:
Note: YAxes[] is an array of AxisY objects.System.Exception: 'Invalid Y axis index'
Note 2: Chart.ViewXY.AxisLayout.YAxesLayout = YAxesLayout.Stacked;
any help is appreciated.