Module: GoogleChart::Axis
Class Method Summary collapse
Instance Method Summary collapse
- #axes ⇒ Object
-
#axes=(axes) ⇒ Object
TODO: Add support for axis label positions/styles, support for multiple label sets per axis.
Class Method Details
.included(klass) ⇒ Object
4 5 6 |
# File 'lib/google_chart/axis.rb', line 4 def self.included(klass) klass.register!(:axes) end |
Instance Method Details
#axes ⇒ Object
30 31 32 33 34 35 36 37 38 |
# File 'lib/google_chart/axis.rb', line 30 def axes unless @axes.nil? || @axes.empty? [ 'chxt=' + @axes.join(','), @axis_labels.empty? ? nil : 'chxl=' + @axis_labels.join('|'), @axis_ranges.empty? ? nil : 'chxr=' + @axis_ranges.join('|') ].compact.join('&') end end |
#axes=(axes) ⇒ Object
TODO: Add support for axis label positions/styles, support for multiple label sets per axis
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/google_chart/axis.rb', line 10 def axes=(axes) idx = 0 @axes, @axis_labels, @axis_ranges = [], [], [] [:x, :y, :r, :t].each do |axis| case axes[axis] when Array @axis_labels << ("#{idx}:|" + axes[axis].map {|l| CGI::escape(l.to_s) }.join('|')) @axes << axis idx += 1 when Range @axis_ranges << ("#{idx},#{axes[axis].first},#{axes[axis].last}") @axes << axis idx += 1 when true @axes << axis idx += 1 end end end |