SciChart® the market leader in Fast WPF Charts, WPF 3D Charts, iOS Chart, Android Chart and JavaScript Chart Components


Hello, I’m looking to do something similar to your example titled “WPF Chart Vertically Stacked YAxis”, but I’d like to be able to hide a data series and associated axis based on check boxes, and have the remainder of the series fill the empty space.

Do you have any example of something like this?


  • You must to post comments

Hi Aaron

We dont have an example, but I’ve created you one as it’s quite simple to achieve.

VerticallyStackedAxis requires that you template the left or right axis panel template in order to show the axis one on top of another. Also, you need some code to dynamically add/remove (or show hide) axis. Like this.

<Window x:Class="WpfApp33.MainWindow"
        Title="MainWindow" Height="450" Width="800">
        <ItemsPanelTemplate x:Key="DynamicPanel">
            <UniformGrid Columns="1"/>

        <wpfApp33:MainViewModel x:Key="vm"/>

    <Grid DataContext="{StaticResource vm}">

            <RowDefinition Height="32"/>
            <RowDefinition Height="*"/>

        <StackPanel Orientation="Horizontal" Grid.Row="0">
            <Button Content="Add Series" Command="{Binding AddSeriesCommand}"/>
            <Button Content="Remove Series" Command="{Binding RemoveSeriesCommand}"/>

        <!--  Create the chart surface  -->
        <s:SciChartSurface x:Name="sciChart"
                            YAxes="{s:AxesBinding YAxis}"
                            RenderableSeries="{s:SeriesBinding Series}"
                            LeftAxesPanelTemplate="{StaticResource DynamicPanel}">

            <!--  Create an X Axis with Growby  -->
                <s:NumericAxis />

                    <s:RubberBandXyZoomModifier IsXAxisOnly="True" />
                    <s:ZoomExtentsModifier />
                    <s:CursorModifier ShowAxisLabels="False" ShowTooltip="False" />


    public class MainViewModel : BindableObject
        public MainViewModel()


        public ICommand AddSeriesCommand => new ActionCommand(() =>
            var axisId = Guid.NewGuid().ToString();
            Series.Add(new LineRenderableSeriesViewModel() { DataSeries = GetData(), YAxisId = axisId});
            // important, left alignment has been templated as vertically stacked axis
            YAxis.Add(new NumericAxisViewModel() { Id = axisId, AxisAlignment = AxisAlignment.Left}); 

        public ICommand RemoveSeriesCommand => new ActionCommand(() =>
            if (Series.Count > 1)

        public ObservableCollection<IAxisViewModel> YAxis { get; } = new ObservableCollection<IAxisViewModel>();

        public ObservableCollection<IRenderableSeriesViewModel> Series { get; } = new ObservableCollection<IRenderableSeriesViewModel>();

        private IDataSeries GetData()
            var xyDataSeries = new XyDataSeries<double>();
            var random = new Random((int)DateTime.UtcNow.Ticks);
            var phase = (random.NextDouble() + 0.5) * 10;
            for (int i = 0; i < 100; i++)
                xyDataSeries.Append(i, Math.Sin(i * phase));

            return xyDataSeries;

The Axis Panel template is a UniformGrid, which automatically spaces out elements equally. I have set it to one column and unlimited rows.

The SciChartSurface binds to ViewModel YAxis and RenderSeries properties, and finally buttons add/remove one series per axis.

This code has also been pushed to our Customer Examples at Github. under DynamicVerticallyStackedAxis.

hope this helps!


  • You must to post comments

Thanks Andrew.

I’ll take a look at your solution in a bit. In the mean time I also got the effect I was looking for using styles and data triggers combined with some checkboxes.

Thanks again.

  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.