michelson / lazy_high_charts

Make highcharts a la ruby , works in rails 5.X / 4.X / 3.X, and other ruby web frameworks

Home Page:http://www.suipit.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Drilldown

indiicheng opened this issue · comments

Hey guys,

I looked, but wasn't able to find any documentation or help on StackOverflow on the correct syntax for utilizing a drill down. Can someone please provide me with an example?

Thanks,
Andy

+1

Here's what I tried and got nowhere, unfortunately. It'll load the chart, but not the drill down.

@chart4 = LazyHighCharts::HighChart.new('collapsable') do |f|
  f.title(text: 'Sales for 2015')
  f.xAxis(categories: ['Cars', 'Fruits', 'Vegetables', 'Pets', 'Electronics'])
  f.series({
    name: 'Sales',
    colorByPoint: true,
    data: [
      {
        name: 'Cars',
        y: 5,
        drilldown: 'cars'
      }, {
        name: 'Fruits',
        y: 14,
        drilldown: 'fruits'
      }, {
        name: 'Vegetables',
        y: 12
      }, {
        name: 'Pets',
        y: 6
      }, {
        name: 'Electronics',
        y: 12,
        drilldown: 'electronics'
      }
    ]
  })

  f.drilldown({
    series: [ {
      id: 'cars',
      data: [
        ['Honda', 1],
        ['Toyota', 2],
        ['GM', 1],
        ['Nissan', 2]]
      }, {
      id: 'fruits',
      data: [
        ['Apples', 8],
        ['Bananas', 3],
        ['Cherries', 3]]
      }, {
      id: 'electronics',
      data: [
        ['iPhone', 3],
        ['iPad', 5],
        ['MacBook', 2],
        ['MacBook Air', 2]]
      } 
    ]
  })
  f.chart({defaultSeriesType: "column"})

  f.legend(layout: 'horizontal')
end

The compiled JavaScript looks exactly like this JavaScript example.

I think this is due to the fact the module highcharts/modules/drilldrown is not required.

I am having more or less the same problem, and I wonder what the stance on highchart modules is. When I look in the vendor/assets/javascripts/highcharts/modules/ folder of this gem I only see exporting and no-data-to-display. What about all the other highcharts modules. How does this gem suggest that you include those?