private void AddFifthChart() { // Create a chart. ChartControl chart = new ChartControl(); // Create an empty Bar series and add it to the chart. Series series = new Series("Series1", ViewType.Bar); chart.Series.Add(series); chart.Location = new Point(820, 498); chart.Size = new Size(356, 236); // Generate a data table and bind the series to it. series.DataSource = CreateChartData(3); // Specify data members to bind the series. series.ArgumentScaleType = ScaleType.Auto; series.ArgumentDataMember = "RefTypeName"; series.ValueScaleType = ScaleType.Numerical; series.ValueDataMembers.AddRange(new string[] { "Value" }); // Set some properties to get a nice-looking chart. ((SideBySideBarSeriesView)series.View).ColorEach = true; ((XYDiagram)chart.Diagram).AxisY.Visible = true; chart.Legend.Visible = true; // Dock the chart into its parent and add it to the current form. chart.Dock = DockStyle.None; this.Controls.Add(chart); chart.BringToFront(); }
private void InitializeLayout(List <Sys_Layout> sys_Layouts, Control parentControl) { try { DataTable dt = (DataTable)gdb.DataSource; parentControl.Visible = false; parentControl.Controls.Clear(); foreach (Sys_Layout sys_Layout in sys_Layouts.OrderBy(s => s.Layout_Sort)) { Control contain = parentControl; if (!string.IsNullOrEmpty(sys_Layout.Layout_Parent)) { Control[] cks = parentControl.Controls.Find(sys_Layout.Layout_Parent, true); if (cks.Length > 0) { contain = cks[0]; } } contain.ControlAdded += delegate(object sender, ControlEventArgs e) { e.Control.Paint += Layout_SizeChanged; e.Control.Click += Layout_Select; }; switch (sys_Layout.Layout_Type) { case 0: //Query GroupControl qry = new GroupControl(); InitializeControl(qry, sys_Layout); contain.Controls.Add(qry); qry.BringToFront(); //this.QueryControl = qry; break; case 12: //GroupControl GroupControl grp = new GroupControl(); InitializeControl(grp, sys_Layout); contain.Controls.Add(grp); grp.BringToFront(); break; case 14: //PanelControl PanelControl panel = new PanelControl(); InitializeControl(panel, sys_Layout); contain.Controls.Add(panel); panel.BorderStyle = BorderStyles.NoBorder; panel.BringToFront(); break; case 13: SplitterControl OneSpli = new SplitterControl(); OneSpli.Dock = (DockStyle)sys_Layout.Layout_Dock; OneSpli.Name = sys_Layout.Layout_Name; contain.Controls.Add(OneSpli); OneSpli.BringToFront(); break; case 1: //Grid case 6: //Submit case 7: //Tree 这三个都只有Grid 是在Grid上覆盖控件实现 Submit 和 Tree 效果 GridControl gd = new GridControl(); InitializeControl(gd, sys_Layout); GridView gv = (GridView)gd.CreateView("GridView"); gv.Name = gd.Name.Replace("d", "v"); gv.OptionsView.ShowGroupPanel = false; gv.OptionsView.ShowFooter = true; gv.OptionsSelection.MultiSelect = true; gd.MainView = gv; contain.Controls.Add(gd); gd.BringToFront(); break; case 9: //TabPage TabEx ntabs = new TabEx(); InitializeControl(ntabs, sys_Layout); ntabs.BorderStyle = BorderStyles.NoBorder; ntabs.BorderStylePage = BorderStyles.NoBorder; contain.Controls.Add(ntabs); ntabs.BringToFront(); break; case 10: DevExpress.XtraTab.XtraTabPage tab = new DevExpress.XtraTab.XtraTabPage(); tab.Name = sys_Layout.Layout_Name; tab.Text = sys_Layout.Layout_Nick; if (contain.GetType() == typeof(TabEx)) { TabEx tabs = (TabEx)contain; tabs.TabPages.Add(tab); } break; case 11: Pagination pagination = new Pagination(); pagination.Name = sys_Layout.Layout_Name; pagination.Dock = (DockStyle)sys_Layout.Layout_Dock; contain.Controls.Add(pagination); pagination.BringToFront(); break; case 2: //Chart ChartControl chart = new ChartControl(); InitializeControl(chart, sys_Layout); chart.BorderOptions.Visibility = DevExpress.Utils.DefaultBoolean.False; contain.Controls.Add(chart); chart.BringToFront(); break; case 3: //text MemoEdit memoEdit = new MemoEdit(); InitializeControl(memoEdit, sys_Layout); memoEdit.BorderStyle = BorderStyles.NoBorder; contain.Controls.Add(memoEdit); memoEdit.BringToFront(); break; case 4: //RichText RichEditControl rtf = new RichEditControl(); InitializeControl(rtf, sys_Layout); rtf.BorderStyle = BorderStyles.NoBorder; rtf.ActiveViewType = RichEditViewType.Simple; contain.Controls.Add(rtf); rtf.BringToFront(); break; case 5: //image PictureEdit pictureEdit = new PictureEdit(); InitializeControl(pictureEdit, sys_Layout); pictureEdit.BorderStyle = BorderStyles.NoBorder; pictureEdit.Properties.PictureStoreMode = PictureStoreMode.ByteArray; pictureEdit.Properties.SizeMode = PictureSizeMode.Squeeze; contain.Controls.Add(pictureEdit); pictureEdit.BringToFront(); break; case 8: //BarCode BarCodeControl barCodeControl = new BarCodeControl(); InitializeControl(barCodeControl, sys_Layout); barCodeControl.BorderStyle = BorderStyles.NoBorder; barCodeControl.BackColor = Color.White; barCodeControl.AutoModule = true; barCodeControl.ShowText = false; //QRCodeGenerator DevExpress.XtraPrinting.BarCode.QRCodeGenerator qrCodeGenerator1 = new DevExpress.XtraPrinting.BarCode.QRCodeGenerator(); qrCodeGenerator1.CompactionMode = DevExpress.XtraPrinting.BarCode.QRCodeCompactionMode.Byte; qrCodeGenerator1.ErrorCorrectionLevel = DevExpress.XtraPrinting.BarCode.QRCodeErrorCorrectionLevel.H; qrCodeGenerator1.Version = DevExpress.XtraPrinting.BarCode.QRCodeVersion.Version1; //Code128Generator DevExpress.XtraPrinting.BarCode.Code128Generator code128Generator1 = new DevExpress.XtraPrinting.BarCode.Code128Generator(); //根据长宽比切换二维码 条码显示 if (barCodeControl.Width > barCodeControl.Height * 2) { barCodeControl.Symbology = code128Generator1; } else { barCodeControl.Symbology = qrCodeGenerator1; } contain.Controls.Add(barCodeControl); barCodeControl.BringToFront(); break; default: break; } } parentControl.Visible = true; } catch (Exception ex) { SharedFunc.RaiseError(ex); } }
private void AddSixthChart(IList <DashBoardCashModel> DashBoardCash) { if (DashBoardCash.Count > 0) { NodataChar3.Visible = false; } else { NodataChar3.Visible = true; } lblCashYear.Text = "NĂM " + DashBoardCash[0].ThisTime.Year.ToString(); CashMonth = DashBoardCash[0].PrevTime.Month; CashYear = DashBoardCash[0].PrevTime.Year; // Create a new chart. //CashChart = new ChartControl(); if (!CashChart.Series.Equals(null) || DashBoardCash.Count <= 0) { CashChart.Series.Clear(); } // Create two full-stacked line series. Series series1 = new Series("Tiền mặt", ViewType.Line); Series series2 = new Series("Tiền gửi", ViewType.Line); Series series3 = new Series("Tiền đang chuyển", ViewType.Line); // Add points to them. series1.Points.Add(new SeriesPoint("Tháng " + DashBoardCash[0].PrevTime.Month, DashBoardCash[0].PrevCash)); series1.Points.Add(new SeriesPoint("Tháng " + DashBoardCash[0].ThisTime.Month, DashBoardCash[0].ThisCash)); series1.Points.Add(new SeriesPoint("Tháng " + DashBoardCash[0].NextTime.Month, DashBoardCash[0].NextCash)); series2.Points.Add(new SeriesPoint("Tháng " + DashBoardCash[0].PrevTime.Month, DashBoardCash[0].PrevCashInBank)); series2.Points.Add(new SeriesPoint("Tháng " + DashBoardCash[0].ThisTime.Month, DashBoardCash[0].ThisCashInBank)); series2.Points.Add(new SeriesPoint("Tháng " + DashBoardCash[0].NextTime.Month, DashBoardCash[0].NextCashInBank)); series3.Points.Add(new SeriesPoint("Tháng " + DashBoardCash[0].PrevTime.Month, DashBoardCash[0].PrevCashInTransit)); series3.Points.Add(new SeriesPoint("Tháng " + DashBoardCash[0].ThisTime.Month, DashBoardCash[0].ThisCashInTransit)); series3.Points.Add(new SeriesPoint("Tháng " + DashBoardCash[0].NextTime.Month, DashBoardCash[0].NextCashInTransit)); //CashChart.Location = new Point(40, 873); //CashChart.Size = new Size(548, 289); // Add both series to the chart. CashChart.Series.AddRange(new Series[] { series1, series2, series3 }); ((LineSeriesView)CashChart.Series[0].View).Color = Color.FromArgb(0, 106, 253); ((LineSeriesView)CashChart.Series[1].View).Color = Color.FromArgb(255, 145, 0); ((LineSeriesView)CashChart.Series[2].View).Color = Color.FromArgb(0, 237, 224); ((LineSeriesView)CashChart.Series[0].View).MarkerVisibility = DevExpress.Utils.DefaultBoolean.True; ((LineSeriesView)CashChart.Series[1].View).MarkerVisibility = DevExpress.Utils.DefaultBoolean.True; ((LineSeriesView)CashChart.Series[2].View).MarkerVisibility = DevExpress.Utils.DefaultBoolean.True; // Access the type-specific options of the diagram. ((XYDiagram)CashChart.Diagram).EnableAxisXZooming = false; //((XYDiagram)CashChart.Diagram).AxisY.Label.TextPattern = "{VP:P0}"; // Hide the legend (if necessary). CashChart.Legend.Visible = true; //// Add a title to the chart (if necessary). //CashChart.Titles.Add(new ChartTitle()); //CashChart.Titles[0].Text = "Full Stacked Line Chart"; // Convert label bên trái sang định dạng mong muốn CashChart.CustomDrawAxisLabel += (s, e) => { var args = (CustomDrawAxisLabelEventArgs)e; AxisBase axis = args.Item.Axis; if (axis is AxisY) { double axisValue = (double)args.Item.AxisValue; string answer = string.Format("{0:0,0}", axisValue); args.Item.Text = answer; } }; // Add the chart to the form. CashChart.Dock = DockStyle.Fill; PanelControlCashSub.Controls.Add(CashChart); CashChart.BringToFront(); }
private void frmViewChart_Load(object sender, EventArgs e) { // Create an empty chart ChartControl barChart = new ChartControl(); // Create the first side-by-side bar series and add points to it. Series series1 = new Series("Gross Amount Series ", ViewType.Bar); for (int i = 0; i <= ds_takeQryData.Tables[0].Rows.Count - 1; i++) { series1.Points.Add(new SeriesPoint(ds_takeQryData.Tables[0].Columns["GrossAmount"], ds_takeQryData.Tables[0].Rows[i]["GrossAmount"])); } //series1.Points.Add(new SeriesPoint("A", new double[] { 10 })); //series1.Points.Add(new SeriesPoint("B", new double[] { 12 })); //series1.Points.Add(new SeriesPoint("C", new double[] { 14 })); //series1.Points.Add(new SeriesPoint("D", new double[] { 17 })); // Create the second side-by-side bar series and add points to it. Series series2 = new Series("Unit Price Series ", ViewType.Bar); for (int i = 0; i <= ds_takeQryData.Tables[0].Rows.Count - 1; i++) { series2.Points.Add(new SeriesPoint(ds_takeQryData.Tables[0].Columns["UnitPrice"], ds_takeQryData.Tables[0].Rows[i]["UnitPrice"])); } //series2.Points.Add(new SeriesPoint("A", new double[] { 15 })); //series2.Points.Add(new SeriesPoint("B", new double[] { 18 })); //series2.Points.Add(new SeriesPoint("C", new double[] { 25 })); //series2.Points.Add(new SeriesPoint("D", new double[] { 33 })); // Create the second side-by-side bar series and add points to it. Series series3 = new Series("Net Amount Series ", ViewType.Bar); for (int i = 0; i <= ds_takeQryData.Tables[0].Rows.Count - 1; i++) { series3.Points.Add(new SeriesPoint(ds_takeQryData.Tables[0].Columns["NetAmount"], ds_takeQryData.Tables[0].Rows[i]["NetAmount"])); } // Add the series to the chart barChart.Series.Add(series1); barChart.Series.Add(series2); barChart.Series.Add(series3); // Hide the legend (if necessary). //sideBySideBarChart.Legend.Visibility = DevExpress.Utils.DefaultBoolean.False; // Rotate the diagram (if necessary). //((XYDiagram)sideBySideBarChart.Diagram).Rotated = true; // Add a title to the chart (if necessary). ChartTitle chartTitle1 = new ChartTitle(); chartTitle1.Text = "Babar Medicine Company Bar Chart"; barChart.Titles.Add(chartTitle1); // Add the chart to the form. barChart.Dock = DockStyle.Fill; this.Controls.Add(barChart); barChart.BringToFront(); }