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

Examples for defining a ChartPalette?

3 Answers 302 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Steven
Top achievements
Rank 1
Steven asked on 06 Jul 2012, 05:10 AM
Just looking for an example of setting up a custom palette.  How?

So instead of:
<telerik:RadCartesianChart Name="Chart1" Palette="Metro">
could I instead?
<telerik:RadCartesianChart Name="Chart1" Palette="SomeOtherStyle">

http://www.telerik.com/help/silverlight/p_telerik_windows_controls_chartview_chartpalette_seriesentries.html
http://www.telerik.com/help/silverlight/t_telerik_windows_controls_chartview_paletteentry.html
http://msdn.microsoft.com/en-us/library/ms634880
http://www.telerik.com/help/silverlight/allmembers_t_telerik_windows_controls_chartview_paletteentrycollection.html
In Particular, these members aren't really defined anywhere:
* AdditionalFill
AdditionalStroke
* Fill
* Stroke
Please define... also please define how the constructors correspond to this.

Lastly, it would be good to see a palette defition in action (code behind please + XAML based approaches).

3 Answers, 1 is accepted

Sort by
0
Sia
Telerik team
answered on 10 Jul 2012, 08:51 AM
Hello Steven,

You can create a custom palette by using the exposed ChartPalette property:
<telerik:RadPolarChart>
    <telerik:RadPolarChart.Palette>
        <telerik:ChartPalette>
            <telerik:ChartPalette.GlobalEntries>
                <telerik:PaletteEntry Stroke="Red" />
                <telerik:PaletteEntry Stroke="Blue" />
            </telerik:ChartPalette.GlobalEntries>
        </telerik:ChartPalette>
    </telerik:RadPolarChart.Palette>
...
</telerik:RadPolarChart>

or in code-behind:
ChartPalette palette = new ChartPalette();
palette.GlobalEntries.Add(new PaletteEntry(null, new SolidColorBrush(Colors.Red)));
palette.GlobalEntries.Add(new PaletteEntry(null, new SolidColorBrush(Colors.Blue)));
this.chart.Palette = palette;

The GlobarEntries are global for all series in RadChartView, colors specific per series family are defined as follows:

<telerik:RadPolarChart>
    <telerik:RadPolarChart.Palette>
        <telerik:ChartPalette>
            <telerik:ChartPalette.SeriesEntries>
                <telerik:PaletteEntryCollection SeriesFamily="Line">              
                    <telerik:PaletteEntry Stroke="Red" />
                    <telerik:PaletteEntry Stroke="Blue" />
                </telerik:PaletteEntryCollection>
            </telerik:ChartPalette.SeriesEntries>
        </telerik:ChartPalette>
    </telerik:RadPolarChart.Palette>
...
</telerik:RadPolarChart>

Alternatively you can customize the appearance of individual LineSeries through the LineSeries.Stroke property, for AreaSeries - through the AreaSeries.Fill property, and for BarSeries you need to define custom BarSeries.DefaultVisualStyle with TargetType="Border" and add style setter for the Border.Background property.
Regards,
Sia
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Colter
Top achievements
Rank 1
answered on 28 May 2013, 06:11 PM
Hello Telerik,

Can you explain the use case behind the GlobalEntries versus the SeriesEntries?

I've been trying to figure this one out and just haven't been able to get to the bottom of it.

Regards,

Colter
0
Evgenia
Telerik team
answered on 31 May 2013, 08:36 AM
Hi Colter,

 The GlobalEntries is a collection of PaletteEntries, which will be used for all types of chart series. The SeriesEntries allows us to specify different collections of PaletteEntries for each type of chart series specified by SeriesFamily property. You may find attached an example that I believe will put some more light on this.
Some words on the project - having this palette in a chart, the first collection of SeriesEntries will be used for the pie series, the second - for area series and for all other types of series - the GlobalEntries collection. The result.PNG says it all.

Regards,
Evgenia
Telerik

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
Chart
Asked by
Steven
Top achievements
Rank 1
Answers by
Sia
Telerik team
Colter
Top achievements
Rank 1
Evgenia
Telerik team
Share this question
or