I am trying to make a legend for a graph with some complex data.
Here is an example of how my data is structured:
By default, SciChartLegend will display 9 entries in the above example, one for every series. However, with many datasets, and more series per dataset, this quickly becomes extremely cumbersome.
What I’d like to do is show 6 items in the legend: a checkbox for each Data Set, and a checkbox for each Series Type.
If the user clicks the Data Set #1 check box => Data Set #1 Series A, Data Set #1 Series B, and Data Set #1 Series C are all shown/hidden.
If the user clicks the Series A check box => Data Set #1 Series A, Data Set #2 Series A, and Data Set #3 Series A are all shown/hidden.
This does not seem to cooperate with the native SciChartLegend, which views all the Data Series as a single flat list. My data is in more of a tree structure.
Do you have any recommendations on how to proceed? I think I will need to make a new UserControl derived from ChartDataObjectBase to replace the SciChartLegend control.
Any help greatly appreciated.
I answered your other question on making a custom usercontrol for the legend. Was this helpful? I linked to the LegendModifier docs and explained how you could make a custom ItemsControl to consume the SeriesInfo objects emitted by LegendModifier.LegendData.
Start by trying out some simple things, create an ItemsControl, bind ItemSource to LegendModifier.LegendData, and have an ItemTemplate to render legend rows. Note each item has a SeriesInfo instance as its DataContext so the properties on SeriesInfo are available, including RenderableSeries and DataSeriesName.
DataSeries itself has a Tag property. You could put extra data on the DataSeries such as ‘Group1’ ‘Group2’ then use this to build out your custom legend with grouping.
If we have time we will try to create an example for you. I will be honest and say we’re extremely busy at the moment though with a huge website re-launch due in a few weeks and releases on all three platforms!
Hence I would try first by creating an ItemsControl that binds to LegendModifier.LegendData. See the docs linked above for how.
Please login first to submit.