I have an requirement in my application to create spline chart instead lineseries chart. I know WPF doesn't provide splineseries directly.
How I can customize (template) lineseries chart to display curve graph, I don't want to use any third part paid tools.
Thanks
If what you mean by spline series is smoothed line series, you can use OxyPlot (which is of course free). Use a LineSeries
and set Smooth
property to be true
:
here an example:
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 };
}
Note this part: series1.Smooth = true;