예제 #1
0
        /// <summary>
        /// 绘制图形
        /// </summary>
        /// <param name="control">图表控件</param>
        /// <param name="seriesName">系列名</param>
        /// <param name="type">类型</param>
        /// <param name="dt">数据源</param>
        /// <param name="column1"></param>
        /// <param name="column2"></param>
        public static void DrawChart(DevExpress.XtraCharts.ChartControl control, string seriesName, ViewType type, DataTable dt, string column1, string column2)
        {
            Series      series = new Series(seriesName, type);
            DataTable   table  = dt;
            SeriesPoint point  = null;

            for (int i = 0; i < table.Rows.Count; i++)
            {
                if (string.IsNullOrEmpty(table.Rows[i][column2].ToString()))
                {
                    point = new SeriesPoint(table.Rows[i][column1].ToString(), 0);
                }
                else
                {
                    point = new SeriesPoint(table.Rows[i][column1].ToString(), Convert.ToDouble(table.Rows[i][column2].ToString()));
                }

                series.Points.Add(point);
            }
            SideBySideBarSeriesLabel label = series.Label as SideBySideBarSeriesLabel;

            series.LabelsVisibility = DefaultBoolean.True;
            label.Position          = BarSeriesLabelPosition.Center;
            BarSeriesView barview = series.View as BarSeriesView;

            barview.BarWidth = 0.3;
            control.Series.Add(series);
            //针对饼图的特殊处理
            if (type == ViewType.Pie)
            {
                //设置显示方式(Argument:显示图例说明,ArgumentAndValues:显示图例内容和数据)
                series.Label.PointOptions.PointView = PointView.ArgumentAndValues;
                //设置数据显示形式(Percent:百分比,Currency:货币类型,数据前添加¥,Scientific:科学计数法)
                series.Label.PointOptions.ValueNumericOptions.Format = NumericFormat.Percent;
                //数据是否保留小数(0:不保留小数位,1保留一位小数,2保留两位小数)
                series.Label.PointOptions.ValueNumericOptions.Precision = 0;

                //数据以百分比显示时只能是Default和None
                ((PieSeriesLabel)series.Label).ResolveOverlappingMode = ResolveOverlappingMode.Default;
            }
        }
