SciChart® the market leader in Fast WPF Charts, WPF 3D Charts, and now iOS Charting & Android Chart Components

Welcome to the SciChart Community Forums!

Please use the forums below to ask questions about SciChart. Take a moment to read our Question asking guidelines on how to ask a good question and our support policy

We also have a tag=SciChart on Stackoverflow.com where you can earn rep for your questions!

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.