ucEquipTimePie.cs
3.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Windows.Forms.DataVisualization.Charting;//微软MSChart的定义空间
using MyClassLib;
namespace MyControlLib
{
public partial class ucEquipTimePie : UserControl
{
public ucEquipTimePie()
{
InitializeComponent();
}
/// <summary>
/// 设定颜色
/// </summary>
public List<Color> color = new List<Color> { Color.Green,Color.SteelBlue,Color.Yellow,Color.Red,Color.Salmon,Color.RoyalBlue,Color.SpringGreen };
public void DrawTimePie(string title,List<double>val,List<string> strTip)
{
//清除所有的数据
//chart1.Series["Serial1"].
//数值显示百分比形式
//chart1.Series["Series1"].Label = "#PERCENT{P}";
//chart1.Series["Series1"].ToolTip = "#LEGENDTEXT: #VAL{D} Min";
Title tl = new Title(title);
chart1.Titles.Clear();
chart1.Titles.Add(tl);
chart1.ChartAreas["ChartArea1"].Area3DStyle.Enable3D = true;
chart1.Series["Series1"].LegendToolTip = "#PERCENT";
//chart1.Series["Series1"].LegendText = "#PERCENT";
//chart1.Series["Series1"].PostBackValue = "#INDEX";
//chart1.Series["Series1"].LegendPostBackValue = "#INDEX";
//chart1.Series["Series1"].
chart1.Series["Series1"].MarkerStyle = MarkerStyle.Circle; //设置点标记样式(此为圆点)
chart1.Series["Series1"].MarkerColor = Color.White;
// chart1.Series["Series1"].BorderColor = Color.Red;
chart1.Series["Series1"].BorderWidth = 1;
chart1.Series["Series1"].MarkerSize = 5; //设置线节点大小
//chart1.Series["Series1"].Points.DataBindXY(strTip, val);
chart1.Series["Series1"].Points.DataBindXY(strTip.ToArray(),val.ToArray());
int i = 0;
foreach (var p in chart1.Series[0].Points)
{
p.Color = color[i++];
if (i >= color.Count)
{
i = 0;
}
}
chart1.Series["Series1"].LabelToolTip = "#PERCENT{P}";
chart1.Series["Series1"].ToolTip = "#PERCENT #VAL min";
//chart1.Series["Series1"].ToolTip = "文章数#VAL"; //#VAL--Y轴数组
}
public void DrawTimePie( string title,string[] strTip,double[] val)
{
Title tl = new Title(title);
chart1.Titles.Clear();
chart1.Titles.Add(tl);
chart1.ChartAreas["ChartArea1"].Area3DStyle.Enable3D = true;
chart1.Series["Series1"].LegendToolTip = "#PERCENT";
//chart1.Series["Series1"].LegendText = "#PERCENT";
//chart1.Series["Series1"].PostBackValue = "#INDEX";
//chart1.Series["Series1"].LegendPostBackValue = "#INDEX";
//chart1.Series["Series1"].
chart1.Series["Series1"].MarkerStyle = MarkerStyle.Circle; //设置点标记样式(此为圆点)
chart1.Series["Series1"].MarkerColor = Color.White;
// chart1.Series["Series1"].BorderColor = Color.Red;
chart1.Series["Series1"].BorderWidth = 1;
chart1.Series["Series1"].MarkerSize = 5; //设置线节点大小
//chart1.Series["Series1"].Points.DataBindXY(strTip, val);
chart1.Series["Series1"].Points.DataBindXY(strTip, val);
chart1.Series["Series1"].ToolTip = "#PERCENT #VAL min";
//chart1.Series["Series1"].ToolTip = "文章数#VAL"; //#VAL--Y轴数组
}
}
}