Beispiel #1
0
        private void DrawChart()
        {
            List <string>  name   = new List <string>();
            List <decimal> amount = new List <decimal>();

            Dictionary <string, decimal> monthlyCashBank = new Dictionary <string, decimal>();
            Dictionary <string, decimal> monthlyIncome   = new Dictionary <string, decimal>();
            Dictionary <string, decimal> monthlyExpense  = new Dictionary <string, decimal>();
            Dictionary <string, decimal> monthlyDebt     = new Dictionary <string, decimal>();
            Dictionary <string, decimal> monthlyAR       = new Dictionary <string, decimal>();
            Dictionary <string, decimal> currentAsset    = new Dictionary <string, decimal>();

            int currentMonth = cbMonth.SelectedIndex + 1;
            int currentYear  = DateTime.Now.Year;

            switch (cbChart.Text)
            {
            case "Cash & Bank":

                pnlFinancialCheckup.Visible = false;
                monthlyCashBank             = chartRepository.GetMonthlyCashAndBank(currentMonth, currentYear);

                foreach (KeyValuePair <string, decimal> pair in monthlyCashBank)
                {
                    name.Add(pair.Key);
                    amount.Add(pair.Value);
                }

                break;

            case "Income":

                pnlFinancialCheckup.Visible = false;

                monthlyIncome = chartRepository.GetMonthlyIncome(currentMonth, currentYear);
                foreach (KeyValuePair <string, decimal> pair in monthlyIncome)
                {
                    name.Add(pair.Key);
                    amount.Add(pair.Value);
                }

                break;

            case "Expense":

                pnlFinancialCheckup.Visible = false;

                monthlyExpense = chartRepository.GetMonthlyExpense(currentMonth, currentYear);

                foreach (KeyValuePair <string, decimal> pair in monthlyExpense)
                {
                    name.Add(pair.Key);
                    amount.Add(pair.Value);
                }

                break;

            case "Account Payable":

                pnlFinancialCheckup.Visible = false;

                monthlyDebt = chartRepository.GetMonthlyDebt(currentMonth, currentYear);

                foreach (KeyValuePair <string, decimal> pair in monthlyDebt)
                {
                    name.Add(pair.Key);
                    amount.Add(pair.Value);
                }

                break;

            case "Account Receivable":

                pnlFinancialCheckup.Visible = false;

                monthlyAR = chartRepository.GetMonthlyAccountReceivable(currentMonth, currentYear);

                foreach (KeyValuePair <string, decimal> pair in monthlyAR)
                {
                    name.Add(pair.Key);
                    amount.Add(pair.Value);
                }

                break;

            case "Asset":

                pnlFinancialCheckup.Visible = false;

                currentAsset = chartRepository.GetCurrentAsset(currentMonth, currentYear);

                foreach (KeyValuePair <string, decimal> pair in currentAsset)
                {
                    name.Add(pair.Key);
                    amount.Add(pair.Value);
                }

                break;

            case "Financial Checkup":
                pnlFinancialCheckup.Visible = true;
                break;
            }



            chart1.Series["Series1"].Points.DataBindXY(name, amount);
            chart1.Series["Series1"].Label = "#PERCENT";

            chart1.Series["Series1"].LegendText = "#AXISLABEL : #VALY{N0}";


            chart1.Series["Series1"].ChartType = SeriesChartType.Doughnut;



            //else if (cbChart.Text == "Income Per Year")
            //{
            //    chart1.Series["Series1"].Points.DataBindXY(xValues, yValues);
            //    chart1.Series["Series1"].ChartType = SeriesChartType.Column;
            //}


            // Set labels style
            chart1.Series["Series1"]["PieLabelStyle"] = "Outside";

            // Set Doughnut radius percentage
            chart1.Series["Series1"]["DoughnutRadius"] = "60";

            // Explode data point with label "Italy"
            // chart1.Series["Series1"].Points[3]["Exploded"] = "true";

            // Enable 3D
            //chart1.ChartAreas[0].Area3DStyle.Enable3D = true;

            // Set drawing style
            //Default, SoftEdge, Concave

            chart1.Series["Series1"]["PieDrawingStyle"] = "Concave";


            //chart1.Legends["Legend1"].HeaderSeparator = LegendSeparatorStyle.Line;
            //chart1.Legends["Legend1"].HeaderSeparatorColor = Color.Gray;

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


            //LegendCellColumn secondColumn = new LegendCellColumn();
            //secondColumn.ColumnType = LegendCellColumnType.Text;
            //secondColumn.HeaderText = "Account";
            //secondColumn.Text = "#N1";
            //secondColumn.HeaderBackColor = Color.WhiteSmoke;
            //chart1.Legends["Legend1"].CellColumns.Add(secondColumn);


            chart1.Visible = true;
        }