agrobbin / highcharts-js-rails

Easily configure a Highcharts JS chart for use in a Rails application
MIT License
16 stars 8 forks source link

No option for stacking #6

Open thoran opened 11 years ago

thoran commented 11 years ago

I tried the following...

chart.plotOptions(series: {stacking: 'percent'})

which of course doesn't work, since I note that there is no built-in way to handle stacking, so I tried the following:

class Highcharts class PlotOptions class PlotType < Base

  def initialize(opts = {})
    @suboptions = {
      :dataLabels => 'Labels',
      :dial => 'Base',
      :events => 'PlotOptions::PlotType::Events',
      :marker => 'PlotOptions::PlotType::Marker',
      :pivot => 'Base',
      :point => 'Point',
      :states => 'PlotOptions::PlotType::States',
      :stacking => 'Base'
    }
    super
  end

end

end end

Of course Base wants a Hash.

I also tried creating a custom class and setting the class constant string above to 'Stacking':

class Highcharts class Stacking < Base

def initialize(opts = {})
  @default = :percent
  super
end

end end

This sort-of works, but it renders as a 'normal' stacking and isn't settable.

If I want to do a quick hack by dropping in a new class definition or definitions, can you suggest how to go about it?

Otherwise, adding stacking to this library would be good.

thoran commented 11 years ago

This is probably more like it...

class Highcharts class PlotOptions class PlotType < Base

  def initialize(opts = {})
    @options = {
      :stacking => opts[:stacking]
    }
    @suboptions = {
      :dataLabels => 'Labels',
      :dial => 'Base',
      :events => 'PlotOptions::PlotType::Events',
      :marker => 'PlotOptions::PlotType::Marker',
      :pivot => 'Base',
      :point => 'Point',
      :states => 'PlotOptions::PlotType::States',
    }
    super
  end

end

end end

Please patch with the above if it seems to be what you'd expect this to look like in order to have this functionality.

Thanks again!