Esempio n. 1
0
        //把數據放入圖例
        private void insert_Legends_Date(Chart chart, string date, string count)
        {
            LegendCellColumn lcc = new LegendCellColumn();

            lcc.Text            = count;
            lcc.HeaderText      = date;
            lcc.HeaderFont      = new Font("微軟正黑體", 16, FontStyle.Bold);
            lcc.HeaderBackColor = Color.WhiteSmoke;
            lcc.HeaderForeColor = Color.Green;
            chart.Legends["Legends1"].CellColumns.Add(lcc);
        }
        /// <summary>
        /// Create series instance in the editor
        /// </summary>
        /// <param name="itemType">Item type.</param>
        /// <returns>Newly created item.</returns>
        protected override object CreateInstance(Type itemType)
        {
            if (Context != null && Context.Instance != null)
            {
                Legend legend = Context.Instance as Legend;
                if (legend != null)
                {
                    int    itemCount = legend.CellColumns.Count + 1;
                    string itemName  = "Column" + itemCount.ToString(System.Globalization.CultureInfo.InvariantCulture);

                    // Check if this name already in use
                    bool itemFound = true;
                    while (itemFound)
                    {
                        itemFound = false;
                        foreach (LegendCellColumn column in legend.CellColumns)
                        {
                            if (column.Name == itemName)
                            {
                                itemFound = true;
                            }
                        }

                        if (itemFound)
                        {
                            ++itemCount;
                            itemName = "Column" + itemCount.ToString(System.Globalization.CultureInfo.InvariantCulture);
                        }
                    }

                    // Create new legend column
                    LegendCellColumn legendColumn = new LegendCellColumn();
                    legendColumn.Name = itemName;
                    return(legendColumn);
                }
            }
            return(base.CreateInstance(itemType));
        }
    protected void FillForm()
    {
        try
        {
            if (!CheckIsValidStartEndDates())
            {
                return;
            }

            SeriesChartType chartType = SeriesChartType.StackedBar;
            if (ddlChartType.SelectedValue == "Pie")
            {
                chartType = SeriesChartType.Pie;
            }
            if (ddlChartType.SelectedValue == "Doughnut")
            {
                chartType = SeriesChartType.Doughnut;
            }
            if (ddlChartType.SelectedValue == "StackedBar")
            {
                chartType = SeriesChartType.StackedBar;
            }
            if (ddlChartType.SelectedValue == "Area")
            {
                chartType = SeriesChartType.Area;
            }
            if (ddlChartType.SelectedValue == "BoxPlot")
            {
                chartType = SeriesChartType.BoxPlot;
            }
            if (ddlChartType.SelectedValue == "Column")
            {
                chartType = SeriesChartType.Column;
            }
            if (ddlChartType.SelectedValue == "Line")
            {
                chartType = SeriesChartType.Line;
            }
            if (ddlChartType.SelectedValue == "Point")
            {
                chartType = SeriesChartType.Point;
            }
            if (ddlChartType.SelectedValue == "Range")
            {
                chartType = SeriesChartType.Range;
            }
            if (ddlChartType.SelectedValue == "RangeBar")
            {
                chartType = SeriesChartType.RangeBar;
            }
            if (ddlChartType.SelectedValue == "RangeColumn")
            {
                chartType = SeriesChartType.RangeColumn;
            }

            chartStaffStats.Series["Series1"].ChartType = chartType;


            DataTable tblStats = StaffDB.GetStats2(GetFromDate(), GetToDate(), chkIncDeleted.Checked, chkIncDeleted.Checked);

            int maxToShow = 350;
            if (tblStats.Rows.Count > maxToShow)
            {
                for (int i = tblStats.Rows.Count - 1; i >= maxToShow; i--)
                {
                    tblStats.Rows.RemoveAt(i);
                }
            }

            tblStats.Columns.Add("fullname", typeof(string));
            for (int i = 0; i < tblStats.Rows.Count; i++)
            {
                tblStats.Rows[i]["fullname"] = tblStats.Rows[i]["firstname"] + " " + tblStats.Rows[i]["surname"] +
                                               (tblStats.Rows[i]["staff_id"] == DBNull.Value || (int)tblStats.Rows[i]["staff_id"] < 0 || (!(bool)tblStats.Rows[i]["is_stakeholder"] && !(bool)tblStats.Rows[i]["is_master_admin"] && !(bool)tblStats.Rows[i]["is_admin"])  ? "" : " (Admin) ") +
                                               (tblStats.Rows[i]["staff_id"] == DBNull.Value || (int)tblStats.Rows[i]["staff_id"] < 0 || !(bool)tblStats.Rows[i]["is_provider"]  ? "" : " (Provider) ") +
                                               (tblStats.Rows[i]["is_external"] == DBNull.Value || tblStats.Rows[i]["staff_id"] == DBNull.Value || !((bool)tblStats.Rows[i]["is_external"]) || (int)tblStats.Rows[i]["staff_id"] < 0 ? "" : " (External) ");
            }

            DataView dv = tblStats.DefaultView;

            string field = string.Empty;
            if (ddlType.SelectedValue == "Total Bookings")
            {
                field = "total_bookings";
            }
            if (ddlType.SelectedValue == "New Bookings Added By")
            {
                field = "n_bookings";
            }
            if (ddlType.SelectedValue == "New Patients")
            {
                field = "n_patients";
            }
            if (ddlType.SelectedValue == "Completions")
            {
                field = "n_completions";
            }
            if (ddlType.SelectedValue == "Invoice Total")
            {
                field = "sum_inv_total";
            }
            if (ddlType.SelectedValue == "Receipts")
            {
                field = "sum_receipts";
            }

            dv.Sort = field;

            chartStaffStats.Titles[0].Text = ddlType.SelectedValue;
            chartStaffStats.Series["Series1"].Points.DataBindXY(dv, "fullname", dv, field);

            lblChartHeading.Text = ddlType.SelectedValue;

            if (chartType == SeriesChartType.StackedBar)
            {
                chartStaffStats.Height = new Unit((tblStats.Rows.Count * 30), UnitType.Pixel);
            }

            chartStaffStats.ChartAreas["ChartArea1"].AxisX.MinorTickMark.Enabled = false;
            chartStaffStats.ChartAreas["ChartArea1"].AxisX.Interval       = 1;
            chartStaffStats.ChartAreas["ChartArea1"].AxisX.IsLabelAutoFit = true;
            //chartStaffStats.ChartAreas["ChartArea1").AxisX.LabelStyle.IsStaggered = True
            //chartStaffStats.ChartAreas["ChartArea1"].AxisX.LabelAutoFitStyle = System.Web.UI.DataVisualization.Charting.LabelAutoFitStyles.DecreaseFont;

            chartStaffStats.ChartAreas["ChartArea1"].AxisY.Enabled = System.Web.UI.DataVisualization.Charting.AxisEnabled.False;

            if (chartType == SeriesChartType.Pie || chartType == SeriesChartType.Doughnut)
            {
                chartStaffStats.Legends.Add("Legend1");
                chartStaffStats.Legends["Legend1"].Enabled         = true;
                chartStaffStats.Legends["Legend1"].Docking         = System.Web.UI.DataVisualization.Charting.Docking.Right;
                chartStaffStats.Legends["Legend1"].LegendItemOrder = System.Web.UI.DataVisualization.Charting.LegendItemOrder.SameAsSeriesOrder;
                chartStaffStats.Legends["Legend1"].Font            = new Font("Trebuchet MS", 10);

                // Add Color column
                LegendCellColumn firstColumn = new LegendCellColumn();
                firstColumn.ColumnType = LegendCellColumnType.SeriesSymbol;
                chartStaffStats.Legends["Legend1"].CellColumns.Add(firstColumn);

                // Add name cell column
                LegendCellColumn textColumn = new LegendCellColumn();
                textColumn.Alignment = System.Drawing.ContentAlignment.MiddleLeft;
                textColumn.Text      = "#LEGENDTEXT";
                textColumn.Name      = "nameColumn";
                chartStaffStats.Legends["Legend1"].CellColumns.Add(textColumn);

                // Add value cell column
                LegendCellColumn valColumn = new LegendCellColumn();
                valColumn.Text = "#VAL";
                valColumn.Name = "totalColumn";
                chartStaffStats.Legends["Legend1"].CellColumns.Add(valColumn);

                // Add percent cell column
                LegendCellColumn percentColumn = new LegendCellColumn();
                percentColumn.Text = "#PERCENT";
                percentColumn.Name = "percentColumn";
                chartStaffStats.Legends["Legend1"].CellColumns.Add(percentColumn);
            }
        }
        catch (CustomMessageException cmEx)
        {
            HideTableAndSetErrorMessage(cmEx.Message);
        }
        catch (Exception ex)
        {
            HideTableAndSetErrorMessage(ex.ToString());
        }
    }
Esempio n. 4
0
        public void BuildAnnualProviderGraph(SimulationResults SimRes, ParameterManagerClass PM, List <string> ParameterFieldNames, int ProviderIndex, string aLabel)
        {
            // create a lits for data
            List <ChartPointsByYear> ChartSeriesList = new List <ChartPointsByYear>();

            int year      = 0;
            int parmvalue = 0;
            int yearCount = SimRes.Length;
            int yearIndex = 0;

            // OK, figure out the years Min Max and Count
            int MaxYear = -1;
            int MinYear = 9999;

            foreach (AnnualSimulationResults ASR in SimRes)
            {
                year = ASR.year;
                if (year > MaxYear)
                {
                    MaxYear = year;
                }
                if (year < MinYear)
                {
                    MinYear = year;
                }
            }

            // Count all the the parameter in first year of SimRes
            int ParameterCount = SimRes[0].Outputs.BaseOutput.Length + SimRes[0].Outputs.ProviderOutput.Length + SimRes[0].Inputs.BaseInput.Length + SimRes[0].Inputs.ProviderInput.Length;

            // Set up the Data array for that many parameters
            int[][] ValueData = new int[ParameterCount][];
            // now set up for array of years data
            for (int i = 0; i < ParameterCount; i++)
            {
                ValueData[i] = new int[yearCount];
            }

            // index for parms
            int ParmDataIndex = 0;

            // ok Build an list of parameter indexes and ModelParameters
            int ParamterCount = ParameterFieldNames.Count;

            int[] ParmIndexes = new int[ParameterCount];
            ModelParameterClass[] ModelParameters = new ModelParameterClass[ParameterCount];
            for (int i = 0; i < ParameterCount; i++)
            {
                ModelParameters[i] = PM.Model_Parameter(ParameterFieldNames[i]);
                if (ModelParameters[i] != null)
                {
                    ParmIndexes[i] = SimRes[0].GetParmIndex(ModelParameters[i]);
                }
                else
                {
                    ParmIndexes[i] = -1;
                }
            }

            foreach (AnnualSimulationResults ASR in SimRes)
            {
                year      = ASR.year;
                yearIndex = year - MinYear;
                for (int i = 0; i < ParameterCount; i++)
                {
                    if (ParmIndexes[i] >= 0)
                    {
                        if (ModelParameters[i].isBaseParam)
                        {
                            ValueData[i][yearIndex] = GrabParmBaseData(ASR, ModelParameters[i].ParamType, ParmIndexes[i]);
                        }
                        else
                        if (ModelParameters[i].isProviderParam)
                        {
                            ValueData[i][yearIndex] = GrabParmProviderData(ASR, ModelParameters[i].ParamType, ParmIndexes[i])[ProviderIndex];
                        }
                    }
                }
            }


            //bool iserr = false;
            //        string errMessage = "";
            //        year =
            //yearIndex = year - MinYear;

            //            // Fetch only records that match the scenario name or if "" then just the first scenario
            //            if (((ScenarioName == "") && (ScnStr == FirstScnName)) || (ScnStr == ScenarioName))
            //            {
            //                // fetch only records for the target provider
            //                pcode = DR[PrvdFldStr].ToString().Trim();
            //                if (pcode.ToUpper() == targetProvider.ToUpper())
            //                {
            //                    int pIndex = 0;
            //                    // Ok get all the fields requested
            //                    foreach (fieldinfo info in dbFields)
            //                    {
            //                        if (DT.Columns.Contains(info.Fieldname))
            //                        {
            //                            parmvalue = UniDB.Tools.ConvertToInt32(DR[info.Fieldname].ToString(), ref iserr, ref errMessage);
            //                            ValueData[pIndex][yearIndex] = parmvalue;
            //                            pIndex++;
            //                        }
            //                    }
            //                    // OK get a years worth of data, increment year count
            //                    YearCnt++;
            //                }
            //            }
            //            // OK, if we have read values for all the years, then break
            //            if (YearCnt == NumberOfYears) break; // from foreach


            //        if (iserr)
            //        {
            //            // Do What?
            //        }
            // OK create the series
            // First create a year array
            int[] allYearValues = new int[yearCount];
            for (int i = 0; i < yearCount; i++)
            {
                allYearValues[i] = MinYear + i;
            }
            for (int i = 0; i < ParameterCount; i++)
            {
                ChartPointsByYear points = new ChartPointsByYear(allYearValues, ValueData[i], ParameterFieldNames[i]);
                ChartSeriesList.Add(points);
            }
            //  Now Sort By Size
            ChartSeriesList.Sort(ChartPointsByYear.CompareForSort_UseMax);

            // ok clear up chart
            FChart.Series.Clear();
            FChart.Legends.Clear();
            FChart.ChartAreas.Clear();
            //                    ProviderPopChart.Update();

            // Setup legend

            FChart.ChartAreas.Add(FTitle);
            System.Windows.Forms.DataVisualization.Charting.Legend MyLegend = new System.Windows.Forms.DataVisualization.Charting.Legend("Default");
            FChart.Legends.Add(MyLegend);
            int index = 0;

            foreach (ChartPointsByYear points in ChartSeriesList)
            {
                Series dSeries = new Series();
                int[]  Years   = points.Years;
                int[]  Values  = points.Values;
                dSeries.LegendText   = points.SeriesLabel;
                dSeries.BorderWidth  = 2;
                dSeries.ChartType    = FChartType;
                dSeries.LabelToolTip = points.SeriesLabel;
                //dSeries.Label = points.SeriesLabel;
                for (int j = 0; j < Years.Length; j++)
                {
                    dSeries.Points.AddXY(Years[j], Values[j]);
                }
                FChart.Series.Add(dSeries);
                index++;
            }
            // Chart Label
            // First build field label
            string fldlabel = "";

            foreach (string str in ParameterFieldNames)
            {
                if (fldlabel != "")
                {
                    fldlabel += ", ";
                }
                fldlabel += str;
            }
            bool  addTitle = false;
            Title myTitle  = null;


            if (FChart.Titles.Count > 0)
            {
                myTitle = FChart.Titles.FindByName("MAIN");
            }
            if (myTitle == null)
            {
                myTitle  = new Title();
                addTitle = true;
            }
            myTitle.Name      = "MAIN";
            myTitle.Text      = aLabel.Trim() + " by " + fldlabel + " and Year";
            myTitle.Alignment = ContentAlignment.MiddleCenter;

            myTitle.Font = new Font(myTitle.Font.Name, 14.0F, FontStyle.Bold, myTitle.Font.Unit);
            if (addTitle)
            {
                FChart.Titles.Add(myTitle);
            }
            // Add Legend
            LegendCellColumn secondColumn = new LegendCellColumn();

            secondColumn.ColumnType      = LegendCellColumnType.Text;
            secondColumn.HeaderText      = "Name";
            secondColumn.Text            = "#LEGENDTEXT";
            secondColumn.HeaderBackColor = Color.WhiteSmoke;
            FChart.Legends["Default"].CellColumns.Add(secondColumn);

            // Set Min cell column attributes
            LegendCellColumn maxColumn = new LegendCellColumn();

            maxColumn.Text            = "#MAX{N1}";
            maxColumn.HeaderText      = "Max";
            maxColumn.Name            = "MaxColumn";
            maxColumn.HeaderBackColor = Color.WhiteSmoke;
            FChart.Legends["Default"].CellColumns.Add(maxColumn);
            // Add Color column
            LegendCellColumn firstColumn = new LegendCellColumn();

            firstColumn.ColumnType      = LegendCellColumnType.SeriesSymbol;
            firstColumn.HeaderText      = "Color";
            firstColumn.HeaderBackColor = Color.WhiteSmoke;
            FChart.Legends["Default"].CellColumns.Add(firstColumn);


            // OK let's see what happens
        }
Esempio n. 5
0
        private void Gestion_legend(Legend leg)
        {
            leg.Title              = "légende";
            leg.Name               = "legend";
            leg.BackColor          = Color.WhiteSmoke;
            leg.BackSecondaryColor = Color.White;
            leg.BackGradientStyle  = GradientStyle.DiagonalLeft;
            leg.BorderColor        = Color.Black;
            leg.BorderWidth        = 2;
            leg.TitleSeparator     = LegendSeparatorStyle.Line;
            leg.BorderDashStyle    = ChartDashStyle.Solid;
            leg.ShadowOffset       = 2;
            leg.Alignment          = StringAlignment.Center;
            leg.InsideChartArea    = "";
            leg.Docking            = Docking.Bottom;

            // Add header separator of type line
            leg.HeaderSeparator      = LegendSeparatorStyle.Line;
            leg.HeaderSeparatorColor = Color.Gray;

            // Add Color column
            LegendCellColumn firstColumn = new LegendCellColumn()
            {
                ColumnType      = LegendCellColumnType.SeriesSymbol,
                HeaderText      = "Color",
                HeaderBackColor = Color.WhiteSmoke
            };

            leg.CellColumns.Add(firstColumn);

            // Add Legend Text column
            LegendCellColumn secondColumn = new LegendCellColumn()
            {
                ColumnType      = LegendCellColumnType.Text,
                HeaderText      = "Name",
                Text            = "#LEGENDTEXT",
                HeaderBackColor = Color.WhiteSmoke
            };

            leg.CellColumns.Add(secondColumn);

            // Add AVG cell column
            LegendCellColumn avgColumn = new LegendCellColumn()
            {
                Text            = "#AVG{N2}",
                HeaderText      = "Avg",
                Name            = "AvgColumn",
                HeaderBackColor = Color.WhiteSmoke
            };

            leg.CellColumns.Add(avgColumn);

            // Add Max cell column
            LegendCellColumn maxColumn = new LegendCellColumn()
            {
                Text            = "#MAX{N1}",
                HeaderText      = "Max",
                Name            = "Maxcolumn",
                HeaderBackColor = Color.WhiteSmoke
            };

            leg.CellColumns.Add(maxColumn);

            // Set Min cell column attributes
            LegendCellColumn minColumn = new LegendCellColumn()
            {
                Text            = "#MIN{N1}",
                HeaderText      = "Min",
                Name            = "MinColumn",
                HeaderBackColor = Color.WhiteSmoke
            };

            leg.CellColumns.Add(minColumn);

            Legends.Add(leg);
        }
