I have a lot of series on my XamDataChart - sometimes as many as 2000 or so. Calling MyChart.Series.Clear() takes upwards of 30-40 seconds. Is there a way I can just hide the series I do not need to display? I tried setting the visibility, but then the series object was still shown on the Y axis. I'm using a ScatterPolylineSeries with a NumericXAxis and a NumbericYAxis.
I have been investigating into the behavior you are seeing, and it is valid to set the Visibility of the different series in the XamDataChart. I am under the impression that by you saying that “the series object is still being shown on the Y-Axis,” you mean that the Y-Axis is not changing to accommodate the visible series? This is expected, as the series is still plotted in the chart and the axis takes that into account more-so than the visibility of the series.
It is worth noting that the NumericX and NumericY axes both have MinimumValue and MaximumValue properties, and so you can calculate this yourself based on the visible series’ data sources if you wish, but this may not be something viable for you.
Something I am curious about in this case is the usage of 2,000 ScatterPolylineSeries in this case. Is there a reason you are using so many series? Perhaps some of these series could be combined as the data source of the ScatterPolylineSeries can be a List<List<Point>> where each inner List<Point> is a line segment?
Please let me know if you have any other questions or concerns on this matter.
I don't believe that will help. I'm already using a a List<List<Point>> to represent each object.I'm using the Chart component to create a scheduler. Each point on the y-axis represents an object and the x axis represents time. There is an example below. Each green line to the right represents the availability of that object (for instance, the time that "Hospital 1" in the sample below is open. For my specific use case, there may be thousands of these objects.In addition, each row has a ScatterSeries that represents the beginning and end of each time period. These are used as grips to change the beginning and end times of each green area. There are at least 2 of these on each line.
I need to be able to use the filters at the top to hide a type of objects - say hide the buildings. Right now, I have to completely rebuild the series. This is not the biggest problem since the series don't take too long to create or add to the chart. But clearing the series from the chart takes a long time. Hiding and showing the object lines would be much faster.
Do you have any ideas on how to do this efficiently?
I am still rather curious as to why it is necessary for you to clear the series in the XamDataChart and rebuild them in this case? It seems like the entirety of the green rectangles in the chart in this case should be able to be a single ScatterPolygonSeries as each inner List<Point> can represent one of those Rectangles.
If you were to bind to an ObservableCollection<List<Point>> in this case and then have your own class that derives from List<Point>, I believe it should be possible to limit the amount of series needed in this case. If the class that derives from List<Point> also exposes some information about the object on the Y-Axis, perhaps you could remove particular objects by removing their corresponding List<Point> from the ObservableCollection?
I am unsure how much the above corresponds to what you are already doing, but I am under the impression that at the moment, each of those Rectangles is its own ScatterPolygonSeries if you are getting up to around 2000 series in the chart at a time. I would also be curious to know where much of the time is being spent if it is taking 30-40 seconds to clear the series collection as this should normally happen relatively quickly? Have you profiled the application to see where the performance bottleneck is happening in this case?
Adding all the lines to the same ScatterPolylineSeries has solved my speed issue.I now have new problems:1. Highlighting the series on hover highlights the all the lines, instead of just the current Y-axis location.
2, I can only have one tooltip for the ScatterPolylineSeries.
I think I can solve each of these with mouse events, though.
--To answer your question -
I had checked speed at various points in my code and all of the 30-40 seconds I mentioned was spent on the single line:MyChart.Series.Clear();
I did not profile the Infragistics code to see why, however.
Regarding the new behaviors you are looking for:
1. In order to highlight the specific polygon that you have hovered, I would recommend setting the HighlightingMode property of the XamDataChart to “BrightenSpecific” as this will brighten the exact point you are hovering over.
2. It is true that the ScatterPolygonSeries will now share a tooltip among all of its points. If you need to customize this, you can do so by providing a custom ToolTip. You can read about this here: https://www.infragistics.com/help/wpf/datachart-chart-tooltips.