Class: Sol::Chart
Overview
Class Attribute Summary collapse
-
.chart_map ⇒ Object
readonly
Returns the value of attribute chart_map.
Instance Attribute Summary collapse
-
#dim ⇒ Object
readonly
Returns the value of attribute dim.
-
#jstype ⇒ Object
readonly
Returns the value of attribute jstype.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#properties ⇒ Object
readonly
Returns the value of attribute properties.
-
#spot ⇒ Object
readonly
Returns the value of attribute spot.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#y_column ⇒ Object
readonly
Returns the value of attribute y_column.
Class Method Summary collapse
Instance Method Summary collapse
-
#header ⇒ Object
————————————————————————————.
-
#initialize(type, x_column, y_column, name) ⇒ Chart
constructor
————————————————————————————.
-
#js_spec ⇒ Object
————————————————————————————.
-
#props ⇒ Object
————————————————————————————.
Methods included from BaseChart
#data, #dimension, #group, #grouped?, #height, #min_height, #min_width, #transition_duration, #width
Constructor Details
#initialize(type, x_column, y_column, name) ⇒ Chart
81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/sol/chart.rb', line 81 def initialize(type, x_column, y_column, name) @type = type @dim = x_column + "Dimension" @jstype = Chart.chart_map[type] @y_column = y_column @name = name @spot = name + "Chart" @properties = Hash.new dimension(Sol.camelcase(@dim.to_s)) end |
Class Attribute Details
.chart_map ⇒ Object (readonly)
Returns the value of attribute chart_map.
63 64 65 |
# File 'lib/sol/chart.rb', line 63 def chart_map @chart_map end |
Instance Attribute Details
#dim ⇒ Object (readonly)
Returns the value of attribute dim.
69 70 71 |
# File 'lib/sol/chart.rb', line 69 def dim @dim end |
#jstype ⇒ Object (readonly)
Returns the value of attribute jstype.
70 71 72 |
# File 'lib/sol/chart.rb', line 70 def jstype @jstype end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
71 72 73 |
# File 'lib/sol/chart.rb', line 71 def name @name end |
#properties ⇒ Object (readonly)
Returns the value of attribute properties.
75 76 77 |
# File 'lib/sol/chart.rb', line 75 def properties @properties end |
#spot ⇒ Object (readonly)
Returns the value of attribute spot.
74 75 76 |
# File 'lib/sol/chart.rb', line 74 def spot @spot end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
68 69 70 |
# File 'lib/sol/chart.rb', line 68 def type @type end |
#y_column ⇒ Object (readonly)
Returns the value of attribute y_column.
72 73 74 |
# File 'lib/sol/chart.rb', line 72 def y_column @y_column end |
Class Method Details
.build(type, x_column, y_column, name) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/sol/chart.rb', line 46 def self.build(type, x_column, y_column, name) case type when :line_chart return LineChart.new(type, x_column, y_column, name) when :bar_chart return BarChart.new(type, x_column, y_column, name) else return Chart.new(type, x_column, y_column, name) end end |
Instance Method Details
#header ⇒ Object
115 116 117 118 119 120 121 122 |
# File 'lib/sol/chart.rb', line 115 def header <<-EOS var #{@name} = dc.#{@jstype}(\"##{@spot}\"); #{@group} EOS end |
#js_spec ⇒ Object
128 129 130 131 |
# File 'lib/sol/chart.rb', line 128 def js_spec gr = header + props gr end |
#props ⇒ Object
99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/sol/chart.rb', line 99 def props # start the chart specification str = @name @properties.each_pair do |key, value| str << "." + "#{key}(#{value})" end str << ";" str end |