Esempio n. 6
0
        private void InitializeChart()
        {
            myChart.ChartAreas.Clear();
            myChart.Series.Clear();

            #region 设置图表的属性
            //图表的背景色
            myChart.BackColor = Color.FromArgb(211, 223, 240);
            //图表背景色的渐变方式
            myChart.BackGradientStyle = GradientStyle.TopBottom;
            //图表的边框颜色、
            myChart.BorderlineColor = Color.FromArgb(26, 59, 105);
            //图表的边框线条样式
            myChart.BorderlineDashStyle = ChartDashStyle.Solid;
            //图表边框线条的宽度
            myChart.BorderlineWidth = 2;
            //图表边框的皮肤
            myChart.BorderSkin.SkinStyle = BorderSkinStyle.Emboss;
            #endregion

            #region 设置图表的标题
            Title title = new Title();
            //标题内容
            title.Text = "曲线图";
            //标题的字体
            title.Font = new System.Drawing.Font("Microsoft Sans Serif", 12, FontStyle.Bold);
            //标题字体颜色
            title.ForeColor = Color.FromArgb(26, 59, 105);
            //标题阴影颜色
            title.ShadowColor = Color.FromArgb(32, 0, 0, 0);
            //标题阴影偏移量
            title.ShadowOffset = 3;
            myChart.Titles.Add(title);
            #endregion

            #region 设置图例的属性
            //注意,需要把原来控件自带的图例删除掉
            this.myChart.Legends.Clear();

            Legend legend = new Legend("Default");
            legend.Alignment   = StringAlignment.Center;
            legend.Docking     = Docking.Bottom;
            legend.LegendStyle = LegendStyle.Column;
            this.myChart.Legends.Add(legend);

            // Add header separator of type line
            legend.HeaderSeparator      = LegendSeparatorStyle.Line;
            legend.HeaderSeparatorColor = Color.Gray;

            LegendCellColumn firstColumn = new LegendCellColumn();
            firstColumn.ColumnType      = LegendCellColumnType.SeriesSymbol;
            firstColumn.HeaderText      = "Color";
            firstColumn.HeaderBackColor = Color.WhiteSmoke;
            myChart.Legends["Default"].CellColumns.Add(firstColumn);

            // Add Legend Text column
            LegendCellColumn secondColumn = new LegendCellColumn();
            secondColumn.ColumnType      = LegendCellColumnType.Text;
            secondColumn.HeaderText      = "Name";
            secondColumn.Text            = "#LEGENDTEXT";
            secondColumn.HeaderBackColor = Color.WhiteSmoke;
            myChart.Legends["Default"].CellColumns.Add(secondColumn);

            // Add AVG cell column
            LegendCellColumn avgColumn = new LegendCellColumn();
            avgColumn.Text            = "#AVG{N2}";
            avgColumn.HeaderText      = "Avg";
            avgColumn.Name            = "AvgColumn";
            avgColumn.HeaderBackColor = Color.WhiteSmoke;
            myChart.Legends["Default"].CellColumns.Add(avgColumn);

            // Add Total cell column
            LegendCellColumn totalColumn = new LegendCellColumn();
            totalColumn.Text            = "#TOTAL{N1}";
            totalColumn.HeaderText      = "Total";
            totalColumn.Name            = "TotalColumn";
            totalColumn.HeaderBackColor = Color.WhiteSmoke;
            myChart.Legends["Default"].CellColumns.Add(totalColumn);

            // Set Min cell column attributes
            LegendCellColumn minColumn = new LegendCellColumn();
            minColumn.Text            = "#MIN{N1}";
            minColumn.HeaderText      = "Min";
            minColumn.Name            = "MinColumn";
            minColumn.HeaderBackColor = Color.WhiteSmoke;
            myChart.Legends["Default"].CellColumns.Add(minColumn);

            // Set Max cell column attributes
            LegendCellColumn maxColumn = new LegendCellColumn();
            maxColumn.Text            = "#MAX{N1}";
            maxColumn.HeaderText      = "Max";
            maxColumn.Name            = "MaxColumn";
            maxColumn.HeaderBackColor = Color.WhiteSmoke;
            myChart.Legends["Default"].CellColumns.Add(maxColumn);

            #endregion

            #region 设置图表区属性
            ChartArea chartArea = new ChartArea("Default");
            //设置Y轴刻度间隔大小
            chartArea.AxisY.Interval = 5;
            //设置Y轴的数据类型格式
            //chartArea.AxisY.LabelStyle.Format = "C";
            //设置背景色
            chartArea.BackColor = Color.FromArgb(64, 165, 191, 228);
            //设置背景渐变方式
            chartArea.BackGradientStyle = GradientStyle.TopBottom;
            //设置渐变和阴影的辅助背景色
            chartArea.BackSecondaryColor = Color.White;
            //设置边框颜色
            chartArea.BorderColor = Color.FromArgb(64, 64, 64, 64);
            //设置阴影颜色
            chartArea.ShadowColor = Color.Transparent;
            //设置X轴和Y轴线条的颜色
            chartArea.AxisX.LineColor = Color.FromArgb(64, 64, 64, 64);
            chartArea.AxisY.LineColor = Color.FromArgb(64, 64, 64, 64);
            //设置X轴和Y轴线条的宽度
            chartArea.AxisX.LineWidth = 1;
            chartArea.AxisY.LineWidth = 1;
            //设置X轴和Y轴的标题
            chartArea.AxisX.Title = "时间";
            chartArea.AxisY.Title = "数值";
            //设置图表区网格横纵线条的颜色
            chartArea.AxisX.MajorGrid.LineColor = Color.FromArgb(64, 64, 64, 64);
            chartArea.AxisY.MajorGrid.LineColor = Color.FromArgb(64, 64, 64, 64);
            //设置图表区网格横纵线条的宽度
            chartArea.AxisX.MajorGrid.LineWidth = 1;
            chartArea.AxisY.MajorGrid.LineWidth = 1;
            //设置坐标轴刻度线不延长出来
            chartArea.AxisX.MajorTickMark.Enabled = false;
            chartArea.AxisY.MajorTickMark.Enabled = false;
            //开启下面两句能够隐藏网格线条
            //chartArea.AxisX.MajorGrid.Enabled = false;
            //chartArea.AxisY.MajorGrid.Enabled = false;
            //设置X轴的显示类型及显示方式
            chartArea.AxisX.Interval               = 0; //设置为0表示由控件自动分配
            chartArea.AxisX.IntervalAutoMode       = IntervalAutoMode.VariableCount;
            chartArea.AxisX.IntervalType           = DateTimeIntervalType.Minutes;
            chartArea.AxisX.LabelStyle.IsStaggered = true;
            //chartArea.AxisX.MajorGrid.IntervalType = DateTimeIntervalType.Minutes;
            //chartArea.AxisX.LabelStyle.IntervalType = DateTimeIntervalType.Minutes;
            chartArea.AxisX.LabelStyle.Format = "yyyy-MM-dd HH:mm:ss";
            //设置文本角度
            //chartArea.AxisX.LabelStyle.Angle = 45;
            //设置文本自适应
            chartArea.AxisX.IsLabelAutoFit = true;
            //设置X轴允许拖动放大
            chartArea.CursorX.IsUserEnabled          = true;
            chartArea.CursorX.IsUserSelectionEnabled = true;
            chartArea.CursorX.Interval                   = 0;
            chartArea.CursorX.IntervalOffset             = 0;
            chartArea.CursorX.IntervalType               = DateTimeIntervalType.Minutes;
            chartArea.AxisX.ScaleView.Zoomable           = true;
            chartArea.AxisX.ScrollBar.IsPositionedInside = false;

            //设置中短线(还没看到效果)
            //chartArea.AxisY.ScaleBreakStyle.Enabled = true;
            //chartArea.AxisY.ScaleBreakStyle.CollapsibleSpaceThreshold = 47;
            //chartArea.AxisY.ScaleBreakStyle.BreakLineStyle = BreakLineStyle.Wave;
            //chartArea.AxisY.ScaleBreakStyle.Spacing = 2;
            //chartArea.AxisY.ScaleBreakStyle.LineColor = Color.Red;
            //chartArea.AxisY.ScaleBreakStyle.LineWidth = 10;

            myChart.ChartAreas.Add(chartArea);
            #endregion

            //线条2:主要曲线
            Series series = new Series("Default");
            //设置线条类型
            series.ChartType = SeriesChartType.Line;
            //线条宽度
            series.BorderWidth = 1;
            //阴影宽度
            series.ShadowOffset = 0;
            //是否显示在图例集合Legends
            series.IsVisibleInLegend = true;
            //线条上数据点上是否有数据显示
            series.IsValueShownAsLabel = true;
            //线条颜色
            series.Color = Color.MediumPurple;
            //设置曲线X轴的显示类型
            series.XValueType = ChartValueType.DateTime;
            //设置数据点的类型
            series.MarkerStyle = MarkerStyle.Circle;
            //线条数据点的大小
            series.MarkerSize = 5;
            myChart.Series.Add(series);

            //手动构造横坐标数据
            DataTable dataTable = new DataTable();
            dataTable.Columns.Add("TheTime", typeof(DateTime)); //注意typeof
            dataTable.Columns.Add("TheValue", typeof(double));  //注意typeof
            Random   random   = new Random();                   //随机数
            DateTime dateTime = System.DateTime.Now;
            for (int n = 0; n < 3; n++)
            {
                dateTime = dateTime.AddSeconds(10);
                DataRow dr = dataTable.NewRow();
                dr["TheTime"]  = dateTime;
                dr["TheValue"] = random.Next(0, 101);
                dataTable.Rows.Add(dr);
            }
            for (int n = 3; n < 1000; n++)
            {
                dateTime = dateTime.AddSeconds(30);
                DataRow dr = dataTable.NewRow();
                dr["TheTime"]  = dateTime;
                dr["TheValue"] = random.Next(0, 101);
                dataTable.Rows.Add(dr);
            }

            //线条1:下限横线
            Series seriesMin = new Series("Min");
            seriesMin.ChartType           = SeriesChartType.Line;
            seriesMin.BorderWidth         = 1;
            seriesMin.ShadowOffset        = 0;
            seriesMin.IsVisibleInLegend   = true;
            seriesMin.IsValueShownAsLabel = false;
            seriesMin.Color       = Color.Red;
            seriesMin.XValueType  = ChartValueType.DateTime;
            seriesMin.MarkerStyle = MarkerStyle.None;
            myChart.Series.Add(seriesMin);

            //线条3:上限横线
            Series seriesMax = new Series("Max");
            seriesMax.ChartType           = SeriesChartType.Line;
            seriesMax.BorderWidth         = 1;
            seriesMax.ShadowOffset        = 0;
            seriesMax.IsVisibleInLegend   = true;
            seriesMax.IsValueShownAsLabel = false;
            seriesMax.Color       = Color.Red;
            seriesMax.XValueType  = ChartValueType.DateTime;
            seriesMax.MarkerStyle = MarkerStyle.None;
            myChart.Series.Add(seriesMax);

            //设置X轴的最小值为第一个点的X坐标值
            chartArea.AxisX.Minimum = Convert.ToDateTime(dataTable.Rows[0]["TheTime"]).ToOADate();

            //开始画线
            foreach (DataRow dr in dataTable.Rows)
            {
                series.Points.AddXY(dr["TheTime"], dr["TheValue"]);

                seriesMin.Points.AddXY(dr["TheTime"], 15); //设置下线为15
                seriesMax.Points.AddXY(dr["TheTime"], 30); //设置上限为30
            }
        }
        private void LoadRMPerformanceChart()
        {
            double  tempAggr     = 0;
            AssetBo assetsBo     = new AssetBo();
            DataSet dsAssetChart = new DataSet();

            //DataSet ds = null;
            try
            {
                Series seriesAssets = new Series("RMPerformance");
                Legend legend       = new Legend("RMPerformanceLegend");
                legend.Enabled = true;

                //ds = assetBo.GetAdvisorRM_All_AssetAgr(advisorVo.advisorId);

                if (ds.Tables[2].Rows.Count > 0)
                {
                    string[]  XValues         = new string[ds.Tables[2].Rows.Count];
                    double[]  YValues         = new double[ds.Tables[2].Rows.Count];
                    DataSet   RMPerformanceDs = new DataSet();
                    int       j = 0;
                    DataRow   drResult;
                    DataRow   dr;
                    DataTable dt = new DataTable();
                    dt.Columns.Add("RMName");
                    dt.Columns.Add("AggregateValue");
                    for (int i = 0; i < ds.Tables[2].Rows.Count; i++)
                    {
                        dr       = dt.NewRow();
                        drResult = ds.Tables[2].Rows[i];
                        dr[0]    = drResult["AR_FirstName"].ToString() + drResult["AR_LastName"].ToString();
                        tempAggr = Math.Round(Convert.ToDouble(drResult["result"].ToString()), 2);
                        if (tempAggr == 0)
                        {
                            j = j + 1;
                        }
                        dr[1] = tempAggr.ToString();
                        dt.Rows.Add(dr);
                    }
                    RMPerformanceDs.Tables.Add(dt);

                    if (j != ds.Tables[2].Rows.Count)
                    {
                        // LoadChart

                        seriesAssets.ChartType        = SeriesChartType.Pie;
                        ChartRMPerformance.DataSource = RMPerformanceDs.Tables[0].DefaultView;


                        Series series1 = ChartRMPerformance.Series[0];
                        ChartRMPerformance.Series.Clear();
                        ChartRMPerformance.Series.Add(seriesAssets);
                        //ChartRMPerformance.Series[0]["CollectedThreshold"] = "5";
                        ChartRMPerformance.Series[0]["CollectedLegendText"] = "Other";
                        ChartRMPerformance.Series[0].XValueMember           = "RMName";
                        ChartRMPerformance.Series[0].YValueMembers          = "AggregateValue";
                        ChartRMPerformance.Legends.Add(legend);
                        ChartRMPerformance.Legends["RMPerformanceLegend"].Title               = "RM Performance";
                        ChartRMPerformance.Legends["RMPerformanceLegend"].TitleAlignment      = StringAlignment.Center;
                        ChartRMPerformance.Legends["RMPerformanceLegend"].TitleSeparator      = LegendSeparatorStyle.DoubleLine;
                        ChartRMPerformance.Legends["RMPerformanceLegend"].BackColor           = Color.FloralWhite;
                        ChartRMPerformance.Legends["RMPerformanceLegend"].TitleSeparatorColor = Color.Black;


                        ChartArea        chartArea1  = ChartRMPerformance.ChartAreas[0];
                        LegendCellColumn colorColumn = new LegendCellColumn();
                        colorColumn.ColumnType      = LegendCellColumnType.SeriesSymbol;
                        colorColumn.HeaderText      = "Color";
                        colorColumn.HeaderBackColor = Color.WhiteSmoke;
                        ChartRMPerformance.Legends["RMPerformanceLegend"].CellColumns.Add(colorColumn);
                        chartArea1.BackColor          = System.Drawing.Color.Transparent;
                        chartArea1.BackSecondaryColor = System.Drawing.Color.Transparent;
                        //ChartRMPerformance.BackSecondaryColor = System.Drawing.Color.Transparent;

                        //LegendCellColumn RMNameColumn = new LegendCellColumn();
                        //RMNameColumn.ColumnType = LegendCellColumnType.Text;
                        //RMNameColumn.HeaderText = "Name";
                        //RMNameColumn.Text = "#RMName";
                        //RMNameColumn.HeaderBackColor = Color.WhiteSmoke;
                        //ChartRMPerformance.Legends["RMPerformanceLegend"].CellColumns.Add(RMNameColumn);


                        LegendCellColumn totalColumn = new LegendCellColumn();
                        totalColumn.Alignment       = ContentAlignment.MiddleLeft;
                        totalColumn.Text            = "#VALX: #PERCENT";
                        totalColumn.HeaderText      = "Performance";
                        totalColumn.Name            = "PerformanceColumn";
                        totalColumn.HeaderBackColor = Color.WhiteSmoke;
                        ChartRMPerformance.Legends["RMPerformanceLegend"].CellColumns.Add(totalColumn);



                        ChartRMPerformance.Series[0]["PieLabelStyle"] = "Disabled";


                        ChartRMPerformance.Series[0].ToolTip = "#VALX: #VALY";
                        ChartRMPerformance.ChartAreas[0].Area3DStyle.Enable3D = true;
                        ChartRMPerformance.DataBind();
                    }
                    else
                    {
                        ChartRMPerformance.DataSource = null;
                        ChartRMPerformance.Visible    = false;
                        // lblRMPerformChart.Visible = false;
                    }
                }
                else
                {
                    ChartRMPerformance.DataSource = null;
                    ChartRMPerformance.Visible    = false;
                    // lblRMPerformChart.Visible = false;
                }
            }
            catch (BaseApplicationException Ex)
            {
                throw Ex;
            }
            catch (Exception Ex)
            {
                BaseApplicationException exBase       = new BaseApplicationException(Ex.Message, Ex);
                NameValueCollection      FunctionInfo = new NameValueCollection();
                FunctionInfo.Add("Method", "IFAAdminMainDashboard.ascx:LoadRMPerformanceChart()");
                object[] objects = new object[3];
                objects[0]   = advisorVo;
                objects[1]   = ds;
                objects[2]   = tempAggr;
                FunctionInfo = exBase.AddObject(FunctionInfo, objects);
                exBase.AdditionalInformation = FunctionInfo;
                ExceptionManager.Publish(exBase);
                throw exBase;
            }
        }
