lib/plasticine/builder/line.rb in plasticine-1.2.0 vs lib/plasticine/builder/line.rb in plasticine-1.2.1

- old
+ new

@@ -27,15 +27,14 @@ def quarter_start_month=(month) @visual[:quarter_start_month] = month end - def order=(direction) + def order=(direction) @visual[:order] = direction # asc or desc end - def add_line(id, label) @lines[id] = { label: label, dots: [], total_y: 0 } if not @lines[id] end def add_dot(line_id, x, y) @@ -47,11 +46,11 @@ super #@chart[:legend] = (@chart[:lines].length > 1) if @chart[:legend].nil? set_max_y @visual[:lines] = @lines.each_value.map { |d| d } - + if @visual[:order] @visual[:lines] = @visual[:lines].sort_by{ |l| l[:total_y] } @visual[:lines].reverse! if @visual[:order] == 'asc' end @@ -67,10 +66,10 @@ stacks[key] = 0 if not stacks[key] 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 end end