rubyvis 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. data.tar.gz.sig +0 -0
  2. data/History.txt +3 -0
  3. data/Manifest.txt +44 -0
  4. data/README.txt +64 -0
  5. data/Rakefile +16 -0
  6. data/examples/crimea-line.rb +64 -0
  7. data/examples/first.rb +17 -0
  8. data/examples/second.rb +14 -0
  9. data/lib/rubyvis.rb +43 -0
  10. data/lib/rubyvis/color/color.rb +241 -0
  11. data/lib/rubyvis/color/colors.rb +40 -0
  12. data/lib/rubyvis/color/ramp.rb +0 -0
  13. data/lib/rubyvis/format.rb +19 -0
  14. data/lib/rubyvis/format/date.rb +18 -0
  15. data/lib/rubyvis/format/number.rb +31 -0
  16. data/lib/rubyvis/internals.rb +215 -0
  17. data/lib/rubyvis/javascript_behaviour.rb +64 -0
  18. data/lib/rubyvis/label.rb +0 -0
  19. data/lib/rubyvis/mark.rb +528 -0
  20. data/lib/rubyvis/mark/anchor.rb +22 -0
  21. data/lib/rubyvis/mark/area.rb +34 -0
  22. data/lib/rubyvis/mark/bar.rb +23 -0
  23. data/lib/rubyvis/mark/label.rb +17 -0
  24. data/lib/rubyvis/mark/line.rb +14 -0
  25. data/lib/rubyvis/mark/panel.rb +87 -0
  26. data/lib/rubyvis/mark/rule.rb +28 -0
  27. data/lib/rubyvis/scale.rb +34 -0
  28. data/lib/rubyvis/scale/linear.rb +5 -0
  29. data/lib/rubyvis/scale/ordinal.rb +52 -0
  30. data/lib/rubyvis/scale/quantitative.rb +263 -0
  31. data/lib/rubyvis/scene/svg_bar.rb +31 -0
  32. data/lib/rubyvis/scene/svg_label.rb +51 -0
  33. data/lib/rubyvis/scene/svg_panel.rb +117 -0
  34. data/lib/rubyvis/scene/svg_rule.rb +29 -0
  35. data/lib/rubyvis/scene/svg_scene.rb +118 -0
  36. data/lib/rubyvis/sceneelement.rb +44 -0
  37. data/lib/rubyvis/transform.rb +25 -0
  38. data/spec/internal_spec.rb +146 -0
  39. data/spec/javascript_behaviour_spec.rb +64 -0
  40. data/spec/panel_spec.rb +8 -0
  41. data/spec/scale_linear_spec.rb +121 -0
  42. data/spec/scale_spec.rb +8 -0
  43. data/spec/spec.opts +3 -0
  44. data/spec/spec_helper.rb +27 -0
  45. metadata +160 -0
  46. metadata.gz.sig +2 -0
