mirror of
https://github.com/red-data-tools/YouPlot.git
synced 2025-05-06 07:10:10 +08:00
Improved error messages.
This commit is contained in:
parent
a09a703c33
commit
9d58b1aaf9
@ -247,6 +247,7 @@ module Uplot
|
|||||||
input.freeze
|
input.freeze
|
||||||
@raw_inputs << input
|
@raw_inputs << input
|
||||||
@data = Preprocessing.input(input, @delimiter, @headers, @transpose)
|
@data = Preprocessing.input(input, @delimiter, @headers, @transpose)
|
||||||
|
pp @data if @debug
|
||||||
case plot_type
|
case plot_type
|
||||||
when :bar, :barplot
|
when :bar, :barplot
|
||||||
Plot.barplot(data, params, @count)
|
Plot.barplot(data, params, @count)
|
||||||
|
@ -86,6 +86,7 @@ module Uplot
|
|||||||
end
|
end
|
||||||
|
|
||||||
def lines(data, params, fmt = 'xyy')
|
def lines(data, params, fmt = 'xyy')
|
||||||
|
check_series_size(data, fmt)
|
||||||
case fmt
|
case fmt
|
||||||
when 'xyy'
|
when 'xyy'
|
||||||
xyy_plot(data, :lineplot, params)
|
xyy_plot(data, :lineplot, params)
|
||||||
@ -95,6 +96,7 @@ module Uplot
|
|||||||
end
|
end
|
||||||
|
|
||||||
def scatter(data, params, fmt = 'xyy')
|
def scatter(data, params, fmt = 'xyy')
|
||||||
|
check_series_size(data, fmt)
|
||||||
case fmt
|
case fmt
|
||||||
when 'xyy'
|
when 'xyy'
|
||||||
xyy_plot(data, :scatterplot, params)
|
xyy_plot(data, :scatterplot, params)
|
||||||
@ -104,6 +106,7 @@ module Uplot
|
|||||||
end
|
end
|
||||||
|
|
||||||
def density(data, params, fmt = 'xyy')
|
def density(data, params, fmt = 'xyy')
|
||||||
|
check_series_size(data, fmt)
|
||||||
case fmt
|
case fmt
|
||||||
when 'xyy'
|
when 'xyy'
|
||||||
xyy_plot(data, :densityplot, params)
|
xyy_plot(data, :densityplot, params)
|
||||||
@ -119,5 +122,16 @@ module Uplot
|
|||||||
series.map! { |s| s.map(&:to_f) }
|
series.map! { |s| s.map(&:to_f) }
|
||||||
UnicodePlot.boxplot(headers, series, **params.to_hc)
|
UnicodePlot.boxplot(headers, series, **params.to_hc)
|
||||||
end
|
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
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user