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!

Please note: SciChart team will only answer questions from customers with active support subscriptions. Expired support questions will be ignored. If your support status shows incorrectly, contact us and we will be glad to help.

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
    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.