We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Toggle multiple Axes on/off

Thread ID:

Created:

Updated:

Platform:

Replies:

129806 Apr 4,2017 05:41 PM UTC Apr 5,2017 10:33 AM UTC WPF 1
loading
Tags: SfChart
Alan L
Asked On April 4, 2017 05:41 PM UTC

I have a chart with 3 series, graphed from a common SfChart's SecondaryAxis.
I've been trying to figure out how I could toggle between displaying the 3 series graphed from a common SecondaryAxis and displaying the 3 series, each with their own axis.
If I add a YAxis to each series, it seems that neither setting IsEnabled = False or Visibility = Collapsed will return the series to be graphed to the common SecondaryAxis.

Any idea how I could toggle multiple axes on/off?

Thanks,
Alan

Devi Aruna Maharasi Murugan [Syncfusion]
Replied On April 5, 2017 10:33 AM UTC

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, 
Sample: ToggleAxis 
  
Regards, 
Devi 





CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;