lib/rorschart/data/multiple_series.rb in rorschart-0.19.0 vs lib/rorschart/data/multiple_series.rb in rorschart-0.19.1

- old
+ new

@@ -30,18 +30,24 @@ } # The Merge: # For abscisse value, grab for each serie the corresponding row - or nil union_series = [] + asc = true union_x.each { |x| row = [x] series_indexed.each { |serie_hash| row << serie_hash[x] + asc = asc && ascending?(serie_hash) } union_series << row.flatten } + if !asc + union_series = union_series.reverse + end + # Return union of all series union_series end private @@ -60,9 +66,13 @@ serie.rows.each { |row| serie_hash[row[0]] = row.drop(1) } serie_hash + end + + def ascending? hsh + hsh.keys == hsh.keys.sort end end end