lib/plasticine/builder/line.rb in plasticine-1.2.3 vs lib/plasticine/builder/line.rb in plasticine-1.2.4
- old
+ new
@@ -2,11 +2,11 @@
attr_reader :lines
def initialize(id, options={})
super
- @visual.merge! lines: [], nature: 'line', axis_x_format: :string, axis_y_format: :number, axis_y_tick_count: 10, chart_layout: 'line', order: nil, quarter_start_month: 1
+ @visual.merge! lines: [], nature: 'line', axis_x_format: :string, axis_y_format: :number, axis_y_tick_count: 10, chart_layout: 'line', max_y_ratio: 1, order: nil, quarter_start_month: 1
@lines = {}
end
def axis_x_format=(format)
@@ -23,10 +23,14 @@
def chart_layout=(clayout)
@visual[:chart_layout] = clayout
end
+ def max_y_ratio=(max_y_ratio)
+ @visual[:max_y_ratio] = max_y_ratio
+ end
+
def quarter_start_month=(month)
@visual[:quarter_start_month] = month
end
def order=(direction)
@@ -67,10 +71,14 @@
stacks[key] += dot[:y]
max_y = dot[:y] if max_y < dot[:y]
end
end
- @visual[:max_y_stack] = stacks.max_by{|k,v| v}[1] # Return the highest stacked value for a specific X
- @visual[:max_y] = max_y
+ if max_y == 0
+ @visual[:max_y_stack] = 0
+ @visual[:max_y] = 0
+ else
+ @visual[:max_y_stack] = stacks.max_by{|k,v| v}[1] # Return the highest stacked value for a specific X
+ @visual[:max_y] = max_y * @visual[:max_y_ratio]
+ end
end
-
end