我使用wpf oxyplot并设置x轴以使用对数 .
我使用mvvm而不是代码风格 .
这是我在vm的 property
public PlotModel ChartPlot
{
get { return _chartPlot; }
set { _chartPlot = value; RaisePropertyChanged(() => ChartPlot); }
}
WPF
<oxy:PlotView Grid.Row="1" Grid.Column="1" Model="{Binding ChartPlot}" />
//--- here is _bigDataPoints data list of points
var _bigDataPoints = new List<DataPoints>();
// #x1 double #y double
_bigDataPoints.Add(410.8070281 , 4943000.0000000 );
_bigDataPoints.Add(432.7935746 , 5041000.0000000 );
_bigDataPoints.Add(436.8319199 , 5059000.0000000 );
_bigDataPoints.Add(9918.193582 , 47320000.0000000 );
_bigDataPoints.Add(10099.91912 , 48130000.0000000 );
_bigDataPoints.Add(10216.58243 , 48650000.0000000 );
_bigDataPoints.Add(104904.5616 , 470700000.0000000 );
_bigDataPoints.Add(107282.6983 , 481300000.0000000 );
_bigDataPoints.Add(108337.1551 , 486000000.0000000 );
_bigDataPoints.Add(991388.6853 , 4422000128.0000000 );
_bigDataPoints.Add(1000362.786 , 4462000128.0000000 );
_bigDataPoints.Add(1006195.923 , 4488000000 );
var logAxisX = new LogarithmicAxis() { Position = AxisPosition.Bottom, Title = "Log(x)", UseSuperExponentialFormat = false, Base = 10 };
var linearAxisY = new LinearAxis() { Position = AxisPosition.Left, Title = "Y", UseSuperExponentialFormat = false };
// PlotModel ChartPlot = new PlotModel(); -> this is property that is binding to oxyplot control
ChartPlot.Axes.Add(linearAxisY);
ChartPlot.Axes.Add(logAxisX);
var lineSeriesBigData = new OxyPlot.Series.LineSeries();
lineSeriesBigData.Points.AddRange(_bigDataPoints);
ChartPlot.Series.Clear();
ChartPlot.Annotations.Clear();
ChartPlot.Series.Add(lineSeriesBigData);
// refresh chart
ChartPlot.InvalidatePlot(true);
曲线完全缺失,为什么?我为图表轴设置了最小/最大间隔,但图表上仍然缺少线性曲线 . 其他的错误是x轴无法用鼠标拖动 . 它似乎是轴冻结 . 如果我设置x轴的最大值,他在x轴上没有显示正确的最大值 . 显示100,为什么? y轴没问题
2 回答
您缺少将
PlotModel
分配给PlotView
,如下所示:XAML:
CS:
该错误与PlotType属性有关
不要使用笛卡儿!