public void SetSalesPerformanceProvider(ISalesPerformanceProvider provider, DateTime?date) { this.provider = provider; Series.ArgumentDataMember = provider.ChartArgumentDataMember; Series.ValueDataMembers.AddRange(provider.ChartValueDataMember); switch (provider.ChartType) { case SalesPerformanceChartType.Area: Series.ChangeView(ViewType.Area); Diagram.AxisX.WholeRange.AutoSideMargins = false; ((AreaSeriesView)Series.View).Border.Visibility = Utils.DefaultBoolean.False; ((AreaSeriesView)Series.View).Transparency = 64; break; case SalesPerformanceChartType.Bar: Series.ChangeView(ViewType.Bar); BarSeriesView view = ((BarSeriesView)Series.View); BarSeriesLabel label = ((BarSeriesLabel)Series.Label); view.ColorEach = true; view.Transparency = 0; view.Border.Visibility = Utils.DefaultBoolean.False; label.Position = BarSeriesLabelPosition.TopInside; label.Border.Visibility = Utils.DefaultBoolean.False; label.FillStyle.FillMode = FillMode.Empty; label.TextColor = Color.White; label.Indent = 6; label.EnableAntialiasing = Utils.DefaultBoolean.True; Diagram.AxisX.WholeRange.AutoSideMargins = true; Series.LabelsVisibility = DefaultBoolean.True; break; default: break; } switch (provider.Mode) { case SalesPerformanceMode.Day: SetDayMode(); break; case SalesPerformanceMode.Month: SetMonthMode(); break; } if (date == null) { date = DateTime.Today; } currentDate = date.Value; UpdateSalesValues(); UpdateChart(currentDate); UpdateNavigationButtons(true, true); }
public void create_Bar_Chart() { chartControl1 = new ChartControl(); Series series1 = new Series("Doanh số", ViewType.Bar); //Legend Format chartControl1.Legend.Title.Alignment = StringAlignment.Near; chartControl1.Legend.Visible = true; chartControl1.Legend.Title.MaxLineCount = 3; chartControl1.Legend.Title.WordWrap = true; foreach (SeriesPoint se in series_data) { series1.Points.Add(se); } chartControl1.Series.Add(series1); XYDiagram diagram = (XYDiagram)chartControl1.Diagram; ((XYDiagram)chartControl1.Diagram).AxisX.QualitativeScaleOptions.AutoGrid = true; ((XYDiagram)chartControl1.Diagram).AxisX.QualitativeScaleOptions.GridSpacing = 3; AxisLabel axisLabel = ((XYDiagram)chartControl1.Diagram).AxisX.Label; //Label settings column X diagram.AxisX.WholeRange.Auto = true; axisLabel.TextPattern = "{A:dd-MM}"; axisLabel.ResolveOverlappingOptions.AllowHide = true; axisLabel.ResolveOverlappingOptions.AllowRotate = true; axisLabel.ResolveOverlappingOptions.AllowStagger = true; axisLabel.ResolveOverlappingOptions.MinIndent = 5; axisLabel.Staggered = true; chartControl1.Legend.AlignmentHorizontal = LegendAlignmentHorizontal.Right; chartControl1.Legend.AlignmentVertical = LegendAlignmentVertical.Top; ((XYDiagram)chartControl1.Diagram).AxisY.Visibility = DevExpress.Utils.DefaultBoolean.True; //Display text On each colummn chartControl1.Series[0].LabelsVisibility = DevExpress.Utils.DefaultBoolean.True; BarSeriesLabel seriesLabel = chartControl1.Series[0].Label as BarSeriesLabel; seriesLabel.BackColor = Color.White; seriesLabel.Border.Color = Color.DarkSlateGray; seriesLabel.Font = new Font("Tahoma", 10, FontStyle.Regular); seriesLabel.Position = BarSeriesLabelPosition.TopInside; seriesLabel.TextOrientation = TextOrientation.Horizontal; seriesLabel.TextPattern = "{V}"; chartControl1.Dock = DockStyle.Fill; this.Controls.Add(chartControl1); }
private void FrmAnalyze_Load(object sender, EventArgs e) { MyGlobals.model.Update(); //MODEL INFORMATION lblObj.Text = ""; lblCon.Text = ""; //OBJECTIVE FUNCTION int int_sense = MyGlobals.model.Get(GRB.IntAttr.ModelSense); if (int_sense == -1) { lblObj.Text = "MAXIMIZE"; } else { lblObj.Text = "MINIMIZE"; } GRBLinExpr func = (GRBLinExpr)MyGlobals.model.GetObjective(); for (int i = 0; i < func.Size; i++) { lblObj.Text = lblObj.Text + " " + func.GetCoeff(i) + func.GetVar(i).Get(GRB.StringAttr.VarName) + " +"; } //CONSTRAINTS GRBConstr[] allCons = MyGlobals.model.GetConstrs(); GRBLinExpr con_info; string co_name; char co_sense; double co_RHS; int n; for (n = 0; n < allCons.Length; n++) { co_name = allCons[n].Get(GRB.StringAttr.ConstrName); co_sense = allCons[n].Get(GRB.CharAttr.Sense); co_RHS = allCons[n].Get(GRB.DoubleAttr.RHS); con_info = (GRBLinExpr)MyGlobals.model.GetRow(allCons[n]); lblCon.Text += co_name + ": "; for (int i = 0; i < con_info.Size; i++) { lblCon.Text += " " + con_info.GetCoeff(i) + con_info.GetVar(i).Get(GRB.StringAttr.VarName) + " +"; } lblCon.Text += " " + co_sense + " " + co_RHS + "\n"; } MyGlobals.model.Optimize(); //VARIABLE TYPE PIE CHART //variables type count int varnum = MyGlobals.model.Get(GRB.IntAttr.NumVars); int NXnum = MyGlobals.model.Get(GRB.IntAttr.NumNZs); int INTnum = MyGlobals.model.Get(GRB.IntAttr.NumIntVars); int BINnum = MyGlobals.model.Get(GRB.IntAttr.NumBinVars); int CONnum = 0; int SEMINTnum = 0; int SEMICONnum = 0; GRBVar[] allVar = MyGlobals.model.GetVars(); for (int i = 0; i < allVar.Length; i++) { if (allVar[i].Get(GRB.CharAttr.VType) == 'C') { CONnum++; } if (allVar[i].Get(GRB.CharAttr.VType) == 'S') { SEMICONnum++; } if (allVar[i].Get(GRB.CharAttr.VType) == 'N') { SEMINTnum++; } } Dictionary <string, int> D = new Dictionary <string, int>(); D.Add("Integer", INTnum); D.Add("Binary", BINnum); D.Add("Continous", CONnum); D.Add("Semi-Integer", SEMINTnum); D.Add("Semi-Continous", SEMICONnum); // Create a chart. ChartControl chartControl1 = new ChartControl(); // Create an empty Bar series and add it to the chart. Series Series_VarType = new Series("Series1", ViewType.Pie); chartControl1.Series.Add(Series_VarType); // Bind chart to dictionary Series_VarType.DataSource = new BindingSource(D, null); // Specify data members to bind the series. Series_VarType.ArgumentScaleType = ScaleType.Qualitative; Series_VarType.ArgumentDataMember = "Key"; Series_VarType.ValueScaleType = ScaleType.Numerical; Series_VarType.ValueDataMembers.AddRange(new string[] { "Value" }); // Adjust the text pattern of the series label. PieSeriesLabel label = (PieSeriesLabel)Series_VarType.Label; label.TextPattern = "{A}: {V:F1} ({VP:P0})"; chartControl1.PaletteName = "Flow"; chartControl1.PaletteBaseColorNumber = 0; // Dock the chart into its parent and add it to the current form. chartControl1.Dock = DockStyle.Bottom; groupBox1.Controls.Add(chartControl1); //OPTIMIZATION RESULTS lblRuntime.Text = ""; lblSolCount.Text = ""; lblOptimal.Text = ""; lblInfeasible.Text = ""; lblRuntime.Text = ""; lblObjSol.Text = ""; lblbound.Text = ""; lblGap.Text = ""; double Runtime = MyGlobals.model.Get(GRB.DoubleAttr.Runtime); if (MyGlobals.model.Get(GRB.IntAttr.Status) == GRB.Status.OPTIMAL) { double ObjSol = MyGlobals.model.Get(GRB.DoubleAttr.ObjVal); double Bound = MyGlobals.model.Get(GRB.DoubleAttr.ObjBound); double Gap = MyGlobals.model.Get(GRB.DoubleAttr.MIPGap); int SolCount = MyGlobals.model.Get(GRB.IntAttr.SolCount); lblOptimal.Text = "OPTIMAL"; lblSolCount.Text = SolCount.ToString(); lblRuntime.Text = Math.Round(Runtime, 3).ToString(); lblObjSol.Text = ObjSol.ToString(); lblbound.Text = Bound.ToString(); lblGap.Text = Gap.ToString(); } else { lblInfeasible.Text = "INFEASIBLE"; lblRuntime.Text = Runtime.ToString(); } //ALGORITHM ITERATION CHART double simplex = MyGlobals.model.Get(GRB.DoubleAttr.IterCount); int bar = MyGlobals.model.Get(GRB.IntAttr.BarIterCount); double barrier = Convert.ToDouble(bar); double branchncut = MyGlobals.model.Get(GRB.DoubleAttr.NodeCount); Dictionary <string, double> DA = new Dictionary <string, double>(); DA.Add("Simplex Iterations", simplex); DA.Add("Barrier Iterations", barrier); DA.Add("Branch-n-Cut Nodes", branchncut); // Create a chart. ChartControl chartControl2 = new ChartControl(); // Create an empty Bar series and add it to the chart. Series Series_Iteration = new Series("Series2", ViewType.Bar); chartControl2.Series.Add(Series_Iteration); // Bind chart to dictionary Series_Iteration.DataSource = new BindingSource(DA, null); // Specify data members to bind the series. Series_Iteration.ArgumentScaleType = ScaleType.Qualitative; Series_Iteration.ArgumentDataMember = "Key"; Series_Iteration.ValueScaleType = ScaleType.Numerical; Series_Iteration.ValueDataMembers.AddRange(new string[] { "Value" }); // Adjust the text pattern of the series label. BarSeriesLabel lbl = (BarSeriesLabel)Series_Iteration.Label; lbl.TextPattern = "{V:F1}"; Legend legend = chartControl2.Legend; // Display the chart control's legend. legend.Visible = false; chartControl2.PaletteName = "Flow"; chartControl2.PaletteBaseColorNumber = 0; // Dock the chart into its parent and add it to the current form. chartControl2.Dock = DockStyle.Fill; pnl_algo.Controls.Add(chartControl2); //COEFF STATS CHART double MAXCOEFF = MyGlobals.model.Get(GRB.DoubleAttr.MaxCoeff); double MINCOEFF = MyGlobals.model.Get(GRB.DoubleAttr.MinCoeff); double MAXBOUND = MyGlobals.model.Get(GRB.DoubleAttr.MaxBound); double MINBOUND = MyGlobals.model.Get(GRB.DoubleAttr.MinBound); double MAXOBJCOEFF = MyGlobals.model.Get(GRB.DoubleAttr.MaxObjCoeff); double MINOBJCOEFF = MyGlobals.model.Get(GRB.DoubleAttr.MinObjCoeff); // Create a chart. ChartControl chartControl3 = new ChartControl(); // Create an empty Bar series and add it to the chart. Series Series_Coeff = new Series("Series3", ViewType.RangeBar); // Add points to them. Series_Coeff.Points.Add(new SeriesPoint("Matrix Coefficient", MAXCOEFF, MINCOEFF)); Series_Coeff.Points.Add(new SeriesPoint("Variable Bound", MAXBOUND, MINBOUND)); Series_Coeff.Points.Add(new SeriesPoint("Linear Obj Coefficient", MAXOBJCOEFF, MINOBJCOEFF)); chartControl3.Series.Add(Series_Coeff); // Adjust the text pattern of the series label. RangeBarSeriesLabel lbl2 = (RangeBarSeriesLabel)Series_Coeff.Label; lbl2.TextPattern = "{V:F1}"; // Hide the legend (if necessary). chartControl3.Legend.Visible = false; chartControl3.PaletteName = "Flow"; chartControl3.PaletteBaseColorNumber = 0; // Dock the chart into its parent and add it to the current form. chartControl3.Dock = DockStyle.Fill; pnl_coeff.Controls.Add(chartControl3); }
private void frmChartManageDao_Load(object sender, EventArgs e) { // gắn title Dao ChartTitle chartTitle = new ChartTitle(); chartTitle.Text = "QUAN LY DAO HOB (TOTAL)"; chartDao.Titles.Add(chartTitle); //khởi tạo series Dao _series1 = new Series("QtyProduct", ViewType.Bar); _series1.ArgumentDataMember = "ProductCode"; _series1.ValueDataMembers[0] = "QtyProduct"; _series1.ArgumentScaleType = ScaleType.Qualitative; _series2 = new Series("QtyProductMax", ViewType.Line); _series2.ArgumentDataMember = "ProductCode"; _series2.ValueDataMembers[0] = "QtyProductMax"; _series2.ArgumentScaleType = ScaleType.Qualitative; _series3 = new Series("QtyMai", ViewType.Line); _series3.ArgumentDataMember = "ProductCode"; _series3.ValueDataMembers[0] = "QtyMai"; _series3.ArgumentScaleType = ScaleType.Qualitative; _series1.LabelsVisibility = DevExpress.Utils.DefaultBoolean.True; _series2.LabelsVisibility = DevExpress.Utils.DefaultBoolean.True; _series3.LabelsVisibility = DevExpress.Utils.DefaultBoolean.True; chartDao.Series.AddRange(new Series[] { _series1, _series2, _series3 }); //Khởi tạo series Dao Detail Series seriesDetail1 = new Series("QtyProduct", ViewType.Bar); seriesDetail1.ArgumentDataMember = "CreatedAt"; seriesDetail1.ValueDataMembers[0] = "QtyProduct"; seriesDetail1.ArgumentScaleType = ScaleType.Qualitative; Series seriesDetail2 = new Series("QtyProductMax", ViewType.Line); seriesDetail2.ArgumentDataMember = "CreatedAt"; seriesDetail2.ValueDataMembers[0] = "QtyProductMax"; seriesDetail2.ArgumentScaleType = ScaleType.Qualitative; Series seriesDetail3 = new Series("TotalProduct", ViewType.Line); seriesDetail3.ArgumentDataMember = "CreatedAt"; seriesDetail3.ValueDataMembers[0] = "TotalProduct"; seriesDetail3.ArgumentScaleType = ScaleType.Qualitative; chartDaoDetail.Series.AddRange(new Series[] { seriesDetail1, seriesDetail2, seriesDetail3 }); seriesDetail1.LabelsVisibility = DevExpress.Utils.DefaultBoolean.True; seriesDetail2.LabelsVisibility = DevExpress.Utils.DefaultBoolean.True; seriesDetail3.LabelsVisibility = DevExpress.Utils.DefaultBoolean.True; // format Axis XYDiagram diagram = chartDaoDetail.Diagram as XYDiagram; //diagram.AxisX.DateTimeScaleOptions.; //diagram.AxisX.DateTimeScaleOptions.GridAlignment = DateTimeGridAlignment.Millisecond; diagram.AxisY.Title.Alignment = StringAlignment.Center; diagram.AxisY.Title.Text = "Cột 1"; diagram.AxisY.Title.Visible = true; diagram.AxisY.Title.TextColor = Color.Red; diagram.AxisY.Label.TextColor = Color.Red; XYDiagram diaDao = chartDao.Diagram as XYDiagram; diaDao.AxisY.Title.Alignment = StringAlignment.Center; diaDao.AxisY.Title.Text = "Cột 1"; diaDao.AxisY.Title.Visible = true; diaDao.AxisY.Title.TextColor = Color.Red; diaDao.AxisY.Label.TextColor = Color.Red; SecondaryAxisY myAxisY = new SecondaryAxisY("my Y-Axis"); ((XYDiagram)chartDao.Diagram).SecondaryAxesY.Add(myAxisY); ((XYDiagram)chartDaoDetail.Diagram).SecondaryAxesY.Add(myAxisY); ((LineSeriesView)_series3.View).AxisY = myAxisY; ((LineSeriesView)seriesDetail3.View).AxisY = myAxisY; myAxisY.Title.Alignment = StringAlignment.Center; myAxisY.Title.Text = "Cột 2"; myAxisY.Title.Visible = true; myAxisY.Title.TextColor = Color.Green; myAxisY.Label.TextColor = Color.Green; myAxisY.Color = Color.Green; // Series Label SeriesPoint s = new SeriesPoint(); PointSeriesLabel barSeries = _series1.Label as PointSeriesLabel; SideBySideBarSeriesLabel l = chartDao.Series[0].Label as SideBySideBarSeriesLabel; SideBySideBarSeriesView v = chartDao.Series[0].View as SideBySideBarSeriesView; BarSeriesLabel seriesLabel = chartDao.Series[0].Label as BarSeriesLabel; PointSeriesLabel p = _series1.Label as PointSeriesLabel; //seriesLabel.BackColor seriesLabel.Position = BarSeriesLabelPosition.TopInside; seriesLabel.TextOrientation = TextOrientation.Horizontal; v.EqualBarWidth = true; //seriesLabel.MaxWidth = (int)barSeries.BarWidth; _lstDao = ManageDaoHOBBO.Instance.FindAll(); if (_lstDao.Count > 0) { chartDao.DataSource = _lstDao; //start thread _threadLoadDaoDetail = new Thread(new ThreadStart(loadDaoDetails)); _threadLoadDaoDetail.IsBackground = true; _threadLoadDaoDetail.Start(); } }