예제 #2
0
        public frmQtyReport(string ad_user_id, string ad_org_id, DataTable dtProcess)
        {
            InitializeComponent();
            dateEdit.DateTime  = DateTime.Now;
            dateEdit1.DateTime = DateTime.Now;
            this.ad_user_id    = ad_user_id;
            this.ad_org_id     = ad_org_id;
            this.dtProcess     = dtProcess;
            dtboPhan           = BUS_BoPhan.LoadBoPhan(ad_org_id);
            utility.SearchProcess(this.Controls, dtProcess);

            dateEdit.DateTime  = DateTime.Now;
            dateEdit1.DateTime = DateTime.Now;
            dateEdit2.DateTime = DateTime.Now;

            #region Chart control 1
            // Create an empty Bar series and add it to the chart.
            chartControl1.Series.Add(series1);
            series1.View.Color = Color.Green;

            chartControl1.Series.Add(series2);
            series2.View.Color = Color.DarkGoldenrod;

            chartControl1.Series.Add(series3);
            series3.View.Color = Color.Red;

            //Show point view lable and customize it
            chartControl1.Series["Sản lượng mục tiêu"].LabelsVisibility = DevExpress.Utils.DefaultBoolean.True;
            SideBySideBarSeriesLabel label1 = chartControl1.Series["Sản lượng mục tiêu"].Label as SideBySideBarSeriesLabel;
            if (label1 != null)
            {
                label1.Position = BarSeriesLabelPosition.Top;
            }

            chartControl1.Series["Sản lượng thực tế"].LabelsVisibility = DevExpress.Utils.DefaultBoolean.True;
            SideBySideBarSeriesLabel label2 = chartControl1.Series["Sản lượng thực tế"].Label as SideBySideBarSeriesLabel;
            if (label2 != null)
            {
                label2.Position = BarSeriesLabelPosition.Top;
            }

            chartControl1.Series["Tỉ lệ đạt mục tiêu(%)"].LabelsVisibility = DevExpress.Utils.DefaultBoolean.True;
            SideBySideBarSeriesLabel label3 = chartControl1.Series["Tỉ lệ đạt mục tiêu(%)"].Label as SideBySideBarSeriesLabel;
            if (label3 != null)
            {
                label3.Position = BarSeriesLabelPosition.Top;
            }

            // Cast Diagram to the XYDiagram type.
            XYDiagram diagram = chartControl1.Diagram as XYDiagram;
            diagram.AxisY.Title.Visibility = DevExpress.Utils.DefaultBoolean.True;
            diagram.AxisY.Title.Text       = "Sản lượng (k)";
            diagram.AxisY.Title.Font       = new Font("Times New Roman", 10, FontStyle.Regular);

            // Add a title to the chart (if necessary).
            chartTitle1.Text = "BIỂU ĐỒ SẢN LƯỢNG HẰNG NGÀY\n(" + DateTime.Now.ToString("dd/MM/yyyy") + ")";
            chartTitle1.Font = new Font("Times New Roman", 15, FontStyle.Bold);
            chartControl1.Titles.Add(chartTitle1);

            // Control legend & position
            chartControl1.Legend.Visibility          = DevExpress.Utils.DefaultBoolean.True;
            chartControl1.Legend.AlignmentHorizontal = LegendAlignmentHorizontal.Center;
            chartControl1.Legend.AlignmentVertical   = LegendAlignmentVertical.BottomOutside;
            chartControl1.Legend.Direction           = LegendDirection.LeftToRight;
            chartControl1.Legend.EquallySpacedItems  = true;

            //Create secondary Y-Axis, and add them to the chart's diagram
            SecondaryAxisY myAxisY = new SecondaryAxisY("Y-Axis");
            ((XYDiagram)chartControl1.Diagram).SecondaryAxesY.Add(myAxisY);

            //Assign series3 to the created axis
            ((LineSeriesView)series3.View).AxisY = myAxisY;

            //Customize the apperance of the secondary axis
            myAxisY.Title.Text       = "Tỉ lệ đạt mục tiêu(%)";
            myAxisY.Title.Visibility = DevExpress.Utils.DefaultBoolean.True;
            myAxisY.Title.TextColor  = Color.Red;
            myAxisY.Title.Font       = new Font("Times New Roman", 10, FontStyle.Regular);
            myAxisY.Label.TextColor  = Color.Red;
            myAxisY.Color            = Color.Red;
            #endregion

            #region Chart control 2
            // Create an empty Bar series and add it to the chart.
            chartControl2.Series.Add(series4);
            series4.View.Color = Color.Green;

            chartControl2.Series.Add(series5);
            series5.View.Color = Color.DarkGoldenrod;

            chartControl2.Series.Add(series6);
            series6.View.Color = Color.Red;

            //Show point view lable and customize it
            chartControl2.Series["Sản lượng mục tiêu"].LabelsVisibility = DevExpress.Utils.DefaultBoolean.True;
            SideBySideBarSeriesLabel label4 = chartControl2.Series["Sản lượng mục tiêu"].Label as SideBySideBarSeriesLabel;
            if (label4 != null)
            {
                label4.Position = BarSeriesLabelPosition.Top;
            }

            chartControl2.Series["Sản lượng thực tế"].LabelsVisibility = DevExpress.Utils.DefaultBoolean.True;
            SideBySideBarSeriesLabel label5 = chartControl2.Series["Sản lượng thực tế"].Label as SideBySideBarSeriesLabel;
            if (label5 != null)
            {
                label5.Position = BarSeriesLabelPosition.Top;
            }

            //chartControl2.Series["Tỉ lệ đạt mục tiêu(%)"].LabelsVisibility = DevExpress.Utils.DefaultBoolean.True;
            //SideBySideBarSeriesLabel label6 = chartControl2.Series["Tỉ lệ đạt mục tiêu(%)"].Label as SideBySideBarSeriesLabel;
            //if (label6 != null)
            //{
            //    label6.Position = BarSeriesLabelPosition.Top;
            //}

            // Cast Diagram to the XYDiagram type.
            XYDiagram diagram2 = chartControl2.Diagram as XYDiagram;
            diagram2.AxisY.Title.Visibility = DevExpress.Utils.DefaultBoolean.True;
            diagram2.AxisY.Title.Text       = "Sản lượng (k)";
            diagram2.AxisY.Title.Font       = new Font("Times New Roman", 10, FontStyle.Regular);

            // Add a title to the chart (if necessary).
            chartTitle2.Text = "BIỂU ĐỒ SẢN LƯỢNG HẰNG THÁNG\n(" + "01/" + DateTime.Now.ToString("MM/yyyy") + " - " + DateTime.Now.ToString("dd/MM/yyyy") + ")";
            chartTitle2.Font = new Font("Times New Roman", 15, FontStyle.Bold);
            chartControl2.Titles.Add(chartTitle2);

            // Control legend & position
            chartControl2.Legend.Visibility          = DevExpress.Utils.DefaultBoolean.True;
            chartControl2.Legend.AlignmentHorizontal = LegendAlignmentHorizontal.Center;
            chartControl2.Legend.AlignmentVertical   = LegendAlignmentVertical.BottomOutside;
            chartControl2.Legend.Direction           = LegendDirection.LeftToRight;
            chartControl2.Legend.EquallySpacedItems  = true;

            //Create secondary Y-Axis, and add them to the chart's diagram
            SecondaryAxisY myAxisY2 = new SecondaryAxisY("Y-Axis2");
            ((XYDiagram)chartControl2.Diagram).SecondaryAxesY.Add(myAxisY2);

            //Assign series3 to the created axis
            ((LineSeriesView)series6.View).AxisY = myAxisY2;

            //Customize the apperance of the secondary axis
            myAxisY2.Title.Text       = "Tỉ lệ đạt mục tiêu(%)";
            myAxisY2.Title.Visibility = DevExpress.Utils.DefaultBoolean.True;
            myAxisY2.Title.TextColor  = Color.Red;
            myAxisY2.Title.Font       = new Font("Times New Roman", 10, FontStyle.Regular);
            myAxisY2.Label.TextColor  = Color.Red;
            myAxisY2.Color            = Color.Red;
            #endregion

            dtChart1 = BUS_SanXuat.ChartQtyDaily(DateTime.Now.ToString("yyyy-MM-dd"), ad_org_id);
            DateTime today     = DateTime.Today;
            DateTime yesterday = today.AddDays(-1);
            lblQtyNgay.Text = "Sản lượng ngày trước (k): " + BUS_SanXuat.ChartQtyTotal(yesterday.ToString("yyyy-MM-dd"), yesterday.ToString("yyyy-MM-dd"), ad_org_id);
            CreateChart1(dtChart1);

            dtChart2 = BUS_SanXuat.ChartQtyMonthly(DateTime.Now.ToString("yyyy-MM-") + "01", DateTime.Now.ToString("yyyy-MM-dd"), ad_org_id);
            DateTime currentMonth = DateTime.Today;
            DateTime lastMonth    = currentMonth.AddMonths(-1);
            lblQtyMonth.Text = "Sản lượng tháng trước (k): " + BUS_SanXuat.ChartQtyTotal(lastMonth.ToString("yyyy-MM-") + "01", lastMonth.ToString("yyyy-MM-") + "31", ad_org_id);
            CreateChart2(dtChart2);
        }
        private void AddSecondChart(IList <DashBoardBudgetModel> DashBoardBudget)
        {
            if (!ExpenseChart.Series.Equals(null) || DashBoardBudget.Count <= 0)
            {
                ExpenseChart.Series.Clear();
                labelControl8.Text = "NĂM " + ((int)DateTime.Now.Year + ExpenseCurentYear).ToString() + ". Không có dữ liệu";
            }
            if (DashBoardBudget.Count >= 1)
            {
                NodataChar2.Visible = false;
                labelControl8.Text  = "NĂM " + ((int)DateTime.Now.Year + ExpenseCurentYear).ToString();
                // Create two stacked bar series.
                Series series1 = new Series("Kinh phí chi", ViewType.StackedBar);
                Series series2 = new Series("Kinh phí còn lại", ViewType.StackedBar);
                Series series3 = new Series("Kinh phí nhận", ViewType.StackedBar);
                // Add points to them
                for (int i = 0; i < DashBoardBudget.Count; i++)
                {
                    series1.Points.Add(new SeriesPoint("Nguồn: " + DashBoardBudget[i].BudgetSourceCode,
                                                       DashBoardBudget[i].BudgetGive));
                    series2.Points.Add(new SeriesPoint("Nguồn: " + DashBoardBudget[i].BudgetSourceCode,
                                                       DashBoardBudget[i].Remaining));
                    series3.Points.Add(new SeriesPoint("Nguồn: " + DashBoardBudget[i].BudgetSourceCode,
                                                       DashBoardBudget[i].BudgetRecive));
                    //Tùy chỉnh nhãn khi hover chuột
                    //series1.CrosshairLabelPattern = "Kinh phí nhận: " + DashBoardBudget[i].BudgetGive;
                    //series2.CrosshairLabelPattern = "Kinh phí còn lại: " + DashBoardBudget[i].Remaining;
                    //series3.CrosshairLabelPattern = "Kinh phí chi: " + DashBoardBudget[i].BudgetRecive;
                }
                // Add both series to the chart.
                ExpenseChart.Series.AddRange(new Series[] { series1, series2, series3 });

                BarSeriesView view = (BarSeriesView)series1.View;
                view.FillStyle.FillMode = FillMode.Empty;
                SideBySideBarSeriesLabel label = ExpenseChart.Series[0].Label as SideBySideBarSeriesLabel;

                ((StackedBarSeriesView)ExpenseChart.Series[0].View).Color = Color.FromArgb(0, 237, 224);
                ((StackedBarSeriesView)ExpenseChart.Series[0].View).FillStyle.FillMode = FillMode.Solid;
                ((StackedBarSeriesView)ExpenseChart.Series[1].View).Color = Color.FromArgb(255, 145, 0);
                ((StackedBarSeriesView)ExpenseChart.Series[1].View).FillStyle.FillMode = FillMode.Solid;
                ((StackedBarSeriesView)ExpenseChart.Series[2].View).Color = Color.FromArgb(0, 106, 253);
                ((StackedBarSeriesView)ExpenseChart.Series[2].View).FillStyle.FillMode = FillMode.Solid;

                //stackedBarChart.ToolTipEnabled = DefaultBoolean.True;
                //stackedBarChart.CrosshairEnabled = DefaultBoolean.False;
                //stackedBarChart.Series[0].ToolTipSeriesPattern = "fdasfasdfasdfasd";
                //// Access the view-type-specific options of the series.
                //((StackedBarSeriesView)series1.View).BarWidth = 1;

                // Access the type-specific options of the diagram.
                ((XYDiagram)ExpenseChart.Diagram).EnableAxisXZooming = false;

                // Hide the legend (if necessary).
                ExpenseChart.Legend.Visible = true;


                //Convert label bên trái sang định dạng mong muốn
                ExpenseChart.CustomDrawAxisLabel += (s, e) =>
                {
                    var      args = (CustomDrawAxisLabelEventArgs)e;
                    AxisBase axis = args.Item.Axis;
                    if (axis is AxisY)
                    {
                        double   axisValue = (double)args.Item.AxisValue;
                        TimeSpan t         = TimeSpan.FromSeconds(axisValue);

                        string answer = string.Format("{0:0,0}",
                                                      axisValue);
                        args.Item.Text = answer;
                    }
                };


                // Add the chart to the form.
                ExpenseChart.Dock = DockStyle.Fill;
                PanelControlExpenseSub.Controls.Add(ExpenseChart);
                //ExpenseChart.BringToFront();
            }
            else
            {
                NodataChar2.Visible = true;
            }
        }
        private void AddFirstChart(IList <UserControlMainDesktopModel> UserControlMainDesktop1)
        {
            // Create a new chart.
            if (!EstimateChart.Series.Equals(null) || UserControlMainDesktop1.Count <= 0)
            {
                EstimateChart.Series.Clear();
                lblEstimateYear.Text = "NĂM " + ((int)DateTime.Now.Year + EstimateCurentYear).ToString() + ". Không có dữ liệu";
            }
            if (UserControlMainDesktop1.Count >= 1)
            {
                NodataChar1.Visible  = false;
                lblEstimateYear.Text = "NĂM " + ((int)DateTime.Now.Year + EstimateCurentYear).ToString();
                // Create two stacked bar series.
                Series series1 = new Series("Dự toán bị hủy", ViewType.StackedBar);
                Series series2 = new Series("Dự toán còn lại", ViewType.StackedBar);
                Series series3 = new Series("Rút dự toán", ViewType.StackedBar);
                // Add points to them
                for (int i = 0; i < UserControlMainDesktop1.Count; i++)
                {
                    series1.Points.Add(new SeriesPoint("Nguồn: " + UserControlMainDesktop1[i].BudgetSourceCode,

                                                       UserControlMainDesktop1[i].Cancel));
                    series2.Points.Add(new SeriesPoint("Nguồn: " + UserControlMainDesktop1[i].BudgetSourceCode,

                                                       UserControlMainDesktop1[i].Remaining));
                    series3.Points.Add(new SeriesPoint("Nguồn: " + UserControlMainDesktop1[i].BudgetSourceCode,

                                                       UserControlMainDesktop1[i].WithDraw));
                    //Tùy chỉnh nhãn khi hover chuột
                    //series1.CrosshairLabelPattern = "Dự toán bị hủy: " + UserControlMainDesktop1[i].Cancel;
                    //series2.CrosshairLabelPattern = "Dự toán còn lại: " + UserControlMainDesktop1[i].Remaining;
                    //series3.CrosshairLabelPattern = "Rút dự toán: " + UserControlMainDesktop1[i].WithDraw;
                }
                // Add both series to the chart.
                EstimateChart.Series.AddRange(new Series[] { series1, series2, series3 });

                BarSeriesView view = (BarSeriesView)series1.View;
                view.FillStyle.FillMode = FillMode.Empty;
                SideBySideBarSeriesLabel label = EstimateChart.Series[0].Label as SideBySideBarSeriesLabel;

                ((StackedBarSeriesView)EstimateChart.Series[0].View).Color = Color.FromArgb(0, 237, 224);
                ((StackedBarSeriesView)EstimateChart.Series[0].View).FillStyle.FillMode = FillMode.Solid;
                ((StackedBarSeriesView)EstimateChart.Series[1].View).Color = Color.FromArgb(255, 145, 0);
                ((StackedBarSeriesView)EstimateChart.Series[1].View).FillStyle.FillMode = FillMode.Solid;
                ((StackedBarSeriesView)EstimateChart.Series[2].View).Color = Color.FromArgb(0, 106, 253);
                ((StackedBarSeriesView)EstimateChart.Series[2].View).FillStyle.FillMode = FillMode.Solid;

                //stackedBarChart.ToolTipEnabled = DefaultBoolean.True;
                //stackedBarChart.CrosshairEnabled = DefaultBoolean.False;
                //stackedBarChart.Series[0].ToolTipSeriesPattern = "fdasfasdfasdfasd";
                //// Access the view-type-specific options of the series.
                //((StackedBarSeriesView)series1.View).BarWidth = 1;

                // Access the type-specific options of the diagram.
                ((XYDiagram)EstimateChart.Diagram).EnableAxisXZooming = false;

                // Hide the legend (if necessary).
                EstimateChart.Legend.Visible = true;

                //// Add a title to the chart (if necessary).
                //EstimateChart.Titles.Clear();
                //EstimateChart.Titles.Add(new ChartTitle());
                //EstimateChart.Titles[0].Text = "NĂM: " + ((int)DateTime.Now.Year + EstimateCurentYear).ToString();
                //EstimateChart.Location = new Point(40, 70);
                //EstimateChart.Location = new Point(PanelControlEstimate.Location.X + 3, PanelControlEstimate.Location.Y + 40);

                //EstimateChart.Size = new Size(548, 289);

                //Convert label bên trái sang định dạng mong muốn
                EstimateChart.CustomDrawAxisLabel += (s, e) =>
                {
                    var      args = (CustomDrawAxisLabelEventArgs)e;
                    AxisBase axis = args.Item.Axis;
                    if (axis is AxisY)
                    {
                        double axisValue = (double)args.Item.AxisValue;
                        //TimeSpan t = TimeSpan.FromSeconds(axisValue);

                        string answer = string.Format("{0:0,0}",
                                                      axisValue);
                        args.Item.Text = answer;
                    }
                };


                // Add the chart to the form.
                EstimateChart.Dock = DockStyle.Fill;
                PanelControlEstimateSub.Controls.Add(EstimateChart);
                //EstimateChart.BringToFront();
            }
            else
            {
                NodataChar1.Visible = true;
            }
        }
