Examples for defining a ChartPalette?

4 posts, 0 answers
  1. Steven
    Steven avatar
    22 posts
    Member since:
    May 2011

    Posted 06 Jul 2012 Link to this post

    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).
  2. Sia
    Admin
    Sia avatar
    667 posts

    Posted 10 Jul 2012 Link to this post

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

  3. DevCraft banner
  4. Colter
    Colter avatar
    10 posts
    Member since:
    Apr 2013

    Posted 28 May 2013 Link to this post

    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
  5. Evgenia
    Admin
    Evgenia avatar
    1407 posts

    Posted 31 May 2013 Link to this post

    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.

Back to Top