private void SetChartNutrition()
        {
            Series series = new Series("series1", ViewType.Doughnut);

            series.Points.Add(new SeriesPoint("Năng lượng", ingredient.Kcal));
            series.Points.Add(new SeriesPoint("Chất đạm", ingredient.Protein));
            series.Points.Add(new SeriesPoint("Chất béo", ingredient.Fat));
            series.Points.Add(new SeriesPoint("Đường bột", ingredient.Glucose));
            series.Points.Add(new SeriesPoint("Chất xơ", ingredient.Fiber));
            series.Points.Add(new SeriesPoint("Canxi", ingredient.Canxi));
            series.Points.Add(new SeriesPoint("Sắt", ingredient.Iron));
            series.Points.Add(new SeriesPoint("Photpho", ingredient.Photpho));
            series.Points.Add(new SeriesPoint("Kali", ingredient.Kali));
            series.Points.Add(new SeriesPoint("Natri", ingredient.Natri));
            series.Points.Add(new SeriesPoint("Vitamin A", ingredient.VitaminA));
            series.Points.Add(new SeriesPoint("Vitamin B1", ingredient.VitaminB1));
            series.Points.Add(new SeriesPoint("Vitamin C", ingredient.VitaminC));
            series.Points.Add(new SeriesPoint("Axit Folic", ingredient.AxitFolic));
            series.Points.Add(new SeriesPoint("Cholesterol", ingredient.Cholesterol));

            chartNutrition.Series.Add(series);
            PieSeriesLabel label = (PieSeriesLabel)series.Label;

            label.TextPattern            = "{A}: {VP:P0}";
            label.ResolveOverlappingMode = ResolveOverlappingMode.Default;
            ChartTitle chartTitle = new ChartTitle();

            chartTitle.Text = "Tỉ lệ dưỡng chất";
            chartNutrition.Titles.Add(chartTitle);
        }
Example #2
0
        private void DrawBars()
        {
            this.chartControl1.Series.Clear();
            foreach (string _yfield in AxisYFields)
            {
                Series _se = new DevExpress.XtraCharts.Series();
                _se.View = new DevExpress.XtraCharts.PieSeriesView();
                PieSeriesView _pv = _se.View as PieSeriesView;
                _pv.RuntimeExploding = true;


                PieSeriesLabel _ps = _se.Label as PieSeriesLabel;
                _ps.Position = PieSeriesLabelPosition.TwoColumns;

                PiePointOptions _piePointOptions = _se.PointOptions as PiePointOptions;
                _se.PointOptions.HiddenSerializableString = "to be serialized";
                _se.PointOptions.PointView = DevExpress.XtraCharts.PointView.ArgumentAndValues;
                _piePointOptions.PercentOptions.ValueAsPercent     = true;
                _piePointOptions.PercentOptions.PercentageAccuracy = dataPrecision + 2;
                _se.PointOptions.ValueNumericOptions.Format        = DevExpress.XtraCharts.NumericFormat.Percent;
                _se.PointOptions.ValueNumericOptions.Precision     = dataPrecision;
                _se.PointOptionsTypeName = "PiePointOptions";
                _se.ValueDataMembers.Clear();
                _se.DataSource         = chartData;
                _se.ArgumentDataMember = AxisXField;
                _se.ValueDataMembers.AddRange(new string[] { _yfield });
                _se.LegendText = AxisYTitle[_yfield];
                this.chartControl1.Series.Add(_se);
            }
            int _rowCount = chartData.Rows.Count;
        }
Example #3
0
 /// <summary>
 /// 设置饼状图的Lable位置
 /// </summary>
 /// <param name="series">SeriesBase</param>
 /// <param name="lablePosition">PieSeriesLabelPosition枚举</param>
 public static void SetLablePosition(this SeriesBase series, PieSeriesLabelPosition lablePosition)
 {
     if (series.Label is PieSeriesLabel)
     {
         PieSeriesLabel _label = series.Label as PieSeriesLabel;
         _label.Position = lablePosition;
     }
     //if (series.Label is Pie3DSeriesLabel)
     //{
     //    Pie3DSeriesLabel _label = series.Label as Pie3DSeriesLabel;
     //    _label.Position = lablePosition;
     //}
 }
Example #4
0
        private void BindData()
        {
            if (string.IsNullOrEmpty(FieldName))
            {
                return;
            }

            //设置报表标题
            this.Text = ReportTitle;
            this.lblReportTitle.Text = ReportTitle;

            this.chartPie.Series.Clear();
            this.chartBar.Series.Clear();

            string where = GetConditionSql();
            dt           = BLLFactory <ItemDetail> .Instance.GetReportData(FieldName, where);

            this.gridControl1.DataSource = dt;

            if (dt != null && dt.Rows.Count > 0)
            {
                this.chartPie.DataSource = dt;

                Series pieSeries = CreateSeries(dt, DevExpress.XtraCharts.ViewType.Pie3D, NumericFormat.Percent);
                chartPie.Series.Add(pieSeries);
                chartPie.Legend.Visible = true;

                PieSeriesLabel label = pieSeries.Label as PieSeriesLabel;
                ((PiePointOptions)label.PointOptions).PercentOptions.PercentageAccuracy = 4;
                ((PiePointOptions)label.PointOptions).PercentOptions.ValueAsPercent     = true;

                label.Position = PieSeriesLabelPosition.TwoColumns;                                         //设置饼图上lable的显示方式,此方式将独立出一个列显示lable
                (pieSeries.View as DevExpress.XtraCharts.Pie3DSeriesView).ExplodeMode = PieExplodeMode.All; //突出显示饼块
                (pieSeries.View as DevExpress.XtraCharts.Pie3DSeriesView).ExplodedDistancePercentage = 5;
                //(pieSeries.View as DevExpress.XtraCharts.PieSeriesView).RuntimeExploding = true; //设置了他,你就可以把你喜欢的饼块拖出来。。。

                this.chartBar.DataSource = dt;
                chartBar.Series.Add(CreateSeries(dt, DevExpress.XtraCharts.ViewType.Bar, NumericFormat.General));
                chartBar.Legend.Visible = false;
                chartBar.SeriesTemplate.LabelsVisibility = DefaultBoolean.True;
            }

            this.xtraTabControl1.SelectedTabPageIndex = 0;
        }
        private void InitChart(ChartControl chart, string title, int completedValue, int waitingValue, int missingValue)
        {
            var series          = new Series();
            var seriesLabel     = new PieSeriesLabel();
            var seriesCompleted = new SeriesPoint("Tamamlanan", new object[] { completedValue }, 0);
            var seriesWaiting   = new SeriesPoint("Bekleyen", new object[] { waitingValue }, 1);
            var seriesMissing   = new SeriesPoint("Eksik", new object[] { missingValue }, 2);
            var pieView         = new PieSeriesView();
            var chartTitle      = new ChartTitle();

            ((ISupportInitialize)chart).BeginInit();
            ((ISupportInitialize)series).BeginInit();
            ((ISupportInitialize)seriesLabel).BeginInit();
            ((ISupportInitialize)pieView).BeginInit();

            SuspendLayout();

            chart.Legend.AlignmentHorizontal = LegendAlignmentHorizontal.Center;
            chart.Legend.AlignmentVertical   = LegendAlignmentVertical.TopOutside;
            chart.Legend.Direction           = LegendDirection.LeftToRight;
            chart.Legend.Name                       = "Default";
            chart.Legend.Font                       = AppAppearance.DefaultFont;
            chart.Location                          = new Point(12, 12);
            seriesLabel.LineVisibility              = DevExpress.Utils.DefaultBoolean.True;
            seriesLabel.TextPattern                 = "{A} : {V} - {VP:0.0%}";
            seriesLabel.Font                        = AppAppearance.DefaultFont;
            seriesLabel.ResolveOverlappingMode      = ResolveOverlappingMode.JustifyAllAroundPoint;
            seriesLabel.ResolveOverlappingMinIndent = 5;
            series.Label = seriesLabel;
            series.Name  = "Sipariş";
            seriesMissing.ColorSerializable = "#9BBB59";
            series.Points.AddRange(seriesCompleted, seriesWaiting, seriesMissing);
            series.View = pieView;
            chart.SeriesSerializable = new[] { series };
            chartTitle.Text          = title;
            chart.Titles.AddRange(new[] { chartTitle });

            ((ISupportInitialize)seriesLabel).EndInit();
            ((ISupportInitialize)pieView).EndInit();
            ((ISupportInitialize)series).EndInit();
            ((ISupportInitialize)chart).EndInit();
            ResumeLayout(false);
        }
        private void InitPieChart(List <ProjectSummary> dataSource, string valueName, ChartControl pieChart)
        {
            // pie chart
            Series pieSeries = new Series();

            pieSeries.ValueScaleType = ScaleType.Numerical;
            pieSeries.LegendPointOptions.PointView = PointView.Argument;
            pieSeries.LegendPointOptions.ValueNumericOptions.Format = NumericFormat.Percent;
            PieSeriesView pieView = new PieSeriesView();

            pieView.ExplodedDistancePercentage = 10;
            SeriesTitle title = new SeriesTitle();

            title.Text = Properties.Resources.ResourceManager.GetString(valueName + "Rate");
            pieView.Titles.Add(title);
            pieView.RuntimeExploding = true;
            pieSeries.View           = pieView;

            foreach (var item in dataSource)
            {
                SeriesPoint seriesPoint = new SeriesPoint(item.Name, new object[] { ((object)(item.GetType().GetProperty(valueName).GetValue(item, null))) });
                pieSeries.Points.Add(seriesPoint);
            }
            pieChart.Series.Add(pieSeries);


            PieSeriesLabel pieSerieslable = pieSeries.Label as PieSeriesLabel;

            if (pieSerieslable != null)
            {
                pieSerieslable.PointOptions.PointView = PointView.ArgumentAndValues;
                pieSerieslable.Position      = PieSeriesLabelPosition.TwoColumns;
                pieSerieslable.TextAlignment = StringAlignment.Center;
            }
            PiePointOptions options = pieSeries.Label.PointOptions as PiePointOptions;

            if (options != null)
            {
                options.PercentOptions.PercentageAccuracy = 2;
                options.PercentOptions.ValueAsPercent     = true;
                options.ValueNumericOptions.Format        = NumericFormat.Percent;
            }
        }
