Class: Highcharts::Chart
- Inherits:
-
Object
- Object
- Highcharts::Chart
- Includes:
- Base
- Defined in:
- lib/opal/highcharts/chart.rb,
lib/opal/highcharts/base.rb
Overview
Ruby wrapper for Highcharts.Chart.js
Instance Method Summary collapse
-
#get ⇒ Axis, ...
Returns a chart element for a given a id.
-
#get_svg ⇒ String
(also: #svg)
Returns an SVG string representing the chart.
-
#initialize(options_or_native) ⇒ Chart
constructor
Creates a Highcharts or Highstock chart.
-
#options ⇒ Highcharts::Options
Returns the current configuration options of the chart.
-
#renderer ⇒ Highcharts::Renderer
Returns the renderer for the chart.
-
#series ⇒ Array<Series>
Returns an array of the series in the chart.
-
#subtitle=(string_or_hash, redraw = true) ⇒ Object
Change the subtitle (but not title) of the chart.
-
#title=(string_or_hash, redraw = true) ⇒ Object
Change the title (but not subtitle) of the chart.
Methods included from Base
Constructor Details
#initialize(options_or_native) ⇒ Chart
Creates a Highcharts or Highstock chart.
If the argument is a native object it is wrapped otherwise a new native chart is created and wrapped. Highcharts.Map is not currently supported.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/opal/highcharts/chart.rb', line 23 def initialize() if native?() super() else = .to_h.dup case mode = .delete(:mode) || :chart when :chart super(`new Highcharts.Chart( #{ .to_n } )`) when :stock super(`new Highcharts.stockChart( #{ .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 |
Instance Method Details
#get ⇒ Axis, ...
Returns a chart element for a given a id.
85 |
# File 'lib/opal/highcharts/chart.rb', line 85 alias_native :get |
#get_svg ⇒ String Also known as: svg
Returns an SVG string representing the chart. Highcharts exporting module required.
92 |
# File 'lib/opal/highcharts/chart.rb', line 92 alias_native :get_svg, :getSVG |
#options ⇒ Highcharts::Options
Returns the current configuration options of the chart.
98 |
# File 'lib/opal/highcharts/chart.rb', line 98 alias_native :options, :options, as: Options |
#renderer ⇒ Highcharts::Renderer
Returns the renderer for the chart.
118 |
# File 'lib/opal/highcharts/chart.rb', line 118 alias_native :renderer, :renderer, as: Renderer |
#series ⇒ Array<Series>
Returns an array of the series in the chart.
130 |
# File 'lib/opal/highcharts/chart.rb', line 130 alias_native :series, :series, as_array_of: Series |
#subtitle=(string_or_hash, redraw = true) ⇒ Object
Change the subtitle (but not title) of the chart.
152 153 154 155 |
# 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 |
#title=(string_or_hash, redraw = true) ⇒ Object
Change the title (but not subtitle) of the chart.
141 142 143 144 |
# 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 |