Hi Alan,
Thanks for contacting Syncfusion Support.
We have achieved your requirement (toggle between the series YAxis and chart secondary axis) with checkbox by applying null for series YAxis as shown in below code.
Please find the code snippet,
C#
public partial class MainWindow : Window
{
NumericalAxis axis1;
NumericalAxis axis2;
NumericalAxis axis3;
public MainWindow()
{
InitializeComponent();
axis1 = new NumericalAxis()
{
Interval = 10,
Foreground = chart.Series[0].Interior ,
Minimum = 10,
ShowGridLines = false
};
axis2 = new NumericalAxis()
{
Interval = 10,
Foreground = chart.Series[1].Interior,
Minimum = 10,
ShowGridLines = false
};
axis3 = new NumericalAxis()
{
Interval = 10,
Foreground = chart.Series[2].Interior,
Minimum = 10,
ShowGridLines = false
};
}
private void CheckBox_Checked(object sender, RoutedEventArgs e)
{
if(chart.SecondaryAxis.Visibility != Visibility.Visible)
{
chart.SecondaryAxis.Visibility = Visibility.Visible;
line1.YAxis = null;
line2.YAxis = null;
line3.YAxis = null;
}
}
private void CheckBox_Unchecked(object sender, RoutedEventArgs e)
{
chart.SecondaryAxis.Visibility = Visibility.Collapsed;
line1.YAxis = axis1;
line2.YAxis = axis2;
line3.YAxis = axis3;
}
} |
Please find the output screenshot,
Series with chart secondary axis,
Series with its YAxis
We have prepared a demo sample for reference and it can be downloaded from below link,
Regards,
Devi