Example #7
0
        private void SetGraphForCommunityTypes()
        {
            CommunitiesByTypeChart.Series.Clear();
            string    statname = "COMMUNITY_TYPE_";
            DataTable dt       = VSWebBL.DashboardBL.ConnectionsBL.Ins.GetStatByName(selectedServer, statname, false);
            Series    series   = new Series("StatName", ViewType.Pie);

            series.ArgumentDataMember = dt.Columns["StatName"].ToString();
            series.LabelsVisibility   = DevExpress.Utils.DefaultBoolean.True;
            PieSeriesLabel label = (PieSeriesLabel)series.Label;

            label.TextPattern        = "{A}: {VP:P0}";
            series.LegendTextPattern = "{A}: {V}";

            ValueDataMemberCollection seriesValueDataMembers = (ValueDataMemberCollection)series.ValueDataMembers;

            seriesValueDataMembers.AddRange(dt.Columns["StatValue"].ToString());
            CommunitiesByTypeChart.Series.Add(series);

            CommunitiesByTypeChart.DataSource = dt;
            CommunitiesByTypeChart.DataBind();
        }
        public void SetGraphForDiskSpace(string serverName)
        {
            DataTable dt = VSWebBL.ConfiguratorBL.DominoServerDetails_BL.Ins.SetGraphForDiskSpace(serverName);

            DiskSpaceWebChartControl.DataSource = dt;

            double[] double1 = new double[dt.Rows.Count];
            double[] double2 = new double[dt.Rows.Count];

            Series series = null;

            if (dt.Rows.Count > 0)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    if (series != null)
                    {
                        DiskSpaceWebChartControl.Series.Add(series);
                        DiskSpaceWebChartControl.DataBind();
                    }
                    series = new Series(dt.Rows[i]["DiskName"].ToString(), ViewType.Pie);
                    if (dt.Rows[i]["DiskFree"] != "" && dt.Rows[i]["DiskFree"] != null)
                    {
                        double1[i] = Convert.ToDouble(dt.Rows[i]["DiskFree"].ToString());
                    }
                    if (dt.Rows[i]["DiskUsed"] != "" && dt.Rows[i]["DiskUsed"] != null)
                    {
                        double2[i] = Convert.ToDouble(dt.Rows[i]["DiskUsed"].ToString());
                    }
                    series.Points.Add(new SeriesPoint("DiskFree", double1[i]));
                    series.Points.Add(new SeriesPoint("DiskUsed", double2[i]));

                    //series.Label.Visible = true;
                    series.LabelsVisibility = DevExpress.Utils.DefaultBoolean.True;
                    PieSeriesLabel seriesLabel = (PieSeriesLabel)series.Label;
                    seriesLabel.Position  = PieSeriesLabelPosition.Radial;
                    seriesLabel.BackColor = System.Drawing.Color.Transparent;
                    seriesLabel.TextColor = System.Drawing.Color.Black;

                    PieSeriesView seriesView = (PieSeriesView)series.View;
                    seriesView.Titles.Add(new SeriesTitle());
                    seriesView.Titles[0].Dock = ChartTitleDockStyle.Bottom;

                    if (i == 0)
                    {
                        PiePointOptions seriesPointOptions = (PiePointOptions)series.LegendPointOptions;
                        series.LegendPointOptions.PointView             = PointView.Argument;
                        DiskSpaceWebChartControl.Series[i].ShowInLegend = true;
                        DiskSpaceWebChartControl.Series[i].LegendPointOptions.PointView = PointView.Argument;
                        DiskSpaceWebChartControl.Series[i].ShowInLegend = true;
                        DiskSpaceWebChartControl.Legend.Visible         = true;
                    }
                    else
                    {
                        DiskSpaceWebChartControl.Series[i].LegendPointOptions.PointView = PointView.Argument;
                        DiskSpaceWebChartControl.Series[i].ShowInLegend = false;
                    }

                    seriesView.Titles[0].Text     = series.Name;
                    seriesView.Titles[0].Visible  = true;
                    seriesView.Titles[0].WordWrap = true;
                }
            }
            if (series != null)
            {
                DiskSpaceWebChartControl.Series.Add(series);
                series.LegendPointOptions.PointView = PointView.Argument;
                DiskSpaceWebChartControl.DataBind();
                //DiskSpaceWebChartControl.Series[i].LegendPointOptions.PointView = PointView.Argument;
                //DiskSpaceWebChartControl.Series[i].ShowInLegend = false;
            }
        }
        private void BindData()
        {
            //设置报表标题
            this.Text = ReportTitle;
            this.lblReportTitle.Text = ReportTitle;
            this.xtraTabControl1.SelectedTabPageIndex = 0;

            #region 初始化图表内容
            this.chartPie.Series.Clear();
            this.chartBar.Series.Clear();

            string where = GetConditionSql();

            dt = DataTableHelper.CreateTable("argument,datavalue|int");
            DataRow   row;
            int       countRepeat = 0;
            CListItem fieldItem   = txtFieldName.SelectedItem as CListItem;
            if (fieldItem != null && !string.IsNullOrEmpty(fieldItem.Value) && this.lstItems.Items.Count > 0)
            {
                string fieldName  = fieldItem.Value;
                int    totalCount = BLLFactory <ItemDetail> .Instance.GetRecordCount(where);//计算总人数

                foreach (string searchItem in this.lstItems.Items)
                {
                    string condition = string.Format("{0} like '%{1}%' ", fieldName, searchItem);
                    if (!string.IsNullOrEmpty(where))
                    {
                        condition += string.Format(" AND {0}", where);
                    }

                    int countValue = BLLFactory <ItemDetail> .Instance.GetRecordCount(condition);//计算总人数

                    countRepeat += countValue;

                    row    = dt.NewRow();
                    row[0] = searchItem;
                    row[1] = countValue;
                    dt.Rows.Add(row);
                }

                //增加其他
                row    = dt.NewRow();
                row[0] = "其他";
                row[1] = totalCount - countRepeat;
                dt.Rows.Add(row);
            }
            else
            {
                MessageDxUtil.ShowTips("请选择统计字段和统计项目,然后才进行统计");
                return;
            }
            this.gridControl1.DataSource = dt;

            if (dt != null && dt.Rows.Count > 0)
            {
                this.chartPie.DataSource = dt;

                Series pieSeries = CreateSeries(dt, DevExpress.XtraCharts.ViewType.Pie3D, NumericFormat.Percent);
                chartPie.Series.Add(pieSeries);
                chartPie.Legend.Visible = true;

                PieSeriesLabel label = pieSeries.Label as PieSeriesLabel;
                ((PiePointOptions)label.PointOptions).PercentOptions.PercentageAccuracy = 4;
                ((PiePointOptions)label.PointOptions).PercentOptions.ValueAsPercent     = true;

                label.Position = PieSeriesLabelPosition.TwoColumns;                                         //设置饼图上lable的显示方式,此方式将独立出一个列显示lable
                (pieSeries.View as DevExpress.XtraCharts.Pie3DSeriesView).ExplodeMode = PieExplodeMode.All; //突出显示饼块
                (pieSeries.View as DevExpress.XtraCharts.Pie3DSeriesView).ExplodedDistancePercentage = 5;
                //(pieSeries.View as DevExpress.XtraCharts.PieSeriesView).RuntimeExploding = true; //设置了他,你就可以把你喜欢的饼块拖出来。。。

                this.chartBar.DataSource = dt;
                chartBar.Series.Add(CreateSeries(dt, DevExpress.XtraCharts.ViewType.Bar, NumericFormat.General));
                chartBar.Legend.Visible = false;
                chartBar.SeriesTemplate.LabelsVisibility = DefaultBoolean.True;
            }
            #endregion
        }
        public void LoadGraph()
        {
            if (_report.State != Report.StateEnum.Executed)
            {
                return;
            }

            bool rotateGraph = false;
            bool rotateAxes  = ((_report.GraphOptions & OlapReport.GraphOptionsEnum.RotateAxes) > 0);

            int seriesPosCount = (rotateAxes ? _report.Cellset.Axis1PosCount: _report.Cellset.Axis0PosCount);
            int seriesMemCount = (rotateAxes ? _report.Cellset.Axis1TupleMemCount: _report.Cellset.Axis0TupleMemCount);
            int catPosCount    = (rotateAxes ? _report.Cellset.Axis0PosCount: _report.Cellset.Axis1PosCount);
            int catMemCount    = (rotateAxes ? _report.Cellset.Axis0TupleMemCount: _report.Cellset.Axis1TupleMemCount);

            if (seriesPosCount > 256)
            {
                seriesPosCount = 256;
            }

            if (catPosCount > 1024)
            {
                catPosCount = 1024;
            }

            bool showValues = (_report.GraphOptions & OlapReport.GraphOptionsEnum.ShowValues) > 0;
            bool showSeries = (_report.GraphOptions & OlapReport.GraphOptionsEnum.ShowSeries) > 0;
            bool showCats   = (_report.GraphOptions & OlapReport.GraphOptionsEnum.ShowCategories) > 0;
            bool setScaling = (_report.GraphOptions & OlapReport.GraphOptionsEnum.SetScaling) > 0;

            // create series
            for (int i = 0; i < seriesPosCount; i++)
            {
                string name = "";
                for (int j = 0; j < seriesMemCount; j++)
                {
                    name += (j == 0 ? "" : " | ") + (rotateAxes ? _report.Cellset.GetCellsetMember(1, j, i).Name : _report.Cellset.GetCellsetMember(0, j, i).Name);
                }

                Series series = new Series();
                series.Name = name;
                _chCtrl.Series.Add(series);

                // type
                if (_report.GraphType == OlapReport.GraphTypeEnum.Pie)
                {
                    // limit number of series
                    if (seriesPosCount > 6)
                    {
                        seriesPosCount = 6;
                    }

                    // disable scaling for pie
                    setScaling = false;

                    series.ChangeView(ViewType.Pie);

                    PiePointOptions ppo = (PiePointOptions)series.PointOptions;
                    PieSeriesView   psw = (PieSeriesView)series.View;
                    PieSeriesLabel  psl = (PieSeriesLabel)series.Label;

                    psl.Position        = PieSeriesLabelPosition.TwoColumns;
                    series.ShowInLegend = false;                   // cause it's shown in pie anyway
                    showValues          = true;
                    showCats            = true;

                    this.chkCat.Checked     = true;
                    this.chkCat.Disabled    = true;
                    this.chkValues.Checked  = true;
                    this.chkValues.Disabled = true;
                }
                else
                {
                    if (_report.GraphType == OlapReport.GraphTypeEnum.BarVertical)
                    {
                        series.ChangeView(ViewType.Bar);
                    }
                    else if (_report.GraphType == OlapReport.GraphTypeEnum.BarHorizontal)
                    {
                        series.ChangeView(ViewType.Bar);
                        rotateGraph = true;
                    }
                    else if (_report.GraphType == OlapReport.GraphTypeEnum.StackedBarVertical)
                    {
                        series.ChangeView(ViewType.StackedBar);
                    }
                    else if (_report.GraphType == OlapReport.GraphTypeEnum.StackedBarHorizontal)
                    {
                        series.ChangeView(ViewType.StackedBar);
                        rotateGraph = true;
                    }
                    else if (_report.GraphType == OlapReport.GraphTypeEnum.LineHorizontal)
                    {
                        series.ChangeView(ViewType.Line);
                    }

                    series.LegendText     = name;
                    series.ShowInLegend   = true;
                    series.ValueScaleType = ScaleType.Numerical;
                    series.Visible        = true;

                    // labels orientation
                    XYDiagram diag = (XYDiagram)_chCtrl.Diagram;
                    diag.Rotated = rotateGraph;
                    if (rotateGraph)
                    {
                        diag.AxisY.Label.Antialiasing = true;
                        diag.AxisY.Label.Angle        = 315;
                    }
                    else
                    {
                        diag.AxisX.Label.Antialiasing = true;
                        diag.AxisX.Label.Angle        = 315;
                    }

                    // if scaling
                    if (setScaling)
                    {
                        diag.AxisY.Visible = false;
                    }

//					if(setScaling)
//					{
//						// hide axis, cause it won't display real values
//						if(seriesPosCount<10)
//							diag.AxisY.Visible=false;
//						if(i<10)
//						{
//							SecondaryAxisY axisY=new SecondaryAxisY(name);
//
//							axisY.Alignment=AxisAlignment.Near;
//							axisY.Title.Text = name;
//							axisY.Title.Visible = true;
//							axisY.Title.Font=new Font(axisY.Title.Font.Name, 10);
//							axisY.Label.Antialiasing=true;
//							axisY.Label.Angle=315;
//
//							diag.SecondaryAxesY.Add(axisY);
//							((XYDiagramSeriesViewBase)series.View).AxisY = axisY;
//						}
//					}
                }


                // prepare scaling ranges
                double scalingMin = double.MaxValue;
                double scalingMax = double.MinValue;
                if (setScaling)
                {
                    for (int l = 0; l < catPosCount; l++)
                    {
                        string val  = (rotateAxes ? _report.Cellset.GetCell(l, i).Value : _report.Cellset.GetCell(i, l).Value);
                        double dVal = 0;
                        double.TryParse(val, System.Globalization.NumberStyles.Float, System.Globalization.NumberFormatInfo.InvariantInfo, out dVal);
                        if (dVal < scalingMin)
                        {
                            scalingMin = dVal;
                        }
                        if (dVal > scalingMax)
                        {
                            scalingMax = dVal;
                        }
                    }
                }
                scalingMin = scalingMin - (scalingMax - scalingMin) * 0.1;

                // set data
                for (int l = 0; l < catPosCount; l++)
                {
                    string argument = "";
                    for (int m = 0; m < catMemCount; m++)
                    {
                        argument += (m == 0 ? "" : " | ") + (rotateAxes ? _report.Cellset.GetCellsetMember(0, m, l).Name : _report.Cellset.GetCellsetMember(1, m, l).Name);
                    }

                    string val  = (rotateAxes ? _report.Cellset.GetCell(l, i).Value : _report.Cellset.GetCell(i, l).Value);
                    string fVal = (rotateAxes ? _report.Cellset.GetCell(l, i).FormattedValue : _report.Cellset.GetCell(i, l).FormattedValue);
                    double dVal = 0;
                    double.TryParse(val, System.Globalization.NumberStyles.Float, System.Globalization.NumberFormatInfo.InvariantInfo, out dVal);

                    if (setScaling)
                    {
                        dVal = (scalingMax - scalingMin == 0 ? 0 : (scalingMin + dVal) / (scalingMax - scalingMin));
                    }

                    // custom point label
                    string customLabel = string.Empty;
                    if (!showValues && !showSeries && !showCats)
                    {
                        series.Label.Visible = false;
                    }
                    else
                    {
                        customLabel  = (showSeries ? series.Name : string.Empty);
                        customLabel += (showCats ? (customLabel != string.Empty ? " | " : string.Empty) + argument : string.Empty);
                        customLabel += (showValues ? (customLabel != string.Empty ? ": " : string.Empty) + fVal : string.Empty);
                    }

                    CustomChartSeriesPoint sp = new CustomChartSeriesPoint(argument, dVal, customLabel);
                    series.Points.Add(sp);
                }
            }


            ChartTitle title = new ChartTitle();

            title.Alignment = StringAlignment.Center;
            title.Lines     = new string[] { _report.Name, _report.Description };
            _chCtrl.Titles.Add(title);

            if (_report.GraphTheme != null && _report.GraphTheme != "")
            {
                _chCtrl.AppearanceName = _report.GraphTheme;
            }
            _chCtrl.Width  = AdjustGraphSize(_report.GraphWidth);
            _chCtrl.Height = AdjustGraphSize(_report.GraphHeight);

            string imgNamePrefix = _report.GetType().Name + _report.ID.ToString();

            //delete older images of same report
            string[] filePaths = System.IO.Directory.GetFiles(FI.Common.AppConfig.TempDir, imgNamePrefix + "*.PNG");
            if (filePaths != null && filePaths.Length > 0)
            {
                for (int j = 0; j < filePaths.Length; j++)
                {
                    try
                    {
                        System.IO.File.Delete(filePaths[j]);
                    }
                    catch (Exception exc)
                    {
                        //do nothing
                        exc = null;
                    }
                }
            }


            //write to file and display, it will overwite itself if needed
            string imgName     = imgNamePrefix + "." + DateTime.Now.ToString("yyyyMMddHHssfff") + ".PNG";
            string imgVirtPath = Request.ApplicationPath + "/" + FI.Common.AppConfig.TempVirtualDir + "/" + imgName;
            string imgPhysPath = FI.Common.AppConfig.TempDir + @"\" + imgName;

            _chCtrl.ExportToImage(imgPhysPath, System.Drawing.Imaging.ImageFormat.Png);

            System.Web.UI.WebControls.Image img = new System.Web.UI.WebControls.Image();
            img.ImageUrl = imgVirtPath;
            this.cellGraph.Controls.Add(img);
        }
