NativeScript Core

RadChart Series Styling Palettes

Telerik Chart for NativeScript uses Palettes to enable the customization of series. Depending on the count of series you have defined in your chart, you can add as many palettes as needed and change several visual parameters of the series. A single palette defines an entries property which contains PaletteEntry instances. A PaletteEntry is essentially a property bag which holds the values that are used to style the associated series. The following properties are exposed by a PaletteEntry object:


To better illustrate the usage of Palettes, we will use a scenario with three series of different kind which are customized. Consider the following series:

    <chart:BarSeries seriesName="Bar" items="{{ categoricalSource }}" categoryProperty="Country" valueProperty="SecondVal"/>
    <chart:LineSeries seriesName="Line" items="{{ categoricalSource }}" categoryProperty="Country" valueProperty="Amount"/>
    <chart:SplineAreaSeries seriesName="Area" items="{{ categoricalSource }}" categoryProperty="Country" valueProperty="ThirdVal"/>

We want to customize all of the series. We will use their seriesName to specify which palette is for which series. We want to change the stroke, as well as their fill color. Let's define a new palette for each series in the palettes collection of the chart:

    <chart:Palette seriesName="Bar">
            <chart:PaletteEntry fillColor="#80FCE49D" strokeColor="#80E2A1F8"/>
    <chart:Palette seriesName="Line">
            <chart:PaletteEntry strokeColor="#FFCF40" strokeWidth="3"/>
    <chart:Palette seriesName="Area">
            <chart:PaletteEntry fillColor="#8060B3FC" strokeColor="#60B3FC"/>

Our palette consists of a single entry that defines values for fillColor, strokeColor and strokeWidth. What remains to be done is mapping the palette to the series it is meant to style. This is done by setting the seriesName property on the series and the palette to the same key. As you can see, the seriesName property is set to the Palette and the series to the same value - in that case Bar, Area and Line. You can use any string token here assuming it is the same on the corresponding series and the palette, as it serves as a mapping key between both.

The images below demonstrates the result of applying this palette to the Bar series:

Chart styling: Bar series Chart styling: Bar series

If you want to specify additional style for selected state of the series you need to define a new Palette with the corresponding seriesName and seriesState property set to Selected value as it is shown in the following example:

<chart:Palette seriesName="myBar" >
        <chart:PaletteEntry strokeWidth="3" strokeColor="Orange" fillColor="Yellow"/>
        <chart:PaletteEntry strokeWidth="3" strokeColor="Pink" fillColor="Green"/>
<chart:Palette seriesName="myBar" seriesState="Selected">
        <chart:PaletteEntry strokeWidth="5" strokeColor="Yellow" fillColor="Orange"/>
        <chart:PaletteEntry strokeWidth="5" strokeColor="Green" fillColor="Pink"/>

In this example the second palette values will be used when the series or data point is selected. If palette for selected state is not explicitly defined the default colors will be used.


By default, the provided palettes (or the default colors) are applied per series, i.e. the first PaletteEntry from a palette will be applied to each of the items in the series. The paletteMode property can be used to change the way the palette is applied, i.e. the first PaletteEntry from the palette to be applied to the first item in the series, the second PaletteEntry to the second item, etc. You can choose from the following paletteMode values: Series or Item depending on how you want the palette to be applied. Here's how to change the paletteMode for BarSeries:

<chart:BarSeries paletteMode="Item" items="{{ categoricalSource }}" categoryProperty="Country" valueProperty="Amount"/>

And here's the result on android (on the left) and on iOS (on the right):

Chart styling: PaletteMode Chart styling: PaletteMode

Note that the paletteMode is applicable only for series where it visually makes sense. LineSeries, SplineSeries, AreaSeries and SplineAreaSeries (where there are no separate items but only connections between them), the paletteMode is not supported.


Want to see this scenario in action? Check our SDK examples repo on GitHub. You will find this and many other practical examples with NativeScript UI.