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

Chart Series Legend Color not matching with series color

1 Answer 191 Views
Chart (Obsolete)
This is a migrated thread and some comments may be shown as answers.
kevin yang
Top achievements
Rank 1
kevin yang asked on 07 Jan 2010, 03:14 AM
Hi,

In my chart ( type StackedBar ), I change my chart series filled color programmtically, the StackedBars colors display fine for each series, but somehow, the corresponding series Legend color is not displaying the same color.  Do I have to set the color for each series legend  or  anything I am missing..

here is my code

Telerik.Reporting.Processing.

Chart chart = sender as Telerik.Reporting.Processing.Chart;

 

Telerik.Reporting.

Chart defChart = chart.ItemDefinition as Telerik.Reporting.Chart;

 

defChart.SeriesPalette =

"";

 

 

int arrayPos = 0;

 

 

foreach (string s in _reporterTypeList)

 

{

 

   ChartSeries serie = new ChartSeries();

 

   serie.Type =

ChartSeriesType.StackedBar;

 

   serie.Clear();

   serie.Name = s;

 

   serie.Appearance.LegendDisplayMode = Telerik.Reporting.Charting.

ChartSeriesLegendDisplayMode.SeriesName;

 

   for (int year = 4; year >= 0; year--)

 

   {

 

      // Define the items in the series

 

      serie.AddItem(_countByReporterTypeYearly[arrayPos, 4 - year]);

 

      serie.Items[serie.Items.Count - 1].Appearance.FillStyle.MainColor = _serieColors[arrayPos];

 

   }

 

   defChart.Series.Add(serie);

   arrayPos++;

 

}


Any help,

thankls

1 Answer, 1 is accepted

Sort by
0
Ves
Telerik team
answered on 08 Jan 2010, 08:47 AM
Hello Kevin

I can see that you set the color for each individual ChartSeriesItem. This color is not shown in the legend as it is possible that you set different colors for different items in the same series. However, it seems you use the same color for all the items within one ChartSeries. In this case, you may remove the line that sets the color for individual items and configure the chart series i.e. remove this line form the inner loop:

serie.Items[serie.Items.Count - 1].Appearance.FillStyle.MainColor = _serieColors[arrayPos];

and add this one to the outer loop:

serie.Appearance.FillStyle.MainColor = _serieColors[arrayPos];


Kind regards,
Ves
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
Chart (Obsolete)
Asked by
kevin yang
Top achievements
Rank 1
Answers by
Ves
Telerik team
Share this question
or