Example #11
0
        public void SetGraphForDiskSpace(string serverName, DashboardReports.DominoDiskAvgXtraRpt report, XRChart CurrentDiskSpaceChart, string serverType)
        {
            bool isSummary;

            //XRChart CurrentDiskSpaceChart = (XRChart)report.FindControl("CurrentDiskSpaceChart", true);
            CurrentDiskSpaceChart.Series.Clear();
            //DataTable dt = VSWebBL.ReportsBL.ReportsBL.Ins.DominoDiskSpaceBL(serverName);
            dt = (DataTable)report.DataSource;
            CurrentDiskSpaceChart.DataSource = dt;
            isSummary = (bool)report.Parameters["IsSummary"].Value;
            double[] double1  = new double[dt.Rows.Count];
            double[] double2  = new double[dt.Rows.Count];
            string   diskName = "";
            string   srvName  = "";

            Series series = null;

            if (!isSummary)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    diskName = dt.Rows[i]["DiskName"].ToString();
                    srvName  = dt.Rows[i]["ServerName"].ToString();
                    //if (diskName == xrTableCell1.Text && srvName == xrLabel18.Text)
                    if (diskName == ((XRTableCell)report.FindControl("xrTableCell1", true)).Text &&
                        srvName == ((XRLabel)report.FindControl("xrLabel18", true)).Text)
                    {
                        if (series != null)
                        {
                            CurrentDiskSpaceChart.Series.Add(series);
                        }


                        series = new Series(dt.Rows[i]["DiskName"].ToString(), ViewType.Pie);

                        string val1 = dt.Rows[i]["PercentFree"].ToString();
                        string val2 = dt.Rows[i]["PercentUsed"].ToString();

                        if (val1 != "" && val2 != "")
                        {
                            double1[i] = Convert.ToDouble(dt.Rows[i]["PercentFree"].ToString());
                            double2[i] = Convert.ToDouble(dt.Rows[i]["PercentUsed"].ToString());

                            series.Points.Add(new SeriesPoint("Percent Free", double1[i]));
                            series.Points.Add(new SeriesPoint("Percent Used", double2[i]));
                            series.ShowInLegend = true;

                            series.LabelsVisibility = DevExpress.Utils.DefaultBoolean.True;
                            PieSeriesLabel seriesLabel = (PieSeriesLabel)series.Label;
                            seriesLabel.Position  = PieSeriesLabelPosition.Radial;
                            seriesLabel.BackColor = System.Drawing.Color.Transparent;
                            seriesLabel.TextColor = System.Drawing.Color.Black;
                        }
                    }
                }
            }
            else
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    srvName = report.Parameters["ServerName"].Value.ToString();
                    if (series != null)
                    {
                        CurrentDiskSpaceChart.Series.Add(series);
                    }

                    series = new Series("All Disks", ViewType.Pie);

                    string val1 = dt.Rows[i]["PercentFree"].ToString();
                    string val2 = dt.Rows[i]["PercentUsed"].ToString();

                    if (val1 != "" && val2 != "")
                    {
                        double1[i] = Convert.ToDouble(dt.Rows[i]["PercentFree"].ToString());
                        double2[i] = Convert.ToDouble(dt.Rows[i]["PercentUsed"].ToString());

                        series.Points.Add(new SeriesPoint("Percent Free", double1[i]));
                        series.Points.Add(new SeriesPoint("Percent Used", double2[i]));
                        series.ShowInLegend = true;

                        series.LabelsVisibility = DevExpress.Utils.DefaultBoolean.True;
                        PieSeriesLabel seriesLabel = (PieSeriesLabel)series.Label;
                        seriesLabel.Position  = PieSeriesLabelPosition.Radial;
                        seriesLabel.BackColor = System.Drawing.Color.Transparent;
                        seriesLabel.TextColor = System.Drawing.Color.Black;
                    }
                }
            }
            if (series != null)
            {
                CurrentDiskSpaceChart.Series.Add(series);
            }
            for (int c = 0; c < CurrentDiskSpaceChart.Series.Count; c++)
            {
                if (c == 0)
                {
                    PiePointOptions seriesPointOptions = (PiePointOptions)series.LegendPointOptions;
                    series.LegendPointOptions.PointView = PointView.Argument;
                    CurrentDiskSpaceChart.Series[0].LegendPointOptions.PointView = PointView.Argument;
                    CurrentDiskSpaceChart.Series[0].ShowInLegend = true;
                    CurrentDiskSpaceChart.Legend.Visible         = true;
                }
                else
                {
                    CurrentDiskSpaceChart.Series[c].ShowInLegend = false;
                }
            }
        }