예제 #5
0
        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();
            }
        }
예제 #6
0
        private void InitSpline2Inner(string enumValue, string titleName, DataTable dt, Color color)
        {
            Series series = new Series(titleName, (ViewType)Enum.Parse(typeof(ViewType), enumValue));

            DevExpress.XtraCharts.PointSeriesLabel         pointSeriesLabel1      = new DevExpress.XtraCharts.PointSeriesLabel();
            DevExpress.XtraCharts.PieSeriesLabel           pieSeriesLabel1        = new DevExpress.XtraCharts.PieSeriesLabel();
            DevExpress.XtraCharts.SideBySideBarSeriesLabel sideBySizeSeriesLabel1 = new SideBySideBarSeriesLabel();

            //************************************************************BeginInit()********************************************************
            ((System.ComponentModel.ISupportInitialize)(chartControl1)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(series)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(pointSeriesLabel1)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(pieSeriesLabel1)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(sideBySizeSeriesLabel1)).BeginInit();

            series.ArgumentScaleType = ScaleType.Qualitative;

            DevExpress.XtraCharts.PiePointOptions piePointOptions1 = new DevExpress.XtraCharts.PiePointOptions();
            piePointOptions1.PointView = DevExpress.XtraCharts.PointView.ArgumentAndValues;
            series.PointOptions        = piePointOptions1;

            series.LegendText = m_ColumnName;
            series.View.Color = color;
            foreach (DataRow dataRow in dt.Rows)
            {
                string name = dataRow[m_X_NameID + "#" + m_X_Name].ToString();
                if (name == "总计")
                {
                    continue;
                }
                string      value = dataRow[m_ColumnID + "#" + m_ColumnName].ToString();
                SeriesPoint sp    = new SeriesPoint(name, value);
                series.Points.Add(sp);
            }
            chartControl1.Series.Add(series);

            PointSeriesView pointView = series.View as PointSeriesView;

            if (pointView != null)
            {
                pointView.PointMarkerOptions.Kind = MarkerKind.Circle;
            }

            //针对饼图的处理
            if (series.View is PieSeriesView)
            {
                this.chartControl1.RuntimeSelection           = false;
                ((PieSeriesView)series.View).RuntimeExploding = true;
            }
            else
            {
                this.chartControl1.RuntimeSelection = true;
            }

            ChartTitle ct1 = new ChartTitle();

            ct1.Text = titleName;
            chartControl1.Titles.Clear();
            chartControl1.Titles.Add(ct1);

            if (series.Label is PointSeriesLabel)
            {
                pointSeriesLabel1.LineLength   = 15;
                pointSeriesLabel1.LineVisible  = true;
                pointSeriesLabel1.Antialiasing = true;
                pointSeriesLabel1.Angle        = 30;
                pointSeriesLabel1.ResolveOverlappingMinIndent = 10;
                pointSeriesLabel1.ResolveOverlappingMode      = DevExpress.XtraCharts.ResolveOverlappingMode.JustifyAllAroundPoint;
                series.Label = pointSeriesLabel1;
            }
            else if (series.Label is PieSeriesLabel)
            {
                pieSeriesLabel1.LineLength   = 15;
                pieSeriesLabel1.LineVisible  = true;
                pieSeriesLabel1.Antialiasing = true;
                pieSeriesLabel1.ResolveOverlappingMinIndent = 10;
                pieSeriesLabel1.ResolveOverlappingMode      = DevExpress.XtraCharts.ResolveOverlappingMode.JustifyAllAroundPoint;
                series.Label = pieSeriesLabel1;
            }
            else if (series.Label is SideBySideBarSeriesLabel)
            {
                sideBySizeSeriesLabel1.LineLength   = 15;
                sideBySizeSeriesLabel1.LineVisible  = true;
                sideBySizeSeriesLabel1.Antialiasing = true;
                sideBySizeSeriesLabel1.Position     = BarSeriesLabelPosition.Top;
                sideBySizeSeriesLabel1.ResolveOverlappingMinIndent = 10;
                sideBySizeSeriesLabel1.ResolveOverlappingMode      = DevExpress.XtraCharts.ResolveOverlappingMode.JustifyAllAroundPoint;
                series.Label = sideBySizeSeriesLabel1;
            }
            ((System.ComponentModel.ISupportInitialize)(pieSeriesLabel1)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(pointSeriesLabel1)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(series)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(chartControl1)).EndInit();
            //************************************************************EndInit()********************************************************
        }
