Pre loader

Maintaining User Legend Selections

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

Good day,

I could use some assistance in properly handling legend selections between chart updates. What I want is to maintain user legend selection through DataSeries changes. See images.

You can see originally we have a StackedColumnRenderableSeries chart with component-based breakdowns on the x-axis. In the “WaterFiltered” image, we see that the bars containing water are hidden; however, when I update the underlying dataseries, the legend is reset and water bars are seen again. I do not desire this behavior. The water should remain unchecked. If the legend changes it is fine to allow the whole thing reset, but in this case I am only changing the underlying data series. Could you suggest some techniques to achieve my desired idea?

Here is some additional xaml resources in order to help:
Item Template:

 

 

 

 

Control Template:

In SciChartSurface’s ChartModifier Group:

 

Thank You,
Nicholas Louks

Version
8.5.0.28148
Images
  • You must to post comments
0
0

Hi Nicholas,

Thank you for contacting us.
I’m going to discuss your inquiry with our team, and we’ll get back to you as soon as we have an update.

However, to provide you with a proper solution, we would need to see how exactly you update the RenderableSeries. Could you please share the corresponding code sample?

Please also note that the code samples mentioned in your post were not attached/displayed.
To ensure that the code is displayed correctly, we recommend marking it as a corresponding content type by selecting the code lines and pressing the “Code sample” button on the toolbar when you create a forum post.
Please see the attached image for reference.

Kind regards,
Lex S., MSEE
SciChart Technical Support Engineer

Images
  • You must to post comments
0
0

Lex:

I appreciate your answering; I have found the bug while formulating my response. Unfortunately, my XAML was filtered by your automated system, but it ended up being my bad in the code behind. I am posting here so that others may benefit from my mistake.

Explanation:
SubstanceMetadata is a class that implements from SciChart’s IPointMetadata interface. I use it to provide some rollover annotations to the chart. The “IsSelected” base class field was being reset each update due to the new instance of metadata being inserted each time the model was updated. What I instead needed to do was update the current metadata so it would retain the “IsSelected” property. (massMap is just an array offset in order to map X values to array indicies)

Old (VB.NET):

Private Sub ModifySeries(model As SubstanceModel, ByRef series As List(Of XyDataSeries(Of Integer, Single)))
Dim i = 0
Dim massMap As Integer = model.HistoModel.StartAMU
For Each material In model.Substances.Values
Dim mag = material.Substance.Magnitude
Dim j = 0
For Each fragPattern In material.Substance.Fragmentations
‘Issue was rebuilding the substance metadata.
series(i).Update(fragPattern.Mass – massMap, fragPattern.Ratio / mag * material.Concentration, New SubstanceMetadata With {.TotalConcentration = material.Concentration, .TotalPercentage = material.Percentage})
j += 1
Next
i += 1
Next
End Sub

Updated (VB.NET):

Dim i = 0
Dim massMap As Integer = model.HistoModel.StartAMU
For Each material In model.Substances.Values
Dim mag = material.Substance.Magnitude
Dim j = 0
For Each fragPattern In material.Substance.Fragmentations
‘Below code was updated…
Dim correctMData As SubstanceMetadata = series(i).Metadata(fragPattern.Mass – massMap)
correctMData.TotalConcentration = material.Concentration
correctMData.TotalPercentage = material.Percentage
series(i).Update(fragPattern.Mass – massMap, fragPattern.Ratio / mag * material.Concentration)
j += 1
Next
i += 1
Next

Thank You,
Nicholas Louks

  • Lex
    • Lex
    • 6 months ago
    Hi Nicholas, I’m sorry for such a delayed response. We’re glad you’ve found a solution! Unfortunately, at the moment, we don’t have VB-specific expertise available, so we’re unable to review VB code as this falls out of our support scope. We appreciate your understanding. Kind regards, Lex
  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.