Esempio n. 8
0
        private void BindAssetChart(DataSet dsAssetChart)
        {
            // Total Assets Chart
            Series    seriesAssets = new Series("Assets");
            Legend    legend       = new Legend("AssetsLegend");
            ChartArea chartArea1   = chrtTotalAssets.ChartAreas[0];

            legend.Enabled = true;
            string[] XValues = new string[dsAssetChart.Tables[0].Rows.Count];
            double[] YValues = new double[dsAssetChart.Tables[0].Rows.Count];
            int      i       = 0;

            seriesAssets.ChartType = SeriesChartType.Pie;

            foreach (DataRow dr in dsAssetChart.Tables[0].Rows)
            {
                XValues[i] = dr["AssetType"].ToString();
                YValues[i] = double.Parse(dr["AggrCurrentValue"].ToString());
                i++;
            }
            seriesAssets.Points.DataBindXY(XValues, YValues);
            //chrtTotalAssets.DataSource = dsAssetChart.Tables[0].DefaultView;

            chrtTotalAssets.Series.Clear();
            chrtTotalAssets.Series.Add(seriesAssets);

            //chrtTotalAssets.Series["Assets"].XValueMember = "AssetType";
            //chrtTotalAssets.Series["Assets"].YValueMembers = "AggrCurrentValue";
            chrtTotalAssets.Legends.Add(legend);
            chrtTotalAssets.Series["Assets"]["CollectedSliceExploded"] = "true";
            chrtTotalAssets.Legends["AssetsLegend"].Title               = "Assets";
            chrtTotalAssets.Legends["AssetsLegend"].TitleAlignment      = StringAlignment.Center;
            chrtTotalAssets.Legends["AssetsLegend"].TitleSeparator      = LegendSeparatorStyle.DoubleLine;
            chrtTotalAssets.Legends["AssetsLegend"].TitleSeparatorColor = Color.Black;
            chrtTotalAssets.Series["Assets"]["PieLabelStyle"]           = "Disabled";

            chrtTotalAssets.ChartAreas[0].Area3DStyle.Enable3D    = true;
            chrtTotalAssets.ChartAreas[0].Area3DStyle.Perspective = 50;
            chrtTotalAssets.Legends["AssetsLegend"].BackColor     = Color.FloralWhite;
            //chrtTotalAssets.ChartAreas[0].InnerPlotPosition.Width = 100;
            chrtTotalAssets.Width                    = 500;
            chrtTotalAssets.BackColor                = Color.Transparent;
            chartArea1.BackColor                     = System.Drawing.Color.Transparent;
            chartArea1.BackSecondaryColor            = System.Drawing.Color.Transparent;
            chrtTotalAssets.ChartAreas[0].BackColor  = Color.Transparent;
            chrtTotalAssets.Series["Assets"].ToolTip = "#VALX: #PERCENT";

            LegendCellColumn colors = new LegendCellColumn();

            colors.HeaderText      = "Color";
            colors.ColumnType      = LegendCellColumnType.SeriesSymbol;
            colors.HeaderBackColor = Color.WhiteSmoke;
            chrtTotalAssets.Legends["AssetsLegend"].CellColumns.Add(colors);

            LegendCellColumn asset = new LegendCellColumn();

            asset.Alignment  = ContentAlignment.MiddleLeft;
            asset.HeaderText = "Asset";
            asset.Text       = "#VALX";
            chrtTotalAssets.Legends["AssetsLegend"].CellColumns.Add(asset);

            LegendCellColumn assetPercent = new LegendCellColumn();

            assetPercent.Alignment  = ContentAlignment.MiddleLeft;
            assetPercent.HeaderText = "Asset Percentage";
            assetPercent.Text       = "#PERCENT";
            chrtTotalAssets.Legends["AssetsLegend"].CellColumns.Add(assetPercent);

            foreach (DataPoint point in chrtTotalAssets.Series["Assets"].Points)
            {
                point["Exploded"] = "true";
            }

            chrtTotalAssets.DataBind();
            //chrtTotalAssets.Series["Assets"].
        }
        /**************************** For Current Asset Allocation Chart *************************************/

        protected void ShowCurrentAssetAllocationPieChart()
        {
            DataTable dtChartCurrAsset = new DataTable();
            DataRow   drChartCurrAsset;

            customerVo = new CustomerVo();
            string CurrEquity     = "0";
            string CurrDebt       = "0";
            string CurrCash       = "0";
            string CurrAlternates = "0";

            if (Session[SessionContents.CustomerVo] != null && Session[SessionContents.CustomerVo].ToString() != "")
            {
                customerVo = (CustomerVo)Session[SessionContents.CustomerVo];
            }

            dsFPCurrentAndRecomondedAssets = customerprospectbo.GetFPCurrentAndRecomondedAssets(CustomerId);
            if (dsFPCurrentAndRecomondedAssets.Tables[0].Rows.Count > 0)
            {
                DataTable dtCurrAssetAllocation = new DataTable();
                dtCurrAssetAllocation = dsFPCurrentAndRecomondedAssets.Tables[0];
                dtChartCurrAsset.Columns.Add("AssetClass");
                dtChartCurrAsset.Columns.Add("CurrentAssetPercentage");

                foreach (DataRow dr in dtCurrAssetAllocation.Rows)
                {
                    drChartCurrAsset = dtChartCurrAsset.NewRow();
                    if (dr["AssetType"].ToString() == "Equity")
                    {
                        if (double.Parse(dr["Percentage"].ToString()) > 0)
                        {
                            drChartCurrAsset["AssetClass"]             = dr["AssetType"].ToString();
                            drChartCurrAsset["CurrentAssetPercentage"] = dr["Percentage"].ToString();
                            CurrEquity = drChartCurrAsset["CurrentAssetPercentage"].ToString();
                            dtChartCurrAsset.Rows.Add(drChartCurrAsset);
                        }
                    }
                    if (dr["AssetType"].ToString() == "Debt")
                    {
                        if (double.Parse(dr["Percentage"].ToString()) > 0)
                        {
                            drChartCurrAsset["AssetClass"]             = dr["AssetType"].ToString();
                            drChartCurrAsset["CurrentAssetPercentage"] = dr["Percentage"].ToString();
                            CurrDebt = drChartCurrAsset["CurrentAssetPercentage"].ToString();
                            dtChartCurrAsset.Rows.Add(drChartCurrAsset);
                        }
                    }
                    if (dr["AssetType"].ToString() == "Cash")
                    {
                        if (double.Parse(dr["Percentage"].ToString()) > 0)
                        {
                            drChartCurrAsset["AssetClass"]             = dr["AssetType"].ToString();
                            drChartCurrAsset["CurrentAssetPercentage"] = dr["Percentage"].ToString();
                            CurrCash = drChartCurrAsset["CurrentAssetPercentage"].ToString();
                            dtChartCurrAsset.Rows.Add(drChartCurrAsset);
                        }
                    }
                    if (dr["AssetType"].ToString() == "Alternates")
                    {
                        if (double.Parse(dr["Percentage"].ToString()) > 0)
                        {
                            drChartCurrAsset["AssetClass"]             = dr["AssetType"].ToString();
                            drChartCurrAsset["CurrentAssetPercentage"] = dr["Percentage"].ToString();
                            CurrAlternates = drChartCurrAsset["CurrentAssetPercentage"].ToString();
                            dtChartCurrAsset.Rows.Add(drChartCurrAsset);
                        }
                    }
                }
                if ((CurrEquity != "0") || (CurrDebt != "0") || (CurrCash != "0") || (CurrAlternates != "0"))
                {
                    /****** For Chart binding *********/
                    Legend ShowCurrentAssetAlllegend = null;
                    ShowCurrentAssetAlllegend         = new Legend("ShowCurrentAssetAlllegendLegends");
                    ShowCurrentAssetAlllegend.Enabled = true;

                    ChartCurrentAsset.Palette             = ChartColorPalette.Pastel;
                    ChartCurrentAsset.PaletteCustomColors = new Color[] { Color.LimeGreen, Color.Yellow, Color.LightBlue, Color.Purple, Color.Goldenrod, Color.Blue, Color.BurlyWood,
                                                                          Color.Chocolate, Color.DeepPink, Color.Plum, Color.Violet, Color.Gainsboro, Color.Tomato, Color.Teal };

                    Series seriesAssets = new Series("CurrentAsset");
                    seriesAssets.ChartType    = SeriesChartType.Pie;
                    ChartCurrentAsset.Visible = true;
                    ChartCurrentAsset.Series.Clear();
                    ChartCurrentAsset.Series.Add(seriesAssets);
                    ChartCurrentAsset.DataSource              = dtChartCurrAsset;
                    ChartCurrentAsset.Series[0].XValueMember  = "AssetClass";
                    ChartCurrentAsset.Series[0].YValueMembers = "CurrentAssetPercentage";
                    ChartCurrentAsset.Series[0].ToolTip       = "#VALX: #PERCENT";

                    ChartCurrentAsset.Legends.Add(ShowCurrentAssetAlllegend);
                    ChartCurrentAsset.Legends["ShowCurrentAssetAlllegendLegends"].Title               = "Assets";
                    ChartCurrentAsset.Legends["ShowCurrentAssetAlllegendLegends"].TitleAlignment      = StringAlignment.Center;
                    ChartCurrentAsset.Legends["ShowCurrentAssetAlllegendLegends"].TitleSeparator      = LegendSeparatorStyle.None;
                    ChartCurrentAsset.Legends["ShowCurrentAssetAlllegendLegends"].Alignment           = StringAlignment.Center;
                    ChartCurrentAsset.Legends["ShowCurrentAssetAlllegendLegends"].TitleSeparator      = LegendSeparatorStyle.GradientLine;
                    ChartCurrentAsset.Legends["ShowCurrentAssetAlllegendLegends"].TitleSeparatorColor = Color.Black;

                    /******** Enable X axis margin *********/
                    LegendCellColumn colorColumn = new LegendCellColumn();
                    colorColumn.ColumnType      = LegendCellColumnType.SeriesSymbol;
                    colorColumn.HeaderBackColor = Color.WhiteSmoke;
                    ChartCurrentAsset.Legends["ShowCurrentAssetAlllegendLegends"].CellColumns.Add(colorColumn);
                    ChartCurrentAsset.Legends["ShowCurrentAssetAlllegendLegends"].BackColor = Color.FloralWhite;
                    LegendCellColumn totalColumn = new LegendCellColumn();
                    totalColumn.Alignment = ContentAlignment.MiddleLeft;

                    totalColumn.Text            = "#VALX: #PERCENT";
                    totalColumn.Name            = "AssetsColumn";
                    totalColumn.HeaderBackColor = Color.WhiteSmoke;
                    ChartCurrentAsset.Legends["ShowCurrentAssetAlllegendLegends"].CellColumns.Add(totalColumn);
                    ChartCurrentAsset.Series[0]["PieLabelStyle"] = "Disabled";

                    ChartCurrentAsset.ChartAreas["caActualAsset"].AxisX.IsMarginVisible = true;
                    ChartCurrentAsset.BackColor = Color.Transparent;
                    ChartCurrentAsset.ChartAreas[0].BackColor               = Color.Transparent;
                    ChartCurrentAsset.ChartAreas[0].BackSecondaryColor      = System.Drawing.Color.Transparent;
                    ChartCurrentAsset.ChartAreas[0].Area3DStyle.Enable3D    = true;
                    ChartCurrentAsset.ChartAreas[0].Area3DStyle.Perspective = 50;
                    tdCurrentAssetAllocation.Visible = true;
                    ChartCurrentAsset.DataBind();
                }
                else
                {
                    lblCurrChartErrorDisplay.Visible = true;
                    ChartCurrentAsset.Visible        = false;
                }
            }
            else
            {
                lblCurrChartErrorDisplay.Visible = true;
                ChartCurrentAsset.Visible        = false;
            }
        }
        /**************************** For Customer FP Asstet Chart *************************************/

        protected void bindChart(int CustomerId)
        {
            Legend Branchlegend = null;

            Branchlegend         = new Legend("BranchAssetsLegends");
            Branchlegend.Enabled = true;
            string[]  XValues = null;
            decimal[] YValues = null;
            DataRow   drChAssets;
            DataRow   drChvalues;
            Series    seriesBranchAssets = null;

            seriesBranchAssets = new Series("seriesBranchAssets");
            double DAssetvalue = 0;
            int    j           = 0;

            if (dsFPAssetsAndLiabilitesDetails.Tables[0].Rows.Count > 0)
            {
                lblChartBranchAUM.Visible = true;
                hrCustAsset.Visible       = true;
                ErrorMessage.Visible      = false;
                drChvalues = branchAumDT.Rows[0];
                for (int i = 0; i < branchAumDT.Columns.Count - 1; i++)
                {
                    drChAssets = branchAumDT.NewRow();

                    branchAumDT.Rows.Add(drChAssets);
                    if (DAssetvalue == 0)
                    {
                        j = j + 1;
                    }
                }
                if (j != branchAumDT.Columns.Count)
                {
                    seriesBranchAssets.ChartType = SeriesChartType.Pie;

                    XValues = new string[10];
                    YValues = new decimal[10];
                    ChartBranchAssets.Series.Clear();
                    ChartBranchAssets.DataSource = branchAumDT;
                    ChartBranchAssets.Series.Clear();
                    ChartBranchAssets.Series.Add(seriesBranchAssets);
                    ChartBranchAssets.Series[0].XValueMember  = "Asset";
                    ChartBranchAssets.Series[0].XValueType    = ChartValueType.String;
                    ChartBranchAssets.Series[0].YValueMembers = "CurrentValue";
                    ChartBranchAssets.Series["seriesBranchAssets"].IsValueShownAsLabel = true;
                    ChartBranchAssets.ChartAreas[0].AxisX.Title = "Assets";
                    ChartBranchAssets.Series[0].XValueMember    = "Asset";
                    ChartBranchAssets.DataManipulator.Sort(PointSortOrder.Descending, "Y", seriesBranchAssets);

                    ChartBranchAssets.Palette             = ChartColorPalette.Pastel;
                    ChartBranchAssets.PaletteCustomColors = new Color[] { Color.LimeGreen, Color.Yellow, Color.LightBlue, Color.Purple, Color.Goldenrod, Color.Blue, Color.BurlyWood,
                                                                          Color.Chocolate, Color.DeepPink, Color.Plum, Color.Violet, Color.Gainsboro, Color.Tomato, Color.Teal };

                    ChartBranchAssets.Legends.Add(Branchlegend);
                    ChartBranchAssets.Legends["BranchAssetsLegends"].Title               = "Assets";
                    ChartBranchAssets.Legends["BranchAssetsLegends"].TitleAlignment      = StringAlignment.Center;
                    ChartBranchAssets.Legends["BranchAssetsLegends"].TitleSeparator      = LegendSeparatorStyle.None;
                    ChartBranchAssets.Legends["BranchAssetsLegends"].Alignment           = StringAlignment.Center;
                    ChartBranchAssets.Legends["BranchAssetsLegends"].TitleSeparator      = LegendSeparatorStyle.GradientLine;
                    ChartBranchAssets.Legends["BranchAssetsLegends"].TitleSeparatorColor = Color.Black;
                    //ChartBranchAssets.Legends["BranchAssetsLegends"].AutoFitMinFontSize
                    ChartBranchAssets.Series[0]["PieLabelStyle"] = "Outside";
                    ChartBranchAssets.Series[0]["PieStartAngle"] = "10";
                    ChartArea chartArea1 = ChartBranchAssets.ChartAreas[0];
                    chartArea1.Area3DStyle.IsClustered      = true;
                    chartArea1.Area3DStyle.Enable3D         = true;
                    chartArea1.Area3DStyle.Perspective      = 10;
                    chartArea1.Area3DStyle.PointGapDepth    = 900;
                    chartArea1.Area3DStyle.IsRightAngleAxes = false;
                    chartArea1.Area3DStyle.WallWidth        = 25;
                    chartArea1.Area3DStyle.Rotation         = 65;
                    chartArea1.Area3DStyle.Inclination      = 35;
                    chartArea1.BackColor          = System.Drawing.Color.Transparent;
                    chartArea1.BackSecondaryColor = System.Drawing.Color.Transparent;
                    chartArea1.Position.Auto      = true;
                    LegendCellColumn colorColumn = new LegendCellColumn();
                    colorColumn.ColumnType      = LegendCellColumnType.SeriesSymbol;
                    colorColumn.HeaderBackColor = Color.WhiteSmoke;
                    ChartBranchAssets.Legends["BranchAssetsLegends"].CellColumns.Add(colorColumn);
                    ChartBranchAssets.Legends["BranchAssetsLegends"].BackColor = Color.FloralWhite;
                    LegendCellColumn totalColumn = new LegendCellColumn();
                    totalColumn.Alignment = ContentAlignment.MiddleLeft;

                    totalColumn.Text            = "#VALX: #PERCENT";
                    totalColumn.Name            = "AssetsColumn";
                    totalColumn.HeaderBackColor = Color.WhiteSmoke;
                    ChartBranchAssets.Legends["BranchAssetsLegends"].CellColumns.Add(totalColumn);
                    ChartBranchAssets.Series[0]["PieLabelStyle"]         = "Disabled";
                    ChartBranchAssets.Series[0].ToolTip                  = "#VALX: #PERCENT";
                    ChartBranchAssets.ChartAreas[0].AxisX.Interval       = 1;
                    ChartBranchAssets.ChartAreas[0].AxisY.Title          = "Total Assets";
                    ChartBranchAssets.ChartAreas[0].Area3DStyle.Enable3D = true;
                    ChartBranchAssets.DataBind();
                }
            }
            else
            {
                lblChartBranchAUM.Visible    = false;
                hrCustAsset.Visible          = false;
                ErrorMessage.Visible         = true;
                ChartBranchAssets.DataSource = null;
                ChartBranchAssets.Visible    = false;
            }
        }
        public void ProcessRequest( HttpContext context )
        {
            SparePartPriceKey key = SparePartPriceKey.Parse(context.Request.QueryString["ID"]);
            SparePartFranch part = SparePartsDac.Load(key);
            if (part != null)
            {
                Int32? beforeTime = part.BeforeTime;
                Int32? onTime = part.OnTime;
                Int32? delay = part.Delay;
                Int32? nonDelivery = part.NonDelivery;

                //beforeTime = 100; onTime = 75; delay = 60; nonDelivery = 35;

                if (beforeTime != null && onTime != null && delay != null && nonDelivery != null)
                {

                    Chart ChartStat = new System.Web.UI.DataVisualization.Charting.Chart();

                    //LiteralControl lc = new LiteralControl();

                    //lc.Text = "123";

                    //ChartStat.Controls.Add(lc);

                    Title t = new Title(("Рейтинг" + Environment.NewLine + "поставщика"), Docking.Top);

                    t.Font = new Font(t.Font.FontFamily,(float)t.Font.SizeInPoints * (float)1.325);

                    t.Position = new ElementPosition(18, 2, 65, 20);

                    ChartStat.Titles.Add(t);

                    ChartStat.Series.Add(new Series("SeriesStat"));
                    ChartStat.ChartAreas.Add(new ChartArea("ChartAreaStat"));

                    int[] yValues = { (int) beforeTime, (int) onTime, (int) delay, (int) nonDelivery};
                    string[] xValues = { "Раньше", "Вовремя", "Задержка", "Непоставка" };
                    ChartStat.Series["SeriesStat"].Points.DataBindXY(xValues, yValues);
                    ChartStat.Series["SeriesStat"].LabelForeColor = Color.FromArgb(0, Color.White);

                    ChartStat.Series["SeriesStat"].Points[0].Color = Color.FromArgb(0, 127, 255); // синий Раньше
                    ChartStat.Series["SeriesStat"].Points[1].Color = Color.FromArgb(47, 229, 107); // зеленый Вовремя
                    ChartStat.Series["SeriesStat"].Points[2].Color = Color.FromArgb(255, 242, 157); // желтый Задержка
                    ChartStat.Series["SeriesStat"].Points[3].Color = Color.FromArgb(254, 192, 192); // красный Непоставка

                    // Set chart type
                    ChartStat.Series["SeriesStat"].ChartType = SeriesChartType.Pie;

                    // Set labels style
                    ChartStat.Series["SeriesStat"]["PieLabelStyle"] = "Inside";

                    // Enable 3D
                    ChartStat.ChartAreas["ChartAreaStat"].Area3DStyle.Enable3D = true;

                    // Show a 30% perspective
                    ChartStat.ChartAreas["ChartAreaStat"].Area3DStyle.Perspective = 30;

                    // Set the X Angle to 70
                    ChartStat.ChartAreas["ChartAreaStat"].Area3DStyle.Inclination = 70;

                    // Set the Y Angle to -2
                    ChartStat.ChartAreas["ChartAreaStat"].Area3DStyle.Rotation = -2;

                    ChartStat.ChartAreas["ChartAreaStat"].Position = new ElementPosition(16, 5, 68, 68);

                    System.Web.UI.DataVisualization.Charting.Legend l = new Legend("LegendStat");

                    //l.TitleFont = new Font();
                    l.Title = "Указанное время доставки:" + Environment.NewLine +
                        part.DisplayDeliveryDaysMin.ToString() + " - " + part.DisplayDeliveryDaysMax.ToString() + " (в рабочих днях)";
                    l.TitleAlignment = StringAlignment.Center;
                    l.TitleFont = new Font(l.TitleFont.FontFamily, l.TitleFont.SizeInPoints * (float) 1.15);

                    ChartStat.Legends.Add(l);

                    LegendCellColumn firstColumn = new LegendCellColumn();
                    firstColumn.ColumnType = LegendCellColumnType.SeriesSymbol;
                    ChartStat.Legends["LegendStat"].CellColumns.Add(firstColumn);

                    LegendCellColumn secondColumn = new LegendCellColumn();
                    secondColumn.ColumnType = LegendCellColumnType.Text;
                    secondColumn.Text = "#LEGENDTEXT";
                    secondColumn.Alignment = ContentAlignment.MiddleLeft;
                    secondColumn.HeaderBackColor = Color.WhiteSmoke;
                    ChartStat.Legends["LegendStat"].CellColumns.Add(secondColumn);

                    LegendCellColumn thirdColumn = new LegendCellColumn();
                    thirdColumn.ColumnType = LegendCellColumnType.Text;
                    thirdColumn.Text = "#PERCENT{0#%}";
                    //thirdColumn.Text = String.Format({0:#%},thirdColumn.Text);
                    thirdColumn.Alignment = ContentAlignment.MiddleRight;
                    thirdColumn.HeaderBackColor = Color.WhiteSmoke;
                    ChartStat.Legends["LegendStat"].CellColumns.Add(thirdColumn);

                    ChartStat.Legends[0].Enabled = true;
                    //(34, 63, 40, 30)
                    ChartStat.Legends[0].Position = new ElementPosition(22, 58, 60, 44);

                    context.Response.ContentType = "image/bmp";
                    context.Response.Cache.SetCacheability(HttpCacheability.ServerAndPrivate);

                    using (System.IO.MemoryStream imageStream = new System.IO.MemoryStream())
                    {
                        ChartStat.SaveImage(imageStream, ChartImageFormat.Bmp);
                        context.Response.BinaryWrite(imageStream.ToArray());
                    }
                    context.Response.End();
                }
            }
            else
            {
                throw new HttpException((int)HttpStatusCode.NotFound, "Not Found");
            }
        }
