DRILLDOWN WITH STACKED CHART

Apr 22, 2016 at 10:44 AM
Edited Apr 22, 2016 at 10:45 AM
does any one have idea how to drilldown with stacked column chart?






Highcharts chart = new Highcharts(string.Format("chart_001"))
           .InitChart(new Chart { Type = ChartTypes.Column })
           .SetTitle(new Title { Text = "Stacked bar chart" })
           .SetXAxis(new XAxis { Categories = new[] { "Apples", "Oranges", "Pears", "Grapes", "Bananas" } })
           .SetYAxis(new YAxis
           {
               Min = 0,
               Title = new YAxisTitle { Text = "Total fruit consumption" }
           })
           .SetTooltip(new Tooltip { Formatter = "function() { return ''+ this.series.name +': '+ this.y +''; }" })
           .SetPlotOptions(new PlotOptions { Column = new PlotOptionsColumn { Stacking = Stackings.Normal } })
           .SetSeries(new[]
           {
                new Series { Name = "John", Data = new Data(new object[] { 5, 3, 4, 7, 2 }) },
                new Series { Name = "Jane", Data = new Data(new object[] { 2, 2, 3, 2, 1 }) },
                new Series { Name = "Joe", Data = new Data(new object[] { 3, 4, 4, 2, 5 }) }
           });
Apr 22, 2016 at 11:58 AM
Edited Apr 22, 2016 at 11:58 AM
resloved using this way......
public static string StackedColumnDrilldown()
    {

        Data data1 = new Data(new[]
       {
            new SeriesData
            {
                Y = 5,
                Name = "A1",
                Drilldown = "animals"
            },
            new SeriesData
            {
                Y = 2,
                Name = "B1",
                Drilldown = "fruits"
            },
            new SeriesData
            {
                Y = 4,
                Name = "C1",
                Drilldown = "cars"
            }
        });


        Data data2 = new Data(new[]
      {
            new SeriesData
            {
                Y = 1,
                Name = "A2",
                Drilldown = "animals2"
            },
            new SeriesData
            {
                Y = 5,
                Name = "B2",
                Drilldown = "fruits2"
            },
            new SeriesData
            {
                Y = 2,
                Name = "C2",
                Drilldown = "cars2"
            }
        });


        var s1 = new Series();
        s1.Name = "Things1";
        s1.Data = data1;

        var s2 = new Series();
        s2.Name = "Things2";
        s2.Data = data2;


        Drilldown drilldown = new Drilldown
        {
            Series = new[]
            {
                new Series
                {
                    Id = "animals",
                    Name="Animals",
                    Data = new Data(new object[,] { { "Cats", 4 }, { "Dogs", 2 }, { "Cows", 1 }, { "Sheep", 2 }, { "Pigs", 1 } })
                },
                 new Series
                {
                    Id = "fruits",
                    Name="Fruits",
                    Data = new Data(new object[,] { { "Apples", 4 }, { "Oranges", 2 }})
                },
                new Series
                {
                    Id = "cars",
                    Name="Cars",
                    Data = new Data(new object[,] { { "Toyota", 4 }, { "Opel", 2 }, { "Volkswagen", 2 }})
                },


                new Series
                {
                    Id = "animals2",
                    Name="Animals2",
                    Data = new Data(new object[,] { { "Cats", 3 }, { "Dogs",5 }, { "Cows", 6 }, { "Sheep", 2 }, { "Pigs", 2} })
                },
                 new Series
                {
                    Id = "fruits2",
                    Name="Fruits2",
                    Data = new Data(new object[,] { { "Apples", 1}, { "Oranges", 5 }})
                },
                new Series
                {
                    Id = "cars2",
                    Name="Cars2",
                    Data = new Data(new object[,] { { "Toyota", 2 }, { "Opel", 3 }, { "Volkswagen", 2 }})
                },

            }
        };


        Highcharts chart = new Highcharts(string.Format("chartK12345"))
           .InitChart(new Chart { Type = ChartTypes.Column })
           .SetTitle(new Title { Text = "Stacked column chart" })
           .SetXAxis(new XAxis { Categories = new[] { "1", "2", "3", "4", "5" } })
           .SetYAxis(new YAxis
           {
               Min = 0,
               Title = new YAxisTitle { Text = "Total" },
               StackLabels = new YAxisStackLabels
               {
                   Enabled = true,
                   Style = "fontWeight: 'bold', color: (Highcharts.theme && Highcharts.theme.textColor) || 'gray'"
               }

           })
           .SetTooltip(new Tooltip { Formatter = "function() { return ''+ this.series.name +': '+ this.y +''; }" })
           .SetPlotOptions(new PlotOptions { Column = new PlotOptionsColumn { Stacking = Stackings.Normal } })
           .SetSeries(new[] { s1, s2 })
           .SetDrilldown(drilldown);


        return chart.ToHtmlString();

    }