This project is read-only.

Drilldown to grouped bar chart

Jul 26, 2012 at 3:12 PM

I'm trying to create a drilldown to a grouped bar chart with multiple series, like this http://jsfiddle.net/EgzfS/2/ but I'm not sure how to

I am able to drilldown into a bar chart with one series using the following code:

 

        Series[] data = new Series[Convert.ToInt32(ds.Tables[0].Rows.Count)];
        Series Store1 = new Series();
        Series Store2 = new Series();

        object[] Target = new object[Convert.ToInt32(ds.Tables[0].Rows.Count)];
        object[] Sales = new object[Convert.ToInt32(ds.Tables[0].Rows.Count)];

        //System.Drawing.Color[] Color = new System.Drawing.Color[Convert.ToInt32(ds.Tables[0].Rows.Count)];



        for (int i = 0; i < Convert.ToInt32(ds.Tables[0].Rows.Count); i++)
        {

            DataTable dt = new DataTable();
            dt = ds.Tables[1];
            DataRow[] dr;
            dr = dt.Select("s_date='" + Convert.ToDateTime(ds.Tables[0].Rows[i][1]) + "'");

            object[] indiSales = new object[Convert.ToInt32(dr.Length)];
            object[] indiTarget = new object[Convert.ToInt32(dr.Length)];
            string[] categoriesindi = new string[dr.Length];

            for (int j = 0; j < Convert.ToInt32(dr.Length); j++)
            {
                indiSales[j] = Convert.ToString(dr[j][4]);
                indiTarget[j] = Convert.ToString(dr[j][3]);
                categoriesindi[j] = Convert.ToString(dr[j][0]) + " " + Convert.ToString(dr[j][1]);
            }
           

            Drilldown[] drill = new Drilldown[dr.Length];
            drill[0] = new Drilldown { Name = "Target", Data = new Data(indiTarget) };
            drill[1] = new Drilldown { Name = "Sales", Data = new Data(indiSales) };

            Target[i] = new Point { Y = Convert.ToInt32(ds.Tables[0].Rows[i][2]), Drilldown = new Drilldown { Name = "Target", Data=new Data(indiTarget) } };

            if (Convert.ToInt32(ds.Tables[0].Rows[i][3]) < Convert.ToInt32(ds.Tables[0].Rows[i][2]))
            {
                Sales[i] = new Point { Y = Convert.ToInt32(ds.Tables[0].Rows[i][3]), Color = ColorTranslator.FromHtml("#AA4643"), Drilldown = new Drilldown { Name = "Sales", Data = new Data(indiSales) } };
            }
            else
            {
                Sales[i] = new Point { Y = Convert.ToInt32(ds.Tables[0].Rows[i][3]), Color = ColorTranslator.FromHtml("#578C59"), Drilldown = new Drilldown { Name = "Sales", Data = new Data(indiSales) } };
            }
        }

        Store1.Data = new Data(Target);
        Store1.Name = "Target";
        Store1.Type = DotNet.Highcharts.Enums.ChartTypes.Column;

        Store2.Data = new Data(Sales);
        Store2.Name = "Sales";
        Store2.Type = DotNet.Highcharts.Enums.ChartTypes.Column;

        data = new Series[] { Store1, Store2 };
        string[] categories = new string[ds.Tables[0].Rows.Count];

        for (int i = 0; i < Convert.ToInt32(ds.Tables[0].Rows.Count); i++)
        {
            categories[i] = Convert.ToString(Convert.ToDateTime(ds.Tables[0].Rows[i][1]).ToShortDateString());
        }

        XAxis x = new XAxis();
        x.Categories = categories;

How do I setup the drilldown with multiple series like the highcharts example?

 

Thanks,

Andrew.