0
我在Visual Studio中使用C#使用Dundas图表。Dundas Charting C#条件色彩规则列
我有一个系列的图表 - 图表显示系列的列。我目前使用下面的代码添加系列:
public void AddSeries(string name, SeriesChartType type, IEnumerable xValues, IEnumerable yValues, bool showLabels = true)
{
Series s = new Series();
s.Points.DataBindXY(xValues, yValues);
s.LegendText = name;
s.Type = type;
if (type == SeriesChartType.Line) s.Color = Color.FromArgb(139,0,0);
else s.Color = _palette[_chart.Series.Count < _palette.Length ? _chart.Series.Count : 0];
s.ShowLabelAsValue = showLabels;
s.FontAngle = -90;
s.LabelFormat = string.IsNullOrWhiteSpace(_chart.ChartAreas["Default"].AxisY.LabelStyle.Format) ? "P0" : _chart.ChartAreas["Default"].AxisY.LabelStyle.Format;
s.Font = new Font("Arial", 5);
_chart.Series.Add(s);
}
我想改变这取决于该列的值每列的颜色 - 这将是基于一个INT目标值。 例如,如果该列小于我们的目标值,它应显示为红色,否则应显示为绿色。
你会如何推荐这样做?
不确定Dundas和MsChart之间的区别;他们似乎很相似。很有可能你需要在点数变化时重新设定点并设置每一种颜色。 - 一些扩展的属性,如工具提示可以通过某些数据绑定方式来设置,但是颜色,我想不是。 – TaW