Example #1
0
        public void GetPieChartReport(ChartControl chartMain, bool first)
        {
            string chartField1 = _data.DrTable["ChartField1"].ToString(); //.ToUpper();
            string chartField2 = _data.DrTable["ChartField2"].ToString(); //.ToUpper();
            string chartField3 = _data.DrTable["ChartField3"].ToString(); //.ToUpper();

            if (chartField1 == string.Empty && chartField2 == string.Empty)
            {
                return;
            }
            _data.GetDataForReport();

            chartMain.DataSource = _data.DtReportData;
            Series s = new Series(chartField2, ViewType.Pie3D);

            s.DataSource         = _data.DtReportData;
            s.ArgumentDataMember = chartField1;
            s.ValueDataMembers.AddRange(new string[] { chartField2 });
            s.ValueScaleType = ScaleType.Numerical;
            ((PieSeriesLabel)s.Label).Position = PieSeriesLabelPosition.TwoColumns;
            ((PiePointOptions)s.PointOptions).PercentOptions.ValueAsPercent = true;
            ((PiePointOptions)s.PointOptions).ValueNumericOptions.Format    = NumericFormat.Percent;
            ((PiePointOptions)s.PointOptions).ValueNumericOptions.Precision = 0;
            ((PiePointOptions)s.PointOptions).PointView = PointView.ArgumentAndValues;

            ((PieSeriesViewBase)s.View).ExplodeMode = PieExplodeMode.All;

            chartMain.Legend.Visible = false;
            chartMain.Series.Clear();
            chartMain.Series.Add(s);
            ChartTitle chartTitle = new ChartTitle();

            chartTitle.Font      = new System.Drawing.Font("Tahoma", 14);
            chartTitle.TextColor = System.Drawing.Color.RoyalBlue;
            chartTitle.Text      = Config.GetValue("Language").ToString() == "0" ? _drReport["MenuName"].ToString() : _drReport["MenuName2"].ToString();
            chartMain.Titles.Clear();
            chartMain.Titles.Add(chartTitle);
            if (first && _data.DrTable["LinkField"].ToString() != "")
            {
                chartMain.MouseDoubleClick += new MouseEventHandler(chartMain_DoubleClick);
            }
        }