rubyvis 0.6.1 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.travis.yml +6 -6
- data/Gemfile +1 -1
- data/Gemfile.lock +27 -21
- data/History.txt +10 -0
- data/lib/rubyvis.rb +1 -4
- data/lib/rubyvis/mark/panel.rb +1 -1
- data/lib/rubyvis/scene/svg_line.rb +0 -1
- data/lib/rubyvis/scene/svg_panel.rb +3 -0
- data/lib/rubyvis/scene/svg_rule.rb +0 -1
- data/lib/rubyvis/sceneelement.rb +1 -0
- data/lib/rubyvis/version.rb +6 -0
- data/rubyvis.gemspec +1 -2
- data/spec/anchor_spec.rb +11 -11
- data/spec/area_spec.rb +10 -10
- data/spec/bar_spec.rb +13 -13
- data/spec/color_spec.rb +24 -24
- data/spec/dom_spec.rb +77 -77
- data/spec/dot_spec.rb +3 -3
- data/spec/flatten_spec.rb +2 -2
- data/spec/histogram_spec.rb +5 -5
- data/spec/image_spec.rb +2 -2
- data/spec/internal_spec.rb +58 -58
- data/spec/javascript_behaviour_spec.rb +14 -14
- data/spec/label_spec.rb +9 -9
- data/spec/layout_arc_spec.rb +5 -5
- data/spec/layout_cluster_spec.rb +4 -4
- data/spec/layout_grid_spec.rb +5 -5
- data/spec/layout_horizon_spec.rb +5 -5
- data/spec/layout_indent_spec.rb +3 -3
- data/spec/layout_matrix_spec.rb +6 -6
- data/spec/layout_pack_spec.rb +2 -2
- data/spec/layout_partition_spec.rb +4 -4
- data/spec/layout_stack_spec.rb +11 -11
- data/spec/layout_tree_spec.rb +4 -4
- data/spec/layout_treemap_spec.rb +2 -2
- data/spec/line_spec.rb +14 -14
- data/spec/mark_spec.rb +7 -7
- data/spec/nest_spec.rb +3 -3
- data/spec/panel_spec.rb +10 -10
- data/spec/readme_spec.rb +6 -6
- data/spec/ruby_api_spec.rb +4 -4
- data/spec/rule_spec.rb +3 -3
- data/spec/scale_linear_datetime_spec.rb +23 -23
- data/spec/scale_linear_spec.rb +37 -37
- data/spec/scale_log_spec.rb +28 -28
- data/spec/scale_ordinal_spec.rb +21 -21
- data/spec/scale_spec.rb +2 -2
- data/spec/spec_helper.rb +6 -5
- data/spec/vector_spec.rb +8 -8
- data/spec/wedge_spec.rb +4 -4
- data/web/build_site.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 1bc738ddd37028cbaddb2ee55bd9ff57b05a5786a0b858f386cf11bbe2794bc5
|
4
|
+
data.tar.gz: 4c5badd172bfd35d57409eef36b2538f8a4a7782e0468ea0fc3173bda8c5d1e7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c79254660bab8923c66feac95ea8aa8edc4ccbf5d42d9092e4575f80341df1c0b632edf8d12da5a4fef1bfe53eba060a531d889e1742ba279b5e6799b3fe27e3
|
7
|
+
data.tar.gz: 7555b9d7944701a60ff82dd3ad8f29b4713203fc02db3430d712490f2a59c9d3d180f8f97a62efe8d649f8fc13073739278f51ca61410907e1d6ae55dd44fb4f
|
data/.travis.yml
CHANGED
@@ -2,12 +2,12 @@ language:
|
|
2
2
|
ruby
|
3
3
|
|
4
4
|
rvm:
|
5
|
-
- '1.9
|
6
|
-
- '
|
7
|
-
- '2.
|
8
|
-
- '2.
|
9
|
-
- jruby-
|
5
|
+
- '2.1.9'
|
6
|
+
- '2.2.10'
|
7
|
+
- '2.5.0'
|
8
|
+
- '2.6.0'
|
9
|
+
- 'jruby-head'
|
10
10
|
# - rbx-2.1.1
|
11
11
|
|
12
12
|
script:
|
13
|
-
bundle exec
|
13
|
+
bundle exec rspec
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,37 +1,43 @@
|
|
1
1
|
GEM
|
2
2
|
remote: https://rubygems.org/
|
3
3
|
specs:
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
4
|
+
coderay (1.1.2)
|
5
|
+
diff-lcs (1.3)
|
6
|
+
haml (5.0.4)
|
7
|
+
temple (>= 0.8.0)
|
8
8
|
tilt
|
9
|
-
|
10
|
-
nokogiri (1.
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
rspec-
|
16
|
-
rspec-
|
17
|
-
|
18
|
-
|
19
|
-
|
9
|
+
mini_portile2 (2.4.0)
|
10
|
+
nokogiri (1.9.1)
|
11
|
+
mini_portile2 (~> 2.4.0)
|
12
|
+
nokogiri (1.9.1-java)
|
13
|
+
rake (12.3.2)
|
14
|
+
rspec (3.8.0)
|
15
|
+
rspec-core (~> 3.8.0)
|
16
|
+
rspec-expectations (~> 3.8.0)
|
17
|
+
rspec-mocks (~> 3.8.0)
|
18
|
+
rspec-core (3.8.0)
|
19
|
+
rspec-support (~> 3.8.0)
|
20
|
+
rspec-expectations (3.8.2)
|
20
21
|
diff-lcs (>= 1.2.0, < 2.0)
|
21
|
-
rspec-support (~> 3.
|
22
|
-
rspec-mocks (3.0
|
23
|
-
|
24
|
-
|
25
|
-
|
22
|
+
rspec-support (~> 3.8.0)
|
23
|
+
rspec-mocks (3.8.0)
|
24
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
25
|
+
rspec-support (~> 3.8.0)
|
26
|
+
rspec-support (3.8.0)
|
27
|
+
temple (0.8.0)
|
28
|
+
tilt (2.0.9)
|
26
29
|
|
27
30
|
PLATFORMS
|
31
|
+
java
|
28
32
|
ruby
|
29
33
|
|
30
34
|
DEPENDENCIES
|
31
|
-
RedCloth
|
32
35
|
coderay
|
33
36
|
haml
|
34
37
|
nokogiri
|
35
38
|
rake
|
36
39
|
rspec
|
37
40
|
rspec-mocks
|
41
|
+
|
42
|
+
BUNDLED WITH
|
43
|
+
1.17.2
|
data/History.txt
CHANGED
@@ -1,10 +1,19 @@
|
|
1
|
+
=== 0.7.0 / 2019-01-02
|
2
|
+
|
3
|
+
* Version for API and Protovis version in lib/rubyvis/version.rb
|
4
|
+
* Travis.CI: Updated to jruby-head, ruby 2.5 and 2.6
|
5
|
+
* Added view_box property
|
6
|
+
* Update rspec tests to new style, fix all warnings
|
7
|
+
|
1
8
|
=== 0.6.1 / 2014-08-07
|
9
|
+
|
2
10
|
* Change license to BSD 2-Clause
|
3
11
|
* Merge pull request #19 from pivotal-cloudplanner/master
|
4
12
|
* Added travis and bundler support
|
5
13
|
* Resolved bug #15
|
6
14
|
|
7
15
|
=== 0.6.0 / 2013-07-10
|
16
|
+
|
8
17
|
+ Added support for dashed lines (ex.: stroke_dasharray('9,5,3'))
|
9
18
|
- Raises an exception on log scale when domain includes 0 or negative values
|
10
19
|
|
@@ -28,6 +37,7 @@
|
|
28
37
|
|
29
38
|
|
30
39
|
=== 0.4.1 / 2011-01-26
|
40
|
+
|
31
41
|
* All tests run on ruby 1.8.7. Not all pass, because on ruby<1.9 hash order are not preserved
|
32
42
|
* Removed warnings for Ruby 1.9+
|
33
43
|
* Changed SvgScene.implicit and Color.names with constants
|
data/lib/rubyvis.rb
CHANGED
@@ -4,6 +4,7 @@ require 'rexml/document'
|
|
4
4
|
require 'rexml/formatters/default'
|
5
5
|
|
6
6
|
require 'pp'
|
7
|
+
require 'rubyvis/version'
|
7
8
|
require 'rubyvis/internals'
|
8
9
|
require 'rubyvis/vector'
|
9
10
|
|
@@ -33,10 +34,6 @@ require 'rubyvis/mark/shorcut_methods'
|
|
33
34
|
#
|
34
35
|
module Rubyvis
|
35
36
|
@@nokogiri=nil
|
36
|
-
# Rubyvis version
|
37
|
-
VERSION = '0.6.1'
|
38
|
-
# Protovis API on which current Rubyvis is based
|
39
|
-
PROTOVIS_API_VERSION='3.3'
|
40
37
|
# You actually can do it! http://snipplr.com/view/2137/uses-for-infinity-in-ruby/
|
41
38
|
Infinity=1.0 / 0
|
42
39
|
#
|
data/lib/rubyvis/mark/panel.rb
CHANGED
@@ -43,7 +43,6 @@ module Rubyvis
|
|
43
43
|
"fill-opacity"=> (fill.opacity==0.0) ? nil : fill.opacity,
|
44
44
|
"stroke"=> stroke.color,
|
45
45
|
"stroke-opacity"=> (stroke.opacity==0.0) ? nil : stroke.opacity,
|
46
|
-
"stroke-dasharray"=> s.stroke_dasharray, # strokeDasharray from Jamie Love (protovis mod)
|
47
46
|
"stroke-width"=> (stroke.opacity>0) ? s.line_width / self.scale : nil,
|
48
47
|
"stroke-linejoin"=> s.line_join
|
49
48
|
});
|
@@ -44,6 +44,9 @@ module Rubyvis
|
|
44
44
|
'width'=>s.width+s.left+s.right,
|
45
45
|
'height'=>s.height+s.top+s.bottom
|
46
46
|
})
|
47
|
+
if not s.view_box.nil?
|
48
|
+
g.set_attribute('viewBox', s.view_box)
|
49
|
+
end
|
47
50
|
#g.attributes['width']=s.width+s.left+s.right
|
48
51
|
#g.attributes['height']=s.height+s.top+s.bottom
|
49
52
|
end
|
data/lib/rubyvis/sceneelement.rb
CHANGED
data/rubyvis.gemspec
CHANGED
data/spec/anchor_spec.rb
CHANGED
@@ -4,12 +4,12 @@ describe Rubyvis::Anchor do
|
|
4
4
|
|
5
5
|
it "should have correct properties" do
|
6
6
|
props=[:antialias, :bottom, :cursor, :data, :events, :id, :left, :name, :reverse, :right, :title, :top, :visible].inject({}) {|ac, v| ac[v]=true; ac}
|
7
|
-
Rubyvis::Anchor.properties.
|
7
|
+
expect(Rubyvis::Anchor.properties).to eq(props)
|
8
8
|
end
|
9
9
|
it "should be initialized with an object which respond to parent" do
|
10
10
|
my_mock=double('mark')
|
11
|
-
my_mock.
|
12
|
-
my_mock.
|
11
|
+
allow(my_mock).to receive(:parent)
|
12
|
+
expect(my_mock).to receive(:parent).with(no_args())
|
13
13
|
Rubyvis.Anchor(my_mock)
|
14
14
|
|
15
15
|
end
|
@@ -42,15 +42,15 @@ describe Rubyvis::Anchor do
|
|
42
42
|
end
|
43
43
|
if(true)
|
44
44
|
it "first loop correct" do
|
45
|
-
@data_p1.
|
45
|
+
expect(@data_p1).to eq(@expected_p1)
|
46
46
|
end
|
47
47
|
it "second loop correct" do
|
48
|
-
@data_p2.
|
48
|
+
expect(@data_p2).to eq(@expected_p2)
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
52
52
|
it "label loop correct" do
|
53
|
-
@data_l.
|
53
|
+
expect(@data_l).to eq(@expected_l)
|
54
54
|
end
|
55
55
|
end
|
56
56
|
|
@@ -85,7 +85,7 @@ describe Rubyvis::Anchor do
|
|
85
85
|
expected=[]
|
86
86
|
a1.each {|a| a2.each {|b| expected.push([b,b,a,nil])}}
|
87
87
|
vis.render
|
88
|
-
adatas.
|
88
|
+
expect(adatas).to eq(expected)
|
89
89
|
|
90
90
|
end
|
91
91
|
|
@@ -104,7 +104,7 @@ describe Rubyvis::Anchor do
|
|
104
104
|
@vis.render
|
105
105
|
expected=[]
|
106
106
|
@values.each {|a| @values.each {|b| expected.push([b,b,a,nil])}}
|
107
|
-
datas.
|
107
|
+
expect(datas).to eq(expected)
|
108
108
|
end
|
109
109
|
end
|
110
110
|
it "should render equal to protovis 'anchor.html' example" do
|
@@ -122,7 +122,7 @@ describe Rubyvis::Anchor do
|
|
122
122
|
text("bottom")
|
123
123
|
@vis.render
|
124
124
|
@pv_out=fixture_svg_read("anchor.svg")
|
125
|
-
@vis.to_svg.
|
125
|
+
expect(@vis.to_svg).to have_same_svg_elements(@pv_out)
|
126
126
|
end
|
127
127
|
context "Panel-bar assigment" do
|
128
128
|
before do
|
@@ -140,7 +140,7 @@ describe Rubyvis::Anchor do
|
|
140
140
|
expected=[[1,nil],[2,nil],[3,nil]]
|
141
141
|
@label.text(lambda {|*args| datas.push args})
|
142
142
|
@vis.render
|
143
|
-
datas.
|
143
|
+
expect(datas).to eq(expected)
|
144
144
|
end
|
145
145
|
|
146
146
|
it "should have correct data for two levels of data" do
|
@@ -150,7 +150,7 @@ describe Rubyvis::Anchor do
|
|
150
150
|
%w{a b c}.each {|a| [1,2,3].each {|b| expected.push([b,a])}}
|
151
151
|
@label.text(lambda {|*args| datas.push args})
|
152
152
|
@vis.render
|
153
|
-
datas.
|
153
|
+
expect(datas).to eq(expected)
|
154
154
|
end
|
155
155
|
end
|
156
156
|
end
|
data/spec/area_spec.rb
CHANGED
@@ -4,10 +4,10 @@ describe Rubyvis::Area do
|
|
4
4
|
include Rubyvis::GeneralSpec
|
5
5
|
it "should have correct properties" do
|
6
6
|
props=[:antialias, :bottom, :cursor, :data, :events, :fill_style, :height, :id, :interpolate, :left, :line_width, :reverse, :right, :segmented, :stroke_dasharray, :stroke_style, :tension, :title, :top, :visible, :width].inject({}) {|ac, v| ac[v]=true; ac}
|
7
|
-
Rubyvis::Area.properties.
|
7
|
+
expect(Rubyvis::Area.properties).to eq(props)
|
8
8
|
end
|
9
9
|
it "Rubyvis.Area be the same as Rubyvis::Area" do
|
10
|
-
Rubyvis.Area.
|
10
|
+
expect(Rubyvis.Area).to eql Rubyvis::Area
|
11
11
|
end
|
12
12
|
it "should render equal to protovis 'area-segmented.html' test" do
|
13
13
|
data=Rubyvis.range(0, 6, 0.1).map {|x| Math.sin(x)}
|
@@ -28,7 +28,7 @@ height(lambda {|d| (d + 1) / 2.0 * 200 + 50}).
|
|
28
28
|
fill_style(lambda {|d| "hsl(#{(d + 1) * 180.0},50,50)"})
|
29
29
|
vis.render()
|
30
30
|
pv_out=fixture_svg_read("area_segmented.svg")
|
31
|
-
vis.to_svg.
|
31
|
+
expect(vis.to_svg).to have_same_svg_elements(pv_out)
|
32
32
|
end
|
33
33
|
|
34
34
|
it "should render correctly 'area_interpolation.html' example" do
|
@@ -83,7 +83,7 @@ top(5)
|
|
83
83
|
end
|
84
84
|
vis.render()
|
85
85
|
pv_out=fixture_svg_read("area_interpolation.svg")
|
86
|
-
vis.to_svg.
|
86
|
+
expect(vis.to_svg).to have_same_svg_elements(pv_out)
|
87
87
|
end
|
88
88
|
|
89
89
|
|
@@ -107,38 +107,38 @@ top(5)
|
|
107
107
|
|
108
108
|
doc=Nokogiri::XML(@vis.to_svg)
|
109
109
|
# <svg font-size="10px" font-family="sans-serif" fill="none" stroke="none" stroke-width="1.5" width="200" height="200"><g><path d="M0,180L20,200L20,200L0,200ZM20,200L40,160L40,200L20,200Z" fill="rgb(31,119,180)"/></g></svg>
|
110
|
-
doc.at_xpath("//xmlns:path").
|
110
|
+
expect(doc.at_xpath("//xmlns:path")).to have_path_data_close_to "M0,180L20,200L20,200L0,200ZM20,200L40,160L40,200L20,200Z"
|
111
111
|
end
|
112
112
|
|
113
113
|
|
114
114
|
it "should return correct default (linear) path" do
|
115
115
|
@vis.render
|
116
116
|
doc=Nokogiri::XML(@vis.to_svg)
|
117
|
-
doc.at_xpath("//xmlns:path").
|
117
|
+
expect(doc.at_xpath("//xmlns:path")).to have_path_data_close_to "M0 180L20 160L40 180L60 120L80 180L100 100L100 200L80 200L60 200L40 200L20 200L0 200Z"
|
118
118
|
end
|
119
119
|
it "should return correct path for interpolate=step-before" do
|
120
120
|
@area.interpolate('step-before')
|
121
121
|
@vis.render
|
122
122
|
doc=Nokogiri::XML(@vis.to_svg)
|
123
|
-
doc.at_xpath("//xmlns:path").
|
123
|
+
expect(doc.at_xpath("//xmlns:path")).to have_path_data_close_to "M0 180V160L20 160V180L40 180V120L60 120V180L80 180V100L100 100L100 200H80L80 200H60L60 200H40L40 200H20L20 200H0L0 200Z"
|
124
124
|
end
|
125
125
|
it "should return correct path for interpolate=step-after" do
|
126
126
|
@area.interpolate('step-after')
|
127
127
|
@vis.render
|
128
128
|
doc=Nokogiri::XML(@vis.to_svg)
|
129
|
-
doc.at_xpath("//xmlns:path").
|
129
|
+
expect(doc.at_xpath("//xmlns:path")).to have_path_data_close_to "M0 180H20L20 160H40L40 180H60L60 120H80L80 180H100L100 100L100 200V200L80 200V200L60 200V200L40 200V200L20 200V200L0 200Z"
|
130
130
|
end
|
131
131
|
it "should return correct path for interpolate=basis" do
|
132
132
|
@area.interpolate('basis')
|
133
133
|
@vis.render
|
134
134
|
doc=Nokogiri::XML(@vis.to_svg)
|
135
|
-
doc.at_xpath("//xmlns:path").
|
135
|
+
expect(doc.at_xpath("//xmlns:path")).to have_path_data_close_to "M0 180C0 180 0 180 3.333333333333333 176.66666666666666C6.666666666666666 173.33333333333331 13.333333333333332 166.66666666666666 20 166.66666666666666C26.666666666666664 166.66666666666666 33.33333333333333 173.33333333333331 40 166.66666666666666C46.666666666666664 160 53.33333333333333 140 60 140C66.66666666666666 140 73.33333333333333 160 80 156.66666666666666C86.66666666666666 153.33333333333331 93.33333333333331 126.66666666666666 96.66666666666666 113.33333333333331C99.99999999999999 99.99999999999999 99.99999999999999 99.99999999999999 99.99999999999997 99.99999999999997L100 200C99.99999999999999 199.99999999999997 99.99999999999999 199.99999999999997 96.66666666666664 199.99999999999994C93.33333333333331 199.99999999999997 86.66666666666666 199.99999999999997 80 199.99999999999994C73.33333333333333 199.99999999999997 66.66666666666666 199.99999999999997 59.99999999999999 199.99999999999994C53.33333333333333 199.99999999999997 46.666666666666664 199.99999999999997 40 199.99999999999994C33.33333333333333 199.99999999999997 26.666666666666664 199.99999999999997 20 199.99999999999994C13.333333333333332 199.99999999999997 6.666666666666666 199.99999999999997 3.333333333333333 199.99999999999994C0 199.99999999999997 0 199.99999999999997 0 199.99999999999994Z"
|
136
136
|
end
|
137
137
|
it "should return correct path for interpolate=cardinal" do
|
138
138
|
@area.interpolate('cardinal')
|
139
139
|
@vis.render
|
140
140
|
doc=Nokogiri::XML(@vis.to_svg)
|
141
|
-
doc.at_xpath("//xmlns:path").
|
141
|
+
expect(doc.at_xpath("//xmlns:path")).to have_path_data_close_to "M0 180Q16 160 20 160C26 160 34 186 40 180S54 120 60 120S74 183 80 180Q84 178 100 100L100 200Q84 200 80 200C74 200 66 200 60 200S46 200 40 200S26 200 20 200Q16 200 0 200Z"
|
142
142
|
end
|
143
143
|
end
|
144
144
|
end
|
data/spec/bar_spec.rb
CHANGED
@@ -2,19 +2,19 @@ require File.expand_path(File.dirname(__FILE__)+"/spec_helper.rb")
|
|
2
2
|
describe Rubyvis::Bar do
|
3
3
|
it "should have correct properties" do
|
4
4
|
props=[:antialias, :bottom, :cursor, :data, :events, :fill_style, :height, :id, :left, :line_width, :reverse, :right, :stroke_style, :title, :top, :visible, :width].inject({}) {|ac, v| ac[v]=true; ac}
|
5
|
-
Rubyvis::Bar.properties.
|
5
|
+
expect(Rubyvis::Bar.properties).to eq(props)
|
6
6
|
end
|
7
7
|
it "Rubyvis.Bar be the same as Rubyvis::Bar" do
|
8
|
-
Rubyvis.Bar.
|
8
|
+
expect(Rubyvis.Bar).to eql Rubyvis::Bar
|
9
9
|
end
|
10
10
|
it "should return correct defaults" do
|
11
11
|
props=Rubyvis::Bar.defaults._properties
|
12
|
-
props.size.
|
13
|
-
props[0].name.
|
14
|
-
props[0].value.
|
15
|
-
props[1].name.
|
16
|
-
props[1].value.
|
17
|
-
Rubyvis::Bar.defaults.proto.
|
12
|
+
expect(props.size).to eq(2)
|
13
|
+
expect(props[0].name).to eq(:line_width)
|
14
|
+
expect(props[0].value).to eq(1.5)
|
15
|
+
expect(props[1].name).to eq(:fill_style)
|
16
|
+
expect(props[1].value).to be_instance_of Proc
|
17
|
+
expect(Rubyvis::Bar.defaults.proto).to be_instance_of Rubyvis::Mark
|
18
18
|
|
19
19
|
end
|
20
20
|
context "on a Panel" do
|
@@ -32,7 +32,7 @@ require File.expand_path(File.dirname(__FILE__)+"/spec_helper.rb")
|
|
32
32
|
attribs=doc.xpath("//xmlns:rect").map {|v|
|
33
33
|
[v.attributes['y'].value, v.attributes['height'].value, v.attributes['fill'].value]
|
34
34
|
}
|
35
|
-
attribs.
|
35
|
+
expect(attribs).to eq([["120","80","rgb(31,119,180)"],["40","160","rgb(31,119,180)"]])
|
36
36
|
end
|
37
37
|
|
38
38
|
it "should bould properly with string fill_style" do
|
@@ -40,14 +40,14 @@ require File.expand_path(File.dirname(__FILE__)+"/spec_helper.rb")
|
|
40
40
|
@vis.render
|
41
41
|
s=@vis.to_svg
|
42
42
|
doc=Nokogiri::XML(s)
|
43
|
-
doc.at_xpath("//xmlns:rect").attributes['fill'].value.
|
43
|
+
expect(doc.at_xpath("//xmlns:rect").attributes['fill'].value).to eq('rgb(255,0,0)')
|
44
44
|
end
|
45
45
|
it "should bould properly with pv.color" do
|
46
46
|
@bar.fill_style(pv.color('red'))
|
47
47
|
@vis.render
|
48
48
|
s=@vis.to_svg
|
49
49
|
doc=Nokogiri::XML(s)
|
50
|
-
doc.at_xpath("//xmlns:rect").attributes['fill'].value.
|
50
|
+
expect(doc.at_xpath("//xmlns:rect").attributes['fill'].value).to eq('rgb(255,0,0)')
|
51
51
|
end
|
52
52
|
it "should bould properly with pv.colors" do
|
53
53
|
@bar.fill_style(pv.colors('black','red'))
|
@@ -55,7 +55,7 @@ require File.expand_path(File.dirname(__FILE__)+"/spec_helper.rb")
|
|
55
55
|
s=@vis.to_svg
|
56
56
|
doc=Nokogiri::XML(s)
|
57
57
|
attr=doc.xpath("//xmlns:rect").map {|x| x.attributes['fill'].value}
|
58
|
-
attr.
|
58
|
+
expect(attr).to eq(['rgb(0,0,0)', 'rgb(255,0,0)'])
|
59
59
|
end
|
60
60
|
|
61
61
|
it "should bould propertly with double data" do
|
@@ -68,7 +68,7 @@ require File.expand_path(File.dirname(__FILE__)+"/spec_helper.rb")
|
|
68
68
|
x=v.attributes['x'] ? v.attributes['x'].value : nil
|
69
69
|
[x, v.attributes['y'].value, v.attributes['height'].value]
|
70
70
|
}
|
71
|
-
attribs.
|
71
|
+
expect(attribs).to eq([[nil,"90","10"], ["25","80","20"], [nil,"70","30"], ["25","40","60"]])
|
72
72
|
end
|
73
73
|
|
74
74
|
end
|
data/spec/color_spec.rb
CHANGED
@@ -2,9 +2,9 @@ require File.expand_path(File.dirname(__FILE__)+"/spec_helper.rb")
|
|
2
2
|
describe "Rubyvis color methods" do
|
3
3
|
it "should return correct Rubyvis.ramp" do
|
4
4
|
a=Rubyvis.ramp("white","red")
|
5
|
-
a[0].
|
6
|
-
a[0.5].
|
7
|
-
a[1].
|
5
|
+
expect(a[0]).to eq Rubyvis.color("rgb(255,255,255)")
|
6
|
+
expect(a[0.5]).to eq Rubyvis.color("rgb(255,128,128)")
|
7
|
+
expect(a[1]).to eq Rubyvis.color("rgb(255,0,0)")
|
8
8
|
end
|
9
9
|
|
10
10
|
# <li>#f00 // #rgb
|
@@ -17,39 +17,39 @@ describe "Rubyvis color methods" do
|
|
17
17
|
describe "Rubyvis.color" do
|
18
18
|
|
19
19
|
it "should return correct Rubyvis.color with three hex" do
|
20
|
-
Rubyvis.color("#f97").
|
20
|
+
expect(Rubyvis.color("#f97")).to eq Rubyvis::Color::Rgb.new("ff".to_i(16), "99".to_i(16),"77".to_i(16),1 )
|
21
21
|
end
|
22
22
|
it "should return correct Rubyvis.color with 6 hex" do
|
23
|
-
Rubyvis.color("#f19171").
|
23
|
+
expect(Rubyvis.color("#f19171")).to eq Rubyvis::Color::Rgb.new("f1".to_i(16), "91".to_i(16),"71".to_i(16),1 )
|
24
24
|
end
|
25
25
|
it "should return correct Rubyvis.color rbg() with integers" do
|
26
26
|
r,g,b=rand(255),rand(255),rand(255)
|
27
|
-
Rubyvis.color("rgb(#{r},#{g},#{b})").
|
27
|
+
expect(Rubyvis.color("rgb(#{r},#{g},#{b})")).to eq Rubyvis::Color::Rgb.new(r, g, b,1 )
|
28
28
|
end
|
29
29
|
it "should return correct Rubyvis.color rbga() with integers" do
|
30
30
|
r,g,b,a=rand(255),rand(255),rand(255), rand()
|
31
|
-
Rubyvis.color("rgba(#{r},#{g},#{b},#{a})").
|
31
|
+
expect(Rubyvis.color("rgba(#{r},#{g},#{b},#{a})")).to eq Rubyvis::Color::Rgb.new(r, g, b,"#{a}".to_f )
|
32
32
|
end
|
33
33
|
it "should return correct Rubyvis.color rbg() with percents" do
|
34
34
|
r,g,b=rand(100),rand(100),rand(100)
|
35
|
-
Rubyvis.color("rgb(#{r}%,#{g}%,#{b}%)").
|
35
|
+
expect(Rubyvis.color("rgb(#{r}%,#{g}%,#{b}%)")).to eq Rubyvis::Color::Rgb.new((r*2.55).round, (g*2.55).round, (b*2.55).round,1 )
|
36
36
|
end
|
37
37
|
it "should return correct Rubyvis.color hsl" do
|
38
|
-
Rubyvis.color("hsl(100,50,50)").
|
38
|
+
expect(Rubyvis.color("hsl(100,50,50)")).to eq Rubyvis::Color::Rgb.new(106,191,64,1)
|
39
39
|
|
40
40
|
h,s,l=rand(360),rand(100),rand(100)
|
41
41
|
|
42
|
-
Rubyvis.color("hsl(#{h},#{s},#{l})").
|
42
|
+
expect(Rubyvis.color("hsl(#{h},#{s},#{l})")).to eq Rubyvis::Color::Hsl.new(h,s/100.0,l/100.0,1).rgb
|
43
43
|
end
|
44
44
|
it "should return correct Rubyvis.color hsla" do
|
45
45
|
h,s,l,a=rand(360),rand(100),rand(100), rand()
|
46
|
-
Rubyvis.color("hsla(#{h},#{s},#{l},#{a})").
|
46
|
+
expect(Rubyvis.color("hsla(#{h},#{s},#{l},#{a})")).to eq Rubyvis::Color::Hsl.new(h,s/100.0,l/100.0, "#{a}".to_f).rgb
|
47
47
|
end
|
48
48
|
end
|
49
49
|
describe Rubyvis::Color::Hsl do
|
50
50
|
it "convert some extreme value" do
|
51
|
-
Rubyvis.color("hsl(96,50,50)").
|
52
|
-
Rubyvis.color("hsl(112.5,50.0,50.0)").
|
51
|
+
expect(Rubyvis.color("hsl(96,50,50)")).to eq Rubyvis.color("rgb(115,191,64)")
|
52
|
+
expect(Rubyvis.color("hsl(112.5,50.0,50.0)")).to eq Rubyvis.color("rgb(80,191,64)")
|
53
53
|
|
54
54
|
end
|
55
55
|
end
|
@@ -59,32 +59,32 @@ describe "Rubyvis color methods" do
|
|
59
59
|
@rgb=Rubyvis::Color::Rgb.new(@r,@g,@b,@a)
|
60
60
|
end
|
61
61
|
it "return correct ==" do
|
62
|
-
Rubyvis::Color::Rgb.new(0, 0,0,1 ).
|
62
|
+
expect(Rubyvis::Color::Rgb.new(0, 0,0,1 )).to eq Rubyvis::Color::Rgb.new(0, 0,0,1 )
|
63
63
|
|
64
|
-
Rubyvis::Color::Rgb.new(10, 0,0,1 ).
|
64
|
+
expect(Rubyvis::Color::Rgb.new(10, 0,0,1 )).not_to eq Rubyvis::Color::Rgb.new(0, 0,0,1 )
|
65
65
|
|
66
|
-
Rubyvis::Color::Rgb.new(0, 10,0,1 ).
|
66
|
+
expect(Rubyvis::Color::Rgb.new(0, 10,0,1 )).not_to eq Rubyvis::Color::Rgb.new(0, 0,0,1 )
|
67
67
|
|
68
|
-
Rubyvis::Color::Rgb.new(0, 0,10,1 ).
|
69
|
-
Rubyvis::Color::Rgb.new(0, 0,0,0 ).
|
68
|
+
expect(Rubyvis::Color::Rgb.new(0, 0,10,1 )).not_to eq Rubyvis::Color::Rgb.new(0, 0,0,1 )
|
69
|
+
expect(Rubyvis::Color::Rgb.new(0, 0,0,0 )).not_to eq Rubyvis::Color::Rgb.new(0, 0,0,1 )
|
70
70
|
end
|
71
71
|
it "return correct red()" do
|
72
|
-
@rgb.red(255).
|
72
|
+
expect(@rgb.red(255)).to eq Rubyvis::Color::Rgb.new(255,@g,@b,@a)
|
73
73
|
end
|
74
74
|
it "return correct green()" do
|
75
|
-
@rgb.green(255).
|
75
|
+
expect(@rgb.green(255)).to eq Rubyvis::Color::Rgb.new(@r,255,@b,@a)
|
76
76
|
end
|
77
77
|
it "return correct blue()" do
|
78
|
-
@rgb.blue(255).
|
78
|
+
expect(@rgb.blue(255)).to eq Rubyvis::Color::Rgb.new(@r,@g,255,@a)
|
79
79
|
end
|
80
80
|
it "return correct alpha()" do
|
81
|
-
@rgb.alpha(0.5).
|
81
|
+
expect(@rgb.alpha(0.5)).to eq Rubyvis::Color::Rgb.new(@r,@g,@b,0.5)
|
82
82
|
end
|
83
83
|
it "return correct darker()" do
|
84
|
-
Rubyvis.color("red").darker().
|
84
|
+
expect(Rubyvis.color("red").darker()).to eq Rubyvis::Color::Rgb.new(178,0,0,1)
|
85
85
|
end
|
86
86
|
it "return correct brighter()" do
|
87
|
-
Rubyvis.color("rgb(100,110,120)").brighter().
|
87
|
+
expect(Rubyvis.color("rgb(100,110,120)").brighter()).to eq Rubyvis::Color::Rgb.new(142,157,171,1)
|
88
88
|
end
|
89
89
|
|
90
90
|
end
|