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
same as like this solution provided in python here
Any help will be very, very helpful. Thank you very much for your attention!
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;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.