0

Can we set different color for individual stacked of stacked bar chart or change the order of color in stacked bar charts bar for example

enter image description here

same as like this solution provided in python here

Any help will be very, very helpful. Thank you very much for your attention!

Community
  • 1
  • 1
Raj
  • 351
  • 2
  • 13
  • 30

1 Answers1

1

Yes you can.

I assume you have 4 series and those series are A,B,C and D.

For changing the color, lets say A's, according to the Data 1,2,3,4 you could use;

Series sr = new Series();
sr.Name = "A";
sr.Points.DataBindXY(xValues, yValues);
sr.ChartType = SeriesChartType.StackedBar;
sr.Font = new System.Drawing.Font("Tahoma", 8, System.Drawing.FontStyle.Bold);

for (int i = 0 ; i < xValues.Lenght; i++) //xValues.Lenght = 4 in this case where you have 4 Data number
{ 
    if(i == 0) // Don't forget xValues[0] is Data4 in your case
        sr.Points[i].Color = Dr.Color.Black;
    else
        sr.Points[i].Color = Dr.Color.Yellow;
}

This will give someting like this; Example of Output

Berkay Turancı
  • 3,373
  • 4
  • 32
  • 45