Esempio n. 12
0
        public override object ChartAdd(string testItem)
        {
            TabItem tim = doneTabControl.CreateTab(testItem);

            if (tim_Click != null)
            {
                tim.Click += tim_Click;
            }

            tim.Name = testItem;
            Chart chart = new Chart();

            // chart.Palette = ChartColorPalette.Bright;
            chart.Palette             = ChartColorPalette.None;
            chart.PaletteCustomColors = new Color[] { Color.Blue, Color.Green, Color.Black, Color.Brown, Color.Cyan, Color.Magenta,
                                                      Color.LightGreen, Color.Orange, Color.Peru, Color.DarkRed, Color.LightBlue, Color.SlateGray, Color.Red };
            chart.Name = testItem;
            chart.Dock = DockStyle.Fill;
            //chart.Width = 999;
            //chart.Height = 336;
            chart.Location = new Point(4, 0);
            if (testItem.StartsWith("T"))
            {
                chart.GetToolTipText += chart_GetToolTipTextTime;
            }
            else
            {
                chart.GetToolTipText += chart_GetToolTipTextFre;
            }



            ChartArea chartArea = new ChartArea("ChartArea1");

            chartArea.CursorX.IsUserEnabled          = true;
            chartArea.CursorX.IsUserSelectionEnabled = true;
            chartArea.CursorX.LineDashStyle          = ChartDashStyle.DashDotDot;
            chartArea.CursorY.IsUserEnabled          = true;
            chartArea.CursorY.IsUserSelectionEnabled = true;
            chartArea.CursorY.LineDashStyle          = ChartDashStyle.DashDotDot;
            //chartArea.Position.Auto = false;
            //chartArea.Position.Height = 98;
            //chartArea.Position.Width = 98;

            //chartArea.BackColor = Color.DarkGoldenrod;
            //chartArea.AxisX.MajorGrid.LineColor = Color.LawnGreen;
            //chartArea.AxisY.MajorGrid.LineColor = Color.LawnGreen;
            //chartArea.AxisX.MajorGrid.
            //chartArea.AxisX.MajorGrid.in
            chart.ChartAreas.Add(chartArea);

            Legend legend = new Legend("legend");

            legend.Title = "Legend";
            legend.Font  = new Font("Arial", 9F,
                                    System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            //legend.InsideChartArea = "ChartArea1";

            legend.CellColumns.Clear();

            legend.CellColumns.Add(new LegendCellColumn()
            {
                Name       = "chbx",
                ColumnType = LegendCellColumnType.Text,
                Text       = "#CUSTOMPROPERTY(CHECK)",
                Font       = new Font("Segoe UI", 9, FontStyle.Bold),
                BackColor  = Color.Transparent
            });

            legend.CellColumns.Add(new LegendCellColumn()
            {
                Name       = "symbol",
                ColumnType = LegendCellColumnType.SeriesSymbol,
                BackColor  = Color.Transparent
            });
            LegendCellColumn a = new LegendCellColumn();

            //a.BackColor = Color.Transparent;

            legend.CellColumns.Add(new LegendCellColumn()
            {
                Name       = "title",
                ColumnType = LegendCellColumnType.Text,
                Text       = "#LEGENDTEXT",
                Alignment  = ContentAlignment.MiddleLeft,
                BackColor  = Color.Transparent
            });
            chart.Legends.Add(legend);
            chart.MouseDown += chart_MouseDown;
            tim.AttachedControl.Controls.Add(chart);
            chart.ChartAreas[0].AxisY.IsStartedFromZero = false;
            chart.Series.Clear();


            return(chart);
        }
Esempio n. 13
0
    protected void FillForm()
    {
        try
        {
            if (!CheckIsValidStartEndDates())
            {
                return;
            }

            SeriesChartType chartType = SeriesChartType.StackedBar;
            if (ddlChartType.SelectedValue == "Pie")
            {
                chartType = SeriesChartType.Pie;
            }
            if (ddlChartType.SelectedValue == "Doughnut")
            {
                chartType = SeriesChartType.Doughnut;
            }
            if (ddlChartType.SelectedValue == "StackedBar")
            {
                chartType = SeriesChartType.StackedBar;
            }
            if (ddlChartType.SelectedValue == "Area")
            {
                chartType = SeriesChartType.Area;
            }
            if (ddlChartType.SelectedValue == "BoxPlot")
            {
                chartType = SeriesChartType.BoxPlot;
            }
            if (ddlChartType.SelectedValue == "Column")
            {
                chartType = SeriesChartType.Column;
            }
            if (ddlChartType.SelectedValue == "Line")
            {
                chartType = SeriesChartType.Line;
            }
            if (ddlChartType.SelectedValue == "Point")
            {
                chartType = SeriesChartType.Point;
            }
            if (ddlChartType.SelectedValue == "Range")
            {
                chartType = SeriesChartType.Range;
            }
            if (ddlChartType.SelectedValue == "RangeBar")
            {
                chartType = SeriesChartType.RangeBar;
            }
            if (ddlChartType.SelectedValue == "RangeColumn")
            {
                chartType = SeriesChartType.RangeColumn;
            }

            chartOrgStats.Series["Series1"].ChartType = chartType;



            DataTable tblStats = OrganisationDB.GetStats(GetFromDate(), GetToDate(), UserView.GetInstance().IsClinicView ? 5 : 6, chkIncDeleted.Checked);

            int maxToShow = 350;
            if (tblStats.Rows.Count > maxToShow)
            {
                for (int i = tblStats.Rows.Count - 1; i >= maxToShow; i--)
                {
                    tblStats.Rows.RemoveAt(i);
                }
            }

            DataView dv = tblStats.DefaultView;

            string field = string.Empty;
            if (ddlType.SelectedValue == "New Bookings Added By")
            {
                field = "n_bookings";
            }
            if (ddlType.SelectedValue == "New Patients")
            {
                field = "n_patients";
            }
            if (ddlType.SelectedValue == "Total Bookings")
            {
                field = "total_bookings";
            }

            dv.Sort = field;

            chartOrgStats.Titles[0].Text = ddlType.SelectedValue;
            chartOrgStats.Series["Series1"].Points.DataBindXY(dv, "name", dv, field);

            lblChartHeading.Text = ddlType.SelectedValue;

            if (chartType == SeriesChartType.StackedBar)
            {
                chartOrgStats.Height = new Unit((tblStats.Rows.Count * 30), UnitType.Pixel);
            }

            chartOrgStats.ChartAreas["ChartArea1"].AxisX.MinorTickMark.Enabled = false;
            chartOrgStats.ChartAreas["ChartArea1"].AxisX.Interval       = 1;
            chartOrgStats.ChartAreas["ChartArea1"].AxisX.IsLabelAutoFit = true;
            //chartOrgStats.ChartAreas["ChartArea1").AxisX.LabelStyle.IsStaggered = True
            //chartOrgStats.ChartAreas["ChartArea1"].AxisX.LabelAutoFitStyle = System.Web.UI.DataVisualization.Charting.LabelAutoFitStyles.DecreaseFont;

            chartOrgStats.ChartAreas["ChartArea1"].AxisY.Enabled = System.Web.UI.DataVisualization.Charting.AxisEnabled.False;

            if (chartType == SeriesChartType.Pie || chartType == SeriesChartType.Doughnut)
            {
                chartOrgStats.Legends.Add("Legend1");
                chartOrgStats.Legends["Legend1"].Enabled         = true;
                chartOrgStats.Legends["Legend1"].Docking         = System.Web.UI.DataVisualization.Charting.Docking.Right;
                chartOrgStats.Legends["Legend1"].LegendItemOrder = System.Web.UI.DataVisualization.Charting.LegendItemOrder.SameAsSeriesOrder;
                chartOrgStats.Legends["Legend1"].Font            = new Font("Trebuchet MS", 10);

                // Add Color column
                LegendCellColumn firstColumn = new LegendCellColumn();
                firstColumn.ColumnType = LegendCellColumnType.SeriesSymbol;
                chartOrgStats.Legends["Legend1"].CellColumns.Add(firstColumn);

                // Add name cell column
                LegendCellColumn textColumn = new LegendCellColumn();
                textColumn.Alignment = System.Drawing.ContentAlignment.MiddleLeft;
                textColumn.Text      = "#LEGENDTEXT";
                textColumn.Name      = "nameColumn";
                chartOrgStats.Legends["Legend1"].CellColumns.Add(textColumn);

                // Add value cell column
                LegendCellColumn valColumn = new LegendCellColumn();
                valColumn.Text = "#VAL";
                valColumn.Name = "totalColumn";
                chartOrgStats.Legends["Legend1"].CellColumns.Add(valColumn);

                // Add percent cell column
                LegendCellColumn percentColumn = new LegendCellColumn();
                percentColumn.Text = "#PERCENT";
                percentColumn.Name = "percentColumn";
                chartOrgStats.Legends["Legend1"].CellColumns.Add(percentColumn);
            }
        }
        catch (CustomMessageException cmEx)
        {
            HideTableAndSetErrorMessage(cmEx.Message);
        }
        catch (Exception ex)
        {
            HideTableAndSetErrorMessage(ex.ToString());
        }
    }
Esempio n. 14
0
        ///-------------------------------------------------------------------------------------------------
        /// <summary> Builds an annual parameter graph. </summary>
        /// <param name="DT">           The datatable. </param>
        /// <param name="DbConnection"> The database connection. </param>
        /// <param name="Providers">    The providers to be charted. </param>
        /// <param name="fldname">      The fldname or column name to be charted. </param>
        ///-------------------------------------------------------------------------------------------------
        //public void BuildAnnualParameterGraph(DataTable DT, UniDbConnection DbConnection, string ScenarioName, List<providerinfo> Providers, string fldname, string fieldlabel)

        public void BuildAnnualParameterGraph(WaterSimManagerClass WSIM, SimulationResults SimRes, string fldname, string fieldlabel, string[] Regions)
        {
            List <string> debug = new List <string>();

            // create a lits for data
            List <ChartPointsByYear> ChartSeriesList = new List <ChartPointsByYear>();

            // ok clear up chart
            FChart.Series.Clear();
            FChart.Legends.Clear();
            FChart.ChartAreas.Clear();
            //                    ProviderPopChart.Update();

            // Setup legend

            FChart.ChartAreas.Add(FTitle);
            System.Windows.Forms.DataVisualization.Charting.Legend MyLegend = new System.Windows.Forms.DataVisualization.Charting.Legend("Default");
            FChart.Legends.Add(MyLegend);
            // get data


            int    pIndex    = -1;
            int    year      = 0;
            int    pop       = 0;
            string pcode     = "";
            int    yearCount = 0;
            int    yearIndex = 0;
            // OK, figure out the years Min Max and Count
            int MaxYear = -1;
            int MinYear = 9999;


            // There must be a way to speed this up!
            foreach (AnnualSimulationResults ASR in SimRes)
            {
                year = ASR.year;
                if (year > MaxYear)
                {
                    MaxYear = year;
                }
                if (year < MinYear)
                {
                    MinYear = year;
                }
            }


            yearCount = (MaxYear - MinYear) + 1;

            // OK can set up the dta
            int ProviderCount = SimRes[0].Outputs.ProviderOutput[0].Values.Length;

            //int ProviderCount = Providers.Count;
            // create provider value data array
            int[][] ValueData = null; // new int[ProviderCount][];
                                      // now create new arrays (years length) for each provider array
                                      //for (int i = 0; i < ProviderCount; i++)
                                      //  ValueData[i] = new int[yearCount];

            // Cycle through each record and stick data into the right slot

            // first get the parmeters index into AnnualResults arrays
            ModelParameterClass theModelParmeter = WSIM.ParamManager.Model_Parameter(fldname);
            int ModelParmIndex = SimRes[0].GetParmIndex(theModelParmeter);

            ValueData = GrabProviderDataByYear(SimRes, theModelParmeter);

            // OK create the series
            // First create a year array
            int[] allYearValues = new int[yearCount];
            for (int i = 0; i < yearCount; i++)
            {
                allYearValues[i] = MinYear + i;
            }
            for (int i = 0; i < ProviderCount; i++)
            {
                string ProviderName   = ProviderClass.ProviderNameList[i];
                bool   DoThisProvider = false;

                if ((Regions == null) || (Regions.Length == 0))
                {
                    DoThisProvider = true;
                }
                else
                {
                    foreach (string RegName in Regions)
                    {
                        if (RegName == ProviderName)
                        {
                            DoThisProvider = true;
                            break;
                        }
                    }
                }

                if (DoThisProvider)
                {
                    ChartPointsByYear points = new ChartPointsByYear(allYearValues, ValueData[i], ProviderName);
                    ChartSeriesList.Add(points);
                }
            }
            //  Now Sort By Size
            ChartSeriesList.Sort(ChartPointsByYear.CompareForSort_UseMax);


            foreach (ChartPointsByYear points in ChartSeriesList)
            {
                Series dSeries = new Series();
                int[]  Years   = points.Years;
                int[]  Values  = points.Values;
                dSeries.LegendText   = points.SeriesLabel;
                dSeries.ChartType    = FChartType;
                dSeries.BorderWidth  = 3;
                dSeries.MarkerSize   = 20;
                dSeries.LabelToolTip = points.SeriesLabel;
                for (int j = 0; j < Years.Length; j++)
                {
                    dSeries.Points.AddXY(Years[j], Values[j]);
                }
                FChart.Series.Add(dSeries);
            }


            FChart.ChartAreas[0].AxisX.Minimum  = MinYear;
            FChart.ChartAreas[0].AxisX.Maximum  = MaxYear;
            FChart.ChartAreas[0].AxisX.Interval = 5;
            // Chart Label
            bool  addTitle = false;
            Title myTitle  = null;

            if (FChart.Titles.Count > 0)
            {
                myTitle = FChart.Titles.FindByName("MAIN");
            }
            if (myTitle == null)
            {
                myTitle  = new Title();
                addTitle = true;
            }
            myTitle.Name      = "MAIN";
            myTitle.Text      = fieldlabel + " by Water Provider and Year";
            myTitle.Font      = new Font(myTitle.Font.Name, 14.0F, FontStyle.Bold, myTitle.Font.Unit);
            myTitle.Alignment = ContentAlignment.MiddleCenter;
            if (addTitle)
            {
                FChart.Titles.Add(myTitle);
            }
            // Chart Legend
            /// <summary> The second column. </summary>
            LegendCellColumn secondColumn = new LegendCellColumn();

            secondColumn.ColumnType      = LegendCellColumnType.Text;
            secondColumn.HeaderText      = "Name";
            secondColumn.Text            = "#LEGENDTEXT";
            secondColumn.HeaderBackColor = Color.WhiteSmoke;
            FChart.Legends["Default"].CellColumns.Add(secondColumn);

            // Set Min cell column attributes
            LegendCellColumn maxColumn = new LegendCellColumn();

            maxColumn.Text            = "#MAX{N1}";
            maxColumn.HeaderText      = "Max";
            maxColumn.Name            = "MaxColumn";
            maxColumn.HeaderBackColor = Color.WhiteSmoke;
            FChart.Legends["Default"].CellColumns.Add(maxColumn);
            // Add Color column
            LegendCellColumn firstColumn = new LegendCellColumn();

            firstColumn.ColumnType      = LegendCellColumnType.SeriesSymbol;
            firstColumn.HeaderText      = "Color";
            firstColumn.HeaderBackColor = Color.WhiteSmoke;
            FChart.Legends["Default"].CellColumns.Add(firstColumn);
            // OK let's see what happens

            //FChart.Update;
            //FChart.Scale(new SizeF())
        }
Esempio n. 15
0
        private void MontarGrafico(Chart grafico, IList <DTOInscritosPorCategoria> dados, int ano)
        {
            grafico.Titles.Add(new Title(string.Format("Ano: {0}", ano.ToString()), Docking.Top, new Font("Arial", 16, GraphicsUnit.Pixel), Color.Black));


            Series serie1 = new Series();

            serie1.ChartType           = SeriesChartType.Pie;
            serie1.IsValueShownAsLabel = true;
            serie1.Name = "FormaAquisicao";
            serie1.Points.DataBindXY(dados, "Categoria", dados, "QuantidadeInscritos");
            //serie1.ToolTip = "Tooltip";
            serie1["PieLabelStyle"] = "Outside";
            grafico.Series.Add(serie1);


            Legend legenda = new Legend();

            legenda.Name = "Legenda";

            //legenda.HeaderSeparator = LegendSeparatorStyle.Line;
            //legenda.BackSecondaryColor = Color.FromArgb(57, 116, 172);


            LegendCellColumn firstColumn = new LegendCellColumn();

            firstColumn.ColumnType      = LegendCellColumnType.SeriesSymbol;
            firstColumn.HeaderText      = "Cor";
            firstColumn.HeaderBackColor = Color.FromArgb(57, 116, 172);
            firstColumn.HeaderForeColor = Color.White;
            legenda.CellColumns.Add(firstColumn);

            LegendCellColumn secondColumn = new LegendCellColumn();

            secondColumn.ColumnType = LegendCellColumnType.Text;
            secondColumn.HeaderText = "Categoria";
            //secondColumn.HeaderAlignment = StringAlignment.;
            secondColumn.Text            = "#LEGENDTEXT";
            secondColumn.Alignment       = ContentAlignment.MiddleLeft;
            secondColumn.HeaderBackColor = Color.FromArgb(57, 116, 172);
            secondColumn.HeaderForeColor = Color.White;
            legenda.CellColumns.Add(secondColumn);

            // Add Total cell column
            LegendCellColumn percColumn = new LegendCellColumn();

            percColumn.Text            = "#PERCENT";
            percColumn.HeaderText      = "%";
            percColumn.Name            = "PercColumn";
            percColumn.HeaderBackColor = Color.FromArgb(57, 116, 172);
            percColumn.HeaderForeColor = Color.White;
            legenda.CellColumns.Add(percColumn);

            grafico.Legends.Add(legenda);

            ChartArea area = new ChartArea();


            //eixo x (eixo horizontal)
            area.Name = "ChatArea2";
            //area.AxisX.Title = "Forma Aquisicao";
            area.AxisX.TitleAlignment      = System.Drawing.StringAlignment.Center;
            area.AxisX.IsStartedFromZero   = false;
            area.AxisX.IntervalOffset      = 1;
            area.AxisX.Interval            = 1;
            area.AxisX.LineColor           = Color.Black;
            area.AxisX.LabelStyle.Font     = new Font("Arial", 9, GraphicsUnit.Pixel);
            area.AxisX.MajorGrid.LineColor = Color.FromArgb(235, 235, 235);


            area.Area3DStyle.IsClustered      = true;
            area.Area3DStyle.Enable3D         = true;
            area.Area3DStyle.Perspective      = 10;
            area.Area3DStyle.PointGapDepth    = 900;
            area.Area3DStyle.IsRightAngleAxes = false;
            area.Area3DStyle.WallWidth        = 25;
            //area.Area3DStyle.Rotation = 65;
            area.Area3DStyle.Inclination = 50;


            area.AxisY.IntervalOffset      = 5;
            area.AxisY.Interval            = 5;
            area.AxisY.MajorGrid.LineColor = Color.FromArgb(235, 235, 235);
            area.AxisY.LineColor           = Color.Black;
            area.AxisY.LabelStyle.Font     = new Font("Arial", 6, GraphicsUnit.Pixel);

            grafico.ChartAreas.Add(area);


            //eixo y (eixo vertical)
            //grafico.ChartAreas["ChartArea1"].AxisY.TextOrientation = TextOrientation.Rotated270;
        }
        /**************************** For Recommended Asset Allocation Chart *************************************/

        public void LoadRecommendedAssetAllocation()
        {
            DataTable dtChartRecommendedAsset = new DataTable();
            DataSet   dsGetCustomerDOBById    = new DataSet();

            customerVo = new CustomerVo();
            string RecommendedEquity     = "0";
            string RecommendedDebt       = "0";
            string RecommendedCash       = "0";
            string RecommendedAlternates = "0";

            dsGetCustomerDOBById = riskprofilebo.GetCustomerDOBById(CustomerId);
            if (Session[SessionContents.CustomerVo] != null && Session[SessionContents.CustomerVo].ToString() != "")
            {
                customerVo = (CustomerVo)Session[SessionContents.CustomerVo];
            }
            if (dsGetCustomerDOBById.Tables[0].Rows[0]["C_DOB"].ToString() != "" && dsGetCustomerDOBById.Tables[0].Rows[0]["C_DOB"].ToString() != null)
            {
                DateTime bday = DateTime.Parse(dsGetCustomerDOBById.Tables[0].Rows[0]["C_DOB"].ToString());
                DateTime now  = DateTime.Today;
                age = now.Year - bday.Year;
                if (now < bday.AddYears(age))
                {
                    age--;
                }
                if (dsFPCurrentAndRecomondedAssets.Tables[1].Rows.Count > 0)
                {
                    DataTable dtRecommendedAssetAllocation = new DataTable();
                    dtRecommendedAssetAllocation = dsFPCurrentAndRecomondedAssets.Tables[1];
                    dtChartRecommendedAsset.Columns.Add("AssetClass");
                    dtChartRecommendedAsset.Columns.Add("RecommendedPercentage");
                    foreach (DataRow dr in dtRecommendedAssetAllocation.Rows)
                    {
                        drChartRecommendedAsset = dtChartRecommendedAsset.NewRow();
                        if (dr["AssetType"].ToString() == "Equity")
                        {
                            if (double.Parse(dr["Percentage"].ToString()) > 0)
                            {
                                drChartRecommendedAsset["AssetClass"]            = dr["AssetType"].ToString();
                                drChartRecommendedAsset["RecommendedPercentage"] = dr["Percentage"].ToString();
                                RecommendedEquity = drChartRecommendedAsset["RecommendedPercentage"].ToString();
                                dtChartRecommendedAsset.Rows.Add(drChartRecommendedAsset);
                            }
                        }
                        if (dr["AssetType"].ToString() == "Debt")
                        {
                            if (double.Parse(dr["Percentage"].ToString()) > 0)
                            {
                                drChartRecommendedAsset["AssetClass"]            = dr["AssetType"].ToString();
                                drChartRecommendedAsset["RecommendedPercentage"] = dr["Percentage"].ToString();
                                RecommendedDebt = drChartRecommendedAsset["RecommendedPercentage"].ToString();
                                dtChartRecommendedAsset.Rows.Add(drChartRecommendedAsset);
                            }
                        }
                        if (dr["AssetType"].ToString() == "Cash")
                        {
                            if (double.Parse(dr["Percentage"].ToString()) > 0)
                            {
                                drChartRecommendedAsset["AssetClass"]            = dr["AssetType"].ToString();
                                drChartRecommendedAsset["RecommendedPercentage"] = dr["Percentage"].ToString();
                                RecommendedCash = drChartRecommendedAsset["RecommendedPercentage"].ToString();
                                dtChartRecommendedAsset.Rows.Add(drChartRecommendedAsset);
                            }
                        }
                        if (dr["AssetType"].ToString() == "Alternates")
                        {
                            if (double.Parse(dr["Percentage"].ToString()) > 0)
                            {
                                drChartRecommendedAsset["AssetClass"]            = dr["AssetType"].ToString();
                                drChartRecommendedAsset["RecommendedPercentage"] = dr["Percentage"].ToString();
                                RecommendedAlternates = drChartRecommendedAsset["RecommendedPercentage"].ToString();
                                dtChartRecommendedAsset.Rows.Add(drChartRecommendedAsset);
                            }
                        }
                    }
                    if ((RecommendedEquity != "0") || (RecommendedDebt != "0") || (RecommendedCash != "0") || (RecommendedAlternates != "0"))
                    {
                        lblCurrChartErrorDisplay.Visible = false;
                        /* For Chart binding */
                        Legend ShowRecomondedAssetAlllegend = null;
                        ShowRecomondedAssetAlllegend         = new Legend("ShowRecomondedAssetAlllegendLegends");
                        ShowRecomondedAssetAlllegend.Enabled = true;

                        ChartRecomonedAsset.Palette             = ChartColorPalette.Pastel;
                        ChartRecomonedAsset.PaletteCustomColors = new Color[] { Color.LimeGreen, Color.Yellow, Color.LightBlue, Color.Purple, Color.Goldenrod, Color.Blue, Color.BurlyWood,
                                                                                Color.Chocolate, Color.DeepPink, Color.Plum, Color.Violet, Color.Gainsboro, Color.Tomato, Color.Teal };

                        Series seriesAssets = new Series("RecomondedAsset");
                        seriesAssets.ChartType      = SeriesChartType.Pie;
                        ChartRecomonedAsset.Visible = true;
                        ChartRecomonedAsset.Series.Clear();
                        ChartRecomonedAsset.Series.Add(seriesAssets);
                        ChartRecomonedAsset.DataSource              = dtChartRecommendedAsset;
                        ChartRecomonedAsset.Series[0].XValueMember  = "AssetClass";
                        ChartRecomonedAsset.Series[0].YValueMembers = "RecommendedPercentage";
                        ChartRecomonedAsset.Series[0].ToolTip       = "#VALX: #PERCENT";

                        ChartRecomonedAsset.Legends.Add(ShowRecomondedAssetAlllegend);
                        ChartRecomonedAsset.Legends["ShowRecomondedAssetAlllegendLegends"].Title               = "Assets";
                        ChartRecomonedAsset.Legends["ShowRecomondedAssetAlllegendLegends"].TitleAlignment      = StringAlignment.Center;
                        ChartRecomonedAsset.Legends["ShowRecomondedAssetAlllegendLegends"].TitleSeparator      = LegendSeparatorStyle.None;
                        ChartRecomonedAsset.Legends["ShowRecomondedAssetAlllegendLegends"].Alignment           = StringAlignment.Center;
                        ChartRecomonedAsset.Legends["ShowRecomondedAssetAlllegendLegends"].TitleSeparator      = LegendSeparatorStyle.GradientLine;
                        ChartRecomonedAsset.Legends["ShowRecomondedAssetAlllegendLegends"].TitleSeparatorColor = Color.Black;

                        // Enable X axis margin
                        LegendCellColumn colorColumn = new LegendCellColumn();
                        colorColumn.ColumnType      = LegendCellColumnType.SeriesSymbol;
                        colorColumn.HeaderBackColor = Color.WhiteSmoke;
                        ChartRecomonedAsset.Legends["ShowRecomondedAssetAlllegendLegends"].CellColumns.Add(colorColumn);
                        ChartRecomonedAsset.Legends["ShowRecomondedAssetAlllegendLegends"].BackColor = Color.FloralWhite;
                        LegendCellColumn totalColumn = new LegendCellColumn();
                        totalColumn.Alignment = ContentAlignment.MiddleLeft;

                        totalColumn.Text            = "#VALX: #PERCENT";
                        totalColumn.Name            = "AssetsColumn";
                        totalColumn.HeaderBackColor = Color.WhiteSmoke;
                        ChartRecomonedAsset.Legends["ShowRecomondedAssetAlllegendLegends"].CellColumns.Add(totalColumn);
                        ChartRecomonedAsset.Series[0]["PieLabelStyle"] = "Disabled";

                        ChartRecomonedAsset.ChartAreas["caActualAsset"].AxisX.IsMarginVisible = true;
                        ChartRecomonedAsset.BackColor = Color.Transparent;
                        ChartRecomonedAsset.ChartAreas[0].BackColor               = Color.Transparent;
                        ChartRecomonedAsset.ChartAreas[0].Area3DStyle.Enable3D    = true;
                        ChartRecomonedAsset.ChartAreas[0].Area3DStyle.Perspective = 50;
                        tdCurrentAssetAllocation.Visible = true;
                        ChartRecomonedAsset.DataBind();
                    }
                    else
                    {
                        lblChartErrorDisplay.Visible = true;
                        ChartRecomonedAsset.Visible  = false;
                    }
                }
                else
                {
                    //GetAssetAllocation();
                    lblChartErrorDisplay.Visible = true;
                    lblChartErrorDisplay.Text    = "Model Portfolio is not set for your age!";
                    ChartRecomonedAsset.Visible  = false;
                }
            }
            else
            {
                lblChartErrorDisplay.Visible = true;
                lblChartErrorDisplay.Text    = "No Age to display chart. Please Fill Date of Birth in profile!";
                ChartRecomonedAsset.Visible  = false;
            }
        }
Esempio n. 17
0
        private void CreateChart()
        {
            Chart chart1 = new Chart();

            //Se ho impostato una palette di colori
            if (PaletteCustomColors != null)
            {
                chart1.PaletteCustomColors = PaletteCustomColors.ToArray();
                chart1.Palette             = ChartColorPalette.None;
            }
            //chart1.BorderSkin.SkinStyle = BorderSkinStyle.Sunken;


            //Titolo
            Title title1 = new Title();

            title1.Font         = new System.Drawing.Font("Tahoma", 13F, System.Drawing.FontStyle.Regular);
            title1.ForeColor    = System.Drawing.Color.FromArgb(((int)(((byte)(26)))), ((int)(((byte)(59)))), ((int)(((byte)(105)))));
            title1.Name         = "Title1";
            title1.ShadowColor  = System.Drawing.Color.FromArgb(((int)(((byte)(32)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))));
            title1.ShadowOffset = 3;
            title1.Text         = Titolo;
            chart1.Titles.Add(title1);

            ChartArea chartArea1 = new ChartArea();

            chartArea1.Area3DStyle.Enable3D    = true;
            chartArea1.Area3DStyle.Inclination = 50;

            /*chartArea1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(165)))), ((int)(((byte)(191)))), ((int)(((byte)(228)))));
             * chartArea1.BackGradientStyle = System.Windows.Forms.DataVisualization.Charting.GradientStyle.TopBottom;
             * chartArea1.BackSecondaryColor = System.Drawing.Color.Transparent;
             * chartArea1.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));*/

            chart1.ChartAreas.Add(chartArea1);

            // serie dati
            Series series1 = new Series();

            series1.Points.DataBindXY(Labels, Values);
            series1.IsValueShownAsLabel = false;
            //series1.Label = "Y = #VALY\nX = #VALX";
            series1.Label            = "#VALY";
            series1.ChartType        = SeriesChartType.Pie;
            series1["PieLabelStyle"] = "Inside";
            series1.BorderColor      = System.Drawing.Color.Goldenrod;
            series1.BorderWidth      = 1;
            series1.BorderDashStyle  = ChartDashStyle.Solid;

            Legend legend1 = new Legend();

            legend1.Alignment     = System.Drawing.StringAlignment.Center;
            legend1.BackColor     = System.Drawing.Color.Transparent;
            legend1.Docking       = System.Windows.Forms.DataVisualization.Charting.Docking.Top;
            legend1.LegendStyle   = LegendStyle.Table;
            legend1.Enabled       = true;
            legend1.Font          = new System.Drawing.Font("Trebuchet MS", 8.25F, System.Drawing.FontStyle.Bold);
            legend1.IsTextAutoFit = false;
            legend1.Name          = "Default";

            LegendCellColumn firstColumn = new LegendCellColumn();

            firstColumn.ColumnType = LegendCellColumnType.SeriesSymbol;
            //firstColumn.HeaderText = "Color";
            firstColumn.HeaderBackColor = System.Drawing.Color.WhiteSmoke;
            legend1.CellColumns.Add(firstColumn);

            LegendCellColumn secondColumn = new LegendCellColumn();

            secondColumn.ColumnType = LegendCellColumnType.Text;
            //secondColumn.HeaderText = "Name";
            secondColumn.Text            = "#VALX";
            secondColumn.HeaderBackColor = System.Drawing.Color.WhiteSmoke;
            legend1.CellColumns.Add(secondColumn);


            chart1.Legends.Add(legend1);

            // Add series to the chart
            chart1.Series.Add(series1);



            // Set chart control location
            //chart1.Location = new System.Drawing.Point(16, 48);

            // Set Chart control size
            chart1.Size             = new System.Drawing.Size(400, 300);
            windowsFormsHost1.Child = chart1;
        }
        public void GetAssetAllocation()
        {
            DataSet dsGetCustomerRiskProfile = riskprofilebo.GetCustomerRiskProfile(CustomerId, advisorVo.advisorId, 1);

            if (dsGetCustomerRiskProfile.Tables[0].Rows.Count > 0)
            {
                riskCode = dsGetCustomerRiskProfile.Tables[0].Rows[0]["XRC_RiskClassCode"].ToString();
                DataSet   dsGetAssetAllocationRules = riskprofilebo.GetAssetAllocationRules(riskCode, advisorVo.advisorId);
                DataTable dtAsset = new DataTable();
                dtAsset.Columns.Add("AssetType");
                dtAsset.Columns.Add("Percentage");
                dtAsset.Columns.Add("AssetTypeCode");
                DataRow drAsset;
                double  equityAdjustment = 0;
                double  equitycalc       = 0.0;
                double  equityPercentage = 0;
                double  debtpercentage   = 0;
                double  cashPercentage   = 0;
                if (dsGetAssetAllocationRules != null && dsGetAssetAllocationRules.Tables[0].Rows[0]["A_AdviserId"].ToString() != advisorVo.advisorId.ToString())
                {
                    foreach (DataRow dr in dsGetAssetAllocationRules.Tables[0].Rows)
                    {
                        if (dr["WAC_AssetClassification"].ToString() == "Cash")
                        {
                            cashPercentage = double.Parse(dr["WAAR_AssetAllocationPercenatge"].ToString());
                        }
                        else if (dr["WAC_AssetClassification"].ToString() == "Equity")
                        {
                            if (dr["WAAR_Adjustment"].ToString() != "")
                            {
                                equityAdjustment = double.Parse(dr["WAAR_Adjustment"].ToString());
                            }
                        }
                    }
                    equitycalc       = double.Parse(((100 - double.Parse(age.ToString())) / 100).ToString());
                    equityPercentage = (((100 - cashPercentage) * equitycalc + (equityAdjustment)));
                    debtpercentage   = (100 - equityPercentage - cashPercentage);
                    drAsset          = dtAsset.NewRow();
                    drAsset[0]       = "Equity";
                    drAsset[1]       = equityPercentage.ToString();
                    drAsset[2]       = 1;
                    dtAsset.Rows.Add(drAsset);
                    drAsset    = dtAsset.NewRow();
                    drAsset[0] = "Debt";
                    drAsset[1] = debtpercentage.ToString();
                    drAsset[2] = 2;
                    dtAsset.Rows.Add(drAsset);
                    drAsset    = dtAsset.NewRow();
                    drAsset[0] = "Cash";
                    drAsset[1] = cashPercentage.ToString();
                    drAsset[2] = 3;
                    dtAsset.Rows.Add(drAsset);
                }
                else
                {
                    foreach (DataRow dr in dsGetAssetAllocationRules.Tables[0].Rows)
                    {
                        drAsset    = dtAsset.NewRow();
                        drAsset[0] = dr["WAC_AssetClassification"].ToString();
                        if (dr["WAAR_AssetAllocationPercenatge"] != null)
                        {
                            drAsset[1] = dr["WAAR_AssetAllocationPercenatge"].ToString();
                        }
                        else
                        {
                            drAsset[1] = 0;
                        }
                        drAsset[2] = dr["WAC_AssetClassificationCode"].ToString();
                        dtAsset.Rows.Add(drAsset);
                    }
                }
                dtRecommendedAllocation = dtAsset;

                if ((dtAsset.Rows.Count > 0) && (dtAsset.ToString() != null))
                {
                    lblCurrChartErrorDisplay.Visible = false;
                    /* For Chart binding */
                    Legend ShowRecomondedAssetAlllegend = null;
                    ShowRecomondedAssetAlllegend         = new Legend("ShowRecomondedAssetAlllegendLegends");
                    ShowRecomondedAssetAlllegend.Enabled = true;
                    Series seriesAssets = new Series("RecomondedAsset");
                    seriesAssets.ChartType      = SeriesChartType.Pie;
                    ChartRecomonedAsset.Visible = true;
                    ChartRecomonedAsset.Series.Clear();
                    ChartRecomonedAsset.Series.Add(seriesAssets);
                    ChartRecomonedAsset.DataSource              = dtAsset;
                    ChartRecomonedAsset.Series[0].XValueMember  = "AssetType";
                    ChartRecomonedAsset.Series[0].YValueMembers = "Percentage";
                    ChartRecomonedAsset.Series[0].ToolTip       = "#VALX: #PERCENT";
                    ChartRecomonedAsset.Legends.Add(ShowRecomondedAssetAlllegend);
                    ChartRecomonedAsset.Legends["ShowRecomondedAssetAlllegendLegends"].Title               = "Assets";
                    ChartRecomonedAsset.Legends["ShowRecomondedAssetAlllegendLegends"].TitleAlignment      = StringAlignment.Center;
                    ChartRecomonedAsset.Legends["ShowRecomondedAssetAlllegendLegends"].TitleSeparator      = LegendSeparatorStyle.None;
                    ChartRecomonedAsset.Legends["ShowRecomondedAssetAlllegendLegends"].Alignment           = StringAlignment.Center;
                    ChartRecomonedAsset.Legends["ShowRecomondedAssetAlllegendLegends"].TitleSeparator      = LegendSeparatorStyle.GradientLine;
                    ChartRecomonedAsset.Legends["ShowRecomondedAssetAlllegendLegends"].TitleSeparatorColor = Color.Black;

                    // Enable X axis margin
                    LegendCellColumn colorColumn = new LegendCellColumn();
                    colorColumn.ColumnType      = LegendCellColumnType.SeriesSymbol;
                    colorColumn.HeaderBackColor = Color.WhiteSmoke;
                    ChartRecomonedAsset.Legends["ShowRecomondedAssetAlllegendLegends"].CellColumns.Add(colorColumn);
                    ChartRecomonedAsset.Legends["ShowRecomondedAssetAlllegendLegends"].BackColor = Color.FloralWhite;
                    LegendCellColumn totalColumn = new LegendCellColumn();
                    totalColumn.Alignment       = ContentAlignment.MiddleLeft;
                    totalColumn.Text            = "#VALX: #PERCENT";
                    totalColumn.Name            = "AssetsColumn";
                    totalColumn.HeaderBackColor = Color.WhiteSmoke;
                    ChartRecomonedAsset.Legends["ShowRecomondedAssetAlllegendLegends"].CellColumns.Add(totalColumn);
                    ChartRecomonedAsset.Series[0]["PieLabelStyle"] = "Disabled";
                    ChartRecomonedAsset.ChartAreas["caActualAsset"].AxisX.IsMarginVisible = true;
                    ChartRecomonedAsset.BackColor = Color.Transparent;
                    ChartRecomonedAsset.ChartAreas[0].BackColor               = Color.Transparent;
                    ChartRecomonedAsset.ChartAreas[0].Area3DStyle.Enable3D    = true;
                    ChartRecomonedAsset.ChartAreas[0].Area3DStyle.Perspective = 50;
                    tdCurrentAssetAllocation.Visible = true;
                    ChartRecomonedAsset.DataBind();
                }
                else
                {
                    lblChartErrorDisplay.Visible = true;
                    ChartRecomonedAsset.Visible  = false;
                }
            }
            else
            {
                lblChartErrorDisplay.Visible = true;
                ChartRecomonedAsset.Visible  = false;
            }
        }
Esempio n. 19
0
        public void BindAssetCurrentValChart()
        {
            Series seriesAssets = null;
            Legend legend       = null;
            int    i            = 0;

            string[] XValues = null;
            double[] YValues = null;
            try
            {
                // Total Assets Chart
                seriesAssets   = new Series("Assets");
                legend         = new Legend("AssetsLegend");
                legend.Enabled = true;
                XValues        = new string[dsAssetAggrCurrentValues.Tables[0].Rows.Count];
                YValues        = new double[dsAssetAggrCurrentValues.Tables[0].Rows.Count];

                seriesAssets.ChartType = SeriesChartType.Pie;


                foreach (DataRow dr in dsAssetAggrCurrentValues.Tables[0].Rows)
                {
                    XValues[i] = dr["AssetType"].ToString();
                    YValues[i] = double.Parse(dr["AggrCurrentValue"].ToString());
                    i++;
                }
                seriesAssets.Points.DataBindXY(XValues, YValues);
                //Chart1.DataSource = dsAssetAggrCurrentValues.Tables[0].DefaultView;
                Chart1.Series.Clear();
                Chart1.Series.Add(seriesAssets);

                //Chart1.Series[0].XValueMember = "AssetType";
                //Chart1.Series[0].YValueMembers = "AggrCurrentValue";
                Chart1.Legends.Add(legend);

                Chart1.Series[0]["CollectedSliceExploded"]         = "true";
                Chart1.Legends["AssetsLegend"].Title               = "Assets";
                Chart1.Legends["AssetsLegend"].TitleAlignment      = StringAlignment.Center;
                Chart1.Legends["AssetsLegend"].TitleSeparator      = LegendSeparatorStyle.DoubleLine;
                Chart1.Legends["AssetsLegend"].TitleSeparatorColor = Color.Black;
                //Chart1.Legends["AssetsLegend"].BackColor = Color.Transparent;
                Chart1.Series[0].IsValueShownAsLabel         = false;
                Chart1.Series[0]["PieLabelStyle"]            = "Disabled";
                Chart1.ChartAreas[0].Area3DStyle.Enable3D    = true;
                Chart1.ChartAreas[0].Area3DStyle.Perspective = 50;
                Chart1.Series[0].ToolTip = "#VALX: #PERCENT";
                //Chart1.Series[0].Label = "#PERCENT";
                //Chart1.Series[0]["CollectedLegendText"] = "Other";
                Chart1.BackColor = Color.Transparent;
                Chart1.ChartAreas[0].BackColor = Color.Transparent;

                LegendCellColumn colorColumn = new LegendCellColumn();
                colorColumn.ColumnType      = LegendCellColumnType.SeriesSymbol;
                colorColumn.HeaderText      = "Color";
                colorColumn.HeaderBackColor = Color.WhiteSmoke;
                Chart1.Legends["AssetsLegend"].CellColumns.Add(colorColumn);

                LegendCellColumn asset = new LegendCellColumn();
                asset.ColumnType      = LegendCellColumnType.Text;
                asset.HeaderText      = "Asset";
                asset.Alignment       = ContentAlignment.TopLeft;
                asset.Text            = "#VALX";
                asset.HeaderBackColor = Color.WhiteSmoke;
                Chart1.Legends["AssetsLegend"].CellColumns.Add(asset);


                LegendCellColumn assetPercent = new LegendCellColumn();
                assetPercent.Alignment       = ContentAlignment.MiddleLeft;
                assetPercent.Text            = "#PERCENT";
                assetPercent.HeaderText      = "% Of Assets";
                assetPercent.Name            = "PerformanceColumn";
                assetPercent.HeaderBackColor = Color.WhiteSmoke;
                Chart1.Legends["AssetsLegend"].CellColumns.Add(assetPercent);


                foreach (DataPoint point in Chart1.Series[0].Points)
                {
                    point["Exploded"] = "true";
                }

                Chart1.DataBind();
            }
            catch (BaseApplicationException Ex)
            {
                throw Ex;
            }

            catch (Exception Ex)
            {
                BaseApplicationException exBase       = new BaseApplicationException(Ex.Message, Ex);
                NameValueCollection      FunctionInfo = new NameValueCollection();
                FunctionInfo.Add("Method", "AdvisorRMCustIndiDashboard.ascx:BindAssetCurrentValChart()");
                object[] objects = new object[4];
                objects[0]   = portfolioId;
                objects[1]   = dsAssetAggrCurrentValues;
                objects[2]   = XValues;
                objects[3]   = YValues;
                FunctionInfo = exBase.AddObject(FunctionInfo, objects);
                exBase.AdditionalInformation = FunctionInfo;
                ExceptionManager.Publish(exBase);
                throw exBase;
            }
        }
    protected void FillForm()
    {
        try
        {
            if (!CheckIsValidStartEndDates())
                return;

            SeriesChartType chartType = SeriesChartType.StackedBar;
            if (ddlChartType.SelectedValue == "Pie")
                chartType = SeriesChartType.Pie;
            if (ddlChartType.SelectedValue == "Doughnut")
                chartType = SeriesChartType.Doughnut;
            if (ddlChartType.SelectedValue == "StackedBar")
                chartType = SeriesChartType.StackedBar;
            if (ddlChartType.SelectedValue == "Area")
                chartType = SeriesChartType.Area;
            if (ddlChartType.SelectedValue == "BoxPlot")
                chartType = SeriesChartType.BoxPlot;
            if (ddlChartType.SelectedValue == "Column")
                chartType = SeriesChartType.Column;
            if (ddlChartType.SelectedValue == "Line")
                chartType = SeriesChartType.Line;
            if (ddlChartType.SelectedValue == "Point")
                chartType = SeriesChartType.Point;
            if (ddlChartType.SelectedValue == "Range")
                chartType = SeriesChartType.Range;
            if (ddlChartType.SelectedValue == "RangeBar")
                chartType = SeriesChartType.RangeBar;
            if (ddlChartType.SelectedValue == "RangeColumn")
                chartType = SeriesChartType.RangeColumn;

            chartStaffStats.Series["Series1"].ChartType = chartType;

            DataTable tblStats = StaffDB.GetStats2(GetFromDate(), GetToDate(), chkIncDeleted.Checked, chkIncDeleted.Checked);

            int maxToShow = 350;
            if (tblStats.Rows.Count > maxToShow)
                for (int i = tblStats.Rows.Count - 1; i >= maxToShow; i--)
                    tblStats.Rows.RemoveAt(i);

            tblStats.Columns.Add("fullname", typeof(string));
            for (int i = 0; i < tblStats.Rows.Count; i++)
            {
                tblStats.Rows[i]["fullname"] = tblStats.Rows[i]["firstname"] + " " + tblStats.Rows[i]["surname"] +
                (tblStats.Rows[i]["staff_id"]    == DBNull.Value || (int)tblStats.Rows[i]["staff_id"] < 0  || (!(bool)tblStats.Rows[i]["is_stakeholder"] && !(bool)tblStats.Rows[i]["is_master_admin"] && !(bool)tblStats.Rows[i]["is_admin"])  ? "" : " (Admin) ") +
                (tblStats.Rows[i]["staff_id"]    == DBNull.Value || (int)tblStats.Rows[i]["staff_id"] < 0  ||  !(bool)tblStats.Rows[i]["is_provider"]  ? "" : " (Provider) ") +
                (tblStats.Rows[i]["is_external"] == DBNull.Value || tblStats.Rows[i]["staff_id"] == DBNull.Value || !((bool)tblStats.Rows[i]["is_external"]) || (int)tblStats.Rows[i]["staff_id"] < 0 ? "" : " (External) ");
            }

            DataView dv = tblStats.DefaultView;

            string field = string.Empty;
            if (ddlType.SelectedValue == "Total Bookings")
                field = "total_bookings";
            if (ddlType.SelectedValue == "New Bookings Added By")
                field = "n_bookings";
            if (ddlType.SelectedValue == "New Patients")
                field = "n_patients";
            if (ddlType.SelectedValue == "Completions")
                field = "n_completions";
            if (ddlType.SelectedValue == "Invoice Total")
                field = "sum_inv_total";
            if (ddlType.SelectedValue == "Receipts")
                field = "sum_receipts";

            dv.Sort = field;

            chartStaffStats.Titles[0].Text = ddlType.SelectedValue;
            chartStaffStats.Series["Series1"].Points.DataBindXY(dv, "fullname", dv, field);

            lblChartHeading.Text = ddlType.SelectedValue;

            if (chartType == SeriesChartType.StackedBar)
                chartStaffStats.Height = new Unit((tblStats.Rows.Count * 30), UnitType.Pixel);

            chartStaffStats.ChartAreas["ChartArea1"].AxisX.MinorTickMark.Enabled = false;
            chartStaffStats.ChartAreas["ChartArea1"].AxisX.Interval = 1;
            chartStaffStats.ChartAreas["ChartArea1"].AxisX.IsLabelAutoFit = true;
            //chartStaffStats.ChartAreas["ChartArea1").AxisX.LabelStyle.IsStaggered = True
            //chartStaffStats.ChartAreas["ChartArea1"].AxisX.LabelAutoFitStyle = System.Web.UI.DataVisualization.Charting.LabelAutoFitStyles.DecreaseFont;

            chartStaffStats.ChartAreas["ChartArea1"].AxisY.Enabled = System.Web.UI.DataVisualization.Charting.AxisEnabled.False;

            if (chartType == SeriesChartType.Pie || chartType == SeriesChartType.Doughnut)
            {
                chartStaffStats.Legends.Add("Legend1");
                chartStaffStats.Legends["Legend1"].Enabled = true;
                chartStaffStats.Legends["Legend1"].Docking = System.Web.UI.DataVisualization.Charting.Docking.Right;
                chartStaffStats.Legends["Legend1"].LegendItemOrder = System.Web.UI.DataVisualization.Charting.LegendItemOrder.SameAsSeriesOrder;
                chartStaffStats.Legends["Legend1"].Font = new Font("Trebuchet MS", 10);

                // Add Color column
                LegendCellColumn firstColumn = new LegendCellColumn();
                firstColumn.ColumnType = LegendCellColumnType.SeriesSymbol;
                chartStaffStats.Legends["Legend1"].CellColumns.Add(firstColumn);

                // Add name cell column
                LegendCellColumn textColumn = new LegendCellColumn();
                textColumn.Alignment = System.Drawing.ContentAlignment.MiddleLeft;
                textColumn.Text = "#LEGENDTEXT";
                textColumn.Name = "nameColumn";
                chartStaffStats.Legends["Legend1"].CellColumns.Add(textColumn);

                // Add value cell column
                LegendCellColumn valColumn = new LegendCellColumn();
                valColumn.Text = "#VAL";
                valColumn.Name = "totalColumn";
                chartStaffStats.Legends["Legend1"].CellColumns.Add(valColumn);

                // Add percent cell column
                LegendCellColumn percentColumn = new LegendCellColumn();
                percentColumn.Text = "#PERCENT";
                percentColumn.Name = "percentColumn";
                chartStaffStats.Legends["Legend1"].CellColumns.Add(percentColumn);
            }
        }
        catch (CustomMessageException cmEx)
        {
            HideTableAndSetErrorMessage(cmEx.Message);
        }
        catch (Exception ex)
        {
            HideTableAndSetErrorMessage(ex.ToString());
        }
    }
Esempio n. 21
0
        public void GetPie(Chart ch3DPie, Label lbl3DPie, Page sida)
        {
            OrderedDictionary dictPieSlizes = new OrderedDictionary();
            int rowcount = 0;

            try
            {
                dictPieSlizes = db.GetWholePie();
                rowcount      = dictPieSlizes.Count;
            }
            finally
            { }


            //Value- och key-kollektioner initieras mha Interface:
            ICollection keyKollektion   = dictPieSlizes.Keys;
            ICollection valueKollektion = dictPieSlizes.Values;

            //Skapar arrays och kopierar kollektionerna till desamma:
            String[] keys   = new String[rowcount];
            int[]    values = new int[rowcount];
            keyKollektion.CopyTo(keys, 0);
            valueKollektion.CopyTo(values, 0);


            if (rowcount > 0)
            {
                //Fyller pajen:
                for (int i = 0; i < rowcount; i++)
                {
                    ch3DPie.Series["Series1"].Points.AddXY(keys[i], values[i]);
                }


                //Div inställningar för pajen:
                ch3DPie.Series["Series1"].ChartType = SeriesChartType.Pie;    // Set the Pie width

                ch3DPie.Series["Series1"]["PointWidth"] = "0.5";              //Ange punktbredd

                ch3DPie.Series["Series1"].IsValueShownAsLabel = true;         //Visa datapunkter som labels

                ch3DPie.Series["Series1"]["BarLabelStyle"] = "Center";        //Sätt datapunkter label style

                ch3DPie.ChartAreas["ChartArea1"].Area3DStyle.Enable3D = true; //Visa paj som 3D

                ch3DPie.Series["Series1"]["DrawingStyle"] = "Cylinder";       //Rita ut paj som 3D

                ch3DPie.Series["Series1"].Font = new Font("Times New Roman", 8, FontStyle.Bold);

                ch3DPie.Series["Series1"].Label = "#VALY";                                      //Värden som anges på paj:

                ch3DPie.Series["Series1"].LabelForeColor = ColorTranslator.FromHtml("#F7F7F7"); //Sätta label-färg


                //Addera kolumn med färgsymboler:
                LegendCellColumn firstColumn = new LegendCellColumn();
                firstColumn.ColumnType      = LegendCellColumnType.SeriesSymbol;
                firstColumn.HeaderText      = "Färg";
                firstColumn.HeaderBackColor = ColorTranslator.FromHtml("#D8D8D8");
                firstColumn.HeaderFont      = new Font("Times New Roman", 8, FontStyle.Bold);
                ch3DPie.Legends["Musiktyp"].CellColumns.Add(firstColumn);

                // Addera textkolumn med musiktyper som ingår i piechart:
                LegendCellColumn secondColumn = new LegendCellColumn();
                secondColumn.ColumnType      = LegendCellColumnType.Text;
                secondColumn.Font            = new Font("Times New Roman", 8, FontStyle.Regular);
                secondColumn.HeaderText      = "Musiktyp";
                secondColumn.Alignment       = ContentAlignment.BottomLeft;
                secondColumn.HeaderFont      = new Font("Times New Roman", 8, FontStyle.Bold);
                secondColumn.Text            = "#VALX";
                secondColumn.HeaderBackColor = ColorTranslator.FromHtml("#D8D8D8");
                ch3DPie.Legends["Musiktyp"].CellColumns.Add(secondColumn);
            }
        }
Esempio n. 22
0
        /// <summary>
        /// 添加说明
        /// </summary>
        /// <param name="chart"></param>
        private void AddLengend(Chart chart)
        {
            var legend = chart.Legends.Add("Legend");
            legend.BackColor = Color.FromArgb(211, 223, 240);
            legend.Docking = Docking.Bottom;
            legend.Alignment = StringAlignment.Center;

            // Add Color column
            LegendCellColumn firstColumn = new LegendCellColumn();
            firstColumn.ColumnType = LegendCellColumnType.SeriesSymbol;
            firstColumn.HeaderText = "Color";
            legend.CellColumns.Add(firstColumn);

            // Add Legend Text column
            LegendCellColumn secondColumn = new LegendCellColumn();
            secondColumn.ColumnType = LegendCellColumnType.Text;
            secondColumn.HeaderText = "Name";
            secondColumn.Text = "#LEGENDTEXT";
            legend.CellColumns.Add(secondColumn);

            // Add AVG cell column
            LegendCellColumn avgColumn = new LegendCellColumn();
            avgColumn.Text = "#AVG{N2}";
            avgColumn.HeaderText = "Avg";
            avgColumn.Name = "AvgColumn";
            legend.CellColumns.Add(avgColumn);

            // Set Min cell column attributes
            LegendCellColumn minColumn = new LegendCellColumn();
            minColumn.Text = "#MAX{N1}";
            minColumn.HeaderText = "Max";
            minColumn.Name = "MAXColumn";
            legend.CellColumns.Add(minColumn);
        }
    protected void FillForm()
    {
        try
        {
            if (!CheckIsValidStartEndDates())
                return;

            SeriesChartType chartType = SeriesChartType.StackedBar;
            if (ddlChartType.SelectedValue == "Pie")
                chartType = SeriesChartType.Pie;
            if (ddlChartType.SelectedValue == "Doughnut")
                chartType = SeriesChartType.Doughnut;
            if (ddlChartType.SelectedValue == "StackedBar")
                chartType = SeriesChartType.StackedBar;
            if (ddlChartType.SelectedValue == "Area")
                chartType = SeriesChartType.Area;
            if (ddlChartType.SelectedValue == "BoxPlot")
                chartType = SeriesChartType.BoxPlot;
            if (ddlChartType.SelectedValue == "Column")
                chartType = SeriesChartType.Column;
            if (ddlChartType.SelectedValue == "Line")
                chartType = SeriesChartType.Line;
            if (ddlChartType.SelectedValue == "Point")
                chartType = SeriesChartType.Point;
            if (ddlChartType.SelectedValue == "Range")
                chartType = SeriesChartType.Range;
            if (ddlChartType.SelectedValue == "RangeBar")
                chartType = SeriesChartType.RangeBar;
            if (ddlChartType.SelectedValue == "RangeColumn")
                chartType = SeriesChartType.RangeColumn;

            chartOrgStats.Series["Series1"].ChartType = chartType;

            DataTable tblStats = OrganisationDB.GetStats(GetFromDate(), GetToDate(), UserView.GetInstance().IsClinicView ? 5 : 6, chkIncDeleted.Checked);

            int maxToShow = 350;
            if (tblStats.Rows.Count > maxToShow)
                for (int i = tblStats.Rows.Count - 1; i >= maxToShow; i--)
                    tblStats.Rows.RemoveAt(i);

            DataView dv = tblStats.DefaultView;

            string field = string.Empty;
            if (ddlType.SelectedValue == "New Bookings Added By")
                field = "n_bookings";
            if (ddlType.SelectedValue == "New Patients")
                field = "n_patients";
            if (ddlType.SelectedValue == "Total Bookings")
                field = "total_bookings";

            dv.Sort = field;

            chartOrgStats.Titles[0].Text = ddlType.SelectedValue;
            chartOrgStats.Series["Series1"].Points.DataBindXY(dv, "name", dv, field);

            lblChartHeading.Text = ddlType.SelectedValue;

            if (chartType == SeriesChartType.StackedBar)
                chartOrgStats.Height = new Unit((tblStats.Rows.Count * 30), UnitType.Pixel);

            chartOrgStats.ChartAreas["ChartArea1"].AxisX.MinorTickMark.Enabled = false;
            chartOrgStats.ChartAreas["ChartArea1"].AxisX.Interval = 1;
            chartOrgStats.ChartAreas["ChartArea1"].AxisX.IsLabelAutoFit = true;
            //chartOrgStats.ChartAreas["ChartArea1").AxisX.LabelStyle.IsStaggered = True
            //chartOrgStats.ChartAreas["ChartArea1"].AxisX.LabelAutoFitStyle = System.Web.UI.DataVisualization.Charting.LabelAutoFitStyles.DecreaseFont;

            chartOrgStats.ChartAreas["ChartArea1"].AxisY.Enabled = System.Web.UI.DataVisualization.Charting.AxisEnabled.False;

            if (chartType == SeriesChartType.Pie || chartType == SeriesChartType.Doughnut)
            {
                chartOrgStats.Legends.Add("Legend1");
                chartOrgStats.Legends["Legend1"].Enabled = true;
                chartOrgStats.Legends["Legend1"].Docking = System.Web.UI.DataVisualization.Charting.Docking.Right;
                chartOrgStats.Legends["Legend1"].LegendItemOrder = System.Web.UI.DataVisualization.Charting.LegendItemOrder.SameAsSeriesOrder;
                chartOrgStats.Legends["Legend1"].Font = new Font("Trebuchet MS", 10);

                // Add Color column
                LegendCellColumn firstColumn = new LegendCellColumn();
                firstColumn.ColumnType = LegendCellColumnType.SeriesSymbol;
                chartOrgStats.Legends["Legend1"].CellColumns.Add(firstColumn);

                // Add name cell column
                LegendCellColumn textColumn = new LegendCellColumn();
                textColumn.Alignment = System.Drawing.ContentAlignment.MiddleLeft;
                textColumn.Text = "#LEGENDTEXT";
                textColumn.Name = "nameColumn";
                chartOrgStats.Legends["Legend1"].CellColumns.Add(textColumn);

                // Add value cell column
                LegendCellColumn valColumn = new LegendCellColumn();
                valColumn.Text = "#VAL";
                valColumn.Name = "totalColumn";
                chartOrgStats.Legends["Legend1"].CellColumns.Add(valColumn);

                // Add percent cell column
                LegendCellColumn percentColumn = new LegendCellColumn();
                percentColumn.Text = "#PERCENT";
                percentColumn.Name = "percentColumn";
                chartOrgStats.Legends["Legend1"].CellColumns.Add(percentColumn);
            }
        }
        catch (CustomMessageException cmEx)
        {
            HideTableAndSetErrorMessage(cmEx.Message);
        }
        catch (Exception ex)
        {
            HideTableAndSetErrorMessage(ex.ToString());
        }
    }
Esempio n. 24
0
        private void UpdateLegendCellColumns()
        {
            // Add first cell column
            LegendCellColumn firstColumn = new LegendCellColumn();
            firstColumn.ColumnType = LegendCellColumnType.SeriesSymbol;
            firstColumn.HeaderText = "Color";
            firstColumn.HeaderBackColor = Color.WhiteSmoke;
            this.Chart1.Legends["Default"].CellColumns.Add(firstColumn);

            // Add second cell column
            LegendCellColumn secondColumn = new LegendCellColumn();
            secondColumn.ColumnType = LegendCellColumnType.Text;
            secondColumn.HeaderText = "Name";
            secondColumn.Text = "#LEGENDTEXT";
            secondColumn.HeaderBackColor = Color.WhiteSmoke;
            this.Chart1.Legends["Default"].CellColumns.Add(secondColumn);

            // Add header separator of type line
            this.Chart1.Legends["Default"].HeaderSeparator = LegendSeparatorStyle.Line;
            this.Chart1.Legends["Default"].HeaderSeparatorColor = Color.FromArgb(64,64,64,64);

            // Add item column separator of type line
            this.Chart1.Legends["Default"].ItemColumnSeparator = LegendSeparatorStyle.Line;
            this.Chart1.Legends["Default"].ItemColumnSeparatorColor = Color.FromArgb(64,64,64,64);

            // Set AVG cell column attributes
            LegendCellColumn avgColumn = new LegendCellColumn();
            avgColumn.Text = "#AVG{N2}";
            avgColumn.HeaderText = "Avg";
            avgColumn.Name = "AvgColumn";
            avgColumn.HeaderBackColor = Color.WhiteSmoke;

            // Set Total cell column attributes
            LegendCellColumn totalColumn = new LegendCellColumn();
            totalColumn.Text = "#TOTAL{N1}";
            totalColumn.HeaderText = "Total";
            totalColumn.Name = "TotalColumn";
            totalColumn.HeaderBackColor = Color.WhiteSmoke;

            // Set Min cell column attributes
            LegendCellColumn minColumn = new LegendCellColumn();
            minColumn.Text = "#MIN{N1}";
            minColumn.HeaderText = "Min";
            minColumn.Name = "MinColumn";
            minColumn.HeaderBackColor = Color.WhiteSmoke;

            if (this.chk_ShowAvg.Checked)
            {
                this.Chart1.Legends["Default"].CellColumns.Add(avgColumn);
            }

            else
            {
                LegendCellColumn cellColumn = this.Chart1.Legends["Default"].CellColumns.FindByName("AvgColumn");
                this.Chart1.Legends["Default"].CellColumns.Remove(cellColumn);
            }

            if (this.chk_ShowTotal.Checked)
            {
                this.Chart1.Legends["Default"].CellColumns.Add(totalColumn);
            }

            else
            {
                LegendCellColumn cellColumn = this.Chart1.Legends["Default"].CellColumns.FindByName("TotalColumn");
                this.Chart1.Legends["Default"].CellColumns.Remove(cellColumn);
            }

            if (this.chk_ShowMin.Checked)
            {
                this.Chart1.Legends["Default"].CellColumns.Add(minColumn);
            }

            else
            {
                LegendCellColumn columnToRemove = this.Chart1.Legends["Default"].CellColumns.FindByName("MinColumn");
                this.Chart1.Legends["Default"].CellColumns.Remove(columnToRemove);
            }
        }
Esempio n. 25
0
        //取得未來七日來測人數
        private void Get_chart_7DayPlayerCount()
        {
            DataUtility du = new DataUtility();
            DataTable   dt = new DataTable();

            dt = du.getDataTableByText("select top 7 * from Count7day where date>=convert(varchar, getdate(), 111) order by date");
            if (dt.Rows.Count > 0)
            {
                string[] xValues = new string[dt.Rows.Count];
                int[]    yValues = new int[dt.Rows.Count];
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    xValues[i] = Convert.ToDateTime(dt.Rows[i]["date"]).ToString("MM/dd");
                    yValues[i] = Convert.ToInt16(dt.Rows[i]["count"].ToString());
                }
                //string[] xValues = { "11/01", "11/02", "11/03", "11/04", "11/05", "11/06", "11/07", };
                //int[] yValues = { 100, 94, 150, 120, 95, 88, 131 };
                string[] titleArr = { "人數" };

                //2018-2-26新版
                chart_7DayPlayerCount.ChartAreas.Add("ChartAreas1"); //建立圖表區塊
                chart_7DayPlayerCount.Series.Add("Series1");         //建立圖表
                chart_7DayPlayerCount.Legends.Add("Legends1");       //建立圖例

                //設定XY軸名稱顯示
                chart_7DayPlayerCount.ChartAreas["ChartAreas1"].AxisX.Title             = "日期";
                chart_7DayPlayerCount.ChartAreas["ChartAreas1"].AxisY.Title             = "人數";
                chart_7DayPlayerCount.ChartAreas["ChartAreas1"].AxisY.TextOrientation   = TextOrientation.Horizontal;//將文字變橫向顯示
                chart_7DayPlayerCount.ChartAreas["ChartAreas1"].AxisX.TitleForeColor    = Color.Red;
                chart_7DayPlayerCount.ChartAreas["ChartAreas1"].AxisY.TitleForeColor    = Color.Blue;
                chart_7DayPlayerCount.ChartAreas["ChartAreas1"].AxisX.TitleFont         = new Font("微軟正黑體", 20, FontStyle.Bold);
                chart_7DayPlayerCount.ChartAreas["ChartAreas1"].AxisY.TitleFont         = new Font("微軟正黑體", 20, FontStyle.Bold);
                chart_7DayPlayerCount.ChartAreas["ChartAreas1"].AxisX.LabelStyle.Font   = new Font("微軟正黑體", 14, FontStyle.Bold);
                chart_7DayPlayerCount.ChartAreas["ChartAreas1"].AxisY.LabelStyle.Font   = new Font("微軟正黑體", 20, FontStyle.Bold);
                chart_7DayPlayerCount.ChartAreas["ChartAreas1"].AxisX.IsLabelAutoFit    = true;                               //X軸名稱顯示可自動調整
                chart_7DayPlayerCount.ChartAreas["ChartAreas1"].AxisX.LabelAutoFitStyle = LabelAutoFitStyles.StaggeredLabels; //調整方式為上下排列

                chart_7DayPlayerCount.Legends["Legends1"].Font      = new Font("微軟正黑體", 16, FontStyle.Bold);
                chart_7DayPlayerCount.Legends["Legends1"].BackColor = Color.Transparent;
                chart_7DayPlayerCount.Legends["Legends1"].TitleFont = new Font("微軟正黑體", 12, FontStyle.Bold);
                chart_7DayPlayerCount.Legends["Legends1"].Alignment = StringAlignment.Center; //圖例距離圖形(置中)
                chart_7DayPlayerCount.Legends["Legends1"].Docking   = Docking.Bottom;         //圖例在下面
                //chart_7DayPlayerCount.Legends["Legends1"].BackColor = Color.Green;

                //測試畫外框中
                chart_7DayPlayerCount.Legends["Legends1"].TableStyle           = LegendTableStyle.Wide;
                chart_7DayPlayerCount.Legends["Legends1"].LegendStyle          = LegendStyle.Table;
                chart_7DayPlayerCount.Legends["Legends1"].BorderColor          = Color.Blue;
                chart_7DayPlayerCount.Legends["Legends1"].BorderDashStyle      = ChartDashStyle.Solid;
                chart_7DayPlayerCount.Legends["Legends1"].BorderWidth          = 3;
                chart_7DayPlayerCount.Legends["Legends1"].HeaderSeparator      = LegendSeparatorStyle.Line;
                chart_7DayPlayerCount.Legends["Legends1"].HeaderSeparatorColor = Color.Gray;


                //加入下方圖例
                //LegendCellColumn firstColumn = new LegendCellColumn();
                //firstColumn.ColumnType = LegendCellColumnType.SeriesSymbol;
                //firstColumn.HeaderText = "Color";
                //firstColumn.HeaderBackColor = Color.WhiteSmoke;
                //chart_7DayPlayerCount.Legends["Legends1"].CellColumns.Add(firstColumn);

                //加入表格資料內容//需寫成一個函式用迴圈執行
                //表格欄位名稱
                LegendCellColumn title_Column = new LegendCellColumn();
                title_Column.Text            = "人數";
                title_Column.HeaderText      = "日期";
                title_Column.Name            = "date_Column";
                title_Column.HeaderFont      = new Font("微軟正黑體", 16, FontStyle.Bold);
                title_Column.HeaderBackColor = Color.WhiteSmoke;
                chart_7DayPlayerCount.Legends["Legends1"].CellColumns.Add(title_Column);

                //使用函式執行插入欄位資料
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    insert_Legends_Date(chart_7DayPlayerCount, Convert.ToDateTime(dt.Rows[i]["date"]).ToString("MM/dd"), dt.Rows[i]["count"].ToString());
                }

                chart_7DayPlayerCount.Series["Series1"].ChartType           = SeriesChartType.Line; //折線圖
                chart_7DayPlayerCount.Series["Series1"].BorderWidth         = 6;                    //線的寬度
                chart_7DayPlayerCount.Series["Series1"].Font                = new Font("微軟正黑體", 20, FontStyle.Bold);
                chart_7DayPlayerCount.Series["Series1"].LegendText          = "人數";
                chart_7DayPlayerCount.Series["Series1"].IsValueShownAsLabel = true;
                chart_7DayPlayerCount.Series["Series1"].Points.DataBindXY(xValues, yValues);
            }
        }
        public void ProcessRequest(HttpContext context)
        {
            string yearString = context.Request["year"];
            int    year       = -1;

            if (yearString != null && int.TryParse(yearString, out year))
            {
                eisEntities ctx    = new eisEntities();
                var         usages = from type in ctx.employeerelatedbudgetusages
                                     where type.Year == year
                                     select type;
                var usageList = usages.ToList();

                List <string>  xValues = new List <string>();
                List <decimal> yValues = new List <decimal>();

                DateTime lastUpdated = DateTime.MinValue;
                decimal  sum         = 0;
                foreach (var usage in usageList)
                {
                    xValues.Add(usage.employeerelatedbudgettype.TypeName);
                    yValues.Add(usage.Amount);
                    sum += usage.Amount;
                    if (usage.LastUpdated > lastUpdated)
                    {
                        lastUpdated = usage.LastUpdated;
                    }
                }
                PieChart chart = new PieChart(xValues.ToArray());
                chart.SetLastUpdated(lastUpdated);
                chart.SetSummary("รวม " + sum.ToString("#,##0") + " ล้านบาท");
                chart.AddSeries("เบิกจ่าย (ล้านบาท)", yValues.ToArray());

                Series series = chart.GetSeries("เบิกจ่าย (ล้านบาท)");
                series.Label = "#VALY{N0}";

                Legend legend = chart.GetLegendBox();
                legend.Position.Auto   = false;
                legend.Position.X      = 0;
                legend.Position.Y      = 10;
                legend.Position.Width  = 100;
                legend.Position.Height = 20;

                // Add Color column
                LegendCellColumn firstColumn = new LegendCellColumn();
                firstColumn.ColumnType = LegendCellColumnType.SeriesSymbol;
                firstColumn.HeaderText = "";
                legend.CellColumns.Add(firstColumn);

                // Add Legend Text column
                LegendCellColumn secondColumn = new LegendCellColumn();
                secondColumn.ColumnType = LegendCellColumnType.Text;
                secondColumn.HeaderText = "";
                secondColumn.Text       = "#VALX (ลบ.)";
                legend.CellColumns.Add(secondColumn);

                byte[] dataArray = chart.Render();

                string filename = "image.png";
                context.Response.ContentType = "image/png";
                context.Response.AddHeader("Content-Disposition", "attachment; filename=\"" + filename + "\"");
                context.Response.OutputStream.Write(dataArray, 0, dataArray.Length);
            }
            else
            {
                context.Response.ContentType = "text/plain";
                context.Response.Write("Error: Year was not specified");
            }
        }
        protected void bindChart(int advisorBranchId, int branchHeadId, int all)
        {
            AdvisorBranchBo advisorBranchBo = new AdvisorBranchBo();
            CustomerVo      customerVo      = new CustomerVo();
            CustomerBo      customerBo      = new CustomerBo();
            Legend          Branchlegend    = null;

            Branchlegend         = new Legend("BranchAssetsLegends");
            Branchlegend.Enabled = true;
            string[]  XValues = null;
            decimal[] YValues = null;
            DataRow   drChAssets;
            DataRow   drChvalues;
            Series    seriesBranchAssets = null;

            seriesBranchAssets = new Series("seriesBranchAssets");
            double DAssetvalue = 0;
            int    j           = 0;

            if (branchAumDT.Rows.Count > 0)
            {
                lblChartBranchAUM.Visible = true;
                ErrorMessage.Visible      = false;
                drChvalues = branchAumDT.Rows[0];
                for (int i = 0; i < branchAumDT.Columns.Count - 1; i++)
                {
                    drChAssets = branchAumDT.NewRow();

                    branchAumDT.Rows.Add(drChAssets);
                    if (DAssetvalue == 0)
                    {
                        j = j + 1;
                    }
                }
                if (j != branchAumDT.Columns.Count)
                {
                    seriesBranchAssets.ChartType = SeriesChartType.Pie;
                    //seriesBranchAssets1.Palette = ChartColorPalette.Chocolate;
                    //seriesBranchAssets.Palette = ChartColorPalette.Chocolate;

                    XValues = new string[10];
                    YValues = new decimal[10];
                    ChartBranchAssets.Series.Clear();
                    ChartBranchAssets.DataSource = branchAumDT;
                    //branchAumDT.DefaultView.Sort = "CurrentValue";
                    ChartBranchAssets.Series.Clear();
                    ChartBranchAssets.Series.Add(seriesBranchAssets);
                    ChartBranchAssets.Series[0].XValueMember  = "Asset";
                    ChartBranchAssets.Series[0].XValueType    = ChartValueType.String;
                    ChartBranchAssets.Series[0].YValueMembers = "CurrentValue";
                    ChartBranchAssets.Series["seriesBranchAssets"].IsValueShownAsLabel = true;
                    ChartBranchAssets.ChartAreas[0].AxisX.Title = "Assets";
                    ChartBranchAssets.Series[0].XValueMember    = "Asset";
                    ChartBranchAssets.DataManipulator.Sort(PointSortOrder.Descending, "Y", seriesBranchAssets);
                    ChartBranchAssets.Legends.Add(Branchlegend);
                    ChartBranchAssets.Legends["BranchAssetsLegends"].Title               = "Assets";
                    ChartBranchAssets.Legends["BranchAssetsLegends"].TitleAlignment      = StringAlignment.Center;
                    ChartBranchAssets.Legends["BranchAssetsLegends"].TitleSeparator      = LegendSeparatorStyle.None;
                    ChartBranchAssets.Legends["BranchAssetsLegends"].Alignment           = StringAlignment.Center;
                    ChartBranchAssets.Legends["BranchAssetsLegends"].TitleSeparator      = LegendSeparatorStyle.GradientLine;
                    ChartBranchAssets.Legends["BranchAssetsLegends"].TitleSeparatorColor = Color.Black;


                    ChartBranchAssets.Series[0]["PieLabelStyle"] = "Outside";
                    ChartBranchAssets.Series[0]["PieStartAngle"] = "10";
                    ChartArea chartArea1 = ChartBranchAssets.ChartAreas[0];
                    chartArea1.Area3DStyle.IsClustered      = true;
                    chartArea1.Area3DStyle.Enable3D         = true;
                    chartArea1.Area3DStyle.Perspective      = 10;
                    chartArea1.Area3DStyle.PointGapDepth    = 900;
                    chartArea1.Area3DStyle.IsRightAngleAxes = false;
                    chartArea1.Area3DStyle.WallWidth        = 25;
                    chartArea1.Area3DStyle.Rotation         = 65;
                    chartArea1.Area3DStyle.Inclination      = 35;
                    chartArea1.BackColor          = System.Drawing.Color.Transparent;
                    chartArea1.BackSecondaryColor = System.Drawing.Color.Transparent;
                    chartArea1.Position.Auto      = true;
                    LegendCellColumn colorColumn = new LegendCellColumn();
                    colorColumn.ColumnType      = LegendCellColumnType.SeriesSymbol;
                    colorColumn.HeaderBackColor = Color.WhiteSmoke;
                    ChartBranchAssets.Legends["BranchAssetsLegends"].CellColumns.Add(colorColumn);
                    ChartBranchAssets.Legends["BranchAssetsLegends"].BackColor = Color.FloralWhite;
                    LegendCellColumn totalColumn = new LegendCellColumn();
                    totalColumn.Alignment = ContentAlignment.MiddleLeft;

                    totalColumn.Text            = "#VALX: #PERCENT";
                    totalColumn.Name            = "AssetsColumn";
                    totalColumn.HeaderBackColor = Color.WhiteSmoke;
                    ChartBranchAssets.Legends["BranchAssetsLegends"].CellColumns.Add(totalColumn);
                    ChartBranchAssets.Series[0]["PieLabelStyle"]         = "Disabled";
                    ChartBranchAssets.Series[0].ToolTip                  = "#VALX: #PERCENT";
                    ChartBranchAssets.ChartAreas[0].AxisX.Interval       = 1;
                    ChartBranchAssets.ChartAreas[0].AxisY.Title          = "Total Assets";
                    ChartBranchAssets.ChartAreas[0].Area3DStyle.Enable3D = true;
                    ChartBranchAssets.DataBind();
                }
            }
            else
            {
                lblChartBranchAUM.Visible    = false;
                ErrorMessage.Visible         = true;
                ChartBranchAssets.DataSource = null;
                ChartBranchAssets.Visible    = false;
            }


            /* For Chart 2 */

            if (topFiveRMDT.Rows.Count > 0)
            {
                lblTop5Rms.Visible = true;
                DataRow drRMCustomersNet;
                DataRow drRMCustomersNetResults;


                Series seriesRMCustNetworth = null;
                seriesRMCustNetworth = new Series("seriesRMCustNetworth");

                Series seriesRMCustNetworth1 = null;
                seriesRMCustNetworth1 = new Series("seriesRMCustNetworth");

                Legend RMCustNetLegend = null;
                Branchlegend = new Legend("legendsTopfiveRM");

                seriesRMCustNetworth    = new Series("CustomerNetworth");
                RMCustNetLegend         = new Legend("CustomerNetworthLegends");
                RMCustNetLegend.Enabled = true;
                XValues          = new string[10];
                YValues          = new decimal[10];
                drRMCustomersNet = topFiveRMDT.Rows[0];
                CharttopfiveRMCustNetworth.Series.Clear();
                CharttopfiveRMCustNetworth.Series.Add(seriesRMCustNetworth);
                CharttopfiveRMCustNetworth.DataSource = topFiveRMDT.DefaultView;
                topFiveRMDT.Columns.Add("RM Name");
                for (int i = 0; i < topFiveRMDT.Rows.Count; i++)
                {
                    drRMCustomersNet        = topFiveRMDT.NewRow();
                    drRMCustomersNetResults = topFiveRMDT.Rows[i];

                    j = j + 1;
                }
                if (j != topFiveRMDT.Rows.Count)
                {
                    seriesRMCustNetworth.ChartType = SeriesChartType.Bar;
                    //CharttopfiveRMCustNetworth.Titles.Add("Top 5 RMs (Customer Base)");


                    CharttopfiveRMCustNetworth.Series.Clear();
                    CharttopfiveRMCustNetworth.Series.Add(seriesRMCustNetworth);
                    CharttopfiveRMCustNetworth.Series[0].XValueMember = "RmName";
                    CharttopfiveRMCustNetworth.Series[0].XValueType   = ChartValueType.String;

                    CharttopfiveRMCustNetworth.Series[0].YValueMembers = "Customer_networth";


                    CharttopfiveRMCustNetworth.Series["CustomerNetworth"].IsValueShownAsLabel = true;
                    CharttopfiveRMCustNetworth.ChartAreas[0].AxisX.Title             = "RM Name";
                    CharttopfiveRMCustNetworth.ChartAreas[0].AxisX.LabelAutoFitStyle = LabelAutoFitStyles.WordWrap;
                    CharttopfiveRMCustNetworth.ChartAreas[0].AxisY.LabelAutoFitStyle = LabelAutoFitStyles.LabelsAngleStep90;

                    CharttopfiveRMCustNetworth.ChartAreas[0].AxisX.Interval       = 1;
                    CharttopfiveRMCustNetworth.ChartAreas[0].AxisY.Title          = "Customer NetWorth";
                    CharttopfiveRMCustNetworth.ChartAreas[0].Area3DStyle.Enable3D = true;

                    //CharttopfiveRMCustNetworth.Legends.Add(Branchlegend);
                    //CharttopfiveRMCustNetworth.Legends["legendsTopfiveRM"].Title = "Assets";
                    //CharttopfiveRMCustNetworth.Legends["legendsTopfiveRM"].TitleAlignment = StringAlignment.Center;
                    //CharttopfiveRMCustNetworth.Legends["legendsTopfiveRM"].TitleSeparator = LegendSeparatorStyle.None;
                    //CharttopfiveRMCustNetworth.Legends["legendsTopfiveRM"].Alignment = StringAlignment.Center;
                    //CharttopfiveRMCustNetworth.Legends["legendsTopfiveRM"].TitleSeparatorColor = Color.Black;

                    ChartArea custArea = ChartBranchAssets.ChartAreas[0];
                    custArea.Area3DStyle.Perspective      = 10;
                    custArea.Area3DStyle.PointGapDepth    = 900;
                    custArea.Area3DStyle.IsRightAngleAxes = false;
                    custArea.Area3DStyle.WallWidth        = 25;
                    custArea.Area3DStyle.Rotation         = 85;
                    custArea.Area3DStyle.Inclination      = 35;

                    seriesRMCustNetworth.Palette = ChartColorPalette.Chocolate;
                    //seriesRMCustNetworth1.Palette = ChartColorPalette.Fire;


                    //seriesRMCustNetworth.Palette = ChartColorPalette.Pastel;
                    //seriesRMCustNetworth1.Palette = ChartColorPalette.Fire;
                    CharttopfiveRMCustNetworth.DataBind();
                }
            }
            else
            {
                lblTop5Rms.Visible = false;
                CharttopfiveRMCustNetworth.DataSource = null;
                CharttopfiveRMCustNetworth.Visible    = false;
            }
            /* *********** */


            /* For Chart 3 */

            if (topFiveCustomerDT.Rows.Count > 0)
            {
                chartCustNetworth.Visible = true;
                DataRow drNetworth;
                DataRow drNetworthResult;

                Series seriesCustNetworth = null;
                seriesCustNetworth = new Series("seriesCustNetworth");

                Series seriesCustNetworth1 = null;
                seriesCustNetworth1 = new Series("seriesCustNetworth");

                Legend CustNetLegend = null;
                Branchlegend = new Legend("legendCustomeAsset");

                seriesCustNetworth    = new Series("CustomerNetworth");
                CustNetLegend         = new Legend("CustomerNetworthLegends");
                CustNetLegend.Enabled = true;
                XValues    = new string[10];
                YValues    = new decimal[10];
                drNetworth = topFiveCustomerDT.Rows[0];
                ChartCustomerNetworth.Series.Clear();
                ChartCustomerNetworth.Series.Add(seriesCustNetworth);
                ChartCustomerNetworth.DataSource = topFiveCustomerDT.DefaultView;
                topFiveCustomerDT.Columns.Add("Customer Name");
                for (int i = 0; i < topFiveCustomerDT.Rows.Count; i++)
                {
                    drNetworth       = topFiveCustomerDT.NewRow();
                    drNetworthResult = topFiveCustomerDT.Rows[i];

                    j = j + 1;
                }
                if (j != topFiveCustomerDT.Rows.Count)
                {
                    seriesCustNetworth.ChartType = SeriesChartType.Bar;

                    ChartCustomerNetworth.Series.Clear();
                    ChartCustomerNetworth.Series.Add(seriesCustNetworth);
                    ChartCustomerNetworth.Series[0].XValueMember  = "Customer";
                    ChartCustomerNetworth.Series[0].XValueType    = ChartValueType.String;
                    ChartCustomerNetworth.Series[0].YValueMembers = "Networth";



                    ChartCustomerNetworth.Series["CustomerNetworth"].IsValueShownAsLabel = true;
                    ChartCustomerNetworth.ChartAreas[0].AxisX.Title = "Customer Name";

                    ChartCustomerNetworth.ChartAreas[0].AxisY.LabelAutoFitStyle       = LabelAutoFitStyles.LabelsAngleStep90;
                    ChartCustomerNetworth.ChartAreas[0].AxisX.Interval                = 1;
                    ChartCustomerNetworth.ChartAreas[0].AxisX.LabelAutoFitStyle       = LabelAutoFitStyles.WordWrap;
                    ChartCustomerNetworth.ChartAreas[0].AxisX.LabelAutoFitMaxFontSize = 5;
                    ChartCustomerNetworth.ChartAreas[0].AxisY.Title          = "Customer NetWorth";
                    ChartCustomerNetworth.ChartAreas[0].Area3DStyle.Enable3D = true;

                    ChartArea custArea = ChartBranchAssets.ChartAreas[0];
                    custArea.Area3DStyle.Perspective      = 10;
                    custArea.Area3DStyle.PointGapDepth    = 900;
                    custArea.Area3DStyle.IsRightAngleAxes = false;
                    custArea.Area3DStyle.WallWidth        = 25;
                    custArea.Area3DStyle.Rotation         = 65;
                    custArea.Area3DStyle.Inclination      = 35;
                    //seriesCustNetworth.Palette = ChartColorPalette.Pastel;
                    seriesCustNetworth.Palette = ChartColorPalette.Chocolate;
                    ChartCustomerNetworth.DataBind();
                }
            }
            else
            {
                chartCustNetworth.Visible        = false;
                ChartCustomerNetworth.DataSource = null;
                ChartCustomerNetworth.Visible    = false;
            }
            /* *********** */
        }