Example #12
0
        public void SetGraphForDiskSpace(DashboardReports.DominoDiskAvgXtraRpt report, DataTable dt, bool isSummary,
                                         XRChart CurrentDiskSpaceChart)
        {
            //2/24/2014 NS added
            try
            {
                CurrentDiskSpaceChart.Series.Clear();
                CurrentDiskSpaceChart.DataSource = dt;
                double[] double1  = new double[dt.Rows.Count];
                double[] double2  = new double[dt.Rows.Count];
                string   diskName = "";
                string   srvName  = "";

                Series series = null;
                if (!isSummary)
                {
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        diskName = dt.Rows[i]["DiskName"].ToString();
                        srvName  = dt.Rows[i]["ServerName"].ToString();
                        //if (diskName == report.FindControl("xrTableCell1", true).Text && srvName == report.FindControl("xrLabel18", true).Text)
                        //{
                        if (series != null)
                        {
                            CurrentDiskSpaceChart.Series.Add(series);
                        }
                        series = new Series(dt.Rows[i]["DiskName"].ToString(), ViewType.Pie);

                        string val1 = dt.Rows[i]["PercentFree"].ToString();
                        string val2 = dt.Rows[i]["PercentUsed"].ToString();
                        if (val1 != "" && val2 != "")
                        {
                            double1[i] = Convert.ToDouble(dt.Rows[i]["PercentFree"].ToString());
                            double2[i] = Convert.ToDouble(dt.Rows[i]["PercentUsed"].ToString());
                            series.Points.Add(new SeriesPoint("Percent Free", double1[i]));
                            series.Points.Add(new SeriesPoint("Percent Used", double2[i]));
                            series.ShowInLegend     = true;
                            series.LabelsVisibility = DevExpress.Utils.DefaultBoolean.True;
                            PieSeriesLabel seriesLabel = (PieSeriesLabel)series.Label;
                            seriesLabel.Position  = PieSeriesLabelPosition.Radial;
                            seriesLabel.BackColor = System.Drawing.Color.Transparent;
                            seriesLabel.TextColor = System.Drawing.Color.Black;
                            //PieSeriesView seriesView = (PieSeriesView)series.View;
                            //seriesView.Titles.Add(new SeriesTitle());
                            //seriesView.Titles[0].Dock = ChartTitleDockStyle.Bottom;
                            //seriesView.Titles[0].Text = series.Name.ToString();
                            //seriesView.Titles[0].Visible = true;
                            //seriesView.Titles[0].WordWrap = true;
                        }
                        //}
                    }
                }
                else
                {
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        srvName = report.Parameters["ServerName"].Value.ToString();
                        if (series != null)
                        {
                            CurrentDiskSpaceChart.Series.Add(series);
                        }

                        series = new Series("All Disks", ViewType.Pie);

                        string val1 = dt.Rows[i]["PercentFree"].ToString();
                        string val2 = dt.Rows[i]["PercentUsed"].ToString();

                        if (val1 != "" && val2 != "")
                        {
                            double1[i] = Convert.ToDouble(dt.Rows[i]["PercentFree"].ToString());
                            double2[i] = Convert.ToDouble(dt.Rows[i]["PercentUsed"].ToString());

                            series.Points.Add(new SeriesPoint("Percent Free", double1[i]));
                            series.Points.Add(new SeriesPoint("Percent Used", double2[i]));
                            series.ShowInLegend = true;

                            series.LabelsVisibility = DevExpress.Utils.DefaultBoolean.True;
                            PieSeriesLabel seriesLabel = (PieSeriesLabel)series.Label;
                            seriesLabel.Position  = PieSeriesLabelPosition.Radial;
                            seriesLabel.BackColor = System.Drawing.Color.Transparent;
                            seriesLabel.TextColor = System.Drawing.Color.Black;
                        }
                    }
                }
                if (series != null)
                {
                    CurrentDiskSpaceChart.Series.Add(series);
                }
                for (int c = 0; c < CurrentDiskSpaceChart.Series.Count; c++)
                {
                    if (c == 0)
                    {
                        PiePointOptions seriesPointOptions = (PiePointOptions)series.LegendPointOptions;
                        series.LegendPointOptions.PointView = PointView.Argument;
                        CurrentDiskSpaceChart.Series[0].LegendPointOptions.PointView = PointView.Argument;
                        CurrentDiskSpaceChart.Series[0].ShowInLegend = true;
                        CurrentDiskSpaceChart.Legend.Visible         = true;
                    }
                    else
                    {
                        CurrentDiskSpaceChart.Series[c].ShowInLegend = false;
                    }
                }
            }
            catch (Exception ex)
            {
                WriteServiceHistoryEntry(DateTime.Now.ToString() + " The following error has occurred in SetGraph: " + ex.Message);
            }
        }
