lib/gchart.rb in matta-googlecharts-1.1.0 vs lib/gchart.rb in matta-googlecharts-1.3.0
- old
+ new
@@ -6,11 +6,11 @@
class Gchart
include GchartInfo
@@url = "http://chart.apis.google.com/chart?"
- @@types = ['line', 'line_xy', 'scatter', 'bar', 'venn', 'pie', 'pie_3d', 'jstize']
+ @@types = ['line', 'line_xy', 'scatter', 'bar', 'venn', 'pie', 'pie_3d', 'jstize', 'sparkline', 'meter']
@@simple_chars = ('A'..'Z').to_a + ('a'..'z').to_a + ('0'..'9').to_a
@@chars = @@simple_chars + ['-', '.']
@@ext_pairs = @@chars.map { |char_1| @@chars.map { |char_2| char_1 + char_2 } }.flatten
@@file_name = 'chart.png'
@@ -245,10 +245,14 @@
"cht=p"
when :venn
"cht=v"
when :scatter
"cht=s"
+ when :sparkline
+ "cht=ls"
+ when :meter
+ "cht=gom"
end
end
def fill_type(type)
case type
@@ -282,10 +286,10 @@
# to about 300 pixels. Simple encoding is suitable for all other types of chart regardless of size.
def simple_encoding(dataset=[])
dataset = prepare_dataset(dataset)
@max_value = dataset.map{|ds| ds.max}.max if @max_value == 'auto'
- if @max_value == false || @max_value == 'false' || @max_value == :false
+ if @max_value == false || @max_value == 'false' || @max_value == :false || @max_value == 0
"s:" + dataset.map { |ds| ds.map { |number| convert_to_simple_value(number) }.join }.join(',')
else
"s:" + dataset.map { |ds| ds.map { |number| convert_to_simple_value( (@@simple_chars.size - 1) * number / @max_value) }.join }.join(',')
end
\ No newline at end of file