2017-02-28 102 views
-3

我在我的应用程序中创建样条曲线图而不是线条图的要求。我知道WPF不直接提供splineseries。WPF样条曲线图由模板线条系列

如何自定义(模板)线条图来显示曲线图,我不想使用任何第三方付费工具。

感谢

回答

3

如果你通过花键系列的意思是平滑线系列,您可以使用OxyPlot(这当然是免费的)。这里一个例子

:使用LineSeries并设置Smooth属性为true

public MainWindow() 
    { 
     this.InitializeComponent(); 
     var plotModel = new PlotModel { Title = "OxyPlot" }; 
     plotModel.Axes.Add(new OxyPlot.Axes.LinearAxis { Position = OxyPlot.Axes.AxisPosition.Bottom }); 
     plotModel.Axes.Add(new OxyPlot.Axes.LinearAxis { Position = OxyPlot.Axes.AxisPosition.Left, Maximum = 10, Minimum = 0 }); 
     var series1 = new OxyPlot.Series.LineSeries 
     { 
      MarkerType = MarkerType.Circle, 
      MarkerSize = 5, 
      MarkerStroke = OxyColors.White 
     }; 
     series1.Points.Add(new DataPoint(0, 6)); 
     series1.Points.Add(new DataPoint(1, 2)); 
     series1.Points.Add(new DataPoint(2, 4)); 
     series1.Points.Add(new DataPoint(3, 2)); 
     series1.Points.Add(new DataPoint(4, 7)); 
     series1.Points.Add(new DataPoint(6, 6)); 
     series1.Points.Add(new DataPoint(8, 8)); 
     series1.Smooth = true; 
     plotModel.Series.Add(series1); 
     this.Content = new OxyPlot.Wpf.PlotView() { Model = plotModel }; 
    } 

注意:此部分:series1.Smooth = true;

+0

是的,这就是我的意思。感谢它是有帮助的。 – Yogesh