This is a migrated thread and some comments may be shown as answers.

How to set different color for each SplineSeries if I use RadCartesianChart.SeriesProvider?

1 Answer 41 Views
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 1
Dmitry asked on 12 Sep 2016, 09:00 AM

Hello. I'm sorry for being bothersome. I use telerik:ChartSeriesProvider for visualizing of variable number of Spline series. I want each curve (series) has its own color. I've written the following XAML markup for it:

<UserControl x:Class="DeviceReading.Views.AutomaticGainControlView"
        <telerik:ChartPalette x:Key="customPalette">
                <telerik:PaletteEntryCollection SeriesFamily="Spline">
                    <telerik:PaletteEntry Fill="DarkBlue" Stroke="DarkBlue"/>
                    <telerik:PaletteEntry Fill="Purple" Stroke="Purple"/>
                    <telerik:PaletteEntry Fill="Red" Stroke="Red"/>
                    <telerik:PaletteEntry Fill="Green" Stroke="Green"/>
                    <telerik:PaletteEntry Fill="Cyan" Stroke="Cyan"/>
                    <telerik:PaletteEntry Fill="Sienna" Stroke="Sienna"/>
                    <telerik:PaletteEntry Fill="Magenta" Stroke="Magenta"/>
                    <telerik:PaletteEntry Fill="DodgerBlue" Stroke="DodgerBlue"/>
        <telerik:RadCartesianChart Visibility="{Binding IsAbsoluteSplineChartVisible}" Palette="{StaticResource customPalette}">
                <telerik:DateTimeContinuousAxis MajorStepUnit="Second" LabelInterval="5" LabelFormat="hh:mm:ss" FontFamily="Segoe UI" PlotMode="OnTicks" TickOrigin="{Binding AlignmentDate}"/>
                <telerik:LinearAxis FontFamily="Segoe UI" Title="Decibels [Db]" />
                <telerik:CartesianChartGrid MajorLinesVisibility="XY" MajorXLineDashArray="3,4" MajorYLineDashArray="3,4"/>
                <telerik:ChartSeriesProvider Source="{Binding SeriesData}">
                        <telerik:CategoricalSeriesDescriptor CategoryPath="Category" ValuePath="Value" ItemsSourcePath="ChartPoints">

Just in case below is SeriesTypeConverter definition.

public class SeriesTypeConverter : IValueConverter
{  public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
    SeriesModel seriesItem = value as SeriesModel;
    if (seriesItem.SeriesType == "Spline")
       return typeof(SplineSeries);
    else if (seriesItem.SeriesType == "Line")
       return typeof(LineSeries);
       return typeof(BarSeries);
  public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
    /*throw new NotImplementedException()*/return null;


The number of series now is vary from 2 to 8 (but upper bound may be larger and will, say 16). As you can see from XAML, I've define my own color palette (customPalette). I bag your pardon, but I do not know how to use it in my XAML, to each curve (series) had its own different color. Now all displayed series (1, 2, 3, 4,...8) are dark blue (have  DarkBlue color which is the first in 'customPalette'). Please tell me, how do I do so that each curve had its own different color. And that this color does not change with each session of the program.

1 Answer, 1 is accepted

Sort by
Telerik team
answered on 14 Sep 2016, 03:12 PM
Hello Yaroslav,

Thank you for the provided code snippet.

In order to apply different colors to the SplineSeries, you can set the SeriesFamily property of the PaletteEntryCollection to Line. 
<telerik:PaletteEntryCollection SeriesFamily="Line">

Telerik by Progress
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
Asked by
Top achievements
Rank 1
Answers by
Telerik team
Share this question