我正在使用 C# 在 Visual Studio 中使用 Dundas Charts。
我有一个带有一个系列的图表 - 图表在列上显示系列。我目前正在使用以下代码添加系列:
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 目标值。例如,如果列小于我们的目标值,则应显示红色,否则应显示绿色。
你会如何建议这样做?