LiveCharts图XY值

时间:2018-06-26 13:21:56

标签: c# data-analysis livecharts

我正在尝试编写将XY值列表绘制到实时图表的代码。附件中有问题的列表,但这是一个示例:

1 0,01
1,01 0,01
1,02 0,01
1,03 0,01
1,04 0,01
1,05 0,01
1,06 0,01
1,07 0,01
1,08 0,01
1,09 0,01
...
2,45 0,15
2,46 0,15
2,47 0,15
2,48 0,16
2,49 0,16
2,5 0,16
2,51 0,17
2,52 0,17

我正在使用以下代码:

List<double> xValues, yValues;
            GenerateValues(out xValues, out yValues);
            ChartValues<ObservablePoint> ListPoints = new ChartValues<ObservablePoint>();
            for (int i = 0; i < xValues.Count; i++)
            {
                ListPoints.Add(new ObservablePoint
                {
                    X = xValues[i],
                    Y = yValues[i]
                });
            }

            var brush = new SolidColorBrush(Colors.Orange);
            brush.Opacity = 0.25;
            var series = new LineSeries();
            series.Values = ListPoints;
            series.Title = "Pressão";
            series.Stroke = new SolidColorBrush(Colors.OrangeRed);
            series.LineSmoothness = 0;
            series.PointGeometry = null;
            series.Fill = brush;

            var seriesCollection = new SeriesCollection { series };

            if (chart.AxisY[0] != null && chart.AxisY[0].Labels != null)
                chart.AxisY[0].Labels.Clear();
            if (chart.Series != null)
                chart.Series.Clear();
            chart.AxisY[0].Title = "Pressão (bar)";
            chart.AxisX[0].Title = "Tempo (min)";
            chart.Series = seriesCollection;

但是,我得到的结果与文件上的X标签不匹配。曲线的形状正确,Y值也正确,但X值不正确。遵循结果示例:ChartResult

有人可以帮助我了解这种行为吗?

GitHub with the Application

0 个答案:

没有答案