plotrb 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +19 -0
- data/.rspec +1 -0
- data/.travis.yml +3 -0
- data/Gemfile +2 -0
- data/LICENSE.txt +38 -0
- data/README.rdoc +77 -0
- data/Rakefile +7 -0
- data/examples/arc.rb +31 -0
- data/examples/area.rb +48 -0
- data/examples/bar.rb +44 -0
- data/examples/barley.rb +66 -0
- data/examples/choropleth.rb +48 -0
- data/examples/lifelines.rb +106 -0
- data/examples/scatter.rb +43 -0
- data/lib/plotrb.rb +25 -0
- data/lib/plotrb/axes.rb +208 -0
- data/lib/plotrb/base.rb +193 -0
- data/lib/plotrb/data.rb +232 -0
- data/lib/plotrb/kernel.rb +136 -0
- data/lib/plotrb/legends.rb +168 -0
- data/lib/plotrb/marks.rb +459 -0
- data/lib/plotrb/scales.rb +346 -0
- data/lib/plotrb/simple.rb +197 -0
- data/lib/plotrb/transforms.rb +592 -0
- data/lib/plotrb/version.rb +3 -0
- data/lib/plotrb/visualization.rb +55 -0
- data/plotrb.gemspec +27 -0
- data/spec/plotrb/axes_spec.rb +227 -0
- data/spec/plotrb/base_spec.rb +321 -0
- data/spec/plotrb/data_spec.rb +258 -0
- data/spec/plotrb/kernel_spec.rb +54 -0
- data/spec/plotrb/legends_spec.rb +157 -0
- data/spec/plotrb/marks_spec.rb +46 -0
- data/spec/plotrb/scales_spec.rb +187 -0
- data/spec/plotrb/simple_spec.rb +61 -0
- data/spec/plotrb/transforms_spec.rb +248 -0
- data/spec/plotrb/visualization_spec.rb +93 -0
- data/spec/plotrb_spec.rb +5 -0
- data/spec/spec_helper.rb +12 -0
- metadata +180 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 1cb130ede17a9ef0b2319d7eb472b67ee2e69faf
|
4
|
+
data.tar.gz: 94c59902102147772878189ef8fbde5f4d688adc
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e144eba4faaa1d534d6359d0e85fd983e90002766bff821a2b20dffbb51bc8cf9410cd1db48606fe264b691bb217decf38946cce9a7c6ccefeae3292788cc1b9
|
7
|
+
data.tar.gz: 462e9b417011f6b2c58dbd10c4a4d3e87e2bfc0978f772e9dc942d43b483d713a12ea40d711f5b55e301feb4fbe8c9b3185c9da11777cbd01b68c769b7c42108
|
data/.gitignore
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--colour --format documentation
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
This version of Plotrb is licensed under the BSD 2-clause license.
|
2
|
+
|
3
|
+
* http://sciruby.com
|
4
|
+
* http://github.com/sciruby/sciruby/wiki/License
|
5
|
+
|
6
|
+
You *must* read the Contributor Agreement before contributing code to
|
7
|
+
the SciRuby Project. This is available online:
|
8
|
+
|
9
|
+
* http://github.com/sciruby/sciruby/wiki/Contributor-Agreement
|
10
|
+
|
11
|
+
-----
|
12
|
+
|
13
|
+
Copyright (c) 2010 - 2013, Wan Zuhao and the Ruby Science Foundation
|
14
|
+
All rights reserved.
|
15
|
+
|
16
|
+
Redistribution and use in source and binary forms, with or without
|
17
|
+
modification, are permitted provided that the following conditions are
|
18
|
+
met:
|
19
|
+
|
20
|
+
* Redistributions of source code must retain the above copyright notice,
|
21
|
+
this list of conditions and the following disclaimer.
|
22
|
+
|
23
|
+
* Redistributions in binary form must reproduce the above copyright
|
24
|
+
notice, this list of conditions and the following disclaimer in the
|
25
|
+
documentation and/or other materials provided with the distribution.
|
26
|
+
|
27
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
28
|
+
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
29
|
+
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
30
|
+
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
31
|
+
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
32
|
+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
33
|
+
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
34
|
+
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
35
|
+
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
36
|
+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
37
|
+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
38
|
+
|
data/README.rdoc
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
= Plotrb
|
2
|
+
|
3
|
+
Vega/D3-based plotting gem for Ruby
|
4
|
+
|
5
|
+
* {sciruby.com}[http://sciruby.com]
|
6
|
+
* {Google+}[https://plus.google.com/109304769076178160953/posts]
|
7
|
+
* {Wan Zuhao}[http://www.wanzuhao.com]
|
8
|
+
* {Examples on bl.ocks.org}[http://bl.ocks.org/zuhao]
|
9
|
+
|
10
|
+
{<img src=https://travis-ci.org/zuhao/plotrb.png>}[https://travis-ci.org/zuhao/plotrb]
|
11
|
+
|
12
|
+
== Description
|
13
|
+
|
14
|
+
Plotrb is an experimental plotting library for the Ruby language. It
|
15
|
+
brings {the simplicity of Vega}[http://trifacta.github.io/vega/] and
|
16
|
+
{the power of D3}[http://d3js.org/] to the Ruby science community, to
|
17
|
+
allow for {fast, customizable design; reusability and shareability; programmatic generation of visualizations; and improved performance and platform flexibility}[https://github.com/trifacta/vega/wiki/Vega-and-D3].
|
18
|
+
|
19
|
+
Plotrb is in many ways the child of
|
20
|
+
{Rubyvis}[http://github.com/SciRuby/rubyvis] (the Ruby port of
|
21
|
+
Protovis). However, it improves upon Rubyvis in that it uses a DSL that
|
22
|
+
will be much more familiar and natural to Ruby coders.
|
23
|
+
|
24
|
+
Plotrb was created by Wan Zuhao as part of Google's Summer of Code 2013.
|
25
|
+
It is part of {SciRuby}[http://sciruby.com].
|
26
|
+
|
27
|
+
== Installation
|
28
|
+
|
29
|
+
Add this line to your application's Gemfile:
|
30
|
+
|
31
|
+
gem 'plotrb'
|
32
|
+
|
33
|
+
And then execute:
|
34
|
+
|
35
|
+
bundle
|
36
|
+
|
37
|
+
Or install it yourself as:
|
38
|
+
|
39
|
+
gem install plotrb
|
40
|
+
|
41
|
+
== Usage
|
42
|
+
|
43
|
+
Currently, Plotrb is intended to generate JSON specification for Vega. If you would like to see the visualization rendered in PNG or SVG, you will have to install {Vega}[https://github.com/trifacta/vega] and use its {Headless Mode}[https://github.com/trifacta/vega/wiki/Headless-Mode].
|
44
|
+
|
45
|
+
Note that Plotrb is a work in progress, so we can't guarantee that every
|
46
|
+
example will work exactly.
|
47
|
+
|
48
|
+
* {Arc}[http://bl.ocks.org/zuhao/6663966]
|
49
|
+
* {Area}[http://bl.ocks.org/zuhao/6663999]
|
50
|
+
* {Bar}[http://bl.ocks.org/zuhao/6662333]
|
51
|
+
* {Barley}[http://bl.ocks.org/zuhao/6664828]
|
52
|
+
* {Lifelines}[http://bl.ocks.org/zuhao/6664107]
|
53
|
+
|
54
|
+
Examples may also be found in the `examples/` directory.
|
55
|
+
|
56
|
+
== Contributing
|
57
|
+
|
58
|
+
1. Fork it
|
59
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
60
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
61
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
62
|
+
5. Create new Pull Request
|
63
|
+
|
64
|
+
== License
|
65
|
+
|
66
|
+
Copyright (c) 2013, Wan Zuhao and the Ruby Science Foundation.
|
67
|
+
|
68
|
+
All rights reserved.
|
69
|
+
|
70
|
+
Plotrb, along with SciRuby, is licensed under the BSD 2-clause license. See
|
71
|
+
{LICENSE.txt}[https://github.com/SciRuby/sciruby/wiki/License] for details.
|
72
|
+
|
73
|
+
== Donations
|
74
|
+
|
75
|
+
Support a SciRuby Fellow:
|
76
|
+
|
77
|
+
{<img src=http://pledgie.com/campaigns/15783.png?skin_name=chrome>}[http://www.pledgie.com/campaigns/15783]
|
data/Rakefile
ADDED
data/examples/arc.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'plotrb'
|
2
|
+
|
3
|
+
data = pdata.name('table').values([12,23,47,6,52,19]).transform(pie_transform)
|
4
|
+
|
5
|
+
scale = sqrt_scale.name('r').from(data).to([20,100])
|
6
|
+
|
7
|
+
mark = arc_mark.from(data) do
|
8
|
+
enter do
|
9
|
+
x_start { group(:width).times(0.5) }
|
10
|
+
y_start { group(:height).times(0.5) }
|
11
|
+
start_angle { from :start_angle }
|
12
|
+
end_angle { from :end_angle }
|
13
|
+
inner_radius 20
|
14
|
+
outer_radius { scale(scale) }
|
15
|
+
stroke '#fff'
|
16
|
+
end
|
17
|
+
update do
|
18
|
+
fill '#ccc'
|
19
|
+
end
|
20
|
+
hover do
|
21
|
+
fill 'pink'
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
vis = visualization.name('arc').width(400).height(400) do
|
26
|
+
data data
|
27
|
+
scales scale
|
28
|
+
marks mark
|
29
|
+
end
|
30
|
+
|
31
|
+
puts vis.generate_spec(:pretty)
|
data/examples/area.rb
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
require './lib/plotrb.rb'
|
2
|
+
|
3
|
+
data = pdata.name('table').values(
|
4
|
+
[
|
5
|
+
{x: 1, y: 28}, {x: 2, y: 55},
|
6
|
+
{x: 3, y: 43}, {x: 4, y: 91},
|
7
|
+
{x: 5, y: 81}, {x: 6, y: 53},
|
8
|
+
{x: 7, y: 19}, {x: 8, y: 87},
|
9
|
+
{x: 9, y: 52}, {x: 10, y: 48},
|
10
|
+
{x: 11, y: 24}, {x: 12, y: 49},
|
11
|
+
{x: 13, y: 87}, {x: 14, y: 66},
|
12
|
+
{x: 15, y: 17}, {x: 16, y: 27},
|
13
|
+
{x: 17, y: 68}, {x: 18, y: 16},
|
14
|
+
{x: 19, y: 49}, {x: 20, y: 15}
|
15
|
+
]
|
16
|
+
)
|
17
|
+
|
18
|
+
xs = linear_scale.name('x').from('table.x').to_width.exclude_zero
|
19
|
+
ys = linear_scale.name('y').from('table.y').to_height.nicely
|
20
|
+
|
21
|
+
xa = x_axis.scale(xs).ticks(20)
|
22
|
+
ya = y_axis.scale(ys)
|
23
|
+
|
24
|
+
mark = area_mark.from(data) do
|
25
|
+
enter do
|
26
|
+
interpolate :monotone
|
27
|
+
x_start {from('x').scale(xs)}
|
28
|
+
y_start {from('y').scale(ys)}
|
29
|
+
y_end {value(0).scale(ys)}
|
30
|
+
fill 'steelblue'
|
31
|
+
end
|
32
|
+
update do
|
33
|
+
fill_opacity 1
|
34
|
+
end
|
35
|
+
hover do
|
36
|
+
fill_opacity 0.5
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
vis = visualization.name('area').width(500).height(200) do
|
41
|
+
padding :top => 10, :left => 30, :bottom => 30, :right => 10
|
42
|
+
data data
|
43
|
+
scales xs, ys
|
44
|
+
axes xa, ya
|
45
|
+
marks mark
|
46
|
+
end
|
47
|
+
|
48
|
+
puts vis.generate_spec(:pretty)
|
data/examples/bar.rb
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'plotrb'
|
2
|
+
|
3
|
+
data = pdata.name('table').values(
|
4
|
+
[
|
5
|
+
{x: 1, y: 28}, {x: 2, y: 55},
|
6
|
+
{x: 3, y: 43}, {x: 4, y: 91},
|
7
|
+
{x: 5, y: 81}, {x: 6, y: 53},
|
8
|
+
{x: 7, y: 19}, {x: 8, y: 87},
|
9
|
+
{x: 9, y: 52}, {x: 10, y: 48},
|
10
|
+
{x: 11, y: 24}, {x: 12, y: 49},
|
11
|
+
{x: 13, y: 87}, {x: 14, y: 66},
|
12
|
+
{x: 15, y: 17}, {x: 16, y: 27},
|
13
|
+
{x: 17, y: 68}, {x: 18, y: 16},
|
14
|
+
{x: 19, y: 49}, {x: 20, y: 15}
|
15
|
+
]
|
16
|
+
)
|
17
|
+
|
18
|
+
xs = ordinal_scale.name('x').from('table.x').to_width
|
19
|
+
ys = linear_scale.name('y').from('table.y').nicely.to_height
|
20
|
+
|
21
|
+
mark = rect_mark.from(data) do
|
22
|
+
enter do
|
23
|
+
x_start { scale(xs).from('x') }
|
24
|
+
width { scale(xs).offset(-1).use_band }
|
25
|
+
y_start { scale(ys).from('y') }
|
26
|
+
y_end { scale(ys).value(0) }
|
27
|
+
end
|
28
|
+
update do
|
29
|
+
fill 'steelblue'
|
30
|
+
end
|
31
|
+
hover do
|
32
|
+
fill 'red'
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
vis = visualization.width(400).height(200) do
|
37
|
+
padding top: 10, left: 30, bottom: 30, right: 10
|
38
|
+
data data
|
39
|
+
scales xs, ys
|
40
|
+
marks mark
|
41
|
+
axes x_axis.scale(xs), y_axis.scale(ys)
|
42
|
+
end
|
43
|
+
|
44
|
+
puts vis.generate_spec(:pretty)
|
data/examples/barley.rb
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
require './lib/plotrb.rb'
|
2
|
+
|
3
|
+
raw_data = pdata.name('barley').url('barley_data.json')
|
4
|
+
variety = pdata.name('variety').source('barley').transform [
|
5
|
+
facet_transform.keys('variety'),
|
6
|
+
stats_transform.value('yield').median,
|
7
|
+
sort_transform.by('-median')
|
8
|
+
]
|
9
|
+
site = pdata.name('site').source('barley').transform [
|
10
|
+
facet_transform.keys('site'),
|
11
|
+
stats_transform.value('yield').median,
|
12
|
+
sort_transform.by('-median')
|
13
|
+
]
|
14
|
+
|
15
|
+
gs = ordinal_scale.name('g').padding(0.15).from('site.key').to_height
|
16
|
+
xs = linear_scale.name('x').from('barley.yield').to_width.nicely
|
17
|
+
cs = ordinal_scale.name('c').to_colors
|
18
|
+
ys = ordinal_scale.name('y').from('variety.key').to_height.as_points.padding(1.2)
|
19
|
+
xaxis = x_axis.scale(xs).offset(-12)
|
20
|
+
yaxis = y_axis.scale(ys).tick_size(0) do
|
21
|
+
properties(:axis) { stroke :transparent }
|
22
|
+
end
|
23
|
+
|
24
|
+
|
25
|
+
tm = text_mark.from(site) do
|
26
|
+
enter do
|
27
|
+
x { group(:width).times(0.5) }
|
28
|
+
y { scale(gs).field(:key).offset(-2) }
|
29
|
+
font_weight :bold
|
30
|
+
text { field(:key) }
|
31
|
+
align :center
|
32
|
+
baseline :bottom
|
33
|
+
fill '#000'
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
sm = symbol_mark.enter do
|
38
|
+
x { scale(xs).field('yield') }
|
39
|
+
y { scale(ys).field('variety') }
|
40
|
+
size 50
|
41
|
+
stroke { scale(cs).field('year') }
|
42
|
+
stroke_width 2
|
43
|
+
end
|
44
|
+
|
45
|
+
gm = group_mark.from(site) do
|
46
|
+
scales ys
|
47
|
+
axes yaxis
|
48
|
+
marks sm
|
49
|
+
enter do
|
50
|
+
x 0.5
|
51
|
+
y { scale(gs).field(:key) }
|
52
|
+
height { scale(gs).use_band }
|
53
|
+
width { group(:width) }
|
54
|
+
stroke '#ccc'
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
vis = visualization.width(200).height(720) do
|
59
|
+
data raw_data, variety, site
|
60
|
+
scales gs, cs, xs, ys
|
61
|
+
axes xaxis
|
62
|
+
marks tm, gm
|
63
|
+
end
|
64
|
+
|
65
|
+
puts vis.generate_spec(:pretty)
|
66
|
+
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require './lib/plotrb.rb'
|
2
|
+
|
3
|
+
ump_data = pdata.name('unemp') do
|
4
|
+
url('unemployment.tsv')
|
5
|
+
format(:tsv) { parse :rate => :number }
|
6
|
+
end
|
7
|
+
cty_data = pdata.name('counties') do
|
8
|
+
url('us-10m.json')
|
9
|
+
format(:topojson) { feature 'counties' }
|
10
|
+
transform [
|
11
|
+
geopath_transform.projection(:albersUsa),
|
12
|
+
zip_transform.with('unemp').match('id').against('id').as('value').default(nil),
|
13
|
+
filter_transform.test('d.path!=null && d.value!=null')
|
14
|
+
]
|
15
|
+
end
|
16
|
+
|
17
|
+
cs = quantize_scale.name('color').from([0, 0.15]).to(
|
18
|
+
[
|
19
|
+
"#f7fbff",
|
20
|
+
"#deebf7",
|
21
|
+
"#c6dbef",
|
22
|
+
"#9ecae1",
|
23
|
+
"#6baed6",
|
24
|
+
"#4292c6",
|
25
|
+
"#2171b5",
|
26
|
+
"#08519c",
|
27
|
+
"#08306b"
|
28
|
+
])
|
29
|
+
|
30
|
+
mark = path_mark.from(cty_data) do
|
31
|
+
enter do
|
32
|
+
path { from 'path' }
|
33
|
+
end
|
34
|
+
update do
|
35
|
+
fill { scale(cs).from('value.data.rate') }
|
36
|
+
end
|
37
|
+
hover do
|
38
|
+
fill 'red'
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
vis = visualization.width(960).height(500) do
|
43
|
+
data ump_data, cty_data
|
44
|
+
scales cs
|
45
|
+
marks mark
|
46
|
+
end
|
47
|
+
|
48
|
+
puts vis.generate_spec(:pretty)
|
@@ -0,0 +1,106 @@
|
|
1
|
+
require './lib/plotrb.rb'
|
2
|
+
|
3
|
+
people = pdata.name('people').values(
|
4
|
+
[
|
5
|
+
{"label" => "Washington",
|
6
|
+
"born" => -7506057600000,
|
7
|
+
"died" => -5366196000000,
|
8
|
+
"enter" => -5701424400000,
|
9
|
+
"leave" => -5453884800000},
|
10
|
+
{"label" => "Adams",
|
11
|
+
"born" => -7389766800000,
|
12
|
+
"died" => -4528285200000,
|
13
|
+
"enter" => -5453884800000,
|
14
|
+
"leave" => -5327740800000},
|
15
|
+
{"label" => "Jefferson",
|
16
|
+
"born" => -7154586000000,
|
17
|
+
"died" => -4528285200000,
|
18
|
+
"enter" => -5327740800000,
|
19
|
+
"leave" => -5075280000000},
|
20
|
+
{"label" => "Madison",
|
21
|
+
"born" => -6904544400000,
|
22
|
+
"died" => -4213184400000,
|
23
|
+
"enter" => -5075280000000,
|
24
|
+
"leave" => -4822819200000},
|
25
|
+
{"label" => "Monroe",
|
26
|
+
"born" => -6679904400000,
|
27
|
+
"died" => -4370518800000,
|
28
|
+
"enter" => -4822819200000,
|
29
|
+
"leave" => -4570358400000}
|
30
|
+
]
|
31
|
+
)
|
32
|
+
|
33
|
+
events = pdata.name('events') do
|
34
|
+
format(:json) { parse 'when' => :date }
|
35
|
+
values [
|
36
|
+
{"name" => "Decl. of Independence", "when" => "July 4, 1776"},
|
37
|
+
{"name" => "U.S. Constitution", "when" => "3/4/1789"},
|
38
|
+
{"name" => "Louisiana Purchase", "when" => "April 30, 1803"},
|
39
|
+
{"name" => "Monroe Doctrine", "when" => "Dec 2, 1823"}
|
40
|
+
]
|
41
|
+
end
|
42
|
+
|
43
|
+
y_scale = ordinal_scale.name('y').from('people.label').to_height
|
44
|
+
x_scale = time_scale.name('x').from(['people.born', 'people.died']).to_width.round.in_years
|
45
|
+
|
46
|
+
events_mark_t = text_mark.from(events) do
|
47
|
+
enter do
|
48
|
+
x_start { scale(x_scale).from('when') }
|
49
|
+
y_start -10
|
50
|
+
angle -25
|
51
|
+
fill '#000'
|
52
|
+
text { from 'name' }
|
53
|
+
font 'Helvetica Neue'
|
54
|
+
font_size 10
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
events_mark_r = rect_mark.from(events) do
|
59
|
+
enter do
|
60
|
+
x_start { scale(x_scale).from('when') }
|
61
|
+
y_start -8
|
62
|
+
width 1
|
63
|
+
height { group(:height).offset(8) }
|
64
|
+
fill '#888'
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
people_mark_t = text_mark.from(people) do
|
69
|
+
enter do
|
70
|
+
x_start { scale(x_scale).from('born') }
|
71
|
+
y_start { scale(y_scale).from('label').offset(-3) }
|
72
|
+
fill '#000'
|
73
|
+
text { from('label') }
|
74
|
+
font 'Helvetica Neue'
|
75
|
+
font_size 10
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
people_mark_r = rect_mark.from(people) do
|
80
|
+
enter do
|
81
|
+
x_start { scale(x_scale).from('born') }
|
82
|
+
x_end { scale(x_scale).from('died') }
|
83
|
+
y_start { scale(y_scale).from('label') }
|
84
|
+
height 2
|
85
|
+
fill '#557'
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
people_mark_r2 = rect_mark.from(people) do
|
90
|
+
enter do
|
91
|
+
x_start { scale(x_scale).from('enter') }
|
92
|
+
x_end { scale(x_scale).from('leave') }
|
93
|
+
y_start { scale(y_scale).from('label').offset(-1) }
|
94
|
+
height 4
|
95
|
+
fill '#e44'
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
vis = visualization.name('lifelines').width(400).height(100) do
|
100
|
+
data people, events
|
101
|
+
scales x_scale, y_scale
|
102
|
+
axes x_axis.scale('x')
|
103
|
+
marks events_mark_t, events_mark_r, people_mark_t, people_mark_r, people_mark_r2
|
104
|
+
end
|
105
|
+
|
106
|
+
puts vis.generate_spec(:pretty)
|