Example #13
0
        private void BindChart()
        {
            string dimensionName = string.Empty;

            if (dimsionValue > 0)
            {
                dimensionName = ((Dimension)dimsionValue).ToString();
            }
            xrChart1.Series.Clear();
            if (dimsionValue <= 0 && chartType == 0)
            {
                Series pieSeries = new Series();
                pieSeries.ValueScaleType = ScaleType.Numerical;
                pieSeries.LegendPointOptions.PointView = PointView.Argument;
                pieSeries.LegendPointOptions.ValueNumericOptions.Format = NumericFormat.Percent;
                PieSeriesView pieView = new PieSeriesView();
                pieView.ExplodedDistancePercentage = 10;
                SeriesTitle title = new SeriesTitle();
                title.Text = GetLocalizedCaption(targetName) + "-" + GetLocalizedCaption("Rate");
                pieView.Titles.Add(title);
                pieView.RuntimeExploding = true;
                pieSeries.View           = pieView;

                List <SaleOverview> dataList = (List <SaleOverview>) this.DataSource;
                var resultData = dataList.AsQueryable().GroupBy("UnitName", "it")
                                 .Select("new (Key as UnitName,Sum(" + targetName + ") as " + targetName + ")", null);

                foreach (var item in resultData)
                {
                    Type        itemType    = item.GetType();
                    SeriesPoint seriesPoint = new SeriesPoint(itemType.GetProperty("UnitName").GetValue(item, null)
                                                              , new object[] { ((object)itemType.GetProperty(targetName).GetValue(item, null)) });
                    pieSeries.Points.Add(seriesPoint);
                }
                xrChart1.Series.Add(pieSeries);

                PieSeriesLabel pieSerieslable = pieSeries.Label as PieSeriesLabel;
                if (pieSerieslable != null)
                {
                    pieSerieslable.PointOptions.PointView = PointView.ArgumentAndValues;
                    pieSerieslable.Position      = PieSeriesLabelPosition.TwoColumns;
                    pieSerieslable.TextAlignment = StringAlignment.Center;
                }
                PiePointOptions options = pieSeries.Label.PointOptions as PiePointOptions;
                if (options != null)
                {
                    options.PercentOptions.PercentageAccuracy = 2;
                    options.PercentOptions.ValueAsPercent     = true;
                    options.ValueNumericOptions.Format        = NumericFormat.Percent;
                }
            }
            else
            {
                List <SaleOverview> dataList     = (List <SaleOverview>) this.DataSource;
                List <string>       demisionList = new List <string>();

                if (!string.IsNullOrEmpty(dimensionName))
                {
                    foreach (var item in dataList)
                    {
                        Type   itemType     = item.GetType();
                        string demisionName = itemType.GetProperty(dimensionName).GetValue(item, null).ToString();
                        if (!demisionList.Contains(demisionName))
                        {
                            demisionList.Add(demisionName);
                        }
                    }
                }
                else
                {
                    demisionList.Add(string.Empty);
                }

                for (int d = 0; d < demisionList.Count; d++)
                {
                    IQueryable resultData = null;
                    if (!string.IsNullOrEmpty(dimensionName))
                    {
                        resultData = dataList.AsQueryable().Where(dimensionName + "=@0", demisionList[d]).GroupBy("UnitName", "it")
                                     .Select("new (Key as UnitName,Sum(" + targetName + ") as " + targetName + ")", null);
                    }
                    else
                    {
                        resultData = dataList.AsQueryable().GroupBy("UnitName", "it")
                                     .Select("new (Key as UnitName,Sum(" + targetName + ") as " + targetName + ")", null);
                    }

                    Series lineSeries = new Series();
                    lineSeries.Name         = demisionList[d];
                    lineSeries.ShowInLegend = true;
                    if (chartType == 1)
                    {
                        LineSeriesView lineView = new LineSeriesView();
                        lineSeries.View = lineView;
                    }
                    else if (chartType == 2)
                    {
                        BarSeriesView barView = new SideBySideBarSeriesView();
                        lineSeries.View = barView;
                    }

                    foreach (var item in resultData)
                    {
                        Type itemType = item.GetType();

                        SeriesPoint effortSeriesPoint = new SeriesPoint(itemType.GetProperty("UnitName").GetValue(item, null)
                                                                        , new object[] { ((object)(itemType.GetProperty(targetName).GetValue(item, null))) });
                        lineSeries.Points.Add(effortSeriesPoint);
                    }
                    xrChart1.Series.Add(lineSeries);
                }
                XYDiagram diagram = xrChart1.Diagram as XYDiagram;
                if (diagram == null)
                {
                    return;
                }
                diagram.AxisY.Title.Visible = true;
                if (!string.IsNullOrEmpty(dimensionName))
                {
                    diagram.AxisY.Title.Text = GetLocalizedCaption(dimensionName) + "-" + GetLocalizedCaption(targetName);
                }
                else
                {
                    diagram.AxisY.Title.Text = string.Empty;
                }
            }
        }
