mirror of
https://github.com/red-data-tools/YouPlot.git
synced 2025-09-25 15:58:06 +08:00
Extract case-branching by fmt into another method
This commit is contained in:
@@ -53,7 +53,7 @@ module Uplot
|
|||||||
(method1.to_s + '!').to_sym
|
(method1.to_s + '!').to_sym
|
||||||
end
|
end
|
||||||
|
|
||||||
def xyy_plot(data, method1, params)
|
def plot_xyy(data, method1, params)
|
||||||
headers = data.headers
|
headers = data.headers
|
||||||
series = data.series
|
series = data.series
|
||||||
method2 = get_method2(method1)
|
method2 = get_method2(method1)
|
||||||
@@ -70,7 +70,7 @@ module Uplot
|
|||||||
plot
|
plot
|
||||||
end
|
end
|
||||||
|
|
||||||
def xyxy_plot(data, method1, params)
|
def plot_xyxy(data, method1, params)
|
||||||
headers = data.headers
|
headers = data.headers
|
||||||
series = data.series
|
series = data.series
|
||||||
method2 = get_method2(method1)
|
method2 = get_method2(method1)
|
||||||
@@ -87,34 +87,30 @@ module Uplot
|
|||||||
plot
|
plot
|
||||||
end
|
end
|
||||||
|
|
||||||
def lines(data, params, fmt = 'xyy')
|
def plot_fmt(data, fmt, method1, params)
|
||||||
check_series_size(data, fmt)
|
|
||||||
case fmt
|
case fmt
|
||||||
when 'xyy'
|
when 'xyy'
|
||||||
xyy_plot(data, :lineplot, params)
|
plot_xyy(data, method1, params)
|
||||||
when 'xyxy'
|
when 'xyxy'
|
||||||
xyxy_plot(data, :lineplot, params)
|
plot_xyxy(data, method1, params)
|
||||||
|
else
|
||||||
|
raise "Unknown format: #{fmt}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def lines(data, params, fmt = 'xyy')
|
||||||
|
check_series_size(data, fmt)
|
||||||
|
plot_fmt(data, fmt, :lineplot, params)
|
||||||
|
end
|
||||||
|
|
||||||
def scatter(data, params, fmt = 'xyy')
|
def scatter(data, params, fmt = 'xyy')
|
||||||
check_series_size(data, fmt)
|
check_series_size(data, fmt)
|
||||||
case fmt
|
plot_fmt(data, fmt, :scatterplot, params)
|
||||||
when 'xyy'
|
|
||||||
xyy_plot(data, :scatterplot, params)
|
|
||||||
when 'xyxy'
|
|
||||||
xyxy_plot(data, :scatterplot, params)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def density(data, params, fmt = 'xyy')
|
def density(data, params, fmt = 'xyy')
|
||||||
check_series_size(data, fmt)
|
check_series_size(data, fmt)
|
||||||
case fmt
|
plot_fmt(data, fmt, :densityplot, params)
|
||||||
when 'xyy'
|
|
||||||
xyy_plot(data, :densityplot, params)
|
|
||||||
when 'xyxy'
|
|
||||||
xyxy_plot(data, :densityplot, params)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def boxplot(data, params)
|
def boxplot(data, params)
|
||||||
|
Reference in New Issue
Block a user