Inheritance: ChartBase
Ejemplo n.º 1
0
    private void GenerateLineChart(string sumObject, string groupByObject, string title, AjaxControlToolkit.LineChart chart)
    {
        string query = string.Format("SELECT SUM({0}), {1} FROM orders GROUP BY {1}", sumObject, groupByObject);

        //todo: create following method un cinnection class
        DataTable dt = ConnectionClass.GetChartDate(query);

        decimal[] x = new decimal[dt.Rows.Count];
        string[]  y = new string[dt.Rows.Count];

        for (int i = 0; i < dt.Rows.Count; i++)
        {
            x[i] = Convert.ToInt32(dt.Rows[i][0].ToString());
            y[i] = dt.Rows[i][1].ToString();
        }

        chart.Series.Add(new AjaxControlToolkit.LineChartSeries {
            Data = x
        });
        chart.CategoriesAxis = string.Join(",", y);
        chart.ChartTitle     = title;

        if (x.Length > 3)
        {
            chart.ChartWidth = (x.Length * 75).ToString();
        }
    }