Example #14
0
        /// <summary>
        /// 初始化统计图
        /// </summary>
        /// <param name="useKind"></param>
        private void InitChart(int useKind)
        {
            Series series1 = new Series();

            DataTable dtResult = null;

            if (useKind == 0)
            {
                dtResult = StateApp.BuilderRuleStyleTable();
            }
            else
            {
                dtResult = StateApp.BuilderLayerStyleTable();
            }

            ReportListView.DataSource = null;
            gridViewMain.Columns.Clear();

            DataRow pRow = dtResult.NewRow();

            if (useKind == 0)
            {
                pRow["检查类型"] = "总计";
            }
            else
            {
                pRow["图层"] = "总计";
            }
            pRow["严重缺陷"] = dtResult.Compute("sum(严重缺陷)", "");
            pRow["重缺陷"]  = dtResult.Compute("sum(重缺陷)", "");
            pRow["轻缺陷"]  = dtResult.Compute("sum(轻缺陷)", "");

            if (pRow["严重缺陷"] is DBNull || pRow["重缺陷"] is DBNull || pRow["轻缺陷"] is DBNull)
            {
                btnExport.Enabled         = dtResult.Rows.Count > 0;
                ReportListView.DataSource = dtResult;
                return;
            }
            double mark = StateApp.GetResultMark(dtResult);

            if (mark < 50)
            {
                labelControlMark.Text = "得分低于50分";
            }
            else
            {
                labelControlMark.Text = "得分:" + mark;
            }

            pRow["错误合计"] = Convert.ToInt32(pRow["严重缺陷"]) + Convert.ToInt32(pRow["重缺陷"]) + Convert.ToInt32(pRow["轻缺陷"]);


            int nErrorCount = Convert.ToInt32(pRow["错误合计"]);

            if (useKind == 0)
            {
                foreach (DataRow dr in dtResult.Rows)
                {
                    SeriesPoint pPoint = new SeriesPoint();
                    long        lcount = Convert.ToInt32(dr["错误合计"]);

                    if (lcount > 0)
                    {
                        double temp = (lcount * 100.0) / nErrorCount;

                        pPoint.Argument = dr["检查类型"] + ":" + temp.ToString("f1") + "%";
                        pPoint.Values   = new double[] { lcount };

                        series1.Points.Add(pPoint);
                    }
                }
            }
            else
            {
                foreach (DataRow dr in dtResult.Rows)
                {
                    SeriesPoint pPoint = new SeriesPoint();
                    long        lcount = Convert.ToInt32(dr["错误合计"]);
                    if (lcount > 0)
                    {
                        double temp = (lcount * 100.0) / nErrorCount;

                        pPoint.Argument = dr["图层"] + ":" + temp.ToString("f1") + "%";
                        pPoint.Values   = new double[] { lcount };
                        series1.Points.Add(pPoint);
                    }
                }
            }

            series1.ChangeView(ViewType.Pie);
            series1.PointOptions.ValueNumericOptions.Format = NumericFormat.FixedPoint;

            series1.PointOptions.ValueNumericOptions.Precision = 2;
            series1.PointOptions.PointView = PointView.Argument;


            PieSeriesLabel label = series1.Label as PieSeriesLabel;

            label.Position  = PieSeriesLabelPosition.Outside;
            label.TextColor = Color.Empty;


            series1.ShowInLegend = false;

            //OverlappingOptions options = series1.Label.OverlappingOptions;
            //options.ResolveOverlapping = true;

            //chartControl1.Series.Clear();
            //chartControl1.Series.Add(series1);

            dtResult.Rows.Add(pRow);

            ReportListView.DataSource = dtResult;
            btnExport.Enabled         = dtResult.Rows.Count > 0;
        }
Example #15
0
        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);
        }
