简体   繁体   中英

LiveChart ColumnSeries change default colors

Today I downloaded and tried LiveChart for WinForms. I displayed a simple BasicColumn Chart. As you may know the default colors are red and blue. I want to change them to gray and orangen.Does anyone know how to do this? Thanks!

My code:

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()
                });
            }

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

col.Fill = Brushes.Orange;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM