mirror of
https://github.com/red-data-tools/YouPlot.git
synced 2025-05-06 15:11:12 +08:00
Minor style changes
This commit is contained in:
parent
59f0fdddca
commit
6db2372c29
@ -184,12 +184,17 @@ module Uplot
|
|||||||
end
|
end
|
||||||
|
|
||||||
def preprocess_count(data)
|
def preprocess_count(data)
|
||||||
|
# tally was added in Ruby 2.7
|
||||||
if Enumerable.method_defined? :tally
|
if Enumerable.method_defined? :tally
|
||||||
data[0].tally
|
data[0].tally
|
||||||
else # https://github.com/marcandre/backports tally
|
else
|
||||||
|
# https://github.com/marcandre/backports
|
||||||
data[0].each_with_object(Hash.new(0)) { |item, res| res[item] += 1 }
|
data[0].each_with_object(Hash.new(0)) { |item, res| res[item] += 1 }
|
||||||
.tap { |h| h.default = nil }
|
.tap { |h| h.default = nil }
|
||||||
end.sort { |a, b| a[1] <=> b[1] }.reverse.transpose
|
end
|
||||||
|
.sort { |a, b| a[1] <=> b[1] }
|
||||||
|
.reverse
|
||||||
|
.transpose
|
||||||
end
|
end
|
||||||
|
|
||||||
def barplot(data, headers)
|
def barplot(data, headers)
|
||||||
|
Loading…
Reference in New Issue
Block a user