예제 #7
0
        public frmAttReport(string ad_user_id, string ad_org_id, DataTable dtProcess)
        {
            InitializeComponent();
            dateEdit.DateTime  = DateTime.Now;
            dateEdit1.DateTime = DateTime.Now;
            this.ad_user_id    = ad_user_id;
            this.ad_org_id     = ad_org_id;
            this.dtProcess     = dtProcess;
            dtCa     = BUS_Ca.LoadCaShift(DateTime.Now.Date, ad_org_id);
            dtboPhan = BUS_BoPhan.LoadBoPhan(ad_org_id);
            utility.SearchProcess(this.Controls, dtProcess);

            #region Chart control 1
            // Create an empty Bar series and add it to the chart.
            chartControl1.Series.Add(series1);
            series1.View.Color = Color.Green;

            chartControl1.Series.Add(series2);
            series2.View.Color = Color.DarkGoldenrod;

            chartControl1.Series.Add(series3);
            series3.View.Color = Color.Red;

            chartControl1.Series.Add(series4);
            series4.View.Color = Color.Red;

            //Show point view lable and customize it
            chartControl1.Series["Tổng số người"].LabelsVisibility = DevExpress.Utils.DefaultBoolean.True;
            SideBySideBarSeriesLabel label1 = chartControl1.Series["Tổng số người"].Label as SideBySideBarSeriesLabel;
            if (label1 != null)
            {
                label1.Position = BarSeriesLabelPosition.Top;
            }

            chartControl1.Series["Số người vắng"].LabelsVisibility = DevExpress.Utils.DefaultBoolean.True;
            SideBySideBarSeriesLabel label2 = chartControl1.Series["Số người vắng"].Label as SideBySideBarSeriesLabel;
            if (label2 != null)
            {
                label2.Position = BarSeriesLabelPosition.Top;
            }

            chartControl1.Series["Số người nghỉ việc"].LabelsVisibility = DevExpress.Utils.DefaultBoolean.True;
            SideBySideBarSeriesLabel label3 = chartControl1.Series["Số người nghỉ việc"].Label as SideBySideBarSeriesLabel;
            if (label3 != null)
            {
                label3.Position = BarSeriesLabelPosition.Top;
            }

            chartControl1.Series["Tỉ lệ người vắng(%)"].LabelsVisibility = DevExpress.Utils.DefaultBoolean.True;
            SideBySideBarSeriesLabel label4 = chartControl1.Series["Tỉ lệ người vắng(%)"].Label as SideBySideBarSeriesLabel;
            if (label4 != null)
            {
                label4.Position = BarSeriesLabelPosition.Top;
            }

            // Cast Diagram to the XYDiagram type.
            XYDiagram diagram = chartControl1.Diagram as XYDiagram;
            diagram.AxisY.Title.Visibility = DevExpress.Utils.DefaultBoolean.True;
            diagram.AxisY.Title.Text       = "Số lượng người";
            diagram.AxisY.Title.Font       = new Font("Times New Roman", 10, FontStyle.Regular);

            // Add a title to the chart (if necessary).
            chartTitle1.Text = "BIỂU ĐỒ NHÂN SỰ\n(" + "01" + DateTime.Now.ToString("/MM/yyyy") + " - " + DateTime.Now.ToString("dd/MM/yyyy") + ")";
            chartTitle1.Font = new Font("Times New Roman", 15, FontStyle.Bold);
            chartControl1.Titles.Add(chartTitle1);

            // Control legend & position
            chartControl1.Legend.Visibility          = DevExpress.Utils.DefaultBoolean.True;
            chartControl1.Legend.AlignmentHorizontal = LegendAlignmentHorizontal.Center;
            chartControl1.Legend.AlignmentVertical   = LegendAlignmentVertical.BottomOutside;
            chartControl1.Legend.Direction           = LegendDirection.LeftToRight;
            chartControl1.Legend.EquallySpacedItems  = true;

            //Create secondary Y-Axis, and add them to the chart's diagram
            SecondaryAxisY myAxisY2 = new SecondaryAxisY("Y-Axis2");
            ((XYDiagram)chartControl1.Diagram).SecondaryAxesY.Add(myAxisY2);

            //Assign series4 to the created axis
            ((LineSeriesView)series4.View).AxisY = myAxisY2;

            //Customize the apperance of the secondary axis
            myAxisY2.Title.Text       = "Tỉ lệ người vắng(%)";
            myAxisY2.Title.Visibility = DevExpress.Utils.DefaultBoolean.True;
            myAxisY2.Title.TextColor  = Color.Red;
            myAxisY2.Title.Font       = new Font("Times New Roman", 10, FontStyle.Regular);
            myAxisY2.Label.TextColor  = Color.Red;
            myAxisY2.Color            = Color.Red;
            #endregion

            #region Chart control 2
            // Add a title to the chart (if necessary).
            chartControl2.Titles.Clear();
            chartTitle2.Text = "BIỂU ĐỒ TỈ LỆ NGƯỜI VẮNG\n(" + "01" + DateTime.Now.ToString("/MM/yyyy") + " - " + DateTime.Now.ToString("dd/MM/yyyy") + ")";
            chartTitle2.Font = new Font("Times New Roman", 15, FontStyle.Bold);
            chartControl2.Titles.Add(chartTitle2);


            #endregion
            dtChart1 = BUS_ChamCong.ChartDiemDanh(DateTime.Now.ToString("yyyy-MM-") + "01", DateTime.Now.ToString("yyyy-MM-dd"), ad_org_id, "0");
            dtChart2 = Utility.CopyChart(dtChart1, "01", DateTime.Now.ToString("dd"));
            CreateChart(dtChart1, dtChart2);
        }