8000 Made x values compulsory, added stacked option · SciRuby/rubyplot@e89fd2f · GitHub
[go: up one dir, main page]

Skip to content

Commit e89fd2f

Browse files
author
alishdipani
committed
Made x values compulsory, added stacked option
1 parent f101e63 commit e89fd2f

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

lib/rubyplot/artist/plot/area.rb

100644100755
Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,16 @@ class Area < Artist::Plot::Base
66

77
def initialize(*)
88
super
9-
@sort_data = false
9+
@sort_data = true
10+
@fill_opacity = 0.3
1011
end
1112

12-
def data y_values, x_values=[]
13-
x_values = Array.new(y_values.size) { |i| i } if x_values.empty?
14-
y_values.sort! if @sort_data
13+
def stacked(bool)
14+
@fill_opacity = 1 if bool
15+
end
16+
17+
def data x_values, y_values
18+
x_values, y_values = x_values.zip(y_values).sort.transpose if @sort_data
1519
super(x_values, y_values)
1620
end
1721

@@ -22,7 +26,7 @@ def draw
2226
x: x_poly_points,
2327
y: y_poly_points,
2428
color: @data[:color],
25-
fill_opacity: 0.3
29+
fill_opacity: @fill_opacity
2630
).draw
2731
end
2832
end # class Area

0 commit comments

Comments
 (0)
0