Exemplo n.º 1
0
 private void GenerateData(string formName, DbConnect postgreConnection, string what, string from, string args, string chartTitle, string yAxisTitle)
 {
     DataTable dt = new DataTable();
     this.Text = formName;
     int currSerial = 0;
     chart1.ChartAreas[0].RecalculateAxesScale();
     chart1.ChartAreas[0].AxisY.Title = yAxisTitle;
     postgreConnection.SelectFromFunc(what, from, args, dt);
     chart1.Titles.Add(chartTitle);
     chart1.ChartAreas[0].AxisX.LabelStyle.Enabled = false;
     foreach (DataRow dr in dt.Rows)
     {
         chart1.Legends.Add(dr.ItemArray[0].ToString());
         chart1.Series.Add(dr.ItemArray[0].ToString());
         chart1.Series[currSerial].Points.AddY(dr.ItemArray[1]);
         currSerial++;
     }
 }
Exemplo n.º 2
0
        public void DrawData(int oper, double number, DbConnect pgc, string from,string formName =null)
        {
            if (formName != null)
            {
                this.Text = formName;
                button3.Enabled = true;
            }
            bool compRes = false;
            chart1.Series.Clear();
            Series sIncome = new Series(), sExpenses = new Series();
            sIncome.ChartType = sExpenses.ChartType = SeriesChartType.Line;
            DataTable dt = new DataTable();
            DataPoint dp = new DataPoint();
            DataTable ordersTable = new DataTable();
            pgc.SelectFrom("*", from, ordersTable);
            sIncome.LegendText = "Доход";
            sIncome.Color = Color.Blue;
            sExpenses.Color = Color.Red;
            sExpenses.LegendText = "Расход";
            foreach (DataRow dr in ordersTable.Rows)
            {
                dp = new DataPoint();
                dp.Color = Color.Blue;
                dp.MarkerSize = 5;
                dp.MarkerColor = Color.Blue;
                dp.MarkerStyle = MarkerStyle.Circle;
                dp.IsEmpty = false;
                pgc.SelectFromFunc("*", "order_expenses_income", dr.ItemArray[0].ToString(), dt);
                if (oper != -1 && number > 0)
                    if (Compare(oper, number, dt.Rows[0].ItemArray[0]) && Compare(oper, number, dt.Rows[0].ItemArray[1]))
                        compRes = true;
                    else
                        compRes = false;
                if ((compRes) || (oper == -1 && number ==-1))
                {
                    try
                    {
                        dp.SetValueXY(DateTime.Parse(dr.ItemArray[6].ToString()), dt.Rows[0].ItemArray[0]);
                        dp.Label = DateTime.Parse(dr.ItemArray[6].ToString()).ToShortDateString() + " " + dr.ItemArray[9].ToString();
                        sIncome.Points.Add(dp);
                    }
                    catch
                    {

                    }
                    dp = new DataPoint();
                    dp.Color = Color.Red;
                    dp.MarkerSize = 5;
                    dp.MarkerColor = Color.Red;
                    dp.MarkerStyle = MarkerStyle.Circle;
                    dp.IsEmpty = false;
                    dp.SetValueXY(DateTime.Parse(dr.ItemArray[6].ToString()), dt.Rows[0].ItemArray[1]);
                    dp.Label = DateTime.Parse(dr.ItemArray[6].ToString()).ToShortDateString() + " " + dr.ItemArray[9].ToString();
                    sExpenses.Points.Add(dp);
                }
                dt.Clear();
            }
            sExpenses.XValueType = ChartValueType.Date;
            sIncome.XValueType = ChartValueType.Date;
            //chart1.ChartAreas[0].AxisX.ScaleView.Zoom(0, 10);
            chart1.Series.Add(sExpenses);
            chart1.Series.Add(sIncome);
            chart1.ChartAreas[0].RecalculateAxesScale();
        }