We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

Custom legend icon

Thread ID:

Created:

Updated:

Platform:

Replies:

121746 Jan 21,2016 08:06 AM Jan 22,2016 06:18 AM WPF 3
loading
Tags: SfChart
Pavel Filip
Asked On January 21, 2016 08:06 AM

Hello,

I would like to create custom legend icons in the legend.
I have multiple series, some of which are for example blue, but differ in the dash style and line width.

I would like to have such line samples in the legend, so that user can see, that a thick, dashed series is for example GDP.
(either by creating my own bitmap image or by any other way possible)

Would that be possible to do in WPF SfChart?

Thanks for the time,

Pavel

Sumathi Jayaraj [Syncfusion]
Replied On January 22, 2016 04:35 AM

Hi Paval,

Thanks for contacting Syncfusion support.

SfChart provides the support for customizing legend icons using LegendIconTemplate in chart series. We can define the template as shown in the code sample and bound the values of Stroke, StrokeThickness and StrokeDashArray of the series to the Line’s properties. 

Code Example [XAML]:



<!--Template for legend customization-->

<DataTemplate x:Key="legendIconTemplate">

    <Line X1="0" X2="15" Y1="8" Y2="8" Stroke="{Binding Series.Interior}"

                  StrokeDashArray="{Binding Series.StrokeDashArray}" 

                  StrokeThickness="{Binding Series.StrokeThickness}"/>
</DataTemplate>
<!--Chart series creation-->

<chart:FastLineSeries StrokeThickness="8" XBindingPath="XData" YBindingPath="YData"

                      ItemsSource="{Binding Datas}" Label="Series1" 

                      StrokeDashArray="2,2" Interior="Blue" 
                      LegendIconTemplate="{StaticResource legendIconTemplate}"/>


Output Image:


 

We have prepared a sample for your requirements and please find the attachment.

Sample: CustomLegend 

Note: For line series, Interior value is assigned to Stroke also default value of Interior is null when its value isn’t explicitly defined.

Regards,
Sumathi J

Pavel Filip
Replied On January 22, 2016 04:41 AM

Sumathi,

this is exactly what we needed,

Thank you!!

Pavel

Sumathi Jayaraj [Syncfusion]
Replied On January 22, 2016 06:18 AM

Hi Pavel,

Thanks for your update. Please let us know if you have any queries.

Regards,
Sumathi J

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;