a_la_chart 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.
- data/History.txt +4 -0
- data/MIT-LICENSE +20 -0
- data/Manifest.txt +28 -0
- data/README.rdoc +25 -0
- data/Rakefile +25 -0
- data/configs/fusion/3.0/angular.xml.builder +11 -0
- data/configs/fusion/3.0/bar.xml.builder +6 -0
- data/configs/fusion/3.0/column.xml.builder +6 -0
- data/configs/fusion/3.0/inline.html.erb +11 -0
- data/configs/fusion/3.0/line.xml.builder +8 -0
- data/configs/fusion/3.0/pie.xml.builder +6 -0
- data/configs/fusion/config.yml +22 -0
- data/configs/google/1.0/pie.html.erb +2 -0
- data/configs/google/config.yml +4 -0
- data/configs/raphael/1.2/dot.html.erb +20 -0
- data/configs/raphael/1.2/impact.js.erb +437 -0
- data/configs/raphael/1.2/inline.html.erb +7 -0
- data/configs/raphael/config.yml +8 -0
- data/init.rb +1 -0
- data/lib/a_la_chart/a_la_chart.rb +171 -0
- data/lib/a_la_chart/a_la_chart_helper.rb +83 -0
- data/lib/a_la_chart.rb +13 -0
- data/script/console +10 -0
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/test/a_la_chart_test.rb +8 -0
- data/test/test_a_la_chart.rb +11 -0
- data/test/test_helper.rb +3 -0
- metadata +95 -0
data/History.txt
ADDED
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 Mobi
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Manifest.txt
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
History.txt
|
2
|
+
MIT-LICENSE
|
3
|
+
Manifest.txt
|
4
|
+
README.rdoc
|
5
|
+
Rakefile
|
6
|
+
configs/fusion/3.0/angular.xml.builder
|
7
|
+
configs/fusion/3.0/bar.xml.builder
|
8
|
+
configs/fusion/3.0/column.xml.builder
|
9
|
+
configs/fusion/3.0/inline.html.erb
|
10
|
+
configs/fusion/3.0/line.xml.builder
|
11
|
+
configs/fusion/3.0/pie.xml.builder
|
12
|
+
configs/fusion/config.yml
|
13
|
+
configs/google/1.0/pie.html.erb
|
14
|
+
configs/google/config.yml
|
15
|
+
configs/raphael/1.2/dot.html.erb
|
16
|
+
configs/raphael/1.2/impact.js.erb
|
17
|
+
configs/raphael/1.2/inline.html.erb
|
18
|
+
configs/raphael/config.yml
|
19
|
+
init.rb
|
20
|
+
lib/a_la_chart.rb
|
21
|
+
lib/a_la_chart/a_la_chart_helper.rb
|
22
|
+
lib/a_la_chart/a_la_chart.rb
|
23
|
+
script/console
|
24
|
+
script/destroy
|
25
|
+
script/generate
|
26
|
+
test/a_la_chart_test.rb
|
27
|
+
test/test_a_la_chart.rb
|
28
|
+
test/test_helper.rb
|
data/README.rdoc
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
= a_la_chart
|
2
|
+
|
3
|
+
* http://github.com/coderoshi/a_la_chart
|
4
|
+
|
5
|
+
== DESCRIPTION:
|
6
|
+
|
7
|
+
This is a general framework for inserting various type of charting implementations - from grabbing the data, to declaring how those values are mapped to the desired type of chart (pie, line, bar, etc).
|
8
|
+
|
9
|
+
== SUPPORT:
|
10
|
+
|
11
|
+
Note: very much in development
|
12
|
+
|
13
|
+
* Fusion Charts (partial)
|
14
|
+
* Google Charts (partial)
|
15
|
+
* gRaphaël (partial)
|
16
|
+
|
17
|
+
== INSTALL:
|
18
|
+
|
19
|
+
To install this plugin:
|
20
|
+
|
21
|
+
script/plugin install git://github.com/coderoshi/a_la_chart.git
|
22
|
+
|
23
|
+
== LICENSE:
|
24
|
+
|
25
|
+
Copyright (c) 2009 Mobi, released under the MIT license
|
data/Rakefile
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
gem 'hoe', '>= 2.1.0'
|
3
|
+
require 'hoe'
|
4
|
+
require 'fileutils'
|
5
|
+
# require './lib/a_la_chart'
|
6
|
+
|
7
|
+
Hoe.plugin :newgem
|
8
|
+
# Hoe.plugin :website
|
9
|
+
# Hoe.plugin :cucumberfeatures
|
10
|
+
|
11
|
+
# Generate all the Rake tasks
|
12
|
+
# Run 'rake -T' to see list of generated tasks (from gem root directory)
|
13
|
+
$hoe = Hoe.spec 'a_la_chart' do
|
14
|
+
self.developer 'Eric Redmond', 'eric.redmond@gmail.com'
|
15
|
+
self.rubyforge_name = self.name # TODO this is default value
|
16
|
+
# self.extra_deps = [['activesupport','>= 2.0.2']]
|
17
|
+
|
18
|
+
end
|
19
|
+
|
20
|
+
require 'newgem/tasks'
|
21
|
+
Dir['tasks/**/*.rake'].each { |t| load t }
|
22
|
+
|
23
|
+
# TODO - want other tests/tasks run by default? Add them to the list
|
24
|
+
# remove_task :default
|
25
|
+
# task :default => [:spec, :features]
|
@@ -0,0 +1,11 @@
|
|
1
|
+
xml.instruct!
|
2
|
+
xml.chart(chart_options.merge(:upperLimit => params[:upperLimit] || 100, :caption => params[:title])) do
|
3
|
+
xml.colorRange do
|
4
|
+
xml.color :minValue => '0', :maxValue => '2', :code => 'FF654F'
|
5
|
+
xml.color :minValue => '2', :maxValue => '4', :code => 'F6BD0F'
|
6
|
+
xml.color :minValue => '4', :maxValue => '5', :code => '8BBA00'
|
7
|
+
end
|
8
|
+
xml.dials do
|
9
|
+
xml.dial :value => value(data, :value)
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
default: 3.0
|
2
|
+
3.0:
|
3
|
+
angular:
|
4
|
+
data: 'angular.xml.builder'
|
5
|
+
chart_type: AngularGauge
|
6
|
+
inline: 'inline.html.erb'
|
7
|
+
bar:
|
8
|
+
data: 'bar.xml.builder'
|
9
|
+
chart_type: Bar2D
|
10
|
+
inline: 'inline.html.erb'
|
11
|
+
column:
|
12
|
+
data: 'column.xml.builder'
|
13
|
+
chart_type: Column2D
|
14
|
+
inline: 'inline.html.erb'
|
15
|
+
line:
|
16
|
+
data: 'line.xml.builder'
|
17
|
+
chart_type: Line2D
|
18
|
+
inline: 'inline.html.erb'
|
19
|
+
pie:
|
20
|
+
data: 'pie.xml.builder'
|
21
|
+
chart_type: Pie2D
|
22
|
+
inline: 'inline.html.erb'
|
@@ -0,0 +1,20 @@
|
|
1
|
+
<div id="<%= div_id %>" class='dot_chart'></div>
|
2
|
+
<script type="text/javascript" charset="utf-8">
|
3
|
+
<% set_chart(:dot) %>
|
4
|
+
window.onload = function () {
|
5
|
+
var r = Raphael("<%= div_id %>"),
|
6
|
+
xs = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23],
|
7
|
+
ys = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],
|
8
|
+
data = <%= data.inspect %>,
|
9
|
+
axisy = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
|
10
|
+
axisx = ["12a", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12p", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11"];
|
11
|
+
r.g.txtattr.font = "11px 'Fontin Sans', Fontin-Sans, sans-serif";
|
12
|
+
|
13
|
+
r.g.dotchart(10, 10, 620, 260, xs, ys, data, {symbol: "o", max: 10, heat: true, axis: "0 0 1 1", axisxstep: 23, axisystep: 6, axisxlabels: axisx, axisxtype: " ", axisytype: " ", axisylabels: axisy}).hover(function () {
|
14
|
+
this.tag = this.tag || r.g.tag(this.x, this.y, this.value, 0, this.r + 2).insertBefore(this);
|
15
|
+
this.tag.show();
|
16
|
+
}, function () {
|
17
|
+
this.tag && this.tag.hide();
|
18
|
+
});
|
19
|
+
};
|
20
|
+
</script>
|
@@ -0,0 +1,437 @@
|
|
1
|
+
var json =
|
2
|
+
{
|
3
|
+
"max":196419,
|
4
|
+
"buckets":
|
5
|
+
[
|
6
|
+
{
|
7
|
+
"d":1195372800,
|
8
|
+
"i":
|
9
|
+
[
|
10
|
+
[
|
11
|
+
0,
|
12
|
+
196419
|
13
|
+
]
|
14
|
+
]
|
15
|
+
},
|
16
|
+
{
|
17
|
+
"d":1195977600,
|
18
|
+
"i":
|
19
|
+
[
|
20
|
+
[
|
21
|
+
0,
|
22
|
+
10
|
23
|
+
]
|
24
|
+
]
|
25
|
+
},
|
26
|
+
{
|
27
|
+
"d":1197187200
|
28
|
+
|
29
|
+
,
|
30
|
+
"i":
|
31
|
+
[
|
32
|
+
[
|
33
|
+
0,
|
34
|
+
1148
|
35
|
+
],
|
36
|
+
[
|
37
|
+
1,
|
38
|
+
97
|
39
|
+
]
|
40
|
+
]
|
41
|
+
},
|
42
|
+
{
|
43
|
+
"d":1197792000,
|
44
|
+
"i":
|
45
|
+
[
|
46
|
+
[
|
47
|
+
1,
|
48
|
+
156
|
49
|
+
],
|
50
|
+
[
|
51
|
+
0,
|
52
|
+
76
|
53
|
+
]
|
54
|
+
]
|
55
|
+
},
|
56
|
+
{
|
57
|
+
"d":1199606400,
|
58
|
+
"i":
|
59
|
+
[
|
60
|
+
[
|
61
|
+
0,
|
62
|
+
619
|
63
|
+
],
|
64
|
+
[
|
65
|
+
1,
|
66
|
+
120
|
67
|
+
]
|
68
|
+
]
|
69
|
+
}
|
70
|
+
|
71
|
+
|
72
|
+
,
|
73
|
+
{
|
74
|
+
"d":1200816000,
|
75
|
+
"i":
|
76
|
+
[
|
77
|
+
[
|
78
|
+
1,
|
79
|
+
157
|
80
|
+
],
|
81
|
+
[
|
82
|
+
0,
|
83
|
+
85
|
84
|
+
]
|
85
|
+
]
|
86
|
+
},
|
87
|
+
{
|
88
|
+
"d":1201420800,
|
89
|
+
"i":
|
90
|
+
[
|
91
|
+
[
|
92
|
+
1,
|
93
|
+
30
|
94
|
+
]
|
95
|
+
]
|
96
|
+
},
|
97
|
+
{
|
98
|
+
"d":1202025600,
|
99
|
+
"i":
|
100
|
+
[
|
101
|
+
[
|
102
|
+
1,
|
103
|
+
54
|
104
|
+
],
|
105
|
+
[
|
106
|
+
0,
|
107
|
+
2
|
108
|
+
|
109
|
+
|
110
|
+
]
|
111
|
+
]
|
112
|
+
},
|
113
|
+
{
|
114
|
+
"d":1206255600,
|
115
|
+
"i":
|
116
|
+
[
|
117
|
+
[
|
118
|
+
8,
|
119
|
+
6
|
120
|
+
]
|
121
|
+
]
|
122
|
+
},
|
123
|
+
{
|
124
|
+
"d":1206860400,
|
125
|
+
"i":
|
126
|
+
[
|
127
|
+
[
|
128
|
+
8,
|
129
|
+
175
|
130
|
+
],
|
131
|
+
[
|
132
|
+
1,
|
133
|
+
40
|
134
|
+
]
|
135
|
+
]
|
136
|
+
},
|
137
|
+
{
|
138
|
+
"d":1207465200,
|
139
|
+
"i":
|
140
|
+
[
|
141
|
+
[
|
142
|
+
1,
|
143
|
+
114
|
144
|
+
]
|
145
|
+
]
|
146
|
+
|
147
|
+
|
148
|
+
|
149
|
+
},
|
150
|
+
{
|
151
|
+
"d":1208070000,
|
152
|
+
"i":
|
153
|
+
[
|
154
|
+
[
|
155
|
+
0,
|
156
|
+
125
|
157
|
+
],
|
158
|
+
[
|
159
|
+
1,
|
160
|
+
2
|
161
|
+
]
|
162
|
+
]
|
163
|
+
},
|
164
|
+
{
|
165
|
+
"d":1208674800,
|
166
|
+
"i":
|
167
|
+
[
|
168
|
+
[
|
169
|
+
1,
|
170
|
+
41
|
171
|
+
],
|
172
|
+
[
|
173
|
+
0,
|
174
|
+
12
|
175
|
+
]
|
176
|
+
]
|
177
|
+
},
|
178
|
+
{
|
179
|
+
"d":1213513200,
|
180
|
+
"i":
|
181
|
+
[
|
182
|
+
[
|
183
|
+
0,
|
184
|
+
4954
|
185
|
+
|
186
|
+
|
187
|
+
],
|
188
|
+
[
|
189
|
+
1,
|
190
|
+
14
|
191
|
+
]
|
192
|
+
]
|
193
|
+
},
|
194
|
+
{
|
195
|
+
"d":1214118000,
|
196
|
+
"i":
|
197
|
+
[
|
198
|
+
[
|
199
|
+
0,
|
200
|
+
14032
|
201
|
+
],
|
202
|
+
[
|
203
|
+
1,
|
204
|
+
11599
|
205
|
+
],
|
206
|
+
[
|
207
|
+
6,
|
208
|
+
3601
|
209
|
+
],
|
210
|
+
[
|
211
|
+
3,
|
212
|
+
250
|
213
|
+
],
|
214
|
+
[
|
215
|
+
5,
|
216
|
+
201
|
217
|
+
],
|
218
|
+
[
|
219
|
+
7,
|
220
|
+
123
|
221
|
+
]
|
222
|
+
]
|
223
|
+
},
|
224
|
+
{
|
225
|
+
"d":1214722800
|
226
|
+
|
227
|
+
,
|
228
|
+
"i":
|
229
|
+
[
|
230
|
+
[
|
231
|
+
1,
|
232
|
+
52
|
233
|
+
]
|
234
|
+
]
|
235
|
+
},
|
236
|
+
{
|
237
|
+
"d":1215327600,
|
238
|
+
"i":
|
239
|
+
[
|
240
|
+
[
|
241
|
+
1,
|
242
|
+
230
|
243
|
+
]
|
244
|
+
]
|
245
|
+
},
|
246
|
+
{
|
247
|
+
"d":1216537200,
|
248
|
+
"i":
|
249
|
+
[
|
250
|
+
[
|
251
|
+
0,
|
252
|
+
185
|
253
|
+
],
|
254
|
+
[
|
255
|
+
1,
|
256
|
+
75
|
257
|
+
]
|
258
|
+
]
|
259
|
+
},
|
260
|
+
{
|
261
|
+
"d":1217746800,
|
262
|
+
"i"
|
263
|
+
|
264
|
+
:
|
265
|
+
[
|
266
|
+
[
|
267
|
+
1,
|
268
|
+
131
|
269
|
+
]
|
270
|
+
]
|
271
|
+
},
|
272
|
+
{
|
273
|
+
"d":1218351600,
|
274
|
+
"i":
|
275
|
+
[
|
276
|
+
[
|
277
|
+
0,
|
278
|
+
44515
|
279
|
+
],
|
280
|
+
[
|
281
|
+
1,
|
282
|
+
8041
|
283
|
+
],
|
284
|
+
[
|
285
|
+
4,
|
286
|
+
3813
|
287
|
+
],
|
288
|
+
[
|
289
|
+
3,
|
290
|
+
146
|
291
|
+
],
|
292
|
+
[
|
293
|
+
5,
|
294
|
+
127
|
295
|
+
]
|
296
|
+
]
|
297
|
+
},
|
298
|
+
{
|
299
|
+
"d":1218956400,
|
300
|
+
"i":
|
301
|
+
[
|
302
|
+
|
303
|
+
|
304
|
+
|
305
|
+
[
|
306
|
+
2,
|
307
|
+
34
|
308
|
+
]
|
309
|
+
]
|
310
|
+
},
|
311
|
+
{
|
312
|
+
"d":1219561200,
|
313
|
+
"i":
|
314
|
+
[
|
315
|
+
[
|
316
|
+
1,
|
317
|
+
110
|
318
|
+
]
|
319
|
+
]
|
320
|
+
},
|
321
|
+
{
|
322
|
+
"d":1220166000,
|
323
|
+
"i":
|
324
|
+
[
|
325
|
+
[
|
326
|
+
1,
|
327
|
+
333
|
328
|
+
],
|
329
|
+
[
|
330
|
+
0,
|
331
|
+
252
|
332
|
+
],
|
333
|
+
[
|
334
|
+
3,
|
335
|
+
103
|
336
|
+
]
|
337
|
+
]
|
338
|
+
},
|
339
|
+
{
|
340
|
+
"d":1220770800,
|
341
|
+
"i":
|
342
|
+
[
|
343
|
+
[
|
344
|
+
0,
|
345
|
+
2890
|
346
|
+
],
|
347
|
+
[
|
348
|
+
1,
|
349
|
+
462
|
350
|
+
],
|
351
|
+
[
|
352
|
+
3,
|
353
|
+
339
|
354
|
+
],
|
355
|
+
[
|
356
|
+
2,
|
357
|
+
81
|
358
|
+
]
|
359
|
+
]
|
360
|
+
}
|
361
|
+
],
|
362
|
+
"authors":
|
363
|
+
{
|
364
|
+
"5":
|
365
|
+
{
|
366
|
+
"a":262,
|
367
|
+
"c":35,
|
368
|
+
"n":"degan@engineyard.com",
|
369
|
+
"d":66,
|
370
|
+
"u":null
|
371
|
+
},
|
372
|
+
"0":
|
373
|
+
{
|
374
|
+
"a":264862,
|
375
|
+
"c":154,
|
376
|
+
"n":"toolmantim",
|
377
|
+
"d":462,
|
378
|
+
"u":153
|
379
|
+
},
|
380
|
+
"6":
|
381
|
+
{
|
382
|
+
"a":3581,
|
383
|
+
"c":5,
|
384
|
+
"n":"philoye",
|
385
|
+
"d":20,
|
386
|
+
"u":15246
|
387
|
+
},
|
388
|
+
"1":
|
389
|
+
{
|
390
|
+
"a":21317,
|
391
|
+
"c":164,
|
392
|
+
"n":"lachlanhardy",
|
393
|
+
"d":541,
|
394
|
+
"u":3682
|
395
|
+
},
|
396
|
+
"7":
|
397
|
+
{
|
398
|
+
"a":89,
|
399
|
+
"c":6,
|
400
|
+
"n":"joho",
|
401
|
+
"d":34,
|
402
|
+
"u":4092
|
403
|
+
},
|
404
|
+
"2":
|
405
|
+
{
|
406
|
+
"a":89,
|
407
|
+
"c":14,
|
408
|
+
"n":"DylanFM",
|
409
|
+
"d":26,
|
410
|
+
"u":14375
|
411
|
+
},
|
412
|
+
"8":
|
413
|
+
{
|
414
|
+
"a":163,
|
415
|
+
"c":4,
|
416
|
+
"n":"tlucas@tim.local",
|
417
|
+
"d":18,
|
418
|
+
"u":null
|
419
|
+
},
|
420
|
+
"3":
|
421
|
+
{
|
422
|
+
"a":777,
|
423
|
+
"c":22,
|
424
|
+
"n":"lstoll",
|
425
|
+
"d":61,
|
426
|
+
"u":694
|
427
|
+
},
|
428
|
+
"4":
|
429
|
+
{
|
430
|
+
"a":3761,
|
431
|
+
"c":13,
|
432
|
+
"n":"lachie",
|
433
|
+
"d":52,
|
434
|
+
"u":265
|
435
|
+
}
|
436
|
+
}
|
437
|
+
};
|
@@ -0,0 +1,7 @@
|
|
1
|
+
<div id="name2" class="hidden">
|
2
|
+
<div id="legend2"> </div>
|
3
|
+
<div id="username2">legend</div>
|
4
|
+
</div>
|
5
|
+
<div id="placeholder">mouse over the graph for more details</div>
|
6
|
+
<div id="bound-chart"></div>
|
7
|
+
<script src="<%= url %>" type="text/javascript" charset="utf-8"></script>
|
data/init.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'lib', 'a_la_chart')
|
@@ -0,0 +1,171 @@
|
|
1
|
+
module ALaChart
|
2
|
+
|
3
|
+
module HelperMethods
|
4
|
+
def meta
|
5
|
+
@metadata ||= defined?(get_meta) ? get_meta : {}
|
6
|
+
end
|
7
|
+
|
8
|
+
def fields
|
9
|
+
@fields ||= defined?(get_fields) ? get_fields : []
|
10
|
+
end
|
11
|
+
|
12
|
+
def data
|
13
|
+
@data ||= defined?(get_data) ? get_data : []
|
14
|
+
end
|
15
|
+
|
16
|
+
def value(object, key)
|
17
|
+
return '' if object.blank?
|
18
|
+
|
19
|
+
# if there is a meta map, use it. else try the key itself
|
20
|
+
key_field = meta[key] || key
|
21
|
+
|
22
|
+
if key_field.class == Proc
|
23
|
+
val = key_field.call(object)
|
24
|
+
else
|
25
|
+
val = object.respond_to?(key_field) ? object.send(key_field) : nil
|
26
|
+
val = object[key_field] if object.respond_to?('[]')
|
27
|
+
val
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def set_chart(chart_type)
|
32
|
+
send "set_chart_#{chart_type}"
|
33
|
+
end
|
34
|
+
|
35
|
+
def a_la_chart_config
|
36
|
+
unless defined?(@@alachart_config)
|
37
|
+
require 'yaml'
|
38
|
+
|
39
|
+
@@alachart_config = {}
|
40
|
+
Dir.foreach(File.join(File.dirname(__FILE__), '..', '..', 'configs')) do |dir|
|
41
|
+
config_path = File.join(File.dirname(__FILE__), '..', '..', 'configs', dir, 'config.yml')
|
42
|
+
if File.exists?(config_path)
|
43
|
+
@@alachart_config[dir.to_sym] = YAML.load_file(config_path)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
@@alachart_config
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
module InstanceMethods
|
52
|
+
include HelperMethods
|
53
|
+
|
54
|
+
def provide_chart_data
|
55
|
+
chart_make = params[:chart_make]
|
56
|
+
chart_type = params[:id]
|
57
|
+
|
58
|
+
chart_type_config, chart_make_version = nil, nil
|
59
|
+
if !chart_make.nil? && (chart_make_config = a_la_chart_config[chart_make.to_sym])
|
60
|
+
chart_make_version = chart_make_version || chart_make_config['default']
|
61
|
+
chart_make_config = chart_make_config[chart_make_version]
|
62
|
+
chart_type_config = chart_make_config[chart_type.to_s]
|
63
|
+
end
|
64
|
+
|
65
|
+
return if chart_type_config.nil? || !respond_to?("set_chart_#{chart_type}")
|
66
|
+
|
67
|
+
respond_to do |format|
|
68
|
+
# format.html # index.html.erb
|
69
|
+
format.xml { render_style chart_make, chart_type, chart_make_version, chart_type_config }
|
70
|
+
format.js { render_style chart_make, chart_type, chart_make_version, chart_type_config }
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
protected
|
75
|
+
|
76
|
+
def render_style(chart_make, chart_type, chart_make_version=nil, chart_type_config=nil)
|
77
|
+
if chart_type_config.nil?
|
78
|
+
unless !chart_make.nil? && (chart_make_config = a_la_chart_config[chart_make.to_sym])
|
79
|
+
raise "Unknown chart_make. Valid type are: #{a_la_chart_config.keys.map{|v|v.to_sym.inspect}.join(', ')}"
|
80
|
+
end
|
81
|
+
|
82
|
+
chart_make_version = chart_make_version || chart_make_config['default']
|
83
|
+
chart_make_config = chart_make_config[chart_make_version]
|
84
|
+
chart_type_config = chart_make_config[chart_type.to_s]
|
85
|
+
end
|
86
|
+
|
87
|
+
data_template = chart_type_config['data']
|
88
|
+
|
89
|
+
send "set_chart_#{chart_type}"
|
90
|
+
render File.join(File.dirname(__FILE__), '..', '..', 'configs', chart_make.to_s, chart_make_version.to_s, data_template)
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
def self.included(base)
|
95
|
+
base.extend(ClassMethods)
|
96
|
+
end
|
97
|
+
|
98
|
+
module ClassMethods
|
99
|
+
|
100
|
+
def a_la_chart
|
101
|
+
include ALaChart::InstanceMethods
|
102
|
+
|
103
|
+
self.before_filter(:provide_chart_data, :only => [:show])
|
104
|
+
|
105
|
+
# Namespace this stuff??
|
106
|
+
[:data, :fields, :meta, :value, :a_la_chart_config, :set_chart].each do |method|
|
107
|
+
master_helper_module.module_eval <<-end_eval
|
108
|
+
def #{method}(*args, &block) # def current_user(*args, &block)
|
109
|
+
controller.send(%(#{method}), *args, &block) # controller.send(%(current_user), *args, &block)
|
110
|
+
end # end
|
111
|
+
end_eval
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
def chart(*types, &block)
|
116
|
+
for type in types
|
117
|
+
define_method("set_chart_#{type}") do
|
118
|
+
block.call if block
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
def data(&block)
|
124
|
+
define_method("get_data") do
|
125
|
+
# note: instance_eval binds scope variables, call does not
|
126
|
+
instance_eval(&block) || []
|
127
|
+
# block.call(binding)
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
def fields(*attrs)
|
132
|
+
field_ary = attrs.map{|d| d.to_sym }
|
133
|
+
|
134
|
+
define_method("get_fields") do
|
135
|
+
field_ary
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
def meta(*attrs)
|
140
|
+
if attrs.size == 1
|
141
|
+
attrs = attrs[0]
|
142
|
+
if attrs.class == Array
|
143
|
+
descriptions = attrs
|
144
|
+
elsif attrs.class == Hash
|
145
|
+
options = attrs
|
146
|
+
elsif attrs.class == Symbol || attrs.class == String
|
147
|
+
descriptions = [attrs]
|
148
|
+
end
|
149
|
+
elsif attrs.size == 2
|
150
|
+
descriptions = attrs[0]
|
151
|
+
if descriptions.class == Symbol || descriptions.class == String
|
152
|
+
descriptions = [descriptions]
|
153
|
+
end
|
154
|
+
options = attrs[1]
|
155
|
+
elsif attrs.size > 2
|
156
|
+
descriptions = attrs[0...-1]
|
157
|
+
options = attrs[-1]
|
158
|
+
end
|
159
|
+
|
160
|
+
descriptions ||= []
|
161
|
+
options ||= {}
|
162
|
+
|
163
|
+
# descriptions = descriptions.map{|d| d.to_sym }
|
164
|
+
|
165
|
+
define_method("get_meta") do
|
166
|
+
# descriptions
|
167
|
+
options
|
168
|
+
end
|
169
|
+
end
|
170
|
+
end
|
171
|
+
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
module ALaChartHelper
|
2
|
+
require "erb"
|
3
|
+
|
4
|
+
def chart_tag(chart_make, chart_style, args={})
|
5
|
+
width = args[:width] || 400
|
6
|
+
height = args[:height] || 300
|
7
|
+
chart_make_version = args[:version]
|
8
|
+
name = args[:name] || args[:case] || 'chart'
|
9
|
+
url = base_url = args[:base_url] || url_for
|
10
|
+
|
11
|
+
chart_make = chart_make.to_sym
|
12
|
+
|
13
|
+
chart_make_config = a_la_chart_config[chart_make]
|
14
|
+
chart_make_version = chart_make_version || chart_make_config['default']
|
15
|
+
chart_make_config = chart_make_config[chart_make_version]
|
16
|
+
|
17
|
+
chart_type_config = chart_make_config[chart_style.to_s]
|
18
|
+
raise "#{chart_style.to_s} is an unsupported chart style" if chart_type_config.blank?
|
19
|
+
chart_type = chart_type_config['chart_type']
|
20
|
+
chart_type = chart_style.to_s if chart_type.blank?
|
21
|
+
inline_template = chart_type_config['inline']
|
22
|
+
|
23
|
+
append_url = chart_type_config['url']
|
24
|
+
append_url = "#{chart_style.to_s}.xml" if append_url.blank?
|
25
|
+
url += "/#{append_url}?"
|
26
|
+
|
27
|
+
explicit_args = args[:args].present? ? params.merge(args[:args]) : params
|
28
|
+
args.reject!{ |k,v| [:name,:width,:height,:base_url].include?(k) }
|
29
|
+
args.merge!(explicit_args)
|
30
|
+
# Can I do this? Or does it make me look like...
|
31
|
+
args.reject!{ |k,v| ['action','controller'].include?(k) }
|
32
|
+
args[:chart_make] = chart_make
|
33
|
+
|
34
|
+
url += args.to_param
|
35
|
+
|
36
|
+
div_id = "#{name}_#{Time.now.to_f.to_s.gsub('.','_')}"
|
37
|
+
|
38
|
+
inline = ERB.new(File.read(File.join(File.dirname(__FILE__), '..', '..', 'configs', chart_make.to_s, chart_make_version.to_s, inline_template)))
|
39
|
+
inline.result(binding)
|
40
|
+
end
|
41
|
+
|
42
|
+
def color_palette
|
43
|
+
["7BB465","B2B4B6","FEC35A","65A4B5","9E65B5","B57765","F7DF65","8F866C","B6A65F","C99D60","C1727A","8AABB9","65B584"]
|
44
|
+
end
|
45
|
+
|
46
|
+
def next_color
|
47
|
+
@colors ||= color_palette
|
48
|
+
@colors.pop
|
49
|
+
end
|
50
|
+
|
51
|
+
def chart_options
|
52
|
+
{
|
53
|
+
:animation => '1',
|
54
|
+
:showBorder => '0',
|
55
|
+
:canvasBorderThickness => '1',
|
56
|
+
:canvasBorderColor => 'eeeeee',
|
57
|
+
:divLineThickness => '1',
|
58
|
+
:bgAlpha => '0',
|
59
|
+
:useRoundEdges => '0',
|
60
|
+
:alpha => '100',
|
61
|
+
:bgColor => 'ffffff',
|
62
|
+
:shadowXShift=>"1",
|
63
|
+
:shadowYShift=>"1",
|
64
|
+
:shadowAlpha=>"75",
|
65
|
+
# :numberprefix => '$',
|
66
|
+
:showValues => '0',
|
67
|
+
:showSum => '1',
|
68
|
+
:enableSmartLabels => '1',
|
69
|
+
:skipOverlapLabels => '1',
|
70
|
+
:decimalPrecision => "2",
|
71
|
+
:captionPadding => '3',
|
72
|
+
:chartLeftMargin => '0',
|
73
|
+
:formatNumber => '1',
|
74
|
+
:formatNumberScale => '0',
|
75
|
+
:baseFont => 'Helvetica, Arial, sans-serif',
|
76
|
+
:baseFontSize => '11',
|
77
|
+
:baseFontColor => '515151',
|
78
|
+
:showToolTip => '1',
|
79
|
+
:toolTipBgColor => 'ffffff'
|
80
|
+
}
|
81
|
+
end
|
82
|
+
|
83
|
+
end
|
data/lib/a_la_chart.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# module ALaChart
|
2
|
+
# VERSION = '0.0.1'
|
3
|
+
# end
|
4
|
+
# $:.unshift(File.dirname(__FILE__)) unless
|
5
|
+
# $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
|
6
|
+
|
7
|
+
require File.join(File.dirname(__FILE__), 'a_la_chart', 'a_la_chart')
|
8
|
+
require File.join(File.dirname(__FILE__), 'a_la_chart', 'a_la_chart_helper')
|
9
|
+
|
10
|
+
ActionController::Base.class_eval do
|
11
|
+
include ALaChart
|
12
|
+
end
|
13
|
+
ActionView::Base.send :include, ALaChartHelper
|
data/script/console
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# File: script/console
|
3
|
+
irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
|
4
|
+
|
5
|
+
libs = " -r irb/completion"
|
6
|
+
# Perhaps use a console_lib to store any extra methods I may want available in the cosole
|
7
|
+
# libs << " -r #{File.dirname(__FILE__) + '/../lib/console_lib/console_logger.rb'}"
|
8
|
+
libs << " -r #{File.dirname(__FILE__) + '/../lib/a_la_chart.rb'}"
|
9
|
+
puts "Loading a_la_chart gem"
|
10
|
+
exec "#{irb} #{libs} --simple-prompt"
|
data/script/destroy
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'rubigen'
|
6
|
+
rescue LoadError
|
7
|
+
require 'rubygems'
|
8
|
+
require 'rubigen'
|
9
|
+
end
|
10
|
+
require 'rubigen/scripts/destroy'
|
11
|
+
|
12
|
+
ARGV.shift if ['--help', '-h'].include?(ARGV[0])
|
13
|
+
RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
|
14
|
+
RubiGen::Scripts::Destroy.new.run(ARGV)
|
data/script/generate
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'rubigen'
|
6
|
+
rescue LoadError
|
7
|
+
require 'rubygems'
|
8
|
+
require 'rubigen'
|
9
|
+
end
|
10
|
+
require 'rubigen/scripts/generate'
|
11
|
+
|
12
|
+
ARGV.shift if ['--help', '-h'].include?(ARGV[0])
|
13
|
+
RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
|
14
|
+
RubiGen::Scripts::Generate.new.run(ARGV)
|
data/test/test_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,95 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: a_la_chart
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Eric Redmond
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-12-11 00:00:00 -05:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: hoe
|
17
|
+
type: :development
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 2.3.3
|
24
|
+
version:
|
25
|
+
description: This is a general framework for inserting various type of charting implementations - from grabbing the data, to declaring how those values are mapped to the desired type of chart (pie, line, bar, etc).
|
26
|
+
email:
|
27
|
+
- eric.redmond@gmail.com
|
28
|
+
executables: []
|
29
|
+
|
30
|
+
extensions: []
|
31
|
+
|
32
|
+
extra_rdoc_files:
|
33
|
+
- History.txt
|
34
|
+
- Manifest.txt
|
35
|
+
files:
|
36
|
+
- History.txt
|
37
|
+
- MIT-LICENSE
|
38
|
+
- Manifest.txt
|
39
|
+
- README.rdoc
|
40
|
+
- Rakefile
|
41
|
+
- configs/fusion/3.0/angular.xml.builder
|
42
|
+
- configs/fusion/3.0/bar.xml.builder
|
43
|
+
- configs/fusion/3.0/column.xml.builder
|
44
|
+
- configs/fusion/3.0/inline.html.erb
|
45
|
+
- configs/fusion/3.0/line.xml.builder
|
46
|
+
- configs/fusion/3.0/pie.xml.builder
|
47
|
+
- configs/fusion/config.yml
|
48
|
+
- configs/google/1.0/pie.html.erb
|
49
|
+
- configs/google/config.yml
|
50
|
+
- configs/raphael/1.2/dot.html.erb
|
51
|
+
- configs/raphael/1.2/impact.js.erb
|
52
|
+
- configs/raphael/1.2/inline.html.erb
|
53
|
+
- configs/raphael/config.yml
|
54
|
+
- init.rb
|
55
|
+
- lib/a_la_chart.rb
|
56
|
+
- lib/a_la_chart/a_la_chart_helper.rb
|
57
|
+
- lib/a_la_chart/a_la_chart.rb
|
58
|
+
- script/console
|
59
|
+
- script/destroy
|
60
|
+
- script/generate
|
61
|
+
- test/a_la_chart_test.rb
|
62
|
+
- test/test_a_la_chart.rb
|
63
|
+
- test/test_helper.rb
|
64
|
+
has_rdoc: true
|
65
|
+
homepage: http://github.com/coderoshi/a_la_chart
|
66
|
+
licenses: []
|
67
|
+
|
68
|
+
post_install_message:
|
69
|
+
rdoc_options:
|
70
|
+
- --main
|
71
|
+
- README.rdoc
|
72
|
+
require_paths:
|
73
|
+
- lib
|
74
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
75
|
+
requirements:
|
76
|
+
- - ">="
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: "0"
|
79
|
+
version:
|
80
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - ">="
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: "0"
|
85
|
+
version:
|
86
|
+
requirements: []
|
87
|
+
|
88
|
+
rubyforge_project: a_la_chart
|
89
|
+
rubygems_version: 1.3.5
|
90
|
+
signing_key:
|
91
|
+
specification_version: 3
|
92
|
+
summary: This is a general framework for inserting various type of charting implementations - from grabbing the data, to declaring how those values are mapped to the desired type of chart (pie, line, bar, etc).
|
93
|
+
test_files:
|
94
|
+
- test/test_a_la_chart.rb
|
95
|
+
- test/test_helper.rb
|