Improved error messages.

This commit is contained in:
kojix2
2020-08-16 13:20:52 +09:00
parent a09a703c33
commit 9d58b1aaf9
2 changed files with 15 additions and 0 deletions

View File

@@ -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