After dynamically applying a palette to a chart, how do I find the color of a particular series on that chart based on the palette application?
My xaml is as follows:
If the value of
Thanks
My xaml is as follows:
<
Controls:RadCartesianChart
x:Name
=
"chart"
Palette
=
"{Binding SelectedPalette, Mode=TwoWay}"
>
If the value of
SelectedPalette
changes, I want to know the resulting color of any given Series in the chart
's SeriesCollection in my xaml.cs. The types of these charts may be BarSeries
,
LineSeries
or
AreaSeries
.Thanks
6 Answers, 1 is accepted
0
Accepted
Hi Kareema,
The chart series get their brushes from the GlobalEntries array. You can get the color for the series by using the index of the series like this:
Hope this information helps!
Greetings,
Yavor
the Telerik team
The chart series get their brushes from the GlobalEntries array. You can get the color for the series by using the index of the series like this:
int
seriesIndex = chart.Series.IndexOf(series);
return
chart.Palette.GlobalEntries[seriesIndex].Fill;
Hope this information helps!
Greetings,
Yavor
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
0
Kareema
Top achievements
Rank 2
answered on 12 Jul 2012, 08:47 AM
Thank you very much Yavor!
I found that this works too:
I found that this works too:
PaletteEntry? paletteEntryForThisSeries = chart.Palette.GetEntry(series, seriesCounter);
if
(paletteEntryForThisSeries.HasValue)
{
var paletteFill = paletteEntryForThisSeries.Value.Fill;
}
0
Greg
Top achievements
Rank 1
answered on 13 Feb 2013, 10:05 PM
This only works with up to 8 series on the chart, then fails with an "index out of range" exception. How can I determine the color of all series beyond 8 in the chart?
0
Hi Greg,
I have just verified that using the GetEntry method of the ChartPalette does not throw an exception in the described scenario. If you keep experiencing problems with this I will ask that you provide us with a small working example that reproduces this issue so that we can test and look for solutions.
Kind regards,
Petar Marchev
the Telerik team
I have just verified that using the GetEntry method of the ChartPalette does not throw an exception in the described scenario. If you keep experiencing problems with this I will ask that you provide us with a small working example that reproduces this issue so that we can test and look for solutions.
Kind regards,
Petar Marchev
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.
0
Bruno
Top achievements
Rank 1
answered on 08 Jul 2015, 10:18 AM
Hello, I'm trying to do a similar thing, but instead of getting this color from code-behind, I need to bind to it from xaml. I've bound my series using a ChartSeriesProvider, and I'd like to display other informations on these series on another control, reusing the color that's chosen by the palette. How would I do that ?
0
Hello Bruno,
You can either use a converter and use code to get the desired color or you can use the legend item and its Fill property. If you need further assistance I will ask that you open a new thread where you can explain in more details the set up you have and the desired output.
Regards,
Petar Marchev
Telerik
You can either use a converter and use code to get the desired color or you can use the legend item and its Fill property. If you need further assistance I will ask that you open a new thread where you can explain in more details the set up you have and the desired output.
Regards,
Petar Marchev
Telerik
Do you want to have your say when we set our development plans?
Do you want to know when a feature you care about is added or when a bug fixed?
Explore the
Telerik Feedback Portal
and vote to affect the priority of the items