data.tar.gz.sig ADDED
Binary file
data/History.txt ADDED
@@ -0,0 +1,3 @@
1
+ === 0.1.0 / 2010-09-30
2
+
3
+ * First (barely) operational version. See examples/first.rb and examples/second.rb
data/Manifest.txt ADDED
@@ -0,0 +1,44 @@
1
+ History.txt
2
+ Manifest.txt
3
+ README.txt
4
+ Rakefile
5
+ examples/crimea-line.rb
6
+ examples/first.rb
7
+ examples/second.rb
8
+ lib/rubyvis.rb
9
+ lib/rubyvis/color/color.rb
10
+ lib/rubyvis/color/colors.rb
11
+ lib/rubyvis/color/ramp.rb
12
+ lib/rubyvis/format.rb
13
+ lib/rubyvis/format/date.rb
14
+ lib/rubyvis/format/number.rb
15
+ lib/rubyvis/internals.rb
16
+ lib/rubyvis/javascript_behaviour.rb
17
+ lib/rubyvis/label.rb
18
+ lib/rubyvis/mark.rb
19
+ lib/rubyvis/mark/anchor.rb
20
+ lib/rubyvis/mark/area.rb
21
+ lib/rubyvis/mark/bar.rb
22
+ lib/rubyvis/mark/label.rb
23
+ lib/rubyvis/mark/line.rb
24
+ lib/rubyvis/mark/panel.rb
25
+ lib/rubyvis/mark/rule.rb
26
+ lib/rubyvis/scale.rb
27
+ lib/rubyvis/scale/linear.rb
28
+ lib/rubyvis/scale/ordinal.rb
29
+ lib/rubyvis/scale/quantitative.rb
30
+ lib/rubyvis/scene/svg_bar.rb
31
+ lib/rubyvis/scene/svg_label.rb
32
+ lib/rubyvis/scene/svg_panel.rb
33
+ lib/rubyvis/scene/svg_rule.rb
34
+ lib/rubyvis/scene/svg_scene.rb
35
+ lib/rubyvis/sceneelement.rb
36
+ lib/rubyvis/transform.rb
37
+ spec/internal_spec.rb
38
+ spec/javascript_behaviour_spec.rb
39
+ spec/panel_spec.rb
40
+ spec/scale_linear_spec.rb
41
+ spec/scale_spec.rb
42
+ spec/spec.opts
43
+ spec/spec_helper.rb
44
+ vendor/protovis
data/README.txt ADDED
@@ -0,0 +1,64 @@
1
+ = protoruby
2
+
3
+ * http://github.com/clbustos/rubyvis
4
+
5
+ == DESCRIPTION:
6
+
7
+ Ruby version of Protovis, a great visualization toolkit
8
+
9
+ == FEATURES/PROBLEMS:
10
+
11
+ NOTE: Barely operational version. Just have bars, panels and scene.
12
+
13
+ I try to maintain, when posible, complete compatibility with Javascript API. Johnson [http://github.com/jbarnette/johnson] - the lovely Javascript wrapper inside Ruby embrace - is out friend.
14
+
15
+ Until version 0.1.0, lambdas should always should created explicitly for method you may be temted to call it with a block.
16
+ On a second stage, traditional block calling could be using maintaining backwards compatibily with Javascript API,
17
+ User could use +pv+ freely, cause is defined as a global method which call Rubyvis.
18
+
19
+ == CURRENT PROGRESS
20
+
21
+ * pv.js
22
+ * pv-internals.js
23
+ * color/Color.js (incomplete)
24
+ * color/Colors.js
25
+ * data/Arrays.js
26
+ * data/Numbers.js
27
+ * data/Scale.js
28
+ * data/LinearScale.js
29
+ * data/QuantitativeScale.js (only numbers)
30
+ * data/OrdinalScale.js (not tested)
31
+ * mark/Mark.js
32
+ * mark/Bar.js
33
+ * mark/Panel.js
34
+ * scene/SvgPanel.js
35
+ * scene/SvgBar.js
36
+ * scene/SvgScene.js
37
+ * text/Format.js (incomplete)
38
+ * text/NumberFormat.js (incomplete)
39
+
40
+ == SYNOPSIS:
41
+
42
+ require 'rubyvis'
43
+
44
+ vis = Rubyvis::Panel.new.width(150).height(150);
45
+ vis.add(pv.Bar).data([1, 1.2, 1.7, 1.5, 0.7, 0.3]).
46
+ width(20).
47
+ height(lambda {|d| d * 80}).
48
+ bottom(0).
49
+ left(lambda {self.index * 25});
50
+ vis.render()
51
+ # All elements are rendered inside tag 'canvas', inside the panel
52
+ puts vis.canvas.elements[1]
53
+
54
+ == REQUIREMENTS:
55
+
56
+ Ruby 1.9.1
57
+
58
+ == INSTALL:
59
+
60
+ Copy from github and create the gem for yourself (sorry)
61
+
62
+ == LICENSE:
63
+
64
+ GPL-2
data/Rakefile ADDED
@@ -0,0 +1,16 @@
1
+ # -*- ruby -*-
2
+ $:.unshift(File.dirname(__FILE__)+"/lib")
3
+ require 'rubygems'
4
+ require 'hoe'
5
+ require 'rubyvis'
6
+
7
+ Hoe.plugin :git
8
+ Hoe.spec 'rubyvis' do
9
+ self.testlib=:rspec
10
+ self.test_globs="spec/*_spec.rb"
11
+ # self.rubyforge_name = 'rubyvis'
12
+ self.developer('Claudio Bustos', 'clbustos_at_gmail.com')
13
+ self.version=Rubyvis::VERSION
14
+ end
15
+
16
+ # vim: syntax=ruby
@@ -0,0 +1,64 @@
1
+ $:.unshift(File.dirname(__FILE__)+"/../lib")
2
+ require 'rubyvis'
3
+ causes = ["wounds", "other", "disease"];
4
+
5
+ crimea = [
6
+ { date: "4/1854", wounds: 0, other: 110, disease: 110 },
7
+ { date: "5/1854", wounds: 0, other: 95, disease: 105 },
8
+ { date: "6/1854", wounds: 0, other: 40, disease: 95 },
9
+ { date: "7/1854", wounds: 0, other: 140, disease: 520 },
10
+ { date: "8/1854", wounds: 20, other: 150, disease: 800 },
11
+ { date: "9/1854", wounds: 220, other: 230, disease: 740 },
12
+ { date: "10/1854", wounds: 305, other: 310, disease: 600 },
13
+ { date: "11/1854", wounds: 480, other: 290, disease: 820 },
14
+ { date: "12/1854", wounds: 295, other: 310, disease: 1100 },
15
+ { date: "1/1855", wounds: 230, other: 460, disease: 1440 },
16
+ { date: "2/1855", wounds: 180, other: 520, disease: 1270 },
17
+ { date: "3/1855", wounds: 155, other: 350, disease: 935 },
18
+ { date: "4/1855", wounds: 195, other: 195, disease: 560 },
19
+ { date: "5/1855", wounds: 180, other: 155, disease: 550 },
20
+ { date: "6/1855", wounds: 330, other: 130, disease: 650 },
21
+ { date: "7/1855", wounds: 260, other: 130, disease: 430 },
22
+ { date: "8/1855", wounds: 290, other: 110, disease: 490 },
23
+ { date: "9/1855", wounds: 355, other: 100, disease: 290 },
24
+ { date: "10/1855", wounds: 135, other: 95, disease: 245 },
25
+ { date: "11/1855", wounds: 100, other: 140, disease: 325 },
26
+ { date: "12/1855", wounds: 40, other: 120, disease: 215 },
27
+ { date: "1/1856", wounds: 0, other: 160, disease: 160 },
28
+ { date: "2/1856", wounds: 0, other: 100, disease: 100 },
29
+ { date: "3/1856", wounds: 0, other: 125, disease: 90 }
30
+ ];
31
+ format = pv.Format.date("%m/%y");
32
+ crimea=crimea.map {|d| d[:date] = format.parse(d[:date]); d}
33
+
34
+
35
+
36
+
37
+ w = 545
38
+ h = 280
39
+ x = pv.Scale.linear(crimea, lambda {|d| d[:date]}).range(0, w)
40
+ y = pv.Scale.linear(0, 1500).range(0, h)
41
+
42
+ fill = pv.colors("lightpink", "darkgray", "lightblue")
43
+ format = pv.Format.date("%b")
44
+
45
+ vis = pv.Panel.new()
46
+ .width(w)
47
+ .height(h)
48
+ .margin(19.5)
49
+ .right(40);
50
+
51
+ vis.add(pv.Panel)
52
+ .data(causes)
53
+ .add(pv.Line)
54
+ .data(crimea)
55
+ .left(lambda {|d| x.scale(d.date)})
56
+ .bottom(lambda {|d,t| y.scale(d[t])})
57
+ .strokeStyle(fill.by(pv.parent))
58
+ .lineWidth(3);
59
+
60
+ vis.add(pv.Label).data(x.ticks()).left(x).bottom(0).text_baseline("top").text_margin(5).text(pv.Format.date("%b"));
61
+
62
+ vis.add(pv.Rule).data(y.ticks()).bottom(y).stroke_style(lambda {|i| i ? "#ccc" : "black"}).anchor("right").add(pv.Label).visible(lambda {!(self.index & 1)}).textMargin(6);
63
+
64
+ vis.render()
data/examples/first.rb ADDED
@@ -0,0 +1,17 @@
1
+ $:.unshift(File.dirname(__FILE__)+"/../lib")
2
+ require 'rubyvis'
3
+ vis = Rubyvis::Panel.new.width(150).height(150);
4
+
5
+ vis.add(pv.Bar).data([1, 1.2, 1.7, 1.5, 0.7, 0.3]).
6
+ width(20).
7
+ height(lambda {|d| d * 80}).
8
+ bottom(0).
9
+ left(lambda {self.index * 25});
10
+
11
+
12
+ =begin
13
+ Should generate this
14
+ <svg height="150" width="150" stroke-width="1.5" stroke="none" fill="none" font-family="sans-serif" font-size="10px"><g><rect fill="rgb(31,119,180)" height="80" width="20" y="70"></rect><rect fill="rgb(31,119,180)" height="96" width="20" y="54" x="25"></rect><rect fill="rgb(31,119,180)" height="136" width="20" y="14" x="50"></rect><rect fill="rgb(31,119,180)" height="120" width="20" y="30" x="75"></rect><rect fill="rgb(31,119,180)" height="56" width="20" y="94" x="100"></rect><rect fill="rgb(31,119,180)" height="24" width="20" y="126" x="125"></rect></g></svg>
15
+ =end
16
+ vis.render()
17
+ puts vis.canvas.elements[1]
@@ -0,0 +1,14 @@
1
+ $:.unshift(File.dirname(__FILE__)+"/../lib")
2
+ require 'rubyvis'
3
+
4
+ vis = pv.Panel.new().width(150).height(150);
5
+
6
+ vis.add(pv.Rule).data(pv.range(0, 2, 0.5)).bottom(lambda {|d| d * 80 + 0.5}).add(pv.Label)
7
+
8
+
9
+ vis.add(pv.Bar).data([1, 1.2, 1.7, 1.5, 0.7]).width(20).height(lambda {|d| d * 80}).bottom(0).left(lambda { self.index * 25 + 25}).anchor("bottom").add(pv.Label)
10
+
11
+ vis.render();
12
+ puts vis.canvas
13
+
14
+ # <svg height="150" width="150" stroke-width="1.5" stroke="none" fill="none" font-family="sans-serif" font-size="10px"><g><line stroke-width="1" stroke="rgb(0,0,0)" y2="149.5" x2="150" y1="149.5" x1="0" shape-rendering="crispEdges"></line><line stroke-width="1" stroke="rgb(0,0,0)" y2="109.5" x2="150" y1="109.5" x1="0" shape-rendering="crispEdges"></line><line stroke-width="1" stroke="rgb(0,0,0)" y2="69.5" x2="150" y1="69.5" x1="0" shape-rendering="crispEdges"></line><line stroke-width="1" stroke="rgb(0,0,0)" y2="29.5" x2="150" y1="29.5" x1="0" shape-rendering="crispEdges"></line></g><g><text fill="rgb(0,0,0)" transform="translate(75, 149.5)" y="-3" x="3" pointer-events="none">0</text><text fill="rgb(0,0,0)" transform="translate(75, 109.5)" y="-3" x="3" pointer-events="none">0.5</text><text fill="rgb(0,0,0)" transform="translate(75, 69.5)" y="-3" x="3" pointer-events="none">1</text><text fill="rgb(0,0,0)" transform="translate(75, 29.5)" y="-3" x="3" pointer-events="none">1.5</text></g><g><rect fill="rgb(31,119,180)" height="80" width="20" y="70" x="25"></rect><rect fill="rgb(31,119,180)" height="96" width="20" y="54" x="50"></rect><rect fill="rgb(31,119,180)" height="136" width="20" y="14" x="75"></rect><rect fill="rgb(31,119,180)" height="120" width="20" y="30" x="100"></rect><rect fill="rgb(31,119,180)" height="56" width="20" y="94" x="125"></rect></g><g><text text-anchor="middle" fill="rgb(0,0,0)" transform="translate(35, 150)" y="-3" pointer-events="none">1</text><text text-anchor="middle" fill="rgb(0,0,0)" transform="translate(60, 150)" y="-3" pointer-events="none">1.2</text><text text-anchor="middle" fill="rgb(0,0,0)" transform="translate(85, 150)" y="-3" pointer-events="none">1.7</text><text text-anchor="middle" fill="rgb(0,0,0)" transform="translate(110, 150)" y="-3" pointer-events="none">1.5</text><text text-anchor="middle" fill="rgb(0,0,0)" transform="translate(135, 150)" y="-3" pointer-events="none">0.7</text></g></svg>
data/lib/rubyvis.rb ADDED
@@ -0,0 +1,43 @@
1
+ require 'date'
2
+ require 'ostruct'
3
+ require 'rexml/document'
4
+ require 'pp'
5
+ require 'rubyvis/internals'
6
+ require 'rubyvis/sceneelement'
7
+
8
+ require 'rubyvis/javascript_behaviour'
9
+ require 'rubyvis/format'
10
+ require 'rubyvis/label'
11
+ require 'rubyvis/mark'
12
+ require 'rubyvis/scale'
13
+ require 'rubyvis/color/color'
14
+ require 'rubyvis/color/colors'
15
+
16
+ require 'rubyvis/scene/svg_scene'
17
+ require 'rubyvis/transform'
18
+
19
+ def pv
20
+ Rubyvis
21
+ end
22
+
23
+ module Rubyvis
24
+ VERSION = '0.1.0'
25
+ Infinity=1.0 / 0 # You actually can do it! http://snipplr.com/view/2137/uses-for-infinity-in-ruby/
26
+ # :section: basic methods
27
+ def self.identity
28
+ lambda {|x,*args| x}
29
+ end
30
+ def self.index
31
+ lambda {|*args| self.index}
32
+ end
33
+ def self.child
34
+ lambda {|*args| self.child_index}
35
+ end
36
+ def self.parent
37
+ lambda {|*args| self.parent.index}
38
+ end
39
+ def self.document
40
+ @document||=REXML::Document.new
41
+ end
42
+
43
+ end
@@ -0,0 +1,241 @@
1
+ module Rubyvis
2
+ def self.color(format)
3
+ return format.rgb if format.respond_to? :rgb
4
+ if (format =~/([a-z]+)\((.*)\)/)
5
+ m2 = $2.split(",")
6
+ a = 1
7
+ if ['hsla','rgba'].include? $1
8
+ a = m2[3].to_f
9
+ return Color.transparent if (a==0)
10
+ end
11
+
12
+ if ['hsla','hsl'].include? $1
13
+ h=m2[0].to_f
14
+ s=m2[0].to_f.quo(100)
15
+ l=m2[0].to_f.quo(100)
16
+ return Color::Hsl.new(h,s,l,a).rgb()
17
+ end
18
+
19
+ if ['rgba','rgb'].include? $1
20
+ parse=lambda {|c|
21
+ f=c.to_f
22
+ return (c[c.size-1]=='%') ? (f*2.55).round : f
23
+ }
24
+ r=parse.call(m2[0])
25
+ g=parse.call(m2[1])
26
+ b=parse.call(m2[2])
27
+ return Rubyvis.rgb(r,g,b,a)
28
+ end
29
+ end
30
+
31
+ named = Rubyvis::Color.names[format];
32
+ return named if (named)
33
+
34
+ # Hexadecimal colors: #rgb and #rrggbb. */
35
+ if (format[0,1]== "#")
36
+ if (format.size == 4)
37
+ r = format[1,1]; r += r
38
+ f = format[2,1]; g +=g
39
+ b = format[3,1]; b +=b
40
+ elsif (format.size == 7)
41
+ r = format[1,2]
42
+ g = format[3,2]
43
+ b = format[5,2]
44
+ end
45
+ return Rubyvis.rgb(r.to_i(16), g.to_i(16), b.to_i(16), 1);
46
+ end
47
+
48
+ # Otherwise, pass-through unsupported colors. */
49
+ return Rubyvis::Color.new(format, 1);
50
+ end
51
+ def self.rgb(r,g,b,a=1)
52
+ Rubyvis::Color::Rgb.new(r,g,b,a)
53
+ end
54
+
55
+ class Color
56
+ attr_reader :color, :opacity
57
+ def initialize(color,opacity)
58
+ @color=color
59
+ @opacity=opacity
60
+ end
61
+
62
+
63
+ def self.names
64
+ {
65
+ :aliceblue=>"#f0f8ff",
66
+ :antiquewhite=>"#faebd7",
67
+ :aqua=>"#00ffff",
68
+ :aquamarine=>"#7fffd4",
69
+ :azure=>"#f0ffff",
70
+ :beige=>"#f5f5dc",
71
+ :bisque=>"#ffe4c4",
72
+ :black=>"#000000",
73
+ :blanchedalmond=>"#ffebcd",
74
+ :blue=>"#0000ff",
75
+ :blueviolet=>"#8a2be2",
76
+ :brown=>"#a52a2a",
77
+ :burlywood=>"#deb887",
78
+ :cadetblue=>"#5f9ea0",
79
+ :chartreuse=>"#7fff00",
80
+ :chocolate=>"#d2691e",
81
+ :coral=>"#ff7f50",
82
+ :cornflowerblue=>"#6495ed",
83
+ :cornsilk=>"#fff8dc",
84
+ :crimson=>"#dc143c",
85
+ :cyan=>"#00ffff",
86
+ :darkblue=>"#00008b",
87
+ :darkcyan=>"#008b8b",
88
+ :darkgoldenrod=>"#b8860b",
89
+ :darkgray=>"#a9a9a9",
90
+ :darkgreen=>"#006400",
91
+ :darkgrey=>"#a9a9a9",
92
+ :darkkhaki=>"#bdb76b",
93
+ :darkmagenta=>"#8b008b",
94
+ :darkolivegreen=>"#556b2f",
95
+ :darkorange=>"#ff8c00",
96
+ :darkorchid=>"#9932cc",
97
+ :darkred=>"#8b0000",
98
+ :darksalmon=>"#e9967a",
99
+ :darkseagreen=>"#8fbc8f",
100
+ :darkslateblue=>"#483d8b",
101
+ :darkslategray=>"#2f4f4f",
102
+ :darkslategrey=>"#2f4f4f",
103
+ :darkturquoise=>"#00ced1",
104
+ :darkviolet=>"#9400d3",
105
+ :deeppink=>"#ff1493",
106
+ :deepskyblue=>"#00bfff",
107
+ :dimgray=>"#696969",
108
+ :dimgrey=>"#696969",
109
+ :dodgerblue=>"#1e90ff",
110
+ :firebrick=>"#b22222",
111
+ :floralwhite=>"#fffaf0",
112
+ :forestgreen=>"#228b22",
113
+ :fuchsia=>"#ff00ff",
114
+ :gainsboro=>"#dcdcdc",
115
+ :ghostwhite=>"#f8f8ff",
116
+ :gold=>"#ffd700",
117
+ :goldenrod=>"#daa520",
118
+ :gray=>"#808080",
119
+ :green=>"#008000",
120
+ :greenyellow=>"#adff2f",
121
+ :grey=>"#808080",
122
+ :honeydew=>"#f0fff0",
123
+ :hotpink=>"#ff69b4",
124
+ :indianred=>"#cd5c5c",
125
+ :indigo=>"#4b0082",
126
+ :ivory=>"#fffff0",
127
+ :khaki=>"#f0e68c",
128
+ :lavender=>"#e6e6fa",
129
+ :lavenderblush=>"#fff0f5",
130
+ :lawngreen=>"#7cfc00",
131
+ :lemonchiffon=>"#fffacd",
132
+ :lightblue=>"#add8e6",
133
+ :lightcoral=>"#f08080",
134
+ :lightcyan=>"#e0ffff",
135
+ :lightgoldenrodyellow=>"#fafad2",
136
+ :lightgray=>"#d3d3d3",
137
+ :lightgreen=>"#90ee90",
138
+ :lightgrey=>"#d3d3d3",
139
+ :lightpink=>"#ffb6c1",
140
+ :lightsalmon=>"#ffa07a",
141
+ :lightseagreen=>"#20b2aa",
142
+ :lightskyblue=>"#87cefa",
143
+ :lightslategray=>"#778899",
144
+ :lightslategrey=>"#778899",
145
+ :lightsteelblue=>"#b0c4de",
146
+ :lightyellow=>"#ffffe0",
147
+ :lime=>"#00ff00",
148
+ :limegreen=>"#32cd32",
149
+ :linen=>"#faf0e6",
150
+ :magenta=>"#ff00ff",
151
+ :maroon=>"#800000",
152
+ :mediumaquamarine=>"#66cdaa",
153
+ :mediumblue=>"#0000cd",
154
+ :mediumorchid=>"#ba55d3",
155
+ :mediumpurple=>"#9370db",
156
+ :mediumseagreen=>"#3cb371",
157
+ :mediumslateblue=>"#7b68ee",
158
+ :mediumspringgreen=>"#00fa9a",
159
+ :mediumturquoise=>"#48d1cc",
160
+ :mediumvioletred=>"#c71585",
161
+ :midnightblue=>"#191970",
162
+ :mintcream=>"#f5fffa",
163
+ :mistyrose=>"#ffe4e1",
164
+ :moccasin=>"#ffe4b5",
165
+ :navajowhite=>"#ffdead",
166
+ :navy=>"#000080",
167
+ :oldlace=>"#fdf5e6",
168
+ :olive=>"#808000",
169
+ :olivedrab=>"#6b8e23",
170
+ :orange=>"#ffa500",
171
+ :orangered=>"#ff4500",
172
+ :orchid=>"#da70d6",
173
+ :palegoldenrod=>"#eee8aa",
174
+ :palegreen=>"#98fb98",
175
+ :paleturquoise=>"#afeeee",
176
+ :palevioletred=>"#db7093",
177
+ :papayawhip=>"#ffefd5",
178
+ :peachpuff=>"#ffdab9",
179
+ :peru=>"#cd853f",
180
+ :pink=>"#ffc0cb",
181
+ :plum=>"#dda0dd",
182
+ :powderblue=>"#b0e0e6",
183
+ :purple=>"#800080",
184
+ :red=>"#ff0000",
185
+ :rosybrown=>"#bc8f8f",
186
+ :royalblue=>"#4169e1",
187
+ :saddlebrown=>"#8b4513",
188
+ :salmon=>"#fa8072",
189
+ :sandybrown=>"#f4a460",
190
+ :seagreen=>"#2e8b57",
191
+ :seashell=>"#fff5ee",
192
+ :sienna=>"#a0522d",
193
+ :silver=>"#c0c0c0",
194
+ :skyblue=>"#87ceeb",
195
+ :slateblue=>"#6a5acd",
196
+ :slategray=>"#708090",
197
+ :slategrey=>"#708090",
198
+ :snow=>"#fffafa",
199
+ :springgreen=>"#00ff7f",
200
+ :steelblue=>"#4682b4",
201
+ :tan=>"#d2b48c",
202
+ :teal=>"#008080",
203
+ :thistle=>"#d8bfd8",
204
+ :tomato=>"#ff6347",
205
+ :turquoise=>"#40e0d0",
206
+ :violet=>"#ee82ee",
207
+ :wheat=>"#f5deb3",
208
+ :white=>"#ffffff",
209
+ :whitesmoke=>"#f5f5f5",
210
+ :yellow=>"#ffff00",
211
+ :yellowgreen=>"#9acd32",
212
+ :transparent=>Rubyvis.rgb(0, 0, 0, 0)
213
+ }
214
+ end
215
+ def self.transparent
216
+ Rubyvis.rgb(0,0,0,0)
217
+ end
218
+
219
+
220
+ class Rgb < Color
221
+ def initialize(r,g,b,a)
222
+ @r=r
223
+ @b=b
224
+ @g=g
225
+ @a=a
226
+ @opacity=a
227
+ if @a>0
228
+ @color="rgb(#{r},#{g},#{b})"
229
+ else
230
+ @color="none"
231
+ end
232
+ end
233
+ def rgb
234
+ self
235
+ end
236
+ def to_s
237
+ @color
238
+ end
239
+ end
240
+ end
241
+ end