LiveChart ColumnSeries更改默认颜色

时间:2017-11-26 17:21:01

标签: c# winforms visual-studio livecharts

今天我下载并试用了LiveChart for WinForms。我展示了一个简单的BasicColumn图表。您可能知道默认颜色是红色和蓝色。我想把它们改成灰色和橙色。有谁知道怎么做? 谢谢!

我的代码:

using(TechnoholzEntities db = new TechnoholzEntities())
            {
                var data = db.GetAngebotsData();
                ColumnSeries col = new ColumnSeries() { DataLabels = true, Values = new LiveCharts.ChartValues<decimal>(), LabelPoint = point => point.Y.ToString() };
                ColumnSeries col2 = new ColumnSeries() { DataLabels = true, Values = new LiveCharts.ChartValues<decimal>(), LabelPoint = point => point.Y.ToString()};

                Axis ax = new Axis() { Separator = new Separator() { Step = 1, IsEnabled = false } };
                ax.Labels = new List<string>();
                foreach(var x in data)
                {
                    col2.Values.Add(x.Kalksumme.Value);
                    col.Values.Add(x.Auftragssumme.Value);
                    ax.Labels.Add(x.Von.ToString());
                }

                cartesianChart1.Series.Add(col);
                cartesianChart1.Series.Add(col2);
                cartesianChart1.AxisX.Add(ax);
                cartesianChart1.AxisY.Add(new Axis
                {
                    LabelFormatter = value => value.ToString(),
                    Separator = new Separator()
                });
            }

1 个答案:

答案 0 :(得分:1)

ColumnSeries有一个属性Fill,可以更改颜色。

col.Fill = Brushes.Orange;