How can I hide and show a set of datapoints with or sometimes without the corresponding axis and labels?
- EJansen asked 12 years ago
- You must login to post comments
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
- Andrew Burnett-Thompson answered 12 years ago
- You must login to post comments
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?
- EJansen answered 12 years ago
-
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 login to post comments
Please login first to submit.