Class: ApexCharts::Charts::MixedCharts

Inherits:
BaseChart
  • Object
show all
Includes:
Features::Annotations, Utils::Hash
Defined in:
lib/apex_charts/charts/mixed_charts.rb

Instance Attribute Summary

Attributes inherited from BaseChart

#options, #sample, #series

Instance Method Summary collapse

Methods included from Utils::Hash

camelize, camelize_keys, deep_merge

Methods included from Features::Annotations

#annotation, #point_annotation, #x_annotation, #y_annotation

Methods inherited from BaseChart

#render

Constructor Details

#initialize(outer_self, options = {}, &block) ⇒ MixedCharts

Returns a new instance of MixedCharts.



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/apex_charts/charts/mixed_charts.rb', line 10

def initialize(outer_self, options={}, &block)
  @outer_self = outer_self
  @series = {series: []}
  options[:id] ||= apexcharts_id
  build_instance_variables

  instance_eval &block

  options[:annotations] = @annotations if @annotations
  @options = build_options(options)

  build_selection_range if brush?
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object



58
59
60
61
62
63
64
# File 'lib/apex_charts/charts/mixed_charts.rb', line 58

def method_missing(method, *args, &block)
  if @outer_self.respond_to?(method, true)
    @outer_self.send method, *args, &block
  else
    super
  end
end

Instance Method Details

#area_chart(data, options = {}, &block) ⇒ Object



34
35
36
37
38
# File 'lib/apex_charts/charts/mixed_charts.rb', line 34

def area_chart(data, options={}, &block)
  outer_self = eval('self', block.binding, __FILE__, __LINE__) if block_given?
  @series[:series] +=
    AreaChart.new(outer_self, data, options, &block).mixed_series
end

#bar_chart(data, options = {}, &block) ⇒ Object



40
41
42
43
44
# File 'lib/apex_charts/charts/mixed_charts.rb', line 40

def bar_chart(data, options={}, &block)
  outer_self = eval('self', block.binding, __FILE__, __LINE__) if block_given?
  @series[:series] +=
    BarChart.new(outer_self, data, options, &block).mixed_series
end

#chart_typeObject



24
25
26
# File 'lib/apex_charts/charts/mixed_charts.rb', line 24

def chart_type
  'area' # chosen default
end

#column_chart(data, options = {}, &block) ⇒ Object



46
47
48
49
50
# File 'lib/apex_charts/charts/mixed_charts.rb', line 46

def column_chart(data, options={}, &block)
  outer_self = eval('self', block.binding, __FILE__, __LINE__) if block_given?
  @series[:series] +=
    ColumnChart.new(outer_self, data, options, &block).mixed_series
end

#line_chart(data, options = {}, &block) ⇒ Object



28
29
30
31
32
# File 'lib/apex_charts/charts/mixed_charts.rb', line 28

def line_chart(data, options={}, &block)
  outer_self = eval('self', block.binding, __FILE__, __LINE__) if block_given?
  @series[:series] +=
    LineChart.new(outer_self, data, options, &block).mixed_series
end

#respond_to_missing?(method, *args) ⇒ Boolean

Returns:

  • (Boolean)


66
67
68
# File 'lib/apex_charts/charts/mixed_charts.rb', line 66

def respond_to_missing?(method, *args)
  @outer_self.respond_to?(method, true) || super
end

#scatter_chart(data, options = {}, &block) ⇒ Object



52
53
54
55
56
# File 'lib/apex_charts/charts/mixed_charts.rb', line 52

def scatter_chart(data, options={}, &block)
  outer_self = eval('self', block.binding, __FILE__, __LINE__) if block_given?
  @series[:series] +=
    ScatterChart.new(outer_self, data, options, &block).mixed_series
end