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,156 +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 colorValue = function (value, total, s, b) {
|
9
|
-
return 'hsb(' + [Math.min((1 - value / total) * .4, 1), s || .75, b || .75] + ')';
|
10
|
-
};
|
11
|
-
|
12
|
-
function Dotchart(paper, x, y, width, height, valuesx, valuesy, size, opts) {
|
13
|
-
|
14
|
-
var chartinst = this;
|
15
|
-
|
16
|
-
function drawAxis(ax) {
|
17
|
-
+ax[0] && (ax[0] = chartinst.axis(x + gutter, y + gutter, width - 2 * gutter, minx, maxx, opts.axisxstep || Math.floor((width - 2 * gutter) / 20), 2, opts.axisxlabels || null, opts.axisxtype || "t", null, paper));
|
18
|
-
+ax[1] && (ax[1] = chartinst.axis(x + width - gutter, y + height - gutter, height - 2 * gutter, miny, maxy, opts.axisystep || Math.floor((height - 2 * gutter) / 20), 3, opts.axisylabels || null, opts.axisytype || "t", null, paper));
|
19
|
-
+ax[2] && (ax[2] = chartinst.axis(x + gutter, y + height - gutter + maxR, width - 2 * gutter, minx, maxx, opts.axisxstep || Math.floor((width - 2 * gutter) / 20), 0, opts.axisxlabels || null, opts.axisxtype || "t", null, paper));
|
20
|
-
+ax[3] && (ax[3] = chartinst.axis(x + gutter - maxR, y + height - gutter, height - 2 * gutter, miny, maxy, opts.axisystep || Math.floor((height - 2 * gutter) / 20), 1, opts.axisylabels || null, opts.axisytype || "t", null, paper));
|
21
|
-
}
|
22
|
-
|
23
|
-
opts = opts || {};
|
24
|
-
var xdim = chartinst.snapEnds(Math.min.apply(Math, valuesx), Math.max.apply(Math, valuesx), valuesx.length - 1),
|
25
|
-
minx = xdim.from,
|
26
|
-
maxx = xdim.to,
|
27
|
-
gutter = opts.gutter || 10,
|
28
|
-
ydim = chartinst.snapEnds(Math.min.apply(Math, valuesy), Math.max.apply(Math, valuesy), valuesy.length - 1),
|
29
|
-
miny = ydim.from,
|
30
|
-
maxy = ydim.to,
|
31
|
-
len = Math.max(valuesx.length, valuesy.length, size.length),
|
32
|
-
symbol = paper[opts.symbol] || "circle",
|
33
|
-
res = paper.set(),
|
34
|
-
series = paper.set(),
|
35
|
-
max = opts.max || 100,
|
36
|
-
top = Math.max.apply(Math, size),
|
37
|
-
R = [],
|
38
|
-
k = Math.sqrt(top / Math.PI) * 2 / max;
|
39
|
-
|
40
|
-
for (var i = 0; i < len; i++) {
|
41
|
-
R[i] = Math.min(Math.sqrt(size[i] / Math.PI) * 2 / k, max);
|
42
|
-
}
|
43
|
-
|
44
|
-
gutter = Math.max.apply(Math, R.concat(gutter));
|
45
|
-
|
46
|
-
var axis = paper.set(),
|
47
|
-
maxR = Math.max.apply(Math, R);
|
48
|
-
|
49
|
-
if (opts.axis) {
|
50
|
-
var ax = (opts.axis + "").split(/[,\s]+/);
|
51
|
-
|
52
|
-
drawAxis.call(chartinst, ax);
|
53
|
-
|
54
|
-
var g = [], b = [];
|
55
|
-
|
56
|
-
for (var i = 0, ii = ax.length; i < ii; i++) {
|
57
|
-
var bb = ax[i].all ? ax[i].all.getBBox()[["height", "width"][i % 2]] : 0;
|
58
|
-
|
59
|
-
g[i] = bb + gutter;
|
60
|
-
b[i] = bb;
|
61
|
-
}
|
62
|
-
|
63
|
-
gutter = Math.max.apply(Math, g.concat(gutter));
|
64
|
-
|
65
|
-
for (var i = 0, ii = ax.length; i < ii; i++) if (ax[i].all) {
|
66
|
-
ax[i].remove();
|
67
|
-
ax[i] = 1;
|
68
|
-
}
|
69
|
-
|
70
|
-
drawAxis.call(chartinst, ax);
|
71
|
-
|
72
|
-
for (var i = 0, ii = ax.length; i < ii; i++) if (ax[i].all) {
|
73
|
-
axis.push(ax[i].all);
|
74
|
-
}
|
75
|
-
|
76
|
-
res.axis = axis;
|
77
|
-
}
|
78
|
-
|
79
|
-
var kx = (width - gutter * 2) / ((maxx - minx) || 1),
|
80
|
-
ky = (height - gutter * 2) / ((maxy - miny) || 1);
|
81
|
-
|
82
|
-
for (var i = 0, ii = valuesy.length; i < ii; i++) {
|
83
|
-
var sym = paper.raphael.is(symbol, "array") ? symbol[i] : symbol,
|
84
|
-
X = x + gutter + (valuesx[i] - minx) * kx,
|
85
|
-
Y = y + height - gutter - (valuesy[i] - miny) * ky;
|
86
|
-
|
87
|
-
sym && R[i] && series.push(paper[sym](X, Y, R[i]).attr({ fill: opts.heat ? colorValue(R[i], maxR) : chartinst.colors[0], "fill-opacity": opts.opacity ? R[i] / max : 1, stroke: "none" }));
|
88
|
-
}
|
89
|
-
|
90
|
-
var covers = paper.set();
|
91
|
-
|
92
|
-
for (var i = 0, ii = valuesy.length; i < ii; i++) {
|
93
|
-
var X = x + gutter + (valuesx[i] - minx) * kx,
|
94
|
-
Y = y + height - gutter - (valuesy[i] - miny) * ky;
|
95
|
-
|
96
|
-
covers.push(paper.circle(X, Y, maxR).attr(chartinst.shim));
|
97
|
-
opts.href && opts.href[i] && covers[i].attr({href: opts.href[i]});
|
98
|
-
covers[i].r = +R[i].toFixed(3);
|
99
|
-
covers[i].x = +X.toFixed(3);
|
100
|
-
covers[i].y = +Y.toFixed(3);
|
101
|
-
covers[i].X = valuesx[i];
|
102
|
-
covers[i].Y = valuesy[i];
|
103
|
-
covers[i].value = size[i] || 0;
|
104
|
-
covers[i].dot = series[i];
|
105
|
-
}
|
106
|
-
|
107
|
-
res.covers = covers;
|
108
|
-
res.series = series;
|
109
|
-
res.push(series, axis, covers);
|
110
|
-
|
111
|
-
res.hover = function (fin, fout) {
|
112
|
-
covers.mouseover(fin).mouseout(fout);
|
113
|
-
return this;
|
114
|
-
};
|
115
|
-
|
116
|
-
res.click = function (f) {
|
117
|
-
covers.click(f);
|
118
|
-
return this;
|
119
|
-
};
|
120
|
-
|
121
|
-
res.each = function (f) {
|
122
|
-
if (!paper.raphael.is(f, "function")) {
|
123
|
-
return this;
|
124
|
-
}
|
125
|
-
|
126
|
-
for (var i = covers.length; i--;) {
|
127
|
-
f.call(covers[i]);
|
128
|
-
}
|
129
|
-
|
130
|
-
return this;
|
131
|
-
};
|
132
|
-
|
133
|
-
res.href = function (map) {
|
134
|
-
var cover;
|
135
|
-
|
136
|
-
for (var i = covers.length; i--;) {
|
137
|
-
cover = covers[i];
|
138
|
-
|
139
|
-
if (cover.X == map.x && cover.Y == map.y && cover.value == map.value) {
|
140
|
-
cover.attr({href: map.href});
|
141
|
-
}
|
142
|
-
}
|
143
|
-
};
|
144
|
-
return res;
|
145
|
-
};
|
146
|
-
|
147
|
-
//inheritance
|
148
|
-
var F = function() {};
|
149
|
-
F.prototype = Raphael.g
|
150
|
-
Dotchart.prototype = new F;
|
151
|
-
|
152
|
-
//public
|
153
|
-
Raphael.fn.dotchart = function(x, y, width, height, valuesx, valuesy, size, opts) {
|
154
|
-
return new Dotchart(this, x, y, width, height, valuesx, valuesy, size, opts);
|
155
|
-
}
|
156
|
-
})();
|
@@ -1,329 +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
|
-
|
9
|
-
function shrink(values, dim) {
|
10
|
-
var k = values.length / dim,
|
11
|
-
j = 0,
|
12
|
-
l = k,
|
13
|
-
sum = 0,
|
14
|
-
res = [];
|
15
|
-
|
16
|
-
while (j < values.length) {
|
17
|
-
l--;
|
18
|
-
|
19
|
-
if (l < 0) {
|
20
|
-
sum += values[j] * (1 + l);
|
21
|
-
res.push(sum / k);
|
22
|
-
sum = values[j++] * -l;
|
23
|
-
l += k;
|
24
|
-
} else {
|
25
|
-
sum += values[j++];
|
26
|
-
}
|
27
|
-
}
|
28
|
-
return res;
|
29
|
-
}
|
30
|
-
|
31
|
-
function getAnchors(p1x, p1y, p2x, p2y, p3x, p3y) {
|
32
|
-
var l1 = (p2x - p1x) / 2,
|
33
|
-
l2 = (p3x - p2x) / 2,
|
34
|
-
a = Math.atan((p2x - p1x) / Math.abs(p2y - p1y)),
|
35
|
-
b = Math.atan((p3x - p2x) / Math.abs(p2y - p3y));
|
36
|
-
|
37
|
-
a = p1y < p2y ? Math.PI - a : a;
|
38
|
-
b = p3y < p2y ? Math.PI - b : b;
|
39
|
-
|
40
|
-
var alpha = Math.PI / 2 - ((a + b) % (Math.PI * 2)) / 2,
|
41
|
-
dx1 = l1 * Math.sin(alpha + a),
|
42
|
-
dy1 = l1 * Math.cos(alpha + a),
|
43
|
-
dx2 = l2 * Math.sin(alpha + b),
|
44
|
-
dy2 = l2 * Math.cos(alpha + b);
|
45
|
-
|
46
|
-
return {
|
47
|
-
x1: p2x - dx1,
|
48
|
-
y1: p2y + dy1,
|
49
|
-
x2: p2x + dx2,
|
50
|
-
y2: p2y + dy2
|
51
|
-
};
|
52
|
-
}
|
53
|
-
|
54
|
-
function Linechart(paper, x, y, width, height, valuesx, valuesy, opts) {
|
55
|
-
|
56
|
-
var chartinst = this;
|
57
|
-
|
58
|
-
opts = opts || {};
|
59
|
-
|
60
|
-
if (!paper.raphael.is(valuesx[0], "array")) {
|
61
|
-
valuesx = [valuesx];
|
62
|
-
}
|
63
|
-
|
64
|
-
if (!paper.raphael.is(valuesy[0], "array")) {
|
65
|
-
valuesy = [valuesy];
|
66
|
-
}
|
67
|
-
|
68
|
-
var gutter = opts.gutter || 10,
|
69
|
-
len = Math.max(valuesx[0].length, valuesy[0].length),
|
70
|
-
symbol = opts.symbol || "",
|
71
|
-
colors = opts.colors || chartinst.colors,
|
72
|
-
columns = null,
|
73
|
-
dots = null,
|
74
|
-
chart = paper.set(),
|
75
|
-
path = [];
|
76
|
-
|
77
|
-
for (var i = 0, ii = valuesy.length; i < ii; i++) {
|
78
|
-
len = Math.max(len, valuesy[i].length);
|
79
|
-
}
|
80
|
-
|
81
|
-
var shades = paper.set();
|
82
|
-
|
83
|
-
for (i = 0, ii = valuesy.length; i < ii; i++) {
|
84
|
-
if (opts.shade) {
|
85
|
-
shades.push(paper.path().attr({ stroke: "none", fill: colors[i], opacity: opts.nostroke ? 1 : .3 }));
|
86
|
-
}
|
87
|
-
|
88
|
-
if (valuesy[i].length > width - 2 * gutter) {
|
89
|
-
valuesy[i] = shrink(valuesy[i], width - 2 * gutter);
|
90
|
-
len = width - 2 * gutter;
|
91
|
-
}
|
92
|
-
|
93
|
-
if (valuesx[i] && valuesx[i].length > width - 2 * gutter) {
|
94
|
-
valuesx[i] = shrink(valuesx[i], width - 2 * gutter);
|
95
|
-
}
|
96
|
-
}
|
97
|
-
|
98
|
-
var allx = Array.prototype.concat.apply([], valuesx),
|
99
|
-
ally = Array.prototype.concat.apply([], valuesy),
|
100
|
-
xdim = chartinst.snapEnds(Math.min.apply(Math, allx), Math.max.apply(Math, allx), valuesx[0].length - 1),
|
101
|
-
minx = xdim.from,
|
102
|
-
maxx = xdim.to,
|
103
|
-
ydim = chartinst.snapEnds(Math.min.apply(Math, ally), Math.max.apply(Math, ally), valuesy[0].length - 1),
|
104
|
-
miny = ydim.from,
|
105
|
-
maxy = ydim.to,
|
106
|
-
kx = (width - gutter * 2) / ((maxx - minx) || 1),
|
107
|
-
ky = (height - gutter * 2) / ((maxy - miny) || 1);
|
108
|
-
|
109
|
-
var axis = paper.set();
|
110
|
-
|
111
|
-
if (opts.axis) {
|
112
|
-
var ax = (opts.axis + "").split(/[,\s]+/);
|
113
|
-
+ax[0] && axis.push(chartinst.axis(x + gutter, y + gutter, width - 2 * gutter, minx, maxx, opts.axisxstep || Math.floor((width - 2 * gutter) / 20), 2, paper));
|
114
|
-
+ax[1] && axis.push(chartinst.axis(x + width - gutter, y + height - gutter, height - 2 * gutter, miny, maxy, opts.axisystep || Math.floor((height - 2 * gutter) / 20), 3, paper));
|
115
|
-
+ax[2] && axis.push(chartinst.axis(x + gutter, y + height - gutter, width - 2 * gutter, minx, maxx, opts.axisxstep || Math.floor((width - 2 * gutter) / 20), 0, paper));
|
116
|
-
+ax[3] && axis.push(chartinst.axis(x + gutter, y + height - gutter, height - 2 * gutter, miny, maxy, opts.axisystep || Math.floor((height - 2 * gutter) / 20), 1, paper));
|
117
|
-
}
|
118
|
-
|
119
|
-
var lines = paper.set(),
|
120
|
-
symbols = paper.set(),
|
121
|
-
line;
|
122
|
-
|
123
|
-
for (i = 0, ii = valuesy.length; i < ii; i++) {
|
124
|
-
if (!opts.nostroke) {
|
125
|
-
lines.push(line = paper.path().attr({
|
126
|
-
stroke: colors[i],
|
127
|
-
"stroke-width": opts.width || 2,
|
128
|
-
"stroke-linejoin": "round",
|
129
|
-
"stroke-linecap": "round",
|
130
|
-
"stroke-dasharray": opts.dash || ""
|
131
|
-
}));
|
132
|
-
}
|
133
|
-
|
134
|
-
var sym = Raphael.is(symbol, "array") ? symbol[i] : symbol,
|
135
|
-
symset = paper.set();
|
136
|
-
|
137
|
-
path = [];
|
138
|
-
|
139
|
-
for (var j = 0, jj = valuesy[i].length; j < jj; j++) {
|
140
|
-
var X = x + gutter + ((valuesx[i] || valuesx[0])[j] - minx) * kx,
|
141
|
-
Y = y + height - gutter - (valuesy[i][j] - miny) * ky;
|
142
|
-
|
143
|
-
(Raphael.is(sym, "array") ? sym[j] : sym) && symset.push(paper[Raphael.is(sym, "array") ? sym[j] : sym](X, Y, (opts.width || 2) * 3).attr({ fill: colors[i], stroke: "none" }));
|
144
|
-
|
145
|
-
if (opts.smooth) {
|
146
|
-
if (j && j != jj - 1) {
|
147
|
-
var X0 = x + gutter + ((valuesx[i] || valuesx[0])[j - 1] - minx) * kx,
|
148
|
-
Y0 = y + height - gutter - (valuesy[i][j - 1] - miny) * ky,
|
149
|
-
X2 = x + gutter + ((valuesx[i] || valuesx[0])[j + 1] - minx) * kx,
|
150
|
-
Y2 = y + height - gutter - (valuesy[i][j + 1] - miny) * ky,
|
151
|
-
a = getAnchors(X0, Y0, X, Y, X2, Y2);
|
152
|
-
|
153
|
-
path = path.concat([a.x1, a.y1, X, Y, a.x2, a.y2]);
|
154
|
-
}
|
155
|
-
|
156
|
-
if (!j) {
|
157
|
-
path = ["M", X, Y, "C", X, Y];
|
158
|
-
}
|
159
|
-
} else {
|
160
|
-
path = path.concat([j ? "L" : "M", X, Y]);
|
161
|
-
}
|
162
|
-
}
|
163
|
-
|
164
|
-
if (opts.smooth) {
|
165
|
-
path = path.concat([X, Y, X, Y]);
|
166
|
-
}
|
167
|
-
|
168
|
-
symbols.push(symset);
|
169
|
-
|
170
|
-
if (opts.shade) {
|
171
|
-
shades[i].attr({ path: path.concat(["L", X, y + height - gutter, "L", x + gutter + ((valuesx[i] || valuesx[0])[0] - minx) * kx, y + height - gutter, "z"]).join(",") });
|
172
|
-
}
|
173
|
-
|
174
|
-
!opts.nostroke && line.attr({ path: path.join(",") });
|
175
|
-
}
|
176
|
-
|
177
|
-
function createColumns(f) {
|
178
|
-
// unite Xs together
|
179
|
-
var Xs = [];
|
180
|
-
|
181
|
-
for (var i = 0, ii = valuesx.length; i < ii; i++) {
|
182
|
-
Xs = Xs.concat(valuesx[i]);
|
183
|
-
}
|
184
|
-
|
185
|
-
Xs.sort();
|
186
|
-
// remove duplicates
|
187
|
-
|
188
|
-
var Xs2 = [],
|
189
|
-
xs = [];
|
190
|
-
|
191
|
-
for (i = 0, ii = Xs.length; i < ii; i++) {
|
192
|
-
Xs[i] != Xs[i - 1] && Xs2.push(Xs[i]) && xs.push(x + gutter + (Xs[i] - minx) * kx);
|
193
|
-
}
|
194
|
-
|
195
|
-
Xs = Xs2;
|
196
|
-
ii = Xs.length;
|
197
|
-
|
198
|
-
var cvrs = f || paper.set();
|
199
|
-
|
200
|
-
for (i = 0; i < ii; i++) {
|
201
|
-
var X = xs[i] - (xs[i] - (xs[i - 1] || x)) / 2,
|
202
|
-
w = ((xs[i + 1] || x + width) - xs[i]) / 2 + (xs[i] - (xs[i - 1] || x)) / 2,
|
203
|
-
C;
|
204
|
-
|
205
|
-
f ? (C = {}) : cvrs.push(C = paper.rect(X - 1, y, Math.max(w + 1, 1), height).attr({ stroke: "none", fill: "#000", opacity: 0 }));
|
206
|
-
C.values = [];
|
207
|
-
C.symbols = paper.set();
|
208
|
-
C.y = [];
|
209
|
-
C.x = xs[i];
|
210
|
-
C.axis = Xs[i];
|
211
|
-
|
212
|
-
for (var j = 0, jj = valuesy.length; j < jj; j++) {
|
213
|
-
Xs2 = valuesx[j] || valuesx[0];
|
214
|
-
|
215
|
-
for (var k = 0, kk = Xs2.length; k < kk; k++) {
|
216
|
-
if (Xs2[k] == Xs[i]) {
|
217
|
-
C.values.push(valuesy[j][k]);
|
218
|
-
C.y.push(y + height - gutter - (valuesy[j][k] - miny) * ky);
|
219
|
-
C.symbols.push(chart.symbols[j][k]);
|
220
|
-
}
|
221
|
-
}
|
222
|
-
}
|
223
|
-
|
224
|
-
f && f.call(C);
|
225
|
-
}
|
226
|
-
|
227
|
-
!f && (columns = cvrs);
|
228
|
-
}
|
229
|
-
|
230
|
-
function createDots(f) {
|
231
|
-
var cvrs = f || paper.set(),
|
232
|
-
C;
|
233
|
-
|
234
|
-
for (var i = 0, ii = valuesy.length; i < ii; i++) {
|
235
|
-
for (var j = 0, jj = valuesy[i].length; j < jj; j++) {
|
236
|
-
var X = x + gutter + ((valuesx[i] || valuesx[0])[j] - minx) * kx,
|
237
|
-
nearX = x + gutter + ((valuesx[i] || valuesx[0])[j ? j - 1 : 1] - minx) * kx,
|
238
|
-
Y = y + height - gutter - (valuesy[i][j] - miny) * ky;
|
239
|
-
|
240
|
-
f ? (C = {}) : cvrs.push(C = paper.circle(X, Y, Math.abs(nearX - X) / 2).attr({ stroke: "none", fill: "#000", opacity: 0 }));
|
241
|
-
C.x = X;
|
242
|
-
C.y = Y;
|
243
|
-
C.value = valuesy[i][j];
|
244
|
-
C.line = chart.lines[i];
|
245
|
-
C.shade = chart.shades[i];
|
246
|
-
C.symbol = chart.symbols[i][j];
|
247
|
-
C.symbols = chart.symbols[i];
|
248
|
-
C.axis = (valuesx[i] || valuesx[0])[j];
|
249
|
-
f && f.call(C);
|
250
|
-
}
|
251
|
-
}
|
252
|
-
|
253
|
-
!f && (dots = cvrs);
|
254
|
-
}
|
255
|
-
|
256
|
-
chart.push(lines, shades, symbols, axis, columns, dots);
|
257
|
-
chart.lines = lines;
|
258
|
-
chart.shades = shades;
|
259
|
-
chart.symbols = symbols;
|
260
|
-
chart.axis = axis;
|
261
|
-
|
262
|
-
chart.hoverColumn = function (fin, fout) {
|
263
|
-
!columns && createColumns();
|
264
|
-
columns.mouseover(fin).mouseout(fout);
|
265
|
-
return this;
|
266
|
-
};
|
267
|
-
|
268
|
-
chart.clickColumn = function (f) {
|
269
|
-
!columns && createColumns();
|
270
|
-
columns.click(f);
|
271
|
-
return this;
|
272
|
-
};
|
273
|
-
|
274
|
-
chart.hrefColumn = function (cols) {
|
275
|
-
var hrefs = paper.raphael.is(arguments[0], "array") ? arguments[0] : arguments;
|
276
|
-
|
277
|
-
if (!(arguments.length - 1) && typeof cols == "object") {
|
278
|
-
for (var x in cols) {
|
279
|
-
for (var i = 0, ii = columns.length; i < ii; i++) if (columns[i].axis == x) {
|
280
|
-
columns[i].attr("href", cols[x]);
|
281
|
-
}
|
282
|
-
}
|
283
|
-
}
|
284
|
-
|
285
|
-
!columns && createColumns();
|
286
|
-
|
287
|
-
for (i = 0, ii = hrefs.length; i < ii; i++) {
|
288
|
-
columns[i] && columns[i].attr("href", hrefs[i]);
|
289
|
-
}
|
290
|
-
|
291
|
-
return this;
|
292
|
-
};
|
293
|
-
|
294
|
-
chart.hover = function (fin, fout) {
|
295
|
-
!dots && createDots();
|
296
|
-
dots.mouseover(fin).mouseout(fout);
|
297
|
-
return this;
|
298
|
-
};
|
299
|
-
|
300
|
-
chart.click = function (f) {
|
301
|
-
!dots && createDots();
|
302
|
-
dots.click(f);
|
303
|
-
return this;
|
304
|
-
};
|
305
|
-
|
306
|
-
chart.each = function (f) {
|
307
|
-
createDots(f);
|
308
|
-
return this;
|
309
|
-
};
|
310
|
-
|
311
|
-
chart.eachColumn = function (f) {
|
312
|
-
createColumns(f);
|
313
|
-
return this;
|
314
|
-
};
|
315
|
-
|
316
|
-
return chart;
|
317
|
-
};
|
318
|
-
|
319
|
-
//inheritance
|
320
|
-
var F = function() {};
|
321
|
-
F.prototype = Raphael.g;
|
322
|
-
Linechart.prototype = new F;
|
323
|
-
|
324
|
-
//public
|
325
|
-
Raphael.fn.linechart = function(x, y, width, height, valuesx, valuesy, opts) {
|
326
|
-
return new Linechart(this, x, y, width, height, valuesx, valuesy, opts);
|
327
|
-
}
|
328
|
-
|
329
|
-
})();
|