class Highcharts::Chart
Ruby wrapper for Highcharts
.Chart.js
@author Colin Gunn @see api.highcharts.com/highcharts#Chart
Public Class Methods
Creates a Highcharts
or Highstock chart.
@param [Hash,Native] options_or_native If the argument is a native object it is wrapped otherwise a new native chart is created and wrapped. @option options_or_native [Symbol] :mode Either :chart, :stock, :map @option options_or_native [Hash] :chart and others per Highcharts
docs
Highcharts
.Map is not currently supported.
@see api.highcharts.com/highcharts#chart @see api.highcharts.com/highstock#chart
# File lib/opal/highcharts/chart.rb, line 23 def initialize(options_or_native) if native?(options_or_native) super(options_or_native) else options = options_or_native.to_h.dup case mode = options.delete(:mode) || :chart when :chart super(`new Highcharts.Chart( #{ options.to_n } )`) when :stock super(`new Highcharts.stockChart( #{ options.to_n } )`) when :map raise UnsupportedFeature, "#{__FILE__}[#{__LINE__}] #{self.class.name}##{__method__} : chart mode : '#{mode}' (Highcharts.Map)" # super(`new Highcharts.Map( #{ options.to_n } )`) else raise ArgumentError, "#{__FILE__}[#{__LINE__}] #{self.class.name}##{__method__} : invalid chart mode '#{mode}'" end end end
Public Instance Methods
Change the subtitle (but not title) of the chart. @param string_or_hash [String,Hash] string_or_hash
If a string, then only the subtitle text will be changed. If a hash it should contain title options.
@param redraw [Boolean] optional, whether to redraw immediately, defaults to true @see api.highcharts.com/highstock#Chart.setTitle
# File lib/opal/highcharts/chart.rb, line 152 def subtitle=(string_or_hash, redraw = true) t = string_or_hash.is_a?(String) ? {text: string_or_hash} : string_or_hash.to_h set_title(nil, t, redraw) end
Change the title (but not subtitle) of the chart. @param string_or_hash [String,Hash]
If a string, then only the title text will be changed. If a hash it should contain title options.
@param redraw [Boolean] optional, whether to redraw immediately, defaults to true @see api.highcharts.com/highstock#Chart.setTitle
# File lib/opal/highcharts/chart.rb, line 141 def title=(string_or_hash, redraw = true) t = string_or_hash.is_a?(String) ? {text: string_or_hash} : string_or_hash.to_h set_title(t, nil, redraw) end