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

Welcome to the SciChart Community Forums!

Please use the forums below to ask questions about SciChart. Take a moment to read our Question asking guidelines on how to ask a good question and our support policy. We also have a tag=SciChart on Stackoverflow.com where you can earn rep for your questions!

Please note: SciChart team will only answer questions from customers with active support subscriptions. Expired support questions will be ignored. If your support status shows incorrectly, contact us and we will be glad to help.

0
0

How can I hide and show a set of datapoints with or sometimes without the corresponding axis and labels?

  • You must to post comments
0
0

Hi Egbert,

Got it. Ok I suppose you are using MVVM similar to the exampl you posted over? If so then you can use the following properties to show/hide lines and their axes:

private void ToggleAxisVisibility()
{
    var rSeries = RenderableSeries.LastOrDefault();
    rSeries.IsVisible = !rSeries.IsVisible;

    var axis = YAxes.GetAxisById(rSeries.YAxisId);
    ((AxisBase) axis).Visibility = rSeries.IsVisible ? Visibility.Visible : Visibility.Collapsed;
}

I’ve also attached the MainViewModel / MainView to this post. Try this (its from your SpeedTest sample). The button “Hide an Axis” toggles the visibility of the last series and its associated axis.

Best regards,
Andrew

  • You must to post comments
0
0

Hi,

This seems to work fine.
I’m using the following code to hide and show all axis and labels, so there will be more space for the graph itself.

        private void ShowHideAllAxis()
        {
            this.AllAxisVisible = !this.AllAxisVisible;

            for (int seriesCnt = 0; seriesCnt < RenderableSeries.Count; seriesCnt++)
            {
                var rSeries = RenderableSeries.ElementAt(seriesCnt);
                var axis = YAxes.GetAxisById(rSeries.YAxisId);

                if (rSeries.IsVisible)
                {
                    Visibility visibility = ((AxisBase)axis).Visibility;
                    if (visibility == Visibility.Visible)
                    {
                        ((AxisBase)axis).Visibility = Visibility.Collapsed;
                    }
                    else
                    {
                        ((AxisBase)axis).Visibility = Visibility.Visible;
                    }
                }
            }
        }

The original graph looks good (GridProblem01).
But when removing/hiding the axis and labels, the graph is growing but the grid not.
I'm missing some grid lines on the right site of the graph (GridProblem02)

Any idea?

Images
  • Andrew
    We are investigating a similar issue now with Axis and Gridlines. For now, as a workaround you can try the following:1.) An axis will not render at all (including gridlines) if Visibility=Collapsed. Instead, your last axis you might want to hide by setting the following properties:- DrawMajorGridLines = true - DrawMinorGridLines = false - DrawMajorTicks = false - DrawMinorTicks = false - DrawAxisLabels = false2.) Another tip is there is a method, Axis.Clear(), which can be used to remove grid lines from the chart if an axis has been removed and lines remain.In any case - grid lines rendering incorrectly is a bug, we have created an issue for it and are working on it.Best regards,
  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.