I don't know if can make it clear otherwise, So here is the code:-
Series series2 = null;
for (int i = 0; i < 4; i++)
{
series2 = chart2.Series.Add(subjectnames[i]);
}
for (int i = 0; i < 4; i++)
{
series2.Points.Add(attemptper[i]);
series2.Points.Add(correctper[i]);
}
Now, I just want to display "attemptper" bars in different color than "correctper" bars. By default they are appearing in greyish-blue color. How do I get it done?
The charts appear all in bluish color. I want them to appear in different colors. I think I haven't added the data correctly to the chart for this to achieve?
To change the color of a data series: Select the data series you wish to edit. Click the Format button on the Chart toolbar (or double-click the data series). Use the Format Data Series dialog box to pick a new color. Click the OK button to accept the Data Series color changes.
Edit or rearrange a series Right-click your chart, and then choose Select Data. In the Legend Entries (Series) box, click the series you want to change. Click Edit, make your changes, and click OK. Changes you make may break links to the source data on the worksheet.
You change the color on the series point(index) like this:
Chart1.Series[1].Points[0].Color = Color.Red
Getting the chart to repaint might also take some code, depending on what you're doing. For me, I wanted to animate my chart, building the data point (a column) dynamically as the program ran, showing the status of some work I was doing, which required this:
Chart1.Series.ResumeUpdates()
Chart1.Series[1].Points.Item[0].YValues = Double(1) {MyNewValue, 0}
Chart1.Series[1].Points[0].Color = Color.Red
Chart1.DataBind()
Chart1.Series.Invalidate()
Chart1.Series.SuspendUpdates()
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