graphael-rails 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile.lock +41 -6
- data/VERSION +1 -1
- data/graphael-rails.gemspec +7 -47
- metadata +16 -59
- data/vendor/assets/javascripts/g.raphael/README.markdown +0 -21
- data/vendor/assets/javascripts/g.raphael/docs/blueprint-min.png +0 -0
- data/vendor/assets/javascripts/g.raphael/docs/dr-print.css +0 -218
- data/vendor/assets/javascripts/g.raphael/docs/dr.css +0 -404
- data/vendor/assets/javascripts/g.raphael/docs/reference.html +0 -350
- data/vendor/assets/javascripts/g.raphael/docs/reference.js +0 -35
- data/vendor/assets/javascripts/g.raphael/g.bar.js +0 -621
- data/vendor/assets/javascripts/g.raphael/g.dot.js +0 -156
- data/vendor/assets/javascripts/g.raphael/g.line.js +0 -329
- data/vendor/assets/javascripts/g.raphael/g.pie.js +0 -255
- data/vendor/assets/javascripts/g.raphael/g.raphael.js +0 -887
- data/vendor/assets/javascripts/g.raphael/g.raphael.json +0 -9
- data/vendor/assets/javascripts/g.raphael/min/g.bar-min.js +0 -7
- data/vendor/assets/javascripts/g.raphael/min/g.dot-min.js +0 -7
- data/vendor/assets/javascripts/g.raphael/min/g.line-min.js +0 -7
- data/vendor/assets/javascripts/g.raphael/min/g.pie-min.js +0 -1
- data/vendor/assets/javascripts/g.raphael/min/g.raphael-min.js +0 -7
- data/vendor/assets/javascripts/g.raphael/raphael-min.js +0 -9
- data/vendor/assets/javascripts/g.raphael/test/barchart.html +0 -37
- data/vendor/assets/javascripts/g.raphael/test/barchart2.html +0 -51
- data/vendor/assets/javascripts/g.raphael/test/brightness.html +0 -47
- data/vendor/assets/javascripts/g.raphael/test/css/demo-print.css +0 -17
- data/vendor/assets/javascripts/g.raphael/test/css/demo.css +0 -21
- data/vendor/assets/javascripts/g.raphael/test/dotchart.html +0 -35
- data/vendor/assets/javascripts/g.raphael/test/images/bg.png +0 -0
- data/vendor/assets/javascripts/g.raphael/test/images/bgbg.png +0 -0
- data/vendor/assets/javascripts/g.raphael/test/linechart.html +0 -66
- data/vendor/assets/javascripts/g.raphael/test/piechart.html +0 -26
- data/vendor/assets/javascripts/g.raphael/test/piechart2.html +0 -46
- data/vendor/assets/javascripts/g.raphael/test/tooltips.html +0 -85
- data/vendor/assets/javascripts/raphael/README.markdown +0 -3
- data/vendor/assets/javascripts/raphael/history.md +0 -82
- data/vendor/assets/javascripts/raphael/license.txt +0 -21
- data/vendor/assets/javascripts/raphael/make +0 -45
- data/vendor/assets/javascripts/raphael/raphael-min.js +0 -10
- data/vendor/assets/javascripts/raphael/raphael.core.js +0 -5189
- data/vendor/assets/javascripts/raphael/raphael.js +0 -5815
- data/vendor/assets/javascripts/raphael/raphael.svg.js +0 -1360
- data/vendor/assets/javascripts/raphael/raphael.vml.js +0 -973
- data/vendor/assets/javascripts/raphael/reference.html +0 -2489
- data/vendor/assets/javascripts/raphael/reference.js +0 -248
@@ -1,35 +0,0 @@
|
|
1
|
-
Raphael(function () {
|
2
|
-
var grad = {
|
3
|
-
stroke: "#fff",
|
4
|
-
fill: "0-#c9de96-#8ab66b:44-#398235"
|
5
|
-
},
|
6
|
-
fill = {
|
7
|
-
stroke: "#fff",
|
8
|
-
fill: "#ff0000",
|
9
|
-
"stroke-width": 2
|
10
|
-
};
|
11
|
-
|
12
|
-
function prepare(id) {
|
13
|
-
var div = document.getElementById(id);
|
14
|
-
div.style.cssText = "display:block;float:right;padding:10px;width:99px;height:99px;background:#2C53B0 url(./blueprint-min.png) no-repeat";
|
15
|
-
return Raphael(div, 99, 99);
|
16
|
-
}
|
17
|
-
|
18
|
-
prepare("Element.popup-extra").circle(50, 50, 5).attr(grad).popup();
|
19
|
-
prepare("Element.tag-extra").circle(50, 50, 15).attr(grad).tag(60);
|
20
|
-
prepare("Element.drop-extra").circle(50, 50, 8).attr(grad).drop(60);
|
21
|
-
prepare("Element.flag-extra").circle(50, 50, 10).attr(grad).flag(60);
|
22
|
-
prepare("Element.label-extra").circle(50, 50, 10).attr(grad).label();
|
23
|
-
prepare("Element.blob-extra").circle(50, 50, 8).attr(grad).blob(60);
|
24
|
-
|
25
|
-
prepare("Paper.popup-extra").popup(50, 50, "Hello", 'down');
|
26
|
-
prepare("Paper.tag-extra").tag(50, 50, "$9.99", 60);
|
27
|
-
prepare("Paper.drop-extra").drop(50, 50, "$10", 60);
|
28
|
-
prepare("Paper.flag-extra").flag(50, 50, "$9.99", 60);
|
29
|
-
prepare("Paper.label-extra").label(50, 50, "$9.99");
|
30
|
-
prepare("Paper.blob-extra").blob(50, 50, "Hello", 60);
|
31
|
-
|
32
|
-
prepare("Element.lighter-extra").circle(50, 50, 20).attr(fill).lighter(6);
|
33
|
-
prepare("Element.darker-extra").circle(50, 50, 20).attr(fill).darker(6);
|
34
|
-
prepare("Element.resetBrightness-extra").circle(50, 50, 20).attr(fill).lighter(6).resetBrightness();
|
35
|
-
});
|
@@ -1,621 +0,0 @@
|
|
1
|
-
/*!
|
2
|
-
* g.Raphael 0.5 - Charting library, based on Raphaël
|
3
|
-
*
|
4
|
-
* Copyright (c) 2009 Dmitry Baranovskiy (http://g.raphaeljs.com)
|
5
|
-
* Licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) license.
|
6
|
-
*/
|
7
|
-
(function () {
|
8
|
-
var mmin = Math.min,
|
9
|
-
mmax = Math.max;
|
10
|
-
|
11
|
-
function finger(x, y, width, height, dir, ending, isPath, paper) {
|
12
|
-
var path,
|
13
|
-
ends = { round: 'round', sharp: 'sharp', soft: 'soft', square: 'square' };
|
14
|
-
|
15
|
-
// dir 0 for horizontal and 1 for vertical
|
16
|
-
if ((dir && !height) || (!dir && !width)) {
|
17
|
-
return isPath ? "" : paper.path();
|
18
|
-
}
|
19
|
-
|
20
|
-
ending = ends[ending] || "square";
|
21
|
-
height = Math.round(height);
|
22
|
-
width = Math.round(width);
|
23
|
-
x = Math.round(x);
|
24
|
-
y = Math.round(y);
|
25
|
-
|
26
|
-
switch (ending) {
|
27
|
-
case "round":
|
28
|
-
if (!dir) {
|
29
|
-
var r = ~~(height / 2);
|
30
|
-
|
31
|
-
if (width < r) {
|
32
|
-
r = width;
|
33
|
-
path = [
|
34
|
-
"M", x + .5, y + .5 - ~~(height / 2),
|
35
|
-
"l", 0, 0,
|
36
|
-
"a", r, ~~(height / 2), 0, 0, 1, 0, height,
|
37
|
-
"l", 0, 0,
|
38
|
-
"z"
|
39
|
-
];
|
40
|
-
} else {
|
41
|
-
path = [
|
42
|
-
"M", x + .5, y + .5 - r,
|
43
|
-
"l", width - r, 0,
|
44
|
-
"a", r, r, 0, 1, 1, 0, height,
|
45
|
-
"l", r - width, 0,
|
46
|
-
"z"
|
47
|
-
];
|
48
|
-
}
|
49
|
-
} else {
|
50
|
-
r = ~~(width / 2);
|
51
|
-
|
52
|
-
if (height < r) {
|
53
|
-
r = height;
|
54
|
-
path = [
|
55
|
-
"M", x - ~~(width / 2), y,
|
56
|
-
"l", 0, 0,
|
57
|
-
"a", ~~(width / 2), r, 0, 0, 1, width, 0,
|
58
|
-
"l", 0, 0,
|
59
|
-
"z"
|
60
|
-
];
|
61
|
-
} else {
|
62
|
-
path = [
|
63
|
-
"M", x - r, y,
|
64
|
-
"l", 0, r - height,
|
65
|
-
"a", r, r, 0, 1, 1, width, 0,
|
66
|
-
"l", 0, height - r,
|
67
|
-
"z"
|
68
|
-
];
|
69
|
-
}
|
70
|
-
}
|
71
|
-
break;
|
72
|
-
case "sharp":
|
73
|
-
if (!dir) {
|
74
|
-
var half = ~~(height / 2);
|
75
|
-
|
76
|
-
path = [
|
77
|
-
"M", x, y + half,
|
78
|
-
"l", 0, -height, mmax(width - half, 0), 0, mmin(half, width), half, -mmin(half, width), half + (half * 2 < height),
|
79
|
-
"z"
|
80
|
-
];
|
81
|
-
} else {
|
82
|
-
half = ~~(width / 2);
|
83
|
-
path = [
|
84
|
-
"M", x + half, y,
|
85
|
-
"l", -width, 0, 0, -mmax(height - half, 0), half, -mmin(half, height), half, mmin(half, height), half,
|
86
|
-
"z"
|
87
|
-
];
|
88
|
-
}
|
89
|
-
break;
|
90
|
-
case "square":
|
91
|
-
if (!dir) {
|
92
|
-
path = [
|
93
|
-
"M", x, y + ~~(height / 2),
|
94
|
-
"l", 0, -height, width, 0, 0, height,
|
95
|
-
"z"
|
96
|
-
];
|
97
|
-
} else {
|
98
|
-
path = [
|
99
|
-
"M", x + ~~(width / 2), y,
|
100
|
-
"l", 1 - width, 0, 0, -height, width - 1, 0,
|
101
|
-
"z"
|
102
|
-
];
|
103
|
-
}
|
104
|
-
break;
|
105
|
-
case "soft":
|
106
|
-
if (!dir) {
|
107
|
-
r = mmin(width, Math.round(height / 5));
|
108
|
-
path = [
|
109
|
-
"M", x + .5, y + .5 - ~~(height / 2),
|
110
|
-
"l", width - r, 0,
|
111
|
-
"a", r, r, 0, 0, 1, r, r,
|
112
|
-
"l", 0, height - r * 2,
|
113
|
-
"a", r, r, 0, 0, 1, -r, r,
|
114
|
-
"l", r - width, 0,
|
115
|
-
"z"
|
116
|
-
];
|
117
|
-
} else {
|
118
|
-
r = mmin(Math.round(width / 5), height);
|
119
|
-
path = [
|
120
|
-
"M", x - ~~(width / 2), y,
|
121
|
-
"l", 0, r - height,
|
122
|
-
"a", r, r, 0, 0, 1, r, -r,
|
123
|
-
"l", width - 2 * r, 0,
|
124
|
-
"a", r, r, 0, 0, 1, r, r,
|
125
|
-
"l", 0, height - r,
|
126
|
-
"z"
|
127
|
-
];
|
128
|
-
}
|
129
|
-
}
|
130
|
-
|
131
|
-
if (isPath) {
|
132
|
-
return path.join(",");
|
133
|
-
} else {
|
134
|
-
return paper.path(path);
|
135
|
-
}
|
136
|
-
}
|
137
|
-
|
138
|
-
/*
|
139
|
-
* Vertical Barchart
|
140
|
-
*/
|
141
|
-
function VBarchart(paper, x, y, width, height, values, opts) {
|
142
|
-
opts = opts || {};
|
143
|
-
|
144
|
-
var chartinst = this,
|
145
|
-
type = opts.type || "square",
|
146
|
-
gutter = parseFloat(opts.gutter || "20%"),
|
147
|
-
chart = paper.set(),
|
148
|
-
bars = paper.set(),
|
149
|
-
covers = paper.set(),
|
150
|
-
covers2 = paper.set(),
|
151
|
-
total = Math.max.apply(Math, values),
|
152
|
-
stacktotal = [],
|
153
|
-
multi = 0,
|
154
|
-
colors = opts.colors || chartinst.colors,
|
155
|
-
len = values.length;
|
156
|
-
|
157
|
-
if (Raphael.is(values[0], "array")) {
|
158
|
-
total = [];
|
159
|
-
multi = len;
|
160
|
-
len = 0;
|
161
|
-
|
162
|
-
for (var i = values.length; i--;) {
|
163
|
-
bars.push(paper.set());
|
164
|
-
total.push(Math.max.apply(Math, values[i]));
|
165
|
-
len = Math.max(len, values[i].length);
|
166
|
-
}
|
167
|
-
|
168
|
-
if (opts.stacked) {
|
169
|
-
for (var i = len; i--;) {
|
170
|
-
var tot = 0;
|
171
|
-
|
172
|
-
for (var j = values.length; j--;) {
|
173
|
-
tot +=+ values[j][i] || 0;
|
174
|
-
}
|
175
|
-
|
176
|
-
stacktotal.push(tot);
|
177
|
-
}
|
178
|
-
}
|
179
|
-
|
180
|
-
for (var i = values.length; i--;) {
|
181
|
-
if (values[i].length < len) {
|
182
|
-
for (var j = len; j--;) {
|
183
|
-
values[i].push(0);
|
184
|
-
}
|
185
|
-
}
|
186
|
-
}
|
187
|
-
|
188
|
-
total = Math.max.apply(Math, opts.stacked ? stacktotal : total);
|
189
|
-
}
|
190
|
-
|
191
|
-
total = (opts.to) || total;
|
192
|
-
|
193
|
-
var barwidth = width / (len * (100 + gutter) + gutter) * 100,
|
194
|
-
barhgutter = barwidth * gutter / 100,
|
195
|
-
barvgutter = opts.vgutter == null ? 20 : opts.vgutter,
|
196
|
-
stack = [],
|
197
|
-
X = x + barhgutter,
|
198
|
-
Y = (height - 2 * barvgutter) / total;
|
199
|
-
|
200
|
-
if (!opts.stretch) {
|
201
|
-
barhgutter = Math.round(barhgutter);
|
202
|
-
barwidth = Math.floor(barwidth);
|
203
|
-
}
|
204
|
-
|
205
|
-
!opts.stacked && (barwidth /= multi || 1);
|
206
|
-
|
207
|
-
for (var i = 0; i < len; i++) {
|
208
|
-
stack = [];
|
209
|
-
|
210
|
-
for (var j = 0; j < (multi || 1); j++) {
|
211
|
-
var h = Math.round((multi ? values[j][i] : values[i]) * Y),
|
212
|
-
top = y + height - barvgutter - h,
|
213
|
-
bar = finger(Math.round(X + barwidth / 2), top + h, barwidth, h, true, type, null, paper).attr({ stroke: "none", fill: colors[multi ? j : i] });
|
214
|
-
|
215
|
-
if (multi) {
|
216
|
-
bars[j].push(bar);
|
217
|
-
} else {
|
218
|
-
bars.push(bar);
|
219
|
-
}
|
220
|
-
|
221
|
-
bar.y = top;
|
222
|
-
bar.x = Math.round(X + barwidth / 2);
|
223
|
-
bar.w = barwidth;
|
224
|
-
bar.h = h;
|
225
|
-
bar.value = multi ? values[j][i] : values[i];
|
226
|
-
|
227
|
-
if (!opts.stacked) {
|
228
|
-
X += barwidth;
|
229
|
-
} else {
|
230
|
-
stack.push(bar);
|
231
|
-
}
|
232
|
-
}
|
233
|
-
|
234
|
-
if (opts.stacked) {
|
235
|
-
var cvr;
|
236
|
-
|
237
|
-
covers2.push(cvr = paper.rect(stack[0].x - stack[0].w / 2, y, barwidth, height).attr(chartinst.shim));
|
238
|
-
cvr.bars = paper.set();
|
239
|
-
|
240
|
-
var size = 0;
|
241
|
-
|
242
|
-
for (var s = stack.length; s--;) {
|
243
|
-
stack[s].toFront();
|
244
|
-
}
|
245
|
-
|
246
|
-
for (var s = 0, ss = stack.length; s < ss; s++) {
|
247
|
-
var bar = stack[s],
|
248
|
-
cover,
|
249
|
-
h = (size + bar.value) * Y,
|
250
|
-
path = finger(bar.x, y + height - barvgutter - !!size * .5, barwidth, h, true, type, 1, paper);
|
251
|
-
|
252
|
-
cvr.bars.push(bar);
|
253
|
-
size && bar.attr({path: path});
|
254
|
-
bar.h = h;
|
255
|
-
bar.y = y + height - barvgutter - !!size * .5 - h;
|
256
|
-
covers.push(cover = paper.rect(bar.x - bar.w / 2, bar.y, barwidth, bar.value * Y).attr(chartinst.shim));
|
257
|
-
cover.bar = bar;
|
258
|
-
cover.value = bar.value;
|
259
|
-
size += bar.value;
|
260
|
-
}
|
261
|
-
|
262
|
-
X += barwidth;
|
263
|
-
}
|
264
|
-
|
265
|
-
X += barhgutter;
|
266
|
-
}
|
267
|
-
|
268
|
-
covers2.toFront();
|
269
|
-
X = x + barhgutter;
|
270
|
-
|
271
|
-
if (!opts.stacked) {
|
272
|
-
for (var i = 0; i < len; i++) {
|
273
|
-
for (var j = 0; j < (multi || 1); j++) {
|
274
|
-
var cover;
|
275
|
-
|
276
|
-
covers.push(cover = paper.rect(Math.round(X), y + barvgutter, barwidth, height - barvgutter).attr(chartinst.shim));
|
277
|
-
cover.bar = multi ? bars[j][i] : bars[i];
|
278
|
-
cover.value = cover.bar.value;
|
279
|
-
X += barwidth;
|
280
|
-
}
|
281
|
-
|
282
|
-
X += barhgutter;
|
283
|
-
}
|
284
|
-
}
|
285
|
-
|
286
|
-
chart.label = function (labels, isBottom) {
|
287
|
-
labels = labels || [];
|
288
|
-
this.labels = paper.set();
|
289
|
-
|
290
|
-
var L, l = -Infinity;
|
291
|
-
|
292
|
-
if (opts.stacked) {
|
293
|
-
for (var i = 0; i < len; i++) {
|
294
|
-
var tot = 0;
|
295
|
-
|
296
|
-
for (var j = 0; j < (multi || 1); j++) {
|
297
|
-
tot += multi ? values[j][i] : values[i];
|
298
|
-
|
299
|
-
if (j == multi - 1) {
|
300
|
-
var label = paper.labelise(labels[i], tot, total);
|
301
|
-
|
302
|
-
L = paper.text(bars[i * (multi || 1) + j].x, y + height - barvgutter / 2, label).attr(txtattr).insertBefore(covers[i * (multi || 1) + j]);
|
303
|
-
|
304
|
-
var bb = L.getBBox();
|
305
|
-
|
306
|
-
if (bb.x - 7 < l) {
|
307
|
-
L.remove();
|
308
|
-
} else {
|
309
|
-
this.labels.push(L);
|
310
|
-
l = bb.x + bb.width;
|
311
|
-
}
|
312
|
-
}
|
313
|
-
}
|
314
|
-
}
|
315
|
-
} else {
|
316
|
-
for (var i = 0; i < len; i++) {
|
317
|
-
for (var j = 0; j < (multi || 1); j++) {
|
318
|
-
var label = paper.labelise(multi ? labels[j] && labels[j][i] : labels[i], multi ? values[j][i] : values[i], total);
|
319
|
-
|
320
|
-
L = paper.text(bars[i * (multi || 1) + j].x, isBottom ? y + height - barvgutter / 2 : bars[i * (multi || 1) + j].y - 10, label).attr(txtattr).insertBefore(covers[i * (multi || 1) + j]);
|
321
|
-
|
322
|
-
var bb = L.getBBox();
|
323
|
-
|
324
|
-
if (bb.x - 7 < l) {
|
325
|
-
L.remove();
|
326
|
-
} else {
|
327
|
-
this.labels.push(L);
|
328
|
-
l = bb.x + bb.width;
|
329
|
-
}
|
330
|
-
}
|
331
|
-
}
|
332
|
-
}
|
333
|
-
return this;
|
334
|
-
};
|
335
|
-
|
336
|
-
chart.hover = function (fin, fout) {
|
337
|
-
covers2.hide();
|
338
|
-
covers.show();
|
339
|
-
covers.mouseover(fin).mouseout(fout);
|
340
|
-
return this;
|
341
|
-
};
|
342
|
-
|
343
|
-
chart.hoverColumn = function (fin, fout) {
|
344
|
-
covers.hide();
|
345
|
-
covers2.show();
|
346
|
-
fout = fout || function () {};
|
347
|
-
covers2.mouseover(fin).mouseout(fout);
|
348
|
-
return this;
|
349
|
-
};
|
350
|
-
|
351
|
-
chart.click = function (f) {
|
352
|
-
covers2.hide();
|
353
|
-
covers.show();
|
354
|
-
covers.click(f);
|
355
|
-
return this;
|
356
|
-
};
|
357
|
-
|
358
|
-
chart.each = function (f) {
|
359
|
-
if (!Raphael.is(f, "function")) {
|
360
|
-
return this;
|
361
|
-
}
|
362
|
-
for (var i = covers.length; i--;) {
|
363
|
-
f.call(covers[i]);
|
364
|
-
}
|
365
|
-
return this;
|
366
|
-
};
|
367
|
-
|
368
|
-
chart.eachColumn = function (f) {
|
369
|
-
if (!Raphael.is(f, "function")) {
|
370
|
-
return this;
|
371
|
-
}
|
372
|
-
for (var i = covers2.length; i--;) {
|
373
|
-
f.call(covers2[i]);
|
374
|
-
}
|
375
|
-
return this;
|
376
|
-
};
|
377
|
-
|
378
|
-
chart.clickColumn = function (f) {
|
379
|
-
covers.hide();
|
380
|
-
covers2.show();
|
381
|
-
covers2.click(f);
|
382
|
-
return this;
|
383
|
-
};
|
384
|
-
|
385
|
-
chart.push(bars, covers, covers2);
|
386
|
-
chart.bars = bars;
|
387
|
-
chart.covers = covers;
|
388
|
-
return chart;
|
389
|
-
};
|
390
|
-
|
391
|
-
/**
|
392
|
-
* Horizontal Barchart
|
393
|
-
*/
|
394
|
-
function HBarchart(paper, x, y, width, height, values, opts) {
|
395
|
-
opts = opts || {};
|
396
|
-
|
397
|
-
var chartinst = this,
|
398
|
-
type = opts.type || "square",
|
399
|
-
gutter = parseFloat(opts.gutter || "20%"),
|
400
|
-
chart = paper.set(),
|
401
|
-
bars = paper.set(),
|
402
|
-
covers = paper.set(),
|
403
|
-
covers2 = paper.set(),
|
404
|
-
total = Math.max.apply(Math, values),
|
405
|
-
stacktotal = [],
|
406
|
-
multi = 0,
|
407
|
-
colors = opts.colors || chartinst.colors,
|
408
|
-
len = values.length;
|
409
|
-
|
410
|
-
if (Raphael.is(values[0], "array")) {
|
411
|
-
total = [];
|
412
|
-
multi = len;
|
413
|
-
len = 0;
|
414
|
-
|
415
|
-
for (var i = values.length; i--;) {
|
416
|
-
bars.push(paper.set());
|
417
|
-
total.push(Math.max.apply(Math, values[i]));
|
418
|
-
len = Math.max(len, values[i].length);
|
419
|
-
}
|
420
|
-
|
421
|
-
if (opts.stacked) {
|
422
|
-
for (var i = len; i--;) {
|
423
|
-
var tot = 0;
|
424
|
-
for (var j = values.length; j--;) {
|
425
|
-
tot +=+ values[j][i] || 0;
|
426
|
-
}
|
427
|
-
stacktotal.push(tot);
|
428
|
-
}
|
429
|
-
}
|
430
|
-
|
431
|
-
for (var i = values.length; i--;) {
|
432
|
-
if (values[i].length < len) {
|
433
|
-
for (var j = len; j--;) {
|
434
|
-
values[i].push(0);
|
435
|
-
}
|
436
|
-
}
|
437
|
-
}
|
438
|
-
|
439
|
-
total = Math.max.apply(Math, opts.stacked ? stacktotal : total);
|
440
|
-
}
|
441
|
-
|
442
|
-
total = (opts.to) || total;
|
443
|
-
|
444
|
-
var barheight = Math.floor(height / (len * (100 + gutter) + gutter) * 100),
|
445
|
-
bargutter = Math.floor(barheight * gutter / 100),
|
446
|
-
stack = [],
|
447
|
-
Y = y + bargutter,
|
448
|
-
X = (width - 1) / total;
|
449
|
-
|
450
|
-
!opts.stacked && (barheight /= multi || 1);
|
451
|
-
|
452
|
-
for (var i = 0; i < len; i++) {
|
453
|
-
stack = [];
|
454
|
-
|
455
|
-
for (var j = 0; j < (multi || 1); j++) {
|
456
|
-
var val = multi ? values[j][i] : values[i],
|
457
|
-
bar = finger(x, Y + barheight / 2, Math.round(val * X), barheight - 1, false, type, null, paper).attr({stroke: "none", fill: colors[multi ? j : i]});
|
458
|
-
|
459
|
-
if (multi) {
|
460
|
-
bars[j].push(bar);
|
461
|
-
} else {
|
462
|
-
bars.push(bar);
|
463
|
-
}
|
464
|
-
|
465
|
-
bar.x = x + Math.round(val * X);
|
466
|
-
bar.y = Y + barheight / 2;
|
467
|
-
bar.w = Math.round(val * X);
|
468
|
-
bar.h = barheight;
|
469
|
-
bar.value = +val;
|
470
|
-
|
471
|
-
if (!opts.stacked) {
|
472
|
-
Y += barheight;
|
473
|
-
} else {
|
474
|
-
stack.push(bar);
|
475
|
-
}
|
476
|
-
}
|
477
|
-
|
478
|
-
if (opts.stacked) {
|
479
|
-
var cvr = paper.rect(x, stack[0].y - stack[0].h / 2, width, barheight).attr(chartinst.shim);
|
480
|
-
|
481
|
-
covers2.push(cvr);
|
482
|
-
cvr.bars = paper.set();
|
483
|
-
|
484
|
-
var size = 0;
|
485
|
-
|
486
|
-
for (var s = stack.length; s--;) {
|
487
|
-
stack[s].toFront();
|
488
|
-
}
|
489
|
-
|
490
|
-
for (var s = 0, ss = stack.length; s < ss; s++) {
|
491
|
-
var bar = stack[s],
|
492
|
-
cover,
|
493
|
-
val = Math.round((size + bar.value) * X),
|
494
|
-
path = finger(x, bar.y, val, barheight - 1, false, type, 1, paper);
|
495
|
-
|
496
|
-
cvr.bars.push(bar);
|
497
|
-
size && bar.attr({ path: path });
|
498
|
-
bar.w = val;
|
499
|
-
bar.x = x + val;
|
500
|
-
covers.push(cover = paper.rect(x + size * X, bar.y - bar.h / 2, bar.value * X, barheight).attr(chartinst.shim));
|
501
|
-
cover.bar = bar;
|
502
|
-
size += bar.value;
|
503
|
-
}
|
504
|
-
|
505
|
-
Y += barheight;
|
506
|
-
}
|
507
|
-
|
508
|
-
Y += bargutter;
|
509
|
-
}
|
510
|
-
|
511
|
-
covers2.toFront();
|
512
|
-
Y = y + bargutter;
|
513
|
-
|
514
|
-
if (!opts.stacked) {
|
515
|
-
for (var i = 0; i < len; i++) {
|
516
|
-
for (var j = 0; j < (multi || 1); j++) {
|
517
|
-
var cover = paper.rect(x, Y, width, barheight).attr(chartinst.shim);
|
518
|
-
|
519
|
-
covers.push(cover);
|
520
|
-
cover.bar = multi ? bars[j][i] : bars[i];
|
521
|
-
cover.value = cover.bar.value;
|
522
|
-
Y += barheight;
|
523
|
-
}
|
524
|
-
|
525
|
-
Y += bargutter;
|
526
|
-
}
|
527
|
-
}
|
528
|
-
|
529
|
-
chart.label = function (labels, isRight) {
|
530
|
-
labels = labels || [];
|
531
|
-
this.labels = paper.set();
|
532
|
-
|
533
|
-
for (var i = 0; i < len; i++) {
|
534
|
-
for (var j = 0; j < multi; j++) {
|
535
|
-
var label = paper.labelise(multi ? labels[j] && labels[j][i] : labels[i], multi ? values[j][i] : values[i], total),
|
536
|
-
X = isRight ? bars[i * (multi || 1) + j].x - barheight / 2 + 3 : x + 5,
|
537
|
-
A = isRight ? "end" : "start",
|
538
|
-
L;
|
539
|
-
|
540
|
-
this.labels.push(L = paper.text(X, bars[i * (multi || 1) + j].y, label).attr(txtattr).attr({ "text-anchor": A }).insertBefore(covers[0]));
|
541
|
-
|
542
|
-
if (L.getBBox().x < x + 5) {
|
543
|
-
L.attr({x: x + 5, "text-anchor": "start"});
|
544
|
-
} else {
|
545
|
-
bars[i * (multi || 1) + j].label = L;
|
546
|
-
}
|
547
|
-
}
|
548
|
-
}
|
549
|
-
|
550
|
-
return this;
|
551
|
-
};
|
552
|
-
|
553
|
-
chart.hover = function (fin, fout) {
|
554
|
-
covers2.hide();
|
555
|
-
covers.show();
|
556
|
-
fout = fout || function () {};
|
557
|
-
covers.mouseover(fin).mouseout(fout);
|
558
|
-
return this;
|
559
|
-
};
|
560
|
-
|
561
|
-
chart.hoverColumn = function (fin, fout) {
|
562
|
-
covers.hide();
|
563
|
-
covers2.show();
|
564
|
-
fout = fout || function () {};
|
565
|
-
covers2.mouseover(fin).mouseout(fout);
|
566
|
-
return this;
|
567
|
-
};
|
568
|
-
|
569
|
-
chart.each = function (f) {
|
570
|
-
if (!Raphael.is(f, "function")) {
|
571
|
-
return this;
|
572
|
-
}
|
573
|
-
for (var i = covers.length; i--;) {
|
574
|
-
f.call(covers[i]);
|
575
|
-
}
|
576
|
-
return this;
|
577
|
-
};
|
578
|
-
|
579
|
-
chart.eachColumn = function (f) {
|
580
|
-
if (!Raphael.is(f, "function")) {
|
581
|
-
return this;
|
582
|
-
}
|
583
|
-
for (var i = covers2.length; i--;) {
|
584
|
-
f.call(covers2[i]);
|
585
|
-
}
|
586
|
-
return this;
|
587
|
-
};
|
588
|
-
|
589
|
-
chart.click = function (f) {
|
590
|
-
covers2.hide();
|
591
|
-
covers.show();
|
592
|
-
covers.click(f);
|
593
|
-
return this;
|
594
|
-
};
|
595
|
-
|
596
|
-
chart.clickColumn = function (f) {
|
597
|
-
covers.hide();
|
598
|
-
covers2.show();
|
599
|
-
covers2.click(f);
|
600
|
-
return this;
|
601
|
-
};
|
602
|
-
|
603
|
-
chart.push(bars, covers, covers2);
|
604
|
-
chart.bars = bars;
|
605
|
-
chart.covers = covers;
|
606
|
-
return chart;
|
607
|
-
};
|
608
|
-
|
609
|
-
//inheritance
|
610
|
-
var F = function() {};
|
611
|
-
F.prototype = Raphael.g;
|
612
|
-
HBarchart.prototype = VBarchart.prototype = new F;
|
613
|
-
|
614
|
-
Raphael.fn.hbarchart = function(x, y, width, height, values, opts) {
|
615
|
-
return new HBarchart(this, x, y, width, height, values, opts);
|
616
|
-
};
|
617
|
-
|
618
|
-
Raphael.fn.barchart = function(x, y, width, height, values, opts) {
|
619
|
-
return new VBarchart(this, x, y, width, height, values, opts);
|
620
|
-
};
|
621
|
-
})();
|