public static Chart ToChart(ChartType type, params DataSeries[] ds) { Chart c; switch (type) { case (ChartType.VBar): c = new VBarChart(ds); break; case (ChartType.HBar): c = new HBarChart(ds); break; case (ChartType.Pie): c = new PieChart(ds); break; case (ChartType.Petal): c = new PetalChart(ds); break; default: c = null; break; } return(c); }
/// <summary> /// 初始化控件,设备使用效率,剩余可用物料 /// </summary> private void InitChartComponent() { chartPerformance = new HBarChart(); chartWarning = new VBarChart(); panelPerformance.Controls.Add(chartPerformance); this.panelWarning.Controls.Add(chartWarning); // Left side chartPerformance.Dock = DockStyle.Fill; chartPerformance.AutoScroll = true; chartPerformance.BarWidth = 28; chartPerformance.SizingMode = BarSizingMode.Normal; chartPerformance.Values.Mode = CValueProperty.ValueMode.Digit; chartPerformance.Scales.Section = 4; //刻度 chartPerformance.Background.PaintingMode = CBackgroundProperty.PaintingModes.RadialGradient; chartPerformance.Background.GradientColor1 = Color.Gainsboro; chartPerformance.Background.GradientColor2 = Color.Gray; chartPerformance.Label.Font = new Font("微软雅黑", 9, FontStyle.Regular); // right side chartWarning.Dock = DockStyle.Fill; chartWarning.AutoScroll = true; chartWarning.BarWidth = 30; chartWarning.SizingMode = BarSizingMode.Normal; chartWarning.Values.Mode = CValueProperty.ValueMode.Digit; chartWarning.Scales.Section = 4; chartWarning.Background.PaintingMode = CBackgroundProperty.PaintingModes.RadialGradient; chartWarning.Background.GradientColor1 = Color.Gainsboro; chartWarning.Background.GradientColor2 = Color.Gray; chartWarning.Label.Font = new Font("微软雅黑", 9, FontStyle.Regular); }
public Statistics_Chart() { InitializeComponent(); // Create, no need if you added the chart by visual editor barChart = new HBarChart(); this.panel1.Controls.Add(barChart); barChart.Dock = DockStyle.Fill; barChart.Description.Text = "业务统计"; }
public Form1() { InitializeComponent(); nCroodX = rand.Next(50, 430); nCroodY = rand.Next(50, 750); MyDateTime = DateTime.Now; nYear = MyDateTime.Year; nMonth = MyDateTime.Month; nDay = MyDateTime.Day; nHour = MyDateTime.Hour; nMin = MyDateTime.Minute + 1; txtCroodX.Text = nCroodX.ToString(); txtCroodY.Text = nCroodY.ToString(); cboHour.SelectedIndex = nHour - 2; txtMinute.Text = nMin.ToString(); txtMinute.Maximum = 59; txtMinute.Minimum = 00; cboMaterial.SelectedIndex = (int)currItem; barColor = new Color[12]; barColor[0] = Color.FromArgb(255, 200, 255, 255); barColor[1] = Color.FromArgb(255, 150, 200, 255); barColor[2] = Color.FromArgb(255, 100, 100, 200); barColor[3] = Color.FromArgb(255, 255, 60, 130); barColor[4] = Color.FromArgb(255, 250, 200, 255); barColor[5] = Color.FromArgb(255, 255, 255, 0); barColor[6] = Color.FromArgb(255, 255, 155, 55); barColor[7] = Color.FromArgb(255, 150, 200, 155); barColor[8] = Color.FromArgb(255, 255, 255, 200); barColor[9] = Color.FromArgb(255, 100, 150, 200); barColor[10] = Color.FromArgb(255, 130, 235, 250); barColor[11] = Color.FromArgb(255, 150, 240, 80); //for (int i = 0; i < barColor.Length; ++i) //{ // barColor[i] = Color.FromArgb(255, 10, 10, 10); //} // Create, no need if you added the chart by visual editor barChart = new HBarChart(); this.panel1.Controls.Add(barChart); barChart.Dock = DockStyle.Fill; //barChart.Background. //barChart.SizingMode = HBarChart.BarSizingMode.AutoScale; barChart.Border.Width = 10; barChart.Shadow.Mode = CShadowProperty.Modes.Outer; barChart.Shadow.WidthInner = 1; barChart.Shadow.WidthOuter = 4; barChart.Shadow.ColorOuter = Color.FromArgb(100, 0, 0, 0); //// Register for control events //barChart.BarClicked += new HBarChart.OnBarEvent(barChart_BarClicked); //barChart.BarDoubleClicked += new HBarChart.OnBarEvent(barChart_BarDoubleClicked); //barChart.BarMouseEnter += new HBarChart.OnBarEvent(barChart_BarMouseEnter); //barChart.BarMouseLeave += new HBarChart.OnBarEvent(barChart_BarMouseLeave); UpdateChart(); }