Example #16
0
        public void LoadGraph()
        {
            int t1 = System.Environment.TickCount;

            if (_report.State != Report.StateEnum.Executed)
            {
                return;
            }

            _chCtrl.BeginInit();

            bool rotateGraph = false;
            bool pivotAxes   = ((_report.GraphOptions & OlapReport.GraphOptionsEnum.Pivot) > 0);

            int seriesPosCount = (pivotAxes ? _report.Cellset.Axis1PosCount : _report.Cellset.Axis0PosCount);
            int seriesMemCount = (pivotAxes ? _report.Cellset.Axis1TupleMemCount : _report.Cellset.Axis0TupleMemCount);
            int catPosCount    = (pivotAxes ? _report.Cellset.Axis0PosCount : _report.Cellset.Axis1PosCount);
            int catMemCount    = (pivotAxes ? _report.Cellset.Axis0TupleMemCount : _report.Cellset.Axis1TupleMemCount);

            if (seriesPosCount == 0 || catPosCount == 0)
            {
                return;
            }

            Size size = new Size(_report.GraphWidth, _report.GraphHeight);

            size = this.AdjustGraphWidth(size, _report.GraphType);

            // limit number of series
            if (seriesPosCount > __MaxSeriesCount)
            {
                seriesPosCount = __MaxSeriesCount;
            }
            if (_report.GraphType == OlapReport.GraphTypeEnum.Pie || _report.GraphType == OlapReport.GraphTypeEnum.PieBrokenApart)
            {
                if (seriesPosCount > __MaxPieCount)
                {
                    seriesPosCount = __MaxPieCount;
                }
            }

            // limit number of categories
            if (catPosCount > __MaxCategoriesCount)
            {
                catPosCount = __MaxCategoriesCount;
            }

            bool showValues      = (_report.GraphOptions & OlapReport.GraphOptionsEnum.ShowValues) > 0;
            bool showSeries      = (_report.GraphOptions & OlapReport.GraphOptionsEnum.ShowSeries) > 0;
            bool showCats        = (_report.GraphOptions & OlapReport.GraphOptionsEnum.ShowCategories) > 0;
            bool setScaling      = _report.GraphType != OlapReport.GraphTypeEnum.Pie && ((_report.GraphOptions & OlapReport.GraphOptionsEnum.ScalingBySeries) > 0);
            bool setPerc         = !setScaling && ((_report.GraphOptions & OlapReport.GraphOptionsEnum.PercentByCategories) > 0);
            byte graphPieColumns = (_report.GraphPieColumns == 0 ?
                                    Convert.ToByte(Math.Sqrt(seriesPosCount)) : _report.GraphPieColumns);
            byte graphMixedLinePos = _report.GraphMixedLinePosition;

            graphMixedLinePos = (graphMixedLinePos <= 0 || graphMixedLinePos > seriesPosCount ? (byte)1 : graphMixedLinePos);

            // theme
            if (_report.GraphTheme != null && _report.GraphTheme != "")
            {
                _chCtrl.AppearanceName = _report.GraphTheme;
            }

            // create series
            for (int i = 0; i < seriesPosCount; i++)
            {
                string name = "";
                for (int j = 0; j < seriesMemCount; j++)
                {
                    name += (j == 0 ? "" : " | ") + (pivotAxes ? _report.Cellset.GetCellsetMember(1, j, i).Name : _report.Cellset.GetCellsetMember(0, j, i).Name);
                }

                Series series = new Series();
                series.Name = name;


                // type
                if (_report.GraphType == OlapReport.GraphTypeEnum.Pie || _report.GraphType == OlapReport.GraphTypeEnum.PieBrokenApart)
                {
                    // if pie, each of series is displayed as individual graph
                    if (_report.GraphType == OlapReport.GraphTypeEnum.PieBrokenApart)
                    {
                        _chCtrl.Series.Clear();
                    }
                    _chCtrl.Series.Add(series);

                    series.ChangeView(ViewType.Pie);

                    PiePointOptions ppo = (PiePointOptions)series.PointOptions;
                    PieSeriesView   psw = (PieSeriesView)series.View;
                    PieSeriesLabel  psl = (PieSeriesLabel)series.Label;

                    psl.Position = PieSeriesLabelPosition.TwoColumns;
                    series.PointOptions.PointView = PointView.Undefined;

                    if (_report.GraphType == OlapReport.GraphTypeEnum.Pie)
                    {
                        SimpleDiagram sd = new SimpleDiagram();
                        sd.LayoutDirection = LayoutDirection.Horizontal;
                        sd.Dimension       = graphPieColumns;
                        _chCtrl.Diagram    = sd;
                    }

                    // legend
                    if (showCats)
                    {
                        _chCtrl.Legend.Visible = false;
                    }

                    series.Label.OverlappingOptions.ResolveOverlapping = true;
                    series.LegendPointOptions.PointView = PointView.Argument;

                    _chCtrl.Legend.AlignmentHorizontal = LegendAlignmentHorizontal.Center;
                    _chCtrl.Legend.AlignmentVertical   = LegendAlignmentVertical.BottomOutside;
                    _chCtrl.Legend.Direction           = LegendDirection.LeftToRight;


                    // series title
                    SeriesTitle sTitle = new SeriesTitle();
                    sTitle.Text      = name;
                    sTitle.Alignment = StringAlignment.Center;
                    sTitle.Dock      = ChartTitleDockStyle.Bottom;
                    psw.Titles.Add(sTitle);
                }
                else
                {
                    // diagram
                    if (_chCtrl.Diagram == null)
                    {
                        _chCtrl.Diagram = new XYDiagram();
                    }
                    XYDiagram diag = (XYDiagram)_chCtrl.Diagram;


                    //// panes
                    //if (_report.GraphType == OlapReport.GraphTypeEnum.LineWithBars && graphMixedLinePos <= seriesPosCount && diag.Panes.Count == 0)
                    //{
                    //    // add new pane
                    //    XYDiagramPane pane = new XYDiagramPane();
                    //    pane.Visible = true;
                    //    pane.SizeMode = PaneSizeMode.UseWeight;
                    //    pane.Weight = 0.66;
                    //    diag.PaneLayoutDirection = PaneLayoutDirection.Vertical;
                    //    diag.Panes.Add(pane);

                    //    // set default pane weight
                    //    diag.DefaultPane.SizeMode = PaneSizeMode.UseWeight;
                    //    diag.DefaultPane.Weight = 0.33;
                    //}

                    // add series
                    _chCtrl.Series.Add(series);

                    // add series to secondary pane if needed (in case of LineWithBars)
                    if (diag.Panes.Count > 0 && i != graphMixedLinePos - 1)
                    {
                        ((XYDiagramSeriesViewBase)series.View).Pane = diag.Panes[0];
                    }

                    if (_report.GraphType == OlapReport.GraphTypeEnum.BarVertical)
                    {
                        series.ChangeView(ViewType.Bar);
                    }
                    else if (_report.GraphType == OlapReport.GraphTypeEnum.BarHorizontal)
                    {
                        series.ChangeView(ViewType.Bar);
                        rotateGraph = true;
                    }
                    else if (_report.GraphType == OlapReport.GraphTypeEnum.StackedBarVertical)
                    {
                        series.ChangeView(ViewType.StackedBar);
                    }
                    else if (_report.GraphType == OlapReport.GraphTypeEnum.StackedBarHorizontal)
                    {
                        series.ChangeView(ViewType.StackedBar);
                        rotateGraph = true;
                    }
                    else if (_report.GraphType == OlapReport.GraphTypeEnum.LineHorizontal)
                    {
                        series.ChangeView(ViewType.Line);
                    }
                    else if (_report.GraphType == OlapReport.GraphTypeEnum.LineWithBars)
                    {
                        if (i == graphMixedLinePos - 1)
                        {
                            //if (!setScaling)
                            //{
                            //    // create secondary axis
                            //    SecondaryAxisY axisY = new SecondaryAxisY(series.Name);
                            //    axisY.Visible = true;
                            //    axisY.Title.Text = series.Name;
                            //    axisY.Title.Visible = true;
                            //    axisY.Alignment = AxisAlignment.Near;
                            //    ((XYDiagram)_chCtrl.Diagram).SecondaryAxesY.Add(axisY);
                            //    ((XYDiagramSeriesViewBase)series.View).AxisY = axisY;

                            //    // set default axis title
                            //    ((XYDiagram)_chCtrl.Diagram).AxisY.Title.Text = "Bar axis";
                            //    ((XYDiagram)_chCtrl.Diagram).AxisY.Title.Visible = true;
                            //}

                            // change view
                            series.ChangeView(ViewType.Line);
                        }
                        else
                        {
                            series.ChangeView(ViewType.Bar);
                        }
                    }

                    // 20 pixels per label (250 pixels for legend), othervise overlapping resolution will never finish
                    if ((size.Width - 250) / catPosCount > 20)
                    {
                        series.Label.OverlappingOptions.ResolveOverlapping = true;
                        PointOverlappingOptions poo = series.Label.OverlappingOptions as PointOverlappingOptions;
                        if (poo != null)
                        {
                            poo.AttractToMarker = true;
                        }
                    }

                    series.LegendText                   = name;
                    series.ShowInLegend                 = true;
                    series.ValueScaleType               = ScaleType.Numerical;
                    series.PointOptions.PointView       = PointView.Undefined;
                    series.LegendPointOptions.PointView = PointView.SeriesName;
                    series.Visible = true;

                    // labels orientation
                    diag.Rotated = rotateGraph;
                    if (rotateGraph)
                    {
                        diag.AxisY.Label.Antialiasing = true;
                        diag.AxisY.Label.Angle        = 315;
                    }
                    else
                    {
                        diag.AxisX.Label.Antialiasing = true;
                        diag.AxisX.Label.Angle        = 315;
                    }

                    // if scaling
                    if (setScaling)
                    {
                        diag.AxisY.Visible = false;
                    }
                }


                // prepare scaling ranges
                double scalingMin = double.MaxValue;
                double scalingMax = double.MinValue;
                if (setScaling)
                {
                    for (int l = 0; l < catPosCount; l++)
                    {
                        string val  = (pivotAxes ? _report.Cellset.GetCell(l, i).Value : _report.Cellset.GetCell(i, l).Value);
                        double dVal = 0;
                        double.TryParse(val, System.Globalization.NumberStyles.Float, System.Globalization.NumberFormatInfo.InvariantInfo, out dVal);
                        if (dVal < scalingMin)
                        {
                            scalingMin = dVal;
                        }
                        if (dVal > scalingMax)
                        {
                            scalingMax = dVal;
                        }
                    }
                }
                scalingMin = scalingMin - (scalingMax - scalingMin) * 0.1;

                // set data
                double percSum = 0;
                for (int l = 0; l < catPosCount; l++)
                {
                    string argument = "";
                    for (int m = 0; m < catMemCount; m++)
                    {
                        argument += (m == 0 ? "" : " | ") + (pivotAxes ? _report.Cellset.GetCellsetMember(0, m, l).Name : _report.Cellset.GetCellsetMember(1, m, l).Name);
                    }

                    string val = (pivotAxes ? _report.Cellset.GetCell(l, i).Value : _report.Cellset.GetCell(i, l).Value);

                    double dVal = 0;
                    double.TryParse(val, System.Globalization.NumberStyles.Float, System.Globalization.NumberFormatInfo.InvariantInfo, out dVal);
                    if (setPerc)
                    {
                        percSum += dVal;
                    }
                    else if (setScaling)
                    {
                        dVal = (scalingMax - scalingMin == 0 ? 0 : (dVal - scalingMin) / (scalingMax - scalingMin));
                    }

                    string fVal = (pivotAxes ? _report.Cellset.GetCell(l, i).FormattedValue : _report.Cellset.GetCell(i, l).FormattedValue);

                    SeriesPoint sp = new SeriesPoint(argument, new double[] { dVal });
                    sp.Tag = fVal;
                    series.Points.Add(sp);
                }

                // set custom labels and value as percentage
                for (int l = 0; l < catPosCount; l++)
                {
                    SeriesPoint sp = series.Points[l];
                    if (setPerc)
                    {
                        sp.Values[0] = sp.Values[0] / percSum;
                        sp.Tag       = sp.Values[0].ToString("P");
                    }

                    // custom point label
                    string customLabel = string.Empty;
                    if (!showValues && !showSeries && !showCats)
                    {
                        series.Label.Visible = false;
                    }
                    else
                    {
                        string fVal = (string)sp.Tag;
                        if (fVal == null || fVal == "")
                        {
                            fVal = "0";
                        }
                        customLabel  = (showSeries ? series.Name : string.Empty);
                        customLabel += (showCats ? (customLabel != string.Empty ? " | " : string.Empty) + sp.Argument : string.Empty);
                        customLabel += (showValues ? (customLabel != string.Empty ? ": " : string.Empty) + fVal : string.Empty);
                    }

                    series.Points[l].Tag = customLabel;
                }

                // for pie, layout each of series individually
                if (_report.GraphType == OlapReport.GraphTypeEnum.PieBrokenApart)
                {
                    _chCtrl.Titles.Clear();
                    _chCtrl.EndInit();
                    LayoutGraph(_report.ID.ToString() + "." + i.ToString(), size, graphPieColumns);

                    // init next chart
                    if (i < seriesPosCount - 1)
                    {
                        _chCtrl = new DevExpress.XtraCharts.Web.WebChartControl();
                        _chCtrl.BeginInit();
                    }
                }
            }


            int t2 = System.Environment.TickCount;

            if (_report.GraphType != OlapReport.GraphTypeEnum.PieBrokenApart)
            {
                ChartTitle title = new ChartTitle();
                title.Alignment = StringAlignment.Center;
                title.Lines     = new string[] { _report.Name, _report.Description };
                _chCtrl.Titles.Add(title);

                LayoutGraph(_report.ID.ToString(), size, 0);
            }

            // if LineWithBars
            if (_report.GraphType == OlapReport.GraphTypeEnum.LineWithBars)
            {
                // fill combo
                for (int i = 0; i < _chCtrl.Series.Count; i++)
                {
                    this.selMixedLinePos.Items.Add(new ListItem(_chCtrl.Series[i].Name, (i + 1).ToString()));
                }
                this.selMixedLinePos.SelectedIndex = graphMixedLinePos - 1;

                // set line as last
                if (!(_chCtrl.Series[_chCtrl.Series.Count - 1].View is LineSeriesView))
                {
                    // roll down through series
                    for (int i = graphMixedLinePos - 1; i < _chCtrl.Series.Count - 1; i++)
                    {
                        _chCtrl.Series.Swap(i, i + 1);
                    }
                }
            }

            int    t3    = System.Environment.TickCount;
            double time1 = (t3 - t2) / 1000.0;
            double time2 = (t2 - t1) / 1000.0;

            t1 = 0;
        }
        private void IBMConnectionsUserAdoptionOverallXtraRpt_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e)
        {
            DataTable dt         = new DataTable();
            Series    series     = null;
            string    servername = "";

            servername = this.ServerName.Value.ToString();
            dt         = VSWebBL.DashboardBL.ConnectionsBL.Ins.GetTop5MostActiveCommunities(servername);
            string seriesname = "";
            string seriesarg  = "";
            int    seriesval  = -1;

            if (dt.Rows.Count > 0)
            {
                xrChart1.Series.Clear();
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    seriesarg  = dt.Rows[i]["Name"].ToString();
                    seriesname = dt.Rows[i]["Type"].ToString();
                    seriesval  = Convert.ToInt32(dt.Rows[i]["Total"].ToString());
                    series     = xrChart1.Series[seriesname];
                    if (series == null)
                    {
                        series = new Series(seriesname, ViewType.StackedBar);
                        series.Points.Add(new SeriesPoint(seriesarg, seriesval));
                        series.SeriesPointsSortingKey = SeriesPointKey.Value_1;
                        series.ShowInLegend           = true;
                        series.LabelsVisibility       = DevExpress.Utils.DefaultBoolean.True;
                        xrChart1.Series.Add(series);
                    }
                    else
                    {
                        series.Points.Add(new SeriesPoint(seriesarg, seriesval));
                        series.SeriesPointsSortingKey = SeriesPointKey.Value_1;
                        series.ShowInLegend           = true;
                        series.LabelsVisibility       = DevExpress.Utils.DefaultBoolean.True;
                    }
                }
                UI uiobj = new UI();
                uiobj.RecalibrateChartAxes(xrChart1.Diagram, "Y", "int", "int");
                xrChart1.SeriesSorting = SortingMode.None;
                xrChart1.DataSource    = dt;
            }

            xrChart2.Series.Clear();
            string statname = "COMMUNITY_TYPE_";

            dt     = VSWebBL.DashboardBL.ConnectionsBL.Ins.GetStatByName(servername, statname, false);
            series = new Series("StatName", ViewType.Pie);

            series.ArgumentDataMember = dt.Columns["StatName"].ToString();
            series.LabelsVisibility   = DevExpress.Utils.DefaultBoolean.True;
            PieSeriesLabel label = (PieSeriesLabel)series.Label;

            label.TextPattern        = "{A}: {VP:P0}";
            series.LegendTextPattern = "{A}: {V}";

            ValueDataMemberCollection seriesValueDataMembers = (ValueDataMemberCollection)series.ValueDataMembers;

            seriesValueDataMembers.AddRange(dt.Columns["StatValue"].ToString());
            xrChart2.Series.Add(series);

            xrChart2.DataSource = dt;

            xrChart3.Series.Clear();
            dt = VSWebBL.DashboardBL.ConnectionsBL.Ins.GetCommunitiesMonthly(servername);
            if (dt.Rows.Count > 0)
            {
                xrChart3.SeriesDataMember = "MName";
                xrChart3.SeriesTemplate.ArgumentDataMember = "MName";
                xrChart3.SeriesTemplate.ValueDataMembers.AddRange(new string[] { "Total" });
                XYDiagram d = (XYDiagram)xrChart3.Diagram;
                d.AxisX.Label.TextPattern = "{A:MMMM, yyyy}";
                xrChart3.DataSource       = dt;
            }

            xrChart4.Series.Clear();
            dt = VSWebBL.DashboardBL.ConnectionsBL.Ins.GetCommunityItemsMonthly(servername);
            if (dt.Rows.Count > 0)
            {
                xrChart4.SeriesDataMember = "MName";
                xrChart4.SeriesTemplate.ArgumentDataMember = "MName";
                xrChart4.SeriesTemplate.ValueDataMembers.AddRange(new string[] { "Total" });
                ((BarSeriesView)xrChart4.SeriesTemplate.View).BarWidth = 0.5;
                XYDiagram d = (XYDiagram)xrChart4.Diagram;
                xrChart4.DataSource = dt;
                UI uiobj = new UI();
                uiobj.RecalibrateChartAxes(xrChart4.Diagram, "Y", "int", "int");
            }

            dt     = new DataTable();
            dt     = VSWebBL.DashboardBL.ConnectionsBL.Ins.GetCommunityItemsMonthlyByType(servername);
            series = null;
            xrChart5.Series.Clear();
            if (dt.Rows.Count > 0)
            {
                seriesname = "";
                seriesarg  = "";
                seriesval  = -1;
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    seriesarg  = dt.Rows[i]["MonthYear"].ToString();
                    seriesname = dt.Rows[i]["Type"].ToString();
                    seriesval  = Convert.ToInt32(dt.Rows[i]["Total"].ToString());
                    series     = xrChart5.Series[seriesname];
                    if (series == null)
                    {
                        series = new Series(seriesname, ViewType.StackedBar);
                        series.Points.Add(new SeriesPoint(seriesarg, seriesval));
                        //((StackedBarSeriesView)series.View).BarWidth = 8;
                        series.ShowInLegend     = true;
                        series.LabelsVisibility = DevExpress.Utils.DefaultBoolean.True;
                        xrChart5.Series.Add(series);
                    }
                    else
                    {
                        series.Points.Add(new SeriesPoint(seriesarg, seriesval));
                        series.ShowInLegend     = true;
                        series.LabelsVisibility = DevExpress.Utils.DefaultBoolean.True;
                    }
                }
                if (xrChart5.Series[0].Points.Count > 1)
                {
                    for (int i = 0; i < xrChart5.Series.Count; i++)
                    {
                        series = xrChart5.Series[i];
                        ((StackedBarSeriesView)series.View).BarWidth = 8;
                    }
                }
                xrChart5.DataSource = dt;
            }
        }