Esempio n. 28
0
        private void Dona(string turno, string estado, string desde, string hasta, string _titulo, Chart gchart)
        {
            string filtro = " r.id_sector = '" + Operador.sector_id + @"' ";

            if (hasta != "")
            {
                filtro = filtro + "  and r.fecha >= '" + desde + "' and r.fecha <= '" + hasta + @"' ";
            }
            else
            {
                filtro = filtro + " and r.fecha = '" + desde + "' ";
            }

            if (turno != "")
            {
                filtro = filtro + " and r.id_turno = '" + turno + "' ";
            }

            if (estado != "")
            {
                filtro = filtro + " and r.estado = '" + estado + "' ";
            }

            Mysql     sql       = new Mysql();
            string    sqlString = @"
SELECT 
COUNT(*) as rechazos,
df.defecto

FROM reparacion r

left join (
    select id,defecto from defecto
) as df
on df.id = r.id_defecto

where 

" + filtro + @"

group by 
r.id_sector,r.id_defecto

order by 
rechazos desc
";
            DataTable md        = sql.Select(sqlString);
            DataView  firstView = new DataView(md);
            ChartArea ch        = gchart.ChartAreas[0];

            gchart.Titles.Clear();
            gchart.Titles.Add(new Title {
                Text = _titulo, Font = new Font("Calibri", 15, FontStyle.Bold), BackColor = System.Drawing.ColorTranslator.FromHtml("#efefef")
            });


            gchart.Series.Clear();
            gchart.Series.Add(new Series {
                ChartType = SeriesChartType.Pie
            });
            Series pie = gchart.Series[0];

            List <double> lRechazo = new List <double>();
            List <string> lX       = new List <string>();

            double[] yRechazos = { 0 };
            string[] xValues   = { "" };

            foreach (DataRow r in md.Rows)
            {
                string rch = r[0].ToString();
                if (rch == "")
                {
                    rch = "0";
                }

                string xv = r[1].ToString();

                double vrechazo = 0;

                if (rch != "")
                {
                    vrechazo = Convert.ToDouble(rch);
                }

                lRechazo.Add(vrechazo);
                lX.Add(xv);
            }

            yRechazos = (double[])lRechazo.ToArray();
            xValues   = (string[])lX.ToArray();

            //Array.Sort(yRechazos);
            //Array.Reverse(yRechazos);

            pie.Points.DataBindXY(xValues, yRechazos);
            pie.ChartType         = SeriesChartType.Doughnut;
            pie["PieLabelStyle"]  = "Outside";
            pie["DoughnutRadius"] = "30";

            pie.Label      = "(#VALY) #PERCENT{P0}";
            pie.LegendText = "#VALX";

            pie["PieDrawingStyle"]  = "Concave";
            pie.IsValueShownAsLabel = true;

            ch.Area3DStyle.Enable3D = true;

            ch.Area3DStyle.Rotation = 30;

            ch.Area3DStyle.Inclination = 40;

            ch.Area3DStyle.IsRightAngleAxes = true;

            if (pie.Points.Count > 0)
            {
                double valorMaximo = pie.Points.Select(p => p.YValues[0]).Max();

                foreach (DataPoint dp in pie.Points)
                {
                    double valor = dp.YValues.First();
                    if (valor >= valorMaximo)
                    {
                        dp["Exploded"] = "True";
                    }
                }
            }

            Legend lg = chart4.Legends[0];

            // Add header separator of type line
            lg.HeaderSeparator      = LegendSeparatorStyle.Line;
            lg.HeaderSeparatorColor = Color.Gray;

//            lg.BorderColor = Color.Aqua;
//            lg.BorderWidth = 5;

            // Add Color column
            LegendCellColumn firstColumn = new LegendCellColumn();

            firstColumn.ColumnType      = LegendCellColumnType.SeriesSymbol;
            firstColumn.HeaderText      = "Color";
            firstColumn.HeaderBackColor = Color.WhiteSmoke;

            // frstColumn.

            // Add AVG cell column
            LegendCellColumn avgColumn = new LegendCellColumn();

            avgColumn.Text       = "#VALY";
            avgColumn.HeaderText = "Total";
//            avgColumn.Name = "Total";
            avgColumn.HeaderBackColor = Color.WhiteSmoke;

            // Add Legend Text column
            LegendCellColumn secondColumn = new LegendCellColumn();

            secondColumn.ColumnType = LegendCellColumnType.Text;

//            secondColumn.MaximumWidth = 100;
            secondColumn.MinimumWidth = 900;

            secondColumn.Alignment       = ContentAlignment.MiddleLeft;
            secondColumn.HeaderText      = "Defecto";
            secondColumn.Text            = "#LEGENDTEXT";
            secondColumn.HeaderBackColor = Color.WhiteSmoke;

            if (
                chart4.Legends[0].CellColumns.Count <= 0
                )
            {
                chart4.Legends[0].CellColumns.Add(firstColumn);
                chart4.Legends[0].CellColumns.Add(avgColumn);
                chart4.Legends[0].CellColumns.Add(secondColumn);
            }
        }