mirror of
https://github.com/red-data-tools/YouPlot.git
synced 2025-05-05 22:31:11 +08:00
Add count
This commit is contained in:
parent
50de2bac48
commit
d72c084602
@ -9,6 +9,7 @@ module Uplot
|
||||
@headers = nil
|
||||
@delimiter = "\t"
|
||||
@output = false
|
||||
@count = false
|
||||
parse_options(argv)
|
||||
end
|
||||
|
||||
@ -35,6 +36,7 @@ module Uplot
|
||||
parsers['lineplot'] = parsers['line']
|
||||
parsers['lineplots'] = parsers['lines']
|
||||
parsers['scatterplot'] = parsers['scatter']
|
||||
parsers['bar'] .on('-c', '--count', TrueClass) { |v| @count = v }
|
||||
parsers['barplot'] = parsers['bar']
|
||||
parsers['boxplot'] = parsers['box']
|
||||
parsers.default = nil
|
||||
@ -91,6 +93,7 @@ module Uplot
|
||||
end
|
||||
|
||||
def barplot(data, headers)
|
||||
data = data[0].tally.sort { |a, b| a[1] <=> b[1] }.reverse.transpose if @count
|
||||
@params[:title] ||= headers[1] if headers
|
||||
UnicodePlot.barplot(data[0], data[1].map(&:to_f), **@params)
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user