Pre loader

Legend Styling

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

how can i apply styling for legend in legend modifier? i want to apply the following style

<Style x:Key="LegendStyle" TargetType="s:LegendModifier">
        <Setter Property="ContentTemplate">
            <Setter.Value>        
                <DataTemplate>
            <s:SciChartLegend  x:Name="legendControl"  Margin="2,2" Orientation="Horizontal"  Background="Transparent" BorderThickness="0" ScrollViewer.VerticalScrollBarVisibility="Auto"
                                Visibility="{Binding IsLegendVisible,Converter={StaticResource  BoolToVisibilityConverter}}" 
                                LegendData="{Binding LegendData,  ElementName=legendModifier,Mode=OneWay}">

                <s:SciChartLegend.Resources>
                    <SciChart:ColorToBrushConverter x:Key="ColorToBrushConverter"/>
                </s:SciChartLegend.Resources>
                <s:SciChartLegend.ItemTemplate>
                    <DataTemplate DataType="SciChart:XyzSeriesInfo">
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto" />
                                <ColumnDefinition Width="Auto" />
                            </Grid.ColumnDefinitions>
                            <Rectangle Grid.Column="0"
                                                VerticalAlignment="Center"
                                                Stretch="Fill"
                                                Width="10"

                                                StrokeThickness="10"
                                                Stroke="{Binding SeriesColor,
                                                Converter={StaticResource ColorToBrushConverter}}" />
                            <TextBlock Grid.Column="1" Foreground="Black" 
                                                Margin="2,0,15,0"
                                                HorizontalAlignment="Center"
                                                Text="{Binding SeriesName}" FontWeight="Normal"/>
                        </Grid>
                    </DataTemplate>
                </s:SciChartLegend.ItemTemplate>
            </s:SciChartLegend>
        </DataTemplate>
            </Setter.Value>
        </Setter>
    </Style>
  • You must to post comments
0
0

Hi Raghupathy,

Have you seen our Legend API Overview article? It shows you the legend API, including templating the legend items.

We also have an advanced tutorial on legend item templating to introduce custom fields into the legend. Perhaps this helps?

enter image description here

If not, please explain clearly what you need and we will do our best to help.

Best regards,
Andrew

  • Raghupathy
    I want to display the legends outside of the chart surface i can't able to use ""
  • Raghupathy
    I want to show the legends outside of the chart surface i can do that for GetLegendDataFor="AllSeries" but i can't do that for GetLegendDataFor="AllVisibleSeries" i got a error message saying that 'Set property 'Abt.Controls.SciChart.ChartModifiers.LegendModifier.GetLegendDataFor' threw an exception.' Line number '67' and line position '39'. I create the chart when my application launch after when the user select the y axis value then only polt the graph.I think this is the problem.also how can i change the legend color it always white??
  • Andrew Burnett-Thompson
    Hi Raghupathy, I believe there was a bug reported with GetLegendDataFor ... see https://www.scichart.com/questions/question/how-programatically-add-legend-to-chart. It was fixed in build 5199. Can you double-check the latest nightly build and let us know if it resolves the problem? If not, please let me know. One of the team will investigate. For your other question - legend color white, why not create a new question, we will answer it asap. 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