Pre loader

Hide and show datapoints / axis / labels

Welcome to the SciChart Forums!

  • Please read our Question Asking Guidelines for how to format a good question
  • Some reputation is required to post answers. Get up-voted to avoid the spam filter!
  • We welcome community answers and upvotes. Every Q&A improves SciChart for everyone

WPF Forums | JavaScript Forums | Android Forums | iOS Forums

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,

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 Burnett-Thompson
    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 = false 2.) 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
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
Showing 2 results
Your Answer

Please first to submit.

Try SciChart Today

Start a trial and discover why we are the choice
of demanding developers worldwide

Start TrialCase Studies