WPF工具包数据可视化-如何在代码隐藏中设置间隔、最小值和最大值



第一个我的xaml

<charting:Chart x:Name="ChartMain" />

下面是我的代码:

List<KeyValuePair<string, int>> valueList1 = new List<KeyValuePair<string, int>>();
valueList1.Insert(0, new KeyValuePair<string, int>(DateTime.Now.ToString(), 1));
LineSeries lineSeries1 = new LineSeries();
lineSeries1.Title = "Eins";
lineSeries1.DependentValuePath = "Value";
lineSeries1.IndependentValuePath = "Key";
lineSeries1.ItemsSource = valueList1;
ChartMain.Series.Add(lineSeries1);

我的问题是:如何在代码后面设置最小值/最大值和间隔?

List<KeyValuePair<string, int>> valueList1 = new List<KeyValuePair<string, int>>();
valueList1.Insert(0, new KeyValuePair<string, int>(DateTime.Now.ToString(), 1));
LineSeries lineSeries1 = new LineSeries();
lineSeries1.Title = "Eins";
lineSeries1.DependentValuePath = "Value";
lineSeries1.IndependentValuePath = "Key";
lineSeries1.ItemsSource = valueList1;
ChartMain.Series.Add(lineSeries1);
LinearAxis linearAxis = new LinearAxis();
linearAxis.Orientation = AxisOrientation.Y;
linearAxis.Minimum = 0;
linearAxis.Maximum = +1;
linearAxis.Interval = 0.1;
ChartMain.Axes.Add(linearAxis);

最新更新