Pre loader

Making a SciChart Legend for more complex data

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

1
0

Hello,

I am trying to make a legend for a graph with some complex data.

Here is an example of how my data is structured:

  • Data Set #1
    • Series A
    • Series B
    • Series C
  • Data Set #2
    • Series A
    • Series B
    • Series C
  • Data Set #3
    • Series A
    • Series B
    • Series C

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.

Thank you,

Kurt

Version
6.5
  • You must to post comments
0
0

Hi Kurt,

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.

Best regards,
Andrew

  • You must to post comments
Showing 1 result
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