Dev ControlChart

僤鯓⒐⒋嵵緔 提交于 2019-12-02 00:11:28
 1 <dxc:ChartControl>
 2             <dxc:ChartControl.Legends>
 3                 <dxc:Legend/>
 4             </dxc:ChartControl.Legends>
 5             <dxc:XYDiagram2D>
 6                 <dxc:LineSeries2D x:Name="UCL" DisplayName="UCL" Brush="Black"/>
 7                 <dxc:LineSeries2D x:Name="CL" DisplayName="CL" Brush="Black"/>
 8                 <dxc:LineSeries2D x:Name="LCL" DisplayName="LCL" Brush="Black"/>
 9                 <dxc:LineSeries2D x:Name="Value" DisplayName="Value" Brush="DarkCyan" MarkerVisible="True"/>
10             </dxc:XYDiagram2D>
11         </dxc:ChartControl>
xaml
 1 private void Button_Click(object sender, RoutedEventArgs e)
 2         {
 3             //Dia.Series.
 4             List<SeriesPoint> PUCL = new List<SeriesPoint>();
 5             List<SeriesPoint> PCL = new List<SeriesPoint>();
 6             List<SeriesPoint> PLCL = new List<SeriesPoint>();
 7             List<SeriesPoint> PValue = new List<SeriesPoint>();
 8 
 9             List<int> X = new List<int>() {1,2,3,4,5,6,7,8,9,10 };
10             List<double> UCLY = new List<double>() { 5, 5, 5, 5, 5, 5, 5, 5, 5, 5 };
11             List<double> CLY = new List<double>() { 3,3,3,3,3,3,3,3,3,3 };
12             List<double> LCLY = new List<double>() { 1,1,1,1,1,1,1,1,1,1 };
13             List<double> ValueY = new List<double>() {2.2,2.3,2.4,2.9,2.5,7.7,5.4,2.4,2.7,2.8 };
14 
15             if (X.Count == UCLY.Count && CLY.Count == LCLY.Count && X.Count == LCLY.Count)
16             {
17                 for (int i = 0; i < X.Count; i++)
18                 {
19                     PUCL.Add(new SeriesPoint() { Argument = X[i].ToString(), Value = UCLY[i] });
20                     PCL.Add(new SeriesPoint() { Argument = X[i].ToString(), Value = CLY[i] });
21                     PLCL.Add(new SeriesPoint() { Argument = X[i].ToString(), Value = LCLY[i] });
22                     if (ValueY[i] > UCLY[i] || ValueY[i] < LCLY[i])
23                     {
24                         SeriesPoint point = new SeriesPoint()
25                         {
26                             Argument = X[i].ToString(),
27                             Value = ValueY[i],
28                             Brush = new SolidColorBrush(Color.FromRgb(255, 0, 0))
29                         };
30                         PValue.Add(point);
31                     }
32                     else
33                     {
34                         SeriesPoint point = new SeriesPoint()
35                         {
36                             Argument = X[i].ToString(),
37                             Value = ValueY[i],
38                             //Brush = new SolidColorBrush(Color.FromRgb(255, 0, 0))
39                         };
40                         PValue.Add(point);
41                     }
42                 }
43             }
44 
45 
46             UCL.Points.AddRange(PUCL);
47             CL.Points.AddRange(PCL);
48             LCL.Points.AddRange(PLCL);
49             Value.Points.AddRange(PValue);
50 
51         }
C#

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!