WPF,Toolkit Chart如何根据两点连接一条曲线,我知道能连成直线,刚开始...
发布网友
发布时间:2024-08-19 06:07
我来回答
共1个回答
热心网友
时间:2024-08-27 09:37
参考代码如下
1 using System.Collections.ObjectModel;
2 using System.Windows.Controls.DataVisualization.Charting;
3 using System;
4 using System.Windows.Media;
5 using System.Windows;
6 using System.Collections.Generic;
7 using System.Linq;
8
9 namespace StepLineChart
10 {
11
12 public class StepLineSeries : LineSeries
13 {
14 /// <summary>
15 /// Gets the collection of points that make up the line.
16 /// </summary>
17 public PointCollection Points
18 {
19 get { return GetValue(PointsProperty) as PointCollection; }
20 private set { SetValue(PointsProperty, value); }
21 }
22
23 protected override void UpdateShapeFromPoints(IEnumerable<Point> points)
24 {
25 if (points.Any())
26 {
27 PointCollection pointCollection = new PointCollection();
28 foreach (Point point in points)
29 {
30 pointCollection.Add(point);
31 }
32 Points = CreateStepLineSeries(pointCollection);
33 }
34 else
35 {
36 Points = null;
37 }
38 }
39
40 /// <summary>
41 /// 根据已有的坐标点插入新的拐点
42 /// </summary>
43 /// <param name="points"></param>
44 /// <returns></returns>
45 private PointCollection CreateStepLineSeries(PointCollection points)
46 {
47 PointCollection returnPoints = new PointCollection();
48 for (int i = 0; i < points.Count; i++)
49 {
50 Point currentPoint = points[i];
51 returnPoints.Add(currentPoint);
52 if (i < points.Count - 1)
53 {
54 Point nextPoint = points[i + 1];
55 returnPoints.Add(new Point(nextPoint.X, currentPoint.Y));
56 }
57 }
58 return returnPoints;
59 }
60 }
61 }
62
WPF,Toolkit Chart如何根据两点连接一条曲线,我知道能连成直线,刚开始...
1 using System.Collections.ObjectModel;2 using System.Windows.Controls.DataVisualization.Charting;3 using System;4 using System.Windows.Media;5 using System.Windows;6 using System.Collections.Generic;7 using System.Linq;8 9 namespace StepLineChart 10 { 11 12 public class ...
如何在WPF中添加chart控件,绘制X,Y轴及动态曲线
我们可以使用Toolkit Chart 控件去绘制图形 添加System.Windows.Controls.DataVisualization.Toolkit.dll 引用后,XAML中可以以下面的方式使用 <Window x:Class="WpfChart3._5.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com...
需要在WPF中绘制曲线图,请问使用哪种控件比较好
WPF的toolkit里有自带的chart控件的。如果你只想做些简单的图表展示就够了。如果你要有很好的用户体验和比较多的图表设置,可以使用第三方控件中的Chart。推荐Visifire的Chart控件,它家是专门做wpf,silverlight,wp的图表控件的。希望对你的回答有帮助。