Pre loader

Disappearing Legend

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
1

Question: I\’m still working with v1 of SciCharts until I find the time to convert everything that needs to be changed for v2, but I\’m playing around with legends right now and running in to an odd issue. I\’m essentially copying your example in to my own code, but the legend doesn\’t want to appear on top of the graph pane. It appears just fine if it is set on an empty section of window, but disappears when placed on the pane. Is there a way to bring the legend to the front on the pane? It may also be worth noting that I’m attempting to apply a legend to seven different panes, would it be possible to apply a single legend, or are individuals required?

  • You must to post comments
0
0

Hi there,

The legend is a totally separate control, not part of SciChart. If you look at the example it is declared in a parent Grid, below the chart in the grid (which puts it higher in the Z-order). E.g. the structure is:

<Grid>
   <s:SciChartSurface>
      <s:SciChartSurface.ChartModifier>
          <s:LegendModifier x:Name="legendSource"/>
      </s:SciChartSurface.ChartModifier>
   </s:SciChartSurface>
   
   <s:SciChartLegend LegendData="{Binding LegendData,
                                                      ElementName=legendSource,
                                                      Mode=OneWay}"/>
</Grid>

The legend can actually be placed anywhere in your application, so long as it can bind to the LegendModifier which acts as a data-source. Think of the LegendModifier as a ViewModel in this case and Legend as a view.

So — to place it above the chart, just make sure its in a grid over the chart. We give it a margin to inset it slightly.

Yes, you will need one legend per chart as each one consumes data from the LegendModifier which must be present on the chart. Of course you could have one legend and re-bind it to each chart one at a time. So long as you’re prepared to do the logic to update the binding then this is also a possibility.

Best regards,
Andrew

  • You must to post comments
0
0

I figured out what the issue was. My implementation was almost correct the first time except the Z order assumption, so because my legend was declared first, the graph itself was building over the legend. Forcing a Z Index worked like a charm. Thanks for your help.

  • You must to post comments
Showing 2 results
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