![]()
1 chartType.Series.Clear(); 2 chartType.ChartAreas.Clear(); 3 if (rbtnPie.Checked) 4 { 5 Series Series1 = new Series(); 6 chartType.Series.Add(Series1); 7 chartType.Series["Series1"].ChartType = SeriesChartType.Pie; 8 chartType.Legends[0].Enabled = true; 9 chartType.Series["Series1"].LegendText = "#INDEX:#VALX";//開啟圖例 10 chartType.Series["Series1"].Label = "#INDEX:#PERCENT"; 11 chartType.Series["Series1"].IsXValueIndexed = false; 12 chartType.Series["Series1"].IsValueShownAsLabel = false; 13 chartType.Series["Series1"]["PieLineColor"] = "Black";//連線顏色 14 chartType.Series["Series1"]["PieLabelStyle"] = "Outside";//標簽位置 15 chartType.Series["Series1"].ToolTip = "#VALX";//顯示提示用語 16 ChartArea ChartArea1 = new ChartArea(); 17 chartType.ChartAreas.Add(ChartArea1); 18 //開啟三維模式的原因是為了避免標簽重疊 19 chartType.ChartAreas["ChartArea1"].Area3DStyle.Enable3D = true;//開啟三維模式;PointDepth:厚度BorderWidth:邊框寬 20 chartType.ChartAreas["ChartArea1"].Area3DStyle.Rotation = 15;//起始角度 21 chartType.ChartAreas["ChartArea1"].Area3DStyle.Inclination = 45;//傾斜度(0~90) 22 chartType.ChartAreas["ChartArea1"].Area3DStyle.LightStyle = LightStyle.Realistic;//表面光澤度 23 } 24 if (rbtnBar.Checked) 25 { 26 Series Series1 = new Series(); 27 chartType.Series.Add(Series1); 28 chartType.Series["Series1"].ChartType = SeriesChartType.Column; 29 chartType.Legends[0].Enabled = false; 30 chartType.Series["Series1"].LegendText = ""; 31 chartType.Series["Series1"].Label = "#VALY"; 32 chartType.Series["Series1"].ToolTip = "#VALX"; 33 chartType.Series["Series1"]["PointWidth"] = "0.5"; 34 ChartArea ChartArea1 = new ChartArea(); 35 chartType.ChartAreas.Add(ChartArea1); 36 //開啟三維模式的原因是為了避免標簽重疊 37 chartType.ChartAreas["ChartArea1"].Area3DStyle.Enable3D = true;//開啟三維模式;PointDepth:厚度BorderWidth:邊框寬 38 chartType.ChartAreas["ChartArea1"].Area3DStyle.Rotation = 15;//起始角度 39 chartType.ChartAreas["ChartArea1"].Area3DStyle.Inclination = 30;//傾斜度(0~90) 40 chartType.ChartAreas["ChartArea1"].Area3DStyle.LightStyle = LightStyle.Realistic;//表面光澤度 41 chartType.ChartAreas["ChartArea1"].AxisX.Interval = 1; //決定x軸顯示文本的間隔,1為強制每個柱狀體都顯示,3則間隔3個顯示 42 chartType.ChartAreas["ChartArea1"].AxisX.LabelStyle.Font =new Font("宋體", 9, FontStyle.Regular); 43 chartType.ChartAreas["ChartArea1"].AxisX.MajorGrid.Enabled = false; 44 } 45 46 chartType.Series[0].XValueMember = "name"; 47 chartType.Series[0].YValueMembers = "sumcount";