diff --git a/lib/uplot/command.rb b/lib/uplot/command.rb index 7241b34..89683a1 100644 --- a/lib/uplot/command.rb +++ b/lib/uplot/command.rb @@ -247,6 +247,7 @@ module Uplot input.freeze @raw_inputs << input @data = Preprocessing.input(input, @delimiter, @headers, @transpose) + pp @data if @debug case plot_type when :bar, :barplot Plot.barplot(data, params, @count) diff --git a/lib/uplot/plot.rb b/lib/uplot/plot.rb index 280a2f6..a740cb9 100644 --- a/lib/uplot/plot.rb +++ b/lib/uplot/plot.rb @@ -86,6 +86,7 @@ module Uplot end def lines(data, params, fmt = 'xyy') + check_series_size(data, fmt) case fmt when 'xyy' xyy_plot(data, :lineplot, params) @@ -95,6 +96,7 @@ module Uplot end def scatter(data, params, fmt = 'xyy') + check_series_size(data, fmt) case fmt when 'xyy' xyy_plot(data, :scatterplot, params) @@ -104,6 +106,7 @@ module Uplot end def density(data, params, fmt = 'xyy') + check_series_size(data, fmt) case fmt when 'xyy' xyy_plot(data, :densityplot, params) @@ -119,5 +122,16 @@ module Uplot series.map! { |s| s.map(&:to_f) } UnicodePlot.boxplot(headers, series, **params.to_hc) end + + def check_series_size(data, fmt) + series = data.series + if series.size == 1 + warn "uplot: There is only one series of input data. Please check the delimiter." + warn "" + warn " The first item is: \e[35m\"#{series[0][0]}\"\e[0m" + warn " The last item is : \e[35m\"#{series[0][-1]}\"\e[0m" + exit 1 + end + end end end