mirror of
https://github.com/red-data-tools/YouPlot.git
synced 2025-05-07 23:51:12 +08:00
Improved permeability on pipelines
This commit is contained in:
parent
203e48e0ed
commit
958ce45635
@ -37,17 +37,20 @@ module Uplot
|
|||||||
end
|
end
|
||||||
|
|
||||||
def run
|
def run
|
||||||
input_lines = readlines.map(&:chomp)
|
# Sometimes the input file does not end with a newline code.
|
||||||
case @ptype
|
while input = Kernel.gets(nil)
|
||||||
when 'hist', 'histogram'
|
input_lines = input.split(/\R/)
|
||||||
histogram(input_lines).render
|
case @ptype
|
||||||
when 'line', 'lineplot'
|
when 'hist', 'histogram'
|
||||||
line(input_lines).render
|
histogram(input_lines)
|
||||||
when 'lines'
|
when 'line', 'lineplot'
|
||||||
lines(input_lines).render
|
line(input_lines)
|
||||||
end
|
when 'lines'
|
||||||
|
lines(input_lines)
|
||||||
|
end.render($stderr)
|
||||||
|
|
||||||
puts input_lines if @params[:p]
|
print input if @params[:p]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def histogram(input_lines)
|
def histogram(input_lines)
|
||||||
@ -67,7 +70,7 @@ module Uplot
|
|||||||
|
|
||||||
def lines(input_lines)
|
def lines(input_lines)
|
||||||
n_cols = input_lines[0].split("\t").size
|
n_cols = input_lines[0].split("\t").size
|
||||||
cols = Array.new(n_cols){ [] }
|
cols = Array.new(n_cols) { [] }
|
||||||
input_lines.each_with_index do |row, i|
|
input_lines.each_with_index do |row, i|
|
||||||
row.split("\t").each_with_index do |v, j|
|
row.split("\t").each_with_index do |v, j|
|
||||||
cols[j][i] = v.to_f
|
cols[j][i] = v.to_f
|
||||||
|
Loading…
Reference in New Issue
Block a user