【发布时间】:2014-12-23 10:31:44
【问题描述】:
我目前正在使用 VS C#,并且我的表单上有一个图表。
图表工作正常,但如果系列中的任何值达到 255(图表顶部),我想更改图表的颜色(颜色)
目前我尝试了这个:
GRAPH_READY = false;
c.ChartAreas[0].AxisY.Maximum = 255;
c.ChartAreas[0].AxisX.Maximum = 256;
c.ChartAreas[0].AxisX.LabelStyle.Enabled = false;
c.Series[s].Points.DataBindY(vals.ToArray());
c.Series[s].ChartType = SeriesChartType.Line;
c.Series[s].BorderWidth = 3;
c.Series[s].BorderColor = Color.Red;
for (int i = 0; i < c.Series[s].Points.Count; i++)
{
//here I'm wanting to check if any of the Y values of the points are over 255
if (c.Series[s].YValuesPerPoint == 255) c.Series[s].Color = Color.Red;
else if (c.Series[s].YValuesPerPoint < 254) c.Series[s].Color = Color.Blue;
}
GRAPH_READY = true;
我尝试了上述方法,但它似乎不起作用 :( 图表在 255 值以下开始时变为蓝色,但当我让它变为 255 时,它保持蓝色。
提前致谢,
J.
【问题讨论】:
标签: c# colors charts linechart series