我不想像这样改变整个系列:
chart1.Series["test1"].Color = Color.Red;
相反,我想改变各行的颜色,如下所示:
private void dispatcherTimer_Tick(object sender, EventArgs e)
{
var r = new Random();
int i = chart1.Series["test1"].Points.AddXY(r.Next(0, 10), r.Next(0, 10));
try
{
chart1.Series["test1"].Points[i - 1].Color = Color.LightPink;
chart1.Series["test1"].Points[i - 2].Color = Color.LightPink;
chart1.Series["test1"].Points[i - 3].BorderDashStyle = ChartDashStyle.Dash;
chart1.Series["test1"].Points[i - 4].BorderDashStyle = ChartDashStyle.Dash;
chart1.Series["test1"].Points.RemoveAt(i - 5);
}
catch { }
}
然而,这不起作用,我不明白为什么。
答案 0 :(得分:0)
问题是SeriesChartType设置为FastLine而不仅仅是Line。
这不起作用:
chart1.Series["test1"].ChartType = SeriesChartType.FastLine;
这有效:
chart1.Series["test1"].ChartType = SeriesChartType.Line;