I have a chart with multiple Series. I am using the ChartColorPalette to set foreach Series automatically a different color.
In that moment, when I am creating my Series, I want to read the Color to give a dropDownList.listItem the same backgroundColor. But unfortunately, in that very moment, the Color is still not set.
Is it possible that the Series are getting their color-definition out of the ChartColorPalette later in the Rendering-Event of ASP.NET?
Or what am I doing wrong?
Chart newChart = new Chart();
newChart.Palette = ChartColorPalette.Bright;
Series newSeries;
foreach (....)
{
newSeries = new Series();
newChart.Series.Add(newSeries);
// no color found :(
string colorName = newSeries.Color.Name
// same here
string colorName = newChart.Series[identifier].Color.Name;
myDropDownList.Items.FindByValue(identifier).Attributes.Add("style", "background: " + colorName + ";");
}
From the Dundas site (original source of MS charting code and no longer available online as of Aug 2018) you can force it to apply the palette manually.
newChart.ApplyPaletteColors();
Color thisColor = newChart.Series[identifier].Color;
I would think you will need to add all of the series in first and then loop through them after applying the palette and getting the colours out to populate the drop down.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With