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

SeriesProvider and LineSeries color

3 Answers 583 Views
ChartView
This is a migrated thread and some comments may be shown as answers.
Louis
Top achievements
Rank 1
Louis asked on 17 Sep 2013, 09:37 PM
I'm trying to specify the color for a set LineSeries (the number of which is dynamic) all to the same color. However, the Stroke Style Setter isn't having any effect. Taking the "Dynamic Number of Series" example from your documentation here:

http://www.telerik.com/help/wpf/radchartview-features-chartseriesprovider.html

and simply adding the Stroke color to the existing style:

                        <telerik:CategoricalSeriesDescriptor ItemsSourcePath="SalesData" ValuePath="Sales" CategoryPath="MonthName" CollectionIndex="2">
                            <telerik:CategoricalSeriesDescriptor.Style>
                                <Style TargetType="telerik:LineSeries">
                                    <Setter Property="StrokeThickness" Value="2"/>
                                    <Setter Property="Stroke" Value="Blue"/>
                                </Style>
                            </telerik:CategoricalSeriesDescriptor.Style>
                        </telerik:CategoricalSeriesDescriptor>

does not affect the color of the line on the chart. Adjustments to the StrokeThickness do affect the Chart, and if I change the Stroke on the LineSeries after-the-fact in code-behind it takes effect, but how can I change it for all the dynamic series generated by a SeriesProvider?

Thanks,
Louis

3 Answers, 1 is accepted

Sort by
0
Milena
Telerik team
answered on 19 Sep 2013, 06:48 AM
Hello Louis,

Using a palette has a higher priority than using a style. So when you use both, the stroke will have the color from the Palette.

In this case if you want to have a different colors for the series and stroke, you can make it only with styles and without palette.

Also you can use a custom palette, you can see an article here: http://www.telerik.com/help/wpf/radchartview-features-palettes-custom-palettes.html

Regards,

Milena
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Louis
Top achievements
Rank 1
answered on 19 Sep 2013, 04:53 PM
Thank you Milena, but I'm not explicitly using a Palette (using the exact XAML from the sample I linked). I'm guessing that it's using an implicit palette?

     In this case if you want to have a different colors for the series and stroke, you can make it only with styles and without palette.

Can you explain how to disable the palette to allow me to use only styles? Alternatively, can you show how to set a palette for a specific CategoricalSeriesDescriptor?

Or maybe I'm going about this the wrong way... What I ultimately want to accomplish is to chart a number of different types, each type consisting of a varying number of disjoint line segments. I want all the line segments for a particular type to be the same color, but have different colors for each of the different types. Is there a better way to do this than using the SeriesProvider?

Thanks again,
Louis
0
Milena
Telerik team
answered on 24 Sep 2013, 03:19 PM
Hello Louis, 

If I understood correctly, there are 2 possible solutions of your issue:

1. Using only styles:
I have attached a project where you can see the scenario using only styles.
The BarSeries are a little bit specific, so you should use PointTemplate where you can use Fill for the Rectangle of the bars and for the LineSeries you can set directly Stroke with the desired color (you will see in the attached example)

2. "Alternatively, can you show how to set a palette for a specific CategoricalSeriesDescriptor"
You can use a custom palette where you can set colors for the different series family: 
<Window.Resources>
        <telerik:ChartPalette x:Key="customPalette">
            <telerik:ChartPalette.SeriesEntries>
                <telerik:PaletteEntryCollection SeriesFamily="Bar">
                    <telerik:PaletteEntry Fill="Pink" Stroke="Pink"/>
                    <telerik:PaletteEntry Fill="Blue" Stroke="Blue"/>
                    <telerik:PaletteEntry Fill="Green" Stroke="Green"/>
                </telerik:PaletteEntryCollection>
 
                <telerik:PaletteEntryCollection SeriesFamily="Line">
                    <telerik:PaletteEntry Fill="RosyBrown" Stroke="RosyBrown"/>
                    <telerik:PaletteEntry Fill="Purple" Stroke="Purple"/>
                </telerik:PaletteEntryCollection>
            </telerik:ChartPalette.SeriesEntries>
        </telerik:ChartPalette>
    </Window.Resources>
and than in the RadCartesianChart:
<telerik:RadCartesianChart x:Name="chart" Palette="{StaticResource customPalette}">
In this case you don't need to write styles for the series.

I hope this helps.

Regards, 
Milena
Tags
ChartView
Asked by
Louis
Top achievements
Rank 1
Answers by
Milena
Telerik team
Louis
Top achievements
Rank 1
Share this question
or