highcharts-rails 3.0.10 → 4.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.asc +13 -13
- data.tar.gz.asc +13 -13
- data/CHANGELOG.markdown +5 -0
- data/Rakefile +4 -5
- data/app/assets/images/highcharts/meteogram-symbols-30px.png +0 -0
- data/app/assets/javascripts/highcharts.js +1221 -1126
- data/app/assets/javascripts/highcharts/adapters/standalone-framework.js +3 -2
- data/app/assets/javascripts/highcharts/highcharts-3d.js +1245 -0
- data/app/assets/javascripts/highcharts/highcharts-more.js +48 -28
- data/app/assets/javascripts/highcharts/modules/canvas-tools.js +1 -1
- data/app/assets/javascripts/highcharts/modules/data.js +8 -4
- data/app/assets/javascripts/highcharts/modules/drilldown.js +52 -26
- data/app/assets/javascripts/highcharts/modules/exporting.js +1 -1
- data/app/assets/javascripts/highcharts/modules/funnel.js +1 -0
- data/app/assets/javascripts/highcharts/modules/heatmap.js +596 -50
- data/app/assets/javascripts/highcharts/modules/no-data-to-display.js +1 -1
- data/app/assets/javascripts/highcharts/modules/solid-gauge.js +224 -0
- data/app/assets/javascripts/highcharts/themes/dark-blue.js +1 -1
- data/app/assets/javascripts/highcharts/themes/dark-green.js +1 -1
- data/app/assets/javascripts/highcharts/themes/dark-unica.js +213 -0
- data/app/assets/javascripts/highcharts/themes/gray.js +1 -1
- data/app/assets/javascripts/highcharts/themes/grid-light.js +74 -0
- data/app/assets/javascripts/highcharts/themes/sand-signika.js +101 -0
- data/lib/highcharts/version.rb +1 -1
- metadata +8 -2
- metadata.gz.asc +13 -13
@@ -1,5 +1,5 @@
|
|
1
1
|
/**
|
2
|
-
* @license Highcharts JS
|
2
|
+
* @license Highcharts JS v4.0.0 (2014-04-22)
|
3
3
|
*
|
4
4
|
* Standalone Highcharts Framework
|
5
5
|
*
|
@@ -88,6 +88,7 @@ function augment(obj) {
|
|
88
88
|
} else if (el.attachEvent) {
|
89
89
|
|
90
90
|
wrappedFn = function (e) {
|
91
|
+
e.target = e.srcElement || window; // #2820
|
91
92
|
fn.call(el, e);
|
92
93
|
};
|
93
94
|
|
@@ -450,7 +451,7 @@ return {
|
|
450
451
|
* Internal method to return CSS value for given element and property
|
451
452
|
*/
|
452
453
|
_getStyle: function (el, prop) {
|
453
|
-
return window.getComputedStyle(el).getPropertyValue(prop);
|
454
|
+
return window.getComputedStyle(el, undefined).getPropertyValue(prop);
|
454
455
|
},
|
455
456
|
|
456
457
|
/**
|
@@ -0,0 +1,1245 @@
|
|
1
|
+
// ==ClosureCompiler==
|
2
|
+
// @compilation_level SIMPLE_OPTIMIZATIONS
|
3
|
+
|
4
|
+
/**
|
5
|
+
* @license Highcharts JS v4.0.0 (2014-04-22)
|
6
|
+
*
|
7
|
+
* (c) 2009-2013 Torstein Hønsi
|
8
|
+
*
|
9
|
+
* License: www.highcharts.com/license
|
10
|
+
*/
|
11
|
+
|
12
|
+
// JSLint options:
|
13
|
+
/*global Highcharts, HighchartsAdapter, document, window, navigator, setInterval, clearInterval, clearTimeout, setTimeout, location, jQuery, $, console */
|
14
|
+
|
15
|
+
(function (Highcharts) {
|
16
|
+
/**
|
17
|
+
Shorthands for often used function
|
18
|
+
*/
|
19
|
+
/**
|
20
|
+
* Mathematical Functionility
|
21
|
+
*/
|
22
|
+
var PI = Math.PI,
|
23
|
+
deg2rad = (PI / 180), // degrees to radians
|
24
|
+
sin = Math.sin,
|
25
|
+
cos = Math.cos,
|
26
|
+
|
27
|
+
round = Math.round;
|
28
|
+
|
29
|
+
function perspective(points, angle2, angle1, origin) {
|
30
|
+
angle1 *= deg2rad;
|
31
|
+
angle2 *= deg2rad;
|
32
|
+
|
33
|
+
var result = [],
|
34
|
+
xe,
|
35
|
+
ye,
|
36
|
+
ze;
|
37
|
+
|
38
|
+
angle1 *= -1;
|
39
|
+
|
40
|
+
xe = origin.x;
|
41
|
+
ye = origin.y;
|
42
|
+
ze = (origin.z === 0 ? 0.0001 : origin.z) * (origin.vd || 25);
|
43
|
+
|
44
|
+
// some kind of minimum?
|
45
|
+
|
46
|
+
var s1 = sin(angle1),
|
47
|
+
c1 = cos(angle1),
|
48
|
+
s2 = sin(angle2),
|
49
|
+
c2 = cos(angle2);
|
50
|
+
|
51
|
+
var x, y, z, p;
|
52
|
+
|
53
|
+
Highcharts.each(points, function (point) {
|
54
|
+
x = point.x - xe;
|
55
|
+
y = point.y - ye;
|
56
|
+
z = point.z || 0;
|
57
|
+
|
58
|
+
p = {
|
59
|
+
x: c1 * x - s1 * z,
|
60
|
+
y: -s1 * s2 * x - c1 * s2 * z + c2 * y,
|
61
|
+
z: s1 * c2 * x + c1 * c2 * z + s2 * y
|
62
|
+
};
|
63
|
+
|
64
|
+
p.x = p.x * ((ze - p.z) / ze) + xe;
|
65
|
+
p.y = p.y * ((ze - p.z) / ze) + ye;
|
66
|
+
|
67
|
+
result.push({x: round(p.x), y: round(p.y), z: round(p.z)});
|
68
|
+
});
|
69
|
+
return result;
|
70
|
+
}
|
71
|
+
/***
|
72
|
+
EXTENSION TO THE SVG-RENDERER TO ENABLE 3D SHAPES
|
73
|
+
***/
|
74
|
+
////// HELPER METHODS //////
|
75
|
+
var dFactor = (4 * (Math.sqrt(2) - 1) / 3) / (PI / 2);
|
76
|
+
|
77
|
+
function curveTo(cx, cy, rx, ry, start, end, dx, dy) {
|
78
|
+
var result = [];
|
79
|
+
if ((end > start) && (end - start > PI / 2 + 0.0001)) {
|
80
|
+
result = result.concat(curveTo(cx, cy, rx, ry, start, start + (PI / 2), dx, dy));
|
81
|
+
result = result.concat(curveTo(cx, cy, rx, ry, start + (PI / 2), end, dx, dy));
|
82
|
+
return result;
|
83
|
+
} else if ((end < start) && (start - end > PI / 2 + 0.0001)) {
|
84
|
+
result = result.concat(curveTo(cx, cy, rx, ry, start, start - (PI / 2), dx, dy));
|
85
|
+
result = result.concat(curveTo(cx, cy, rx, ry, start - (PI / 2), end, dx, dy));
|
86
|
+
return result;
|
87
|
+
} else {
|
88
|
+
var arcAngle = end - start;
|
89
|
+
return [
|
90
|
+
'C',
|
91
|
+
cx + (rx * cos(start)) - ((rx * dFactor * arcAngle) * sin(start)) + dx,
|
92
|
+
cy + (ry * sin(start)) + ((ry * dFactor * arcAngle) * cos(start)) + dy,
|
93
|
+
cx + (rx * cos(end)) + ((rx * dFactor * arcAngle) * sin(end)) + dx,
|
94
|
+
cy + (ry * sin(end)) - ((ry * dFactor * arcAngle) * cos(end)) + dy,
|
95
|
+
|
96
|
+
cx + (rx * cos(end)) + dx,
|
97
|
+
cy + (ry * sin(end)) + dy
|
98
|
+
];
|
99
|
+
}
|
100
|
+
}
|
101
|
+
|
102
|
+
Highcharts.SVGRenderer.prototype.toLinePath = function (points, closed) {
|
103
|
+
var result = [];
|
104
|
+
|
105
|
+
// Put "L x y" for each point
|
106
|
+
Highcharts.each(points, function (point) {
|
107
|
+
result.push('L', point.x, point.y);
|
108
|
+
});
|
109
|
+
|
110
|
+
// Set the first element to M
|
111
|
+
result[0] = 'M';
|
112
|
+
|
113
|
+
// If it is a closed line, add Z
|
114
|
+
if (closed) {
|
115
|
+
result.push('Z');
|
116
|
+
}
|
117
|
+
|
118
|
+
return result;
|
119
|
+
};
|
120
|
+
|
121
|
+
////// CUBOIDS //////
|
122
|
+
Highcharts.SVGRenderer.prototype.cuboid = function (shapeArgs) {
|
123
|
+
|
124
|
+
var result = this.g(),
|
125
|
+
paths = this.cuboidPath(shapeArgs);
|
126
|
+
|
127
|
+
result.front = this.path(paths[0]).attr({zIndex: paths[3], 'stroke-linejoin': 'round'}).add(result);
|
128
|
+
result.top = this.path(paths[1]).attr({zIndex: paths[4], 'stroke-linejoin': 'round'}).add(result);
|
129
|
+
result.side = this.path(paths[2]).attr({zIndex: paths[5], 'stroke-linejoin': 'round'}).add(result);
|
130
|
+
|
131
|
+
result.fillSetter = function (color) {
|
132
|
+
var c0 = color,
|
133
|
+
c1 = Highcharts.Color(color).brighten(0.1).get(),
|
134
|
+
c2 = Highcharts.Color(color).brighten(-0.1).get();
|
135
|
+
|
136
|
+
this.front.attr({fill: c0});
|
137
|
+
this.top.attr({fill: c1});
|
138
|
+
this.side.attr({fill: c2});
|
139
|
+
|
140
|
+
this.color = color;
|
141
|
+
return this;
|
142
|
+
};
|
143
|
+
|
144
|
+
result.opacitySetter = function (opacity) {
|
145
|
+
this.front.attr({opacity: opacity});
|
146
|
+
this.top.attr({opacity: opacity});
|
147
|
+
this.side.attr({opacity: opacity});
|
148
|
+
return this;
|
149
|
+
};
|
150
|
+
|
151
|
+
result.attr = function (args) {
|
152
|
+
if (args.shapeArgs || args.x) {
|
153
|
+
var shapeArgs = args.shapeArgs || args;
|
154
|
+
var paths = this.renderer.cuboidPath(shapeArgs);
|
155
|
+
this.front.attr({d: paths[0], zIndex: paths[3]});
|
156
|
+
this.top.attr({d: paths[1], zIndex: paths[4]});
|
157
|
+
this.side.attr({d: paths[2], zIndex: paths[5]});
|
158
|
+
} else {
|
159
|
+
Highcharts.SVGElement.prototype.attr.call(this, args);
|
160
|
+
}
|
161
|
+
|
162
|
+
return this;
|
163
|
+
};
|
164
|
+
|
165
|
+
result.animate = function (args, duration, complete) {
|
166
|
+
if (args.x && args.y) {
|
167
|
+
var paths = this.renderer.cuboidPath(args);
|
168
|
+
this.front.attr({zIndex: paths[3]}).animate({d: paths[0]}, duration, complete);
|
169
|
+
this.top.attr({zIndex: paths[4]}).animate({d: paths[1]}, duration, complete);
|
170
|
+
this.side.attr({zIndex: paths[5]}).animate({d: paths[2]}, duration, complete);
|
171
|
+
} else if (args.opacity) {
|
172
|
+
this.front.animate(args, duration, complete);
|
173
|
+
this.top.animate(args, duration, complete);
|
174
|
+
this.side.animate(args, duration, complete);
|
175
|
+
} else {
|
176
|
+
Highcharts.SVGElement.prototype.animate.call(this, args, duration, complete);
|
177
|
+
}
|
178
|
+
return this;
|
179
|
+
};
|
180
|
+
|
181
|
+
result.destroy = function () {
|
182
|
+
this.front.destroy();
|
183
|
+
this.top.destroy();
|
184
|
+
this.side.destroy();
|
185
|
+
|
186
|
+
return null;
|
187
|
+
};
|
188
|
+
|
189
|
+
// Apply the Z index to the cuboid group
|
190
|
+
result.attr({ zIndex: paths[3] });
|
191
|
+
|
192
|
+
return result;
|
193
|
+
};
|
194
|
+
|
195
|
+
|
196
|
+
Highcharts.SVGRenderer.prototype.cuboidPath = function (shapeArgs) {
|
197
|
+
var x = shapeArgs.x,
|
198
|
+
y = shapeArgs.y,
|
199
|
+
z = shapeArgs.z,
|
200
|
+
h = shapeArgs.height,
|
201
|
+
w = shapeArgs.width,
|
202
|
+
d = shapeArgs.depth,
|
203
|
+
alpha = shapeArgs.alpha,
|
204
|
+
beta = shapeArgs.beta,
|
205
|
+
origin = shapeArgs.origin;
|
206
|
+
|
207
|
+
var pArr = [
|
208
|
+
{x: x, y: y, z: z},
|
209
|
+
{x: x + w, y: y, z: z},
|
210
|
+
{x: x + w, y: y + h, z: z},
|
211
|
+
{x: x, y: y + h, z: z},
|
212
|
+
{x: x, y: y + h, z: z + d},
|
213
|
+
{x: x + w, y: y + h, z: z + d},
|
214
|
+
{x: x + w, y: y, z: z + d},
|
215
|
+
{x: x, y: y, z: z + d}
|
216
|
+
];
|
217
|
+
|
218
|
+
pArr = perspective(pArr, alpha, beta, origin);
|
219
|
+
|
220
|
+
var path1, // FRONT
|
221
|
+
path2, // TOP OR BOTTOM
|
222
|
+
path3; // LEFT OR RIGHT
|
223
|
+
|
224
|
+
// front
|
225
|
+
path1 = [
|
226
|
+
'M', pArr[0].x, pArr[0].y,
|
227
|
+
'L', pArr[1].x, pArr[1].y,
|
228
|
+
'L', pArr[2].x, pArr[2].y,
|
229
|
+
'L', pArr[3].x, pArr[3].y,
|
230
|
+
'Z'
|
231
|
+
];
|
232
|
+
var z1 = (pArr[0].z + pArr[1].z + pArr[2].z + pArr[3].z) / 4;
|
233
|
+
|
234
|
+
// top or bottom
|
235
|
+
var top = [
|
236
|
+
'M', pArr[0].x, pArr[0].y,
|
237
|
+
'L', pArr[7].x, pArr[7].y,
|
238
|
+
'L', pArr[6].x, pArr[6].y,
|
239
|
+
'L', pArr[1].x, pArr[1].y,
|
240
|
+
'Z'
|
241
|
+
];
|
242
|
+
var bottom = [
|
243
|
+
'M', pArr[3].x, pArr[3].y,
|
244
|
+
'L', pArr[2].x, pArr[2].y,
|
245
|
+
'L', pArr[5].x, pArr[5].y,
|
246
|
+
'L', pArr[4].x, pArr[4].y,
|
247
|
+
'Z'
|
248
|
+
];
|
249
|
+
if (pArr[7].y < pArr[1].y) {
|
250
|
+
path2 = top;
|
251
|
+
} else if (pArr[4].y > pArr[2].y) {
|
252
|
+
path2 = bottom;
|
253
|
+
} else {
|
254
|
+
path2 = [];
|
255
|
+
}
|
256
|
+
var z2 = (beta > 0 ? (pArr[0].z + pArr[7].z + pArr[6].z + pArr[1].z) / 4 : (pArr[3].z + pArr[2].z + pArr[5].z + pArr[4].z) / 4);
|
257
|
+
|
258
|
+
// side
|
259
|
+
var right = [
|
260
|
+
'M', pArr[1].x, pArr[1].y,
|
261
|
+
'L', pArr[2].x, pArr[2].y,
|
262
|
+
'L', pArr[5].x, pArr[5].y,
|
263
|
+
'L', pArr[6].x, pArr[6].y,
|
264
|
+
'Z'
|
265
|
+
];
|
266
|
+
var left = [
|
267
|
+
'M', pArr[0].x, pArr[0].y,
|
268
|
+
'L', pArr[7].x, pArr[7].y,
|
269
|
+
'L', pArr[4].x, pArr[4].y,
|
270
|
+
'L', pArr[3].x, pArr[3].y,
|
271
|
+
'Z'
|
272
|
+
];
|
273
|
+
if (pArr[6].x > pArr[1].x) {
|
274
|
+
path3 = right;
|
275
|
+
} else if (pArr[7].x < pArr[0].x) {
|
276
|
+
path3 = left;
|
277
|
+
} else {
|
278
|
+
path3 = [];
|
279
|
+
}
|
280
|
+
var z3 = (alpha > 0 ? (pArr[1].z + pArr[2].z + pArr[5].z + pArr[6].z) / 4 : (pArr[0].z + pArr[7].z + pArr[4].z + pArr[3].z) / 4);
|
281
|
+
|
282
|
+
return [path1, path2, path3, z1, z2, z3];
|
283
|
+
};
|
284
|
+
|
285
|
+
////// SECTORS //////
|
286
|
+
Highcharts.SVGRenderer.prototype.arc3d = function (shapeArgs) {
|
287
|
+
|
288
|
+
shapeArgs.alpha *= deg2rad;
|
289
|
+
shapeArgs.beta *= deg2rad;
|
290
|
+
var result = this.g(),
|
291
|
+
paths = this.arc3dPath(shapeArgs),
|
292
|
+
renderer = result.renderer;
|
293
|
+
|
294
|
+
var zIndex = paths.zAll * 100;
|
295
|
+
|
296
|
+
result.shapeArgs = shapeArgs; // Store for later use
|
297
|
+
|
298
|
+
result.side1 = renderer.path(paths.side2).attr({zIndex: paths.zSide2}).add(result);
|
299
|
+
result.side2 = renderer.path(paths.side1).attr({zIndex: paths.zSide1}).add(result);
|
300
|
+
result.inn = renderer.path(paths.inn).attr({zIndex: paths.zInn}).add(result);
|
301
|
+
result.out = renderer.path(paths.out).attr({zIndex: paths.zOut}).add(result);
|
302
|
+
result.top = renderer.path(paths.top).attr({zIndex: paths.zTop}).add(result);
|
303
|
+
|
304
|
+
result.fillSetter = function (color) {
|
305
|
+
this.color = color;
|
306
|
+
|
307
|
+
var c0 = color,
|
308
|
+
c2 = Highcharts.Color(color).brighten(-0.1).get();
|
309
|
+
|
310
|
+
this.side1.attr({fill: c2});
|
311
|
+
this.side2.attr({fill: c2});
|
312
|
+
this.inn.attr({fill: c2});
|
313
|
+
this.out.attr({fill: c2});
|
314
|
+
this.top.attr({fill: c0});
|
315
|
+
return this;
|
316
|
+
};
|
317
|
+
|
318
|
+
result.animate = function (args, duration, complete) {
|
319
|
+
Highcharts.SVGElement.prototype.animate.call(this, args, duration, complete);
|
320
|
+
|
321
|
+
if (args.x && args.y) {
|
322
|
+
|
323
|
+
// Recreate
|
324
|
+
var result = this,
|
325
|
+
renderer = this.renderer,
|
326
|
+
shapeArgs = Highcharts.splat(args)[0];
|
327
|
+
|
328
|
+
shapeArgs.alpha *= deg2rad;
|
329
|
+
shapeArgs.beta *= deg2rad;
|
330
|
+
|
331
|
+
var paths = renderer.arc3dPath(shapeArgs);
|
332
|
+
|
333
|
+
result.shapeArgs = shapeArgs; // Store for later use
|
334
|
+
|
335
|
+
result.inn.attr({d: paths.inn, zIndex: paths.zInn});
|
336
|
+
result.out.attr({d: paths.out, zIndex: paths.zOut});
|
337
|
+
result.side1.attr({d: paths.side1, zIndex: paths.zSide2});
|
338
|
+
result.side2.attr({d: paths.side2, zIndex: paths.zSide1});
|
339
|
+
result.top.attr({d: paths.top, zIndex: paths.zTop});
|
340
|
+
|
341
|
+
result.attr({fill: result.color});
|
342
|
+
result.attr({zIndex: paths.zAll * 100});
|
343
|
+
}
|
344
|
+
|
345
|
+
return this;
|
346
|
+
};
|
347
|
+
|
348
|
+
result.zIndex = zIndex;
|
349
|
+
result.attr({zIndex: zIndex});
|
350
|
+
return result;
|
351
|
+
};
|
352
|
+
|
353
|
+
|
354
|
+
Highcharts.SVGRenderer.prototype.arc3dPath = function (shapeArgs) {
|
355
|
+
var cx = shapeArgs.x,
|
356
|
+
cy = shapeArgs.y,
|
357
|
+
start = shapeArgs.start,
|
358
|
+
end = shapeArgs.end - 0.00001,
|
359
|
+
r = shapeArgs.r,
|
360
|
+
ir = shapeArgs.innerR,
|
361
|
+
d = shapeArgs.depth,
|
362
|
+
alpha = shapeArgs.alpha,
|
363
|
+
beta = shapeArgs.beta;
|
364
|
+
|
365
|
+
// Some Variables
|
366
|
+
var cs = cos(start),
|
367
|
+
ss = sin(start),
|
368
|
+
ce = cos(end),
|
369
|
+
se = sin(end),
|
370
|
+
rx = r * cos(beta),
|
371
|
+
ry = r * cos(alpha),
|
372
|
+
irx = ir * cos(beta),
|
373
|
+
iry = ir * cos(alpha),
|
374
|
+
dx = d * sin(beta),
|
375
|
+
dy = d * sin(alpha);
|
376
|
+
|
377
|
+
// TOP
|
378
|
+
var top = ['M', cx + (rx * cs), cy + (ry * ss)];
|
379
|
+
top = top.concat(curveTo(cx, cy, rx, ry, start, end, 0, 0));
|
380
|
+
top = top.concat([
|
381
|
+
'L', cx + (irx * ce), cy + (iry * se)
|
382
|
+
]);
|
383
|
+
top = top.concat(curveTo(cx, cy, irx, iry, end, start, 0, 0));
|
384
|
+
top = top.concat(['Z']);
|
385
|
+
|
386
|
+
var midAngle = ((shapeArgs.start + shapeArgs.end) / 2);
|
387
|
+
var zIndex = ((sin(beta) * cos(midAngle)) + (sin(-alpha) * sin(-midAngle)));
|
388
|
+
|
389
|
+
// OUTSIDE
|
390
|
+
var b = (beta > 0 ? PI / 2 : 0),
|
391
|
+
a = (alpha > 0 ? 0 : PI / 2);
|
392
|
+
|
393
|
+
var start2 = start > -b ? start : (end > -b ? -b : start),
|
394
|
+
end2 = end < PI - a ? end : (start < PI - a ? PI - a : end);
|
395
|
+
|
396
|
+
var out = ['M', cx + (rx * cos(start2)), cy + (ry * sin(start2))];
|
397
|
+
out = out.concat(curveTo(cx, cy, rx, ry, start2, end2, 0, 0));
|
398
|
+
out = out.concat([
|
399
|
+
'L', cx + (rx * cos(end2)) + dx, cy + (ry * sin(end2)) + dy
|
400
|
+
]);
|
401
|
+
out = out.concat(curveTo(cx, cy, rx, ry, end2, start2, dx, dy));
|
402
|
+
out = out.concat(['Z']);
|
403
|
+
|
404
|
+
// INSIDE
|
405
|
+
var inn = ['M', cx + (irx * cs), cy + (iry * ss)];
|
406
|
+
inn = inn.concat(curveTo(cx, cy, irx, iry, start, end, 0, 0));
|
407
|
+
inn = inn.concat([
|
408
|
+
'L', cx + (irx * cos(end)) + dx, cy + (iry * sin(end)) + dy
|
409
|
+
]);
|
410
|
+
inn = inn.concat(curveTo(cx, cy, irx, iry, end, start, dx, dy));
|
411
|
+
inn = inn.concat(['Z']);
|
412
|
+
|
413
|
+
// SIDES
|
414
|
+
var side1 = [
|
415
|
+
'M', cx + (rx * cs), cy + (ry * ss),
|
416
|
+
'L', cx + (rx * cs) + dx, cy + (ry * ss) + dy,
|
417
|
+
'L', cx + (irx * cs) + dx, cy + (iry * ss) + dy,
|
418
|
+
'L', cx + (irx * cs), cy + (iry * ss),
|
419
|
+
'Z'
|
420
|
+
];
|
421
|
+
var side2 = [
|
422
|
+
'M', cx + (rx * ce), cy + (ry * se),
|
423
|
+
'L', cx + (rx * ce) + dx, cy + (ry * se) + dy,
|
424
|
+
'L', cx + (irx * ce) + dx, cy + (iry * se) + dy,
|
425
|
+
'L', cx + (irx * ce), cy + (iry * se),
|
426
|
+
'Z'
|
427
|
+
];
|
428
|
+
|
429
|
+
var mr = ir + ((r - ir) / 2);
|
430
|
+
|
431
|
+
var zTop = Math.abs(zIndex * 2 * mr),
|
432
|
+
zOut = zIndex * r,
|
433
|
+
zInn = zIndex * ir,
|
434
|
+
zSide1 = ((sin(beta) * cos(start)) + (sin(-alpha) * sin(-start))) * mr,
|
435
|
+
zSide2 = ((sin(beta) * cos(end)) + (sin(-alpha) * sin(-end))) * mr;
|
436
|
+
|
437
|
+
return {
|
438
|
+
top: top,
|
439
|
+
zTop: zTop * 100,
|
440
|
+
out: out,
|
441
|
+
zOut: zOut * 100,
|
442
|
+
inn: inn,
|
443
|
+
zInn: zInn * 100,
|
444
|
+
side1: side1,
|
445
|
+
zSide1: zSide1 * 100,
|
446
|
+
side2: side2,
|
447
|
+
zSide2: zSide2 * 100,
|
448
|
+
zAll: zIndex
|
449
|
+
};
|
450
|
+
};
|
451
|
+
/***
|
452
|
+
EXTENSION FOR 3D CHARTS
|
453
|
+
***/
|
454
|
+
// Shorthand to check the is3d flag
|
455
|
+
Highcharts.Chart.prototype.is3d = function () {
|
456
|
+
return this.options.chart.options3d && this.options.chart.options3d.enabled;
|
457
|
+
};
|
458
|
+
|
459
|
+
Highcharts.wrap(Highcharts.Chart.prototype, 'isInsidePlot', function (proceed) {
|
460
|
+
if (this.is3d()) {
|
461
|
+
return true;
|
462
|
+
} else {
|
463
|
+
return proceed.apply(this, [].slice.call(arguments, 1));
|
464
|
+
}
|
465
|
+
});
|
466
|
+
|
467
|
+
Highcharts.wrap(Highcharts.Chart.prototype, 'init', function (proceed) {
|
468
|
+
var args = arguments;
|
469
|
+
args[1] = Highcharts.merge({
|
470
|
+
chart: {
|
471
|
+
options3d: {
|
472
|
+
enabled: false,
|
473
|
+
alpha: 0,
|
474
|
+
beta: 0,
|
475
|
+
depth: 100,
|
476
|
+
viewDistance: 25,
|
477
|
+
|
478
|
+
frame: {
|
479
|
+
bottom: { size: 1, color: 'rgba(255,255,255,0)' },
|
480
|
+
side: { size: 1, color: 'rgba(255,255,255,0)' },
|
481
|
+
back: { size: 1, color: 'rgba(255,255,255,0)' }
|
482
|
+
}
|
483
|
+
}
|
484
|
+
}
|
485
|
+
}, args[1]);
|
486
|
+
|
487
|
+
proceed.apply(this, [].slice.call(args, 1));
|
488
|
+
});
|
489
|
+
|
490
|
+
Highcharts.wrap(Highcharts.Chart.prototype, 'setChartSize', function (proceed) {
|
491
|
+
proceed.apply(this, [].slice.call(arguments, 1));
|
492
|
+
|
493
|
+
if (this.is3d()) {
|
494
|
+
var inverted = this.inverted,
|
495
|
+
clipBox = this.clipBox,
|
496
|
+
margin = this.margin,
|
497
|
+
x = inverted ? 'y' : 'x',
|
498
|
+
y = inverted ? 'x' : 'y',
|
499
|
+
w = inverted ? 'height' : 'width',
|
500
|
+
h = inverted ? 'width' : 'height';
|
501
|
+
|
502
|
+
clipBox[x] = -(margin[3] || 0);
|
503
|
+
clipBox[y] = -(margin[0] || 0);
|
504
|
+
clipBox[w] = this.chartWidth + (margin[3] || 0) + (margin[1] || 0);
|
505
|
+
clipBox[h] = this.chartHeight + (margin[0] || 0) + (margin[2] || 0);
|
506
|
+
}
|
507
|
+
});
|
508
|
+
|
509
|
+
Highcharts.wrap(Highcharts.Chart.prototype, 'redraw', function (proceed) {
|
510
|
+
if (this.is3d()) {
|
511
|
+
// Set to force a redraw of all elements
|
512
|
+
this.isDirtyBox = true;
|
513
|
+
}
|
514
|
+
proceed.apply(this, [].slice.call(arguments, 1));
|
515
|
+
});
|
516
|
+
|
517
|
+
Highcharts.Chart.prototype.retrieveStacks = function () {
|
518
|
+
var stacks = {},
|
519
|
+
type = this.options.chart.type,
|
520
|
+
typeOptions = this.options.plotOptions[type],
|
521
|
+
stacking = typeOptions.stacking,
|
522
|
+
grouping = typeOptions.grouping;
|
523
|
+
|
524
|
+
if (grouping || !stacking) { return this.series; }
|
525
|
+
|
526
|
+
Highcharts.each(this.series, function (S) {
|
527
|
+
if (!stacks[S.options.stack || 0]) {
|
528
|
+
stacks[S.options.stack || 0] = [S];
|
529
|
+
} else {
|
530
|
+
stacks[S.options.stack || 0].push(S);
|
531
|
+
}
|
532
|
+
});
|
533
|
+
return stacks;
|
534
|
+
};
|
535
|
+
|
536
|
+
/***
|
537
|
+
EXTENSION TO THE AXIS
|
538
|
+
***/
|
539
|
+
Highcharts.wrap(Highcharts.Axis.prototype, 'init', function (proceed) {
|
540
|
+
var args = arguments;
|
541
|
+
if (args[1].is3d()) {
|
542
|
+
args[2].tickWidth = Highcharts.pick(args[2].tickWidth, 0);
|
543
|
+
args[2].gridLineWidth = Highcharts.pick(args[2].gridLineWidth, 1);
|
544
|
+
}
|
545
|
+
|
546
|
+
proceed.apply(this, [].slice.call(arguments, 1));
|
547
|
+
});
|
548
|
+
Highcharts.wrap(Highcharts.Axis.prototype, 'render', function (proceed) {
|
549
|
+
proceed.apply(this, [].slice.call(arguments, 1));
|
550
|
+
|
551
|
+
// Do not do this if the chart is not 3D
|
552
|
+
if (!this.chart.is3d()) {
|
553
|
+
return;
|
554
|
+
}
|
555
|
+
|
556
|
+
var chart = this.chart,
|
557
|
+
renderer = chart.renderer,
|
558
|
+
options3d = chart.options.chart.options3d,
|
559
|
+
alpha = options3d.alpha,
|
560
|
+
beta = options3d.beta * (chart.yAxis[0].opposite ? -1 : 1),
|
561
|
+
frame = options3d.frame,
|
562
|
+
fbottom = frame.bottom,
|
563
|
+
fback = frame.back,
|
564
|
+
fside = frame.side,
|
565
|
+
depth = options3d.depth,
|
566
|
+
height = this.height,
|
567
|
+
width = this.width,
|
568
|
+
left = this.left,
|
569
|
+
top = this.top;
|
570
|
+
|
571
|
+
var origin = {
|
572
|
+
x: chart.plotLeft + (chart.plotWidth / 2),
|
573
|
+
y: chart.plotTop + (chart.plotHeight / 2),
|
574
|
+
z: depth,
|
575
|
+
vd: options3d.viewDistance
|
576
|
+
};
|
577
|
+
if (this.horiz) {
|
578
|
+
/// BOTTOM
|
579
|
+
if (this.axisLine) {
|
580
|
+
this.axisLine.hide();
|
581
|
+
}
|
582
|
+
var bottomShape = {
|
583
|
+
x: left,
|
584
|
+
y: top + (chart.yAxis[0].reversed ? -fbottom.size : height),
|
585
|
+
z: 0,
|
586
|
+
width: width,
|
587
|
+
height: fbottom.size,
|
588
|
+
depth: depth,
|
589
|
+
alpha: alpha,
|
590
|
+
beta: beta,
|
591
|
+
origin: origin
|
592
|
+
};
|
593
|
+
if (!this.bottomFrame) {
|
594
|
+
this.bottomFrame = renderer.cuboid(bottomShape).attr({fill: fbottom.color, zIndex: (chart.yAxis[0].reversed && alpha > 0 ? 4 : -1)}).css({stroke: fbottom.color}).add();
|
595
|
+
} else {
|
596
|
+
this.bottomFrame.animate(bottomShape);
|
597
|
+
}
|
598
|
+
} else {
|
599
|
+
// BACK
|
600
|
+
var backShape = {
|
601
|
+
x: left,
|
602
|
+
y: top,
|
603
|
+
z: depth + 1,
|
604
|
+
width: width,
|
605
|
+
height: height + fbottom.size,
|
606
|
+
depth: fback.size,
|
607
|
+
alpha: alpha,
|
608
|
+
beta: beta,
|
609
|
+
origin: origin
|
610
|
+
};
|
611
|
+
if (!this.backFrame) {
|
612
|
+
this.backFrame = renderer.cuboid(backShape).attr({fill: fback.color, zIndex: -3}).css({stroke: fback.color}).add();
|
613
|
+
} else {
|
614
|
+
this.backFrame.animate(backShape);
|
615
|
+
}
|
616
|
+
// SIDE
|
617
|
+
if (this.axisLine) {
|
618
|
+
this.axisLine.hide();
|
619
|
+
}
|
620
|
+
var sideShape = {
|
621
|
+
x: (chart.yAxis[0].opposite ? width : 0) + left - fside.size,
|
622
|
+
y: top,
|
623
|
+
z: 0,
|
624
|
+
width: fside.size,
|
625
|
+
height: height + fbottom.size,
|
626
|
+
depth: depth + fback.size,
|
627
|
+
alpha: alpha,
|
628
|
+
beta: beta,
|
629
|
+
origin: origin
|
630
|
+
};
|
631
|
+
if (!this.sideFrame) {
|
632
|
+
this.sideFrame = renderer.cuboid(sideShape).attr({fill: fside.color, zIndex: -2}).css({stroke: fside.color}).add();
|
633
|
+
} else {
|
634
|
+
this.sideFrame.animate(sideShape);
|
635
|
+
}
|
636
|
+
}
|
637
|
+
});
|
638
|
+
|
639
|
+
Highcharts.wrap(Highcharts.Axis.prototype, 'getPlotLinePath', function (proceed) {
|
640
|
+
var path = proceed.apply(this, [].slice.call(arguments, 1));
|
641
|
+
|
642
|
+
// Do not do this if the chart is not 3D
|
643
|
+
if (!this.chart.is3d()) {
|
644
|
+
return path;
|
645
|
+
}
|
646
|
+
|
647
|
+
if (path === null) { return path; }
|
648
|
+
|
649
|
+
var chart = this.chart,
|
650
|
+
options3d = chart.options.chart.options3d;
|
651
|
+
|
652
|
+
var d = options3d.depth;
|
653
|
+
|
654
|
+
options3d.origin = {
|
655
|
+
x: chart.plotLeft + (chart.plotWidth / 2),
|
656
|
+
y: chart.plotTop + (chart.plotHeight / 2),
|
657
|
+
z: d,
|
658
|
+
vd: options3d.viewDistance
|
659
|
+
};
|
660
|
+
|
661
|
+
var pArr = [
|
662
|
+
{ x: path[1], y: path[2], z : (this.horiz || this.opposite ? d : 0)},
|
663
|
+
{ x: path[1], y: path[2], z : d },
|
664
|
+
{ x: path[4], y: path[5], z : d },
|
665
|
+
{ x: path[4], y: path[5], z : (this.horiz || this.opposite ? 0 : d)}
|
666
|
+
];
|
667
|
+
|
668
|
+
var alpha = chart.options.inverted ? options3d.beta : options3d.alpha,
|
669
|
+
beta = chart.options.inverted ? options3d.alpha : options3d.beta;
|
670
|
+
|
671
|
+
beta *= (chart.yAxis[0].opposite ? -1 : 1);
|
672
|
+
|
673
|
+
pArr = perspective(pArr, alpha, beta, options3d.origin);
|
674
|
+
path = this.chart.renderer.toLinePath(pArr, false);
|
675
|
+
|
676
|
+
return path;
|
677
|
+
});
|
678
|
+
|
679
|
+
/***
|
680
|
+
EXTENSION TO THE TICKS
|
681
|
+
***/
|
682
|
+
|
683
|
+
Highcharts.wrap(Highcharts.Tick.prototype, 'getMarkPath', function (proceed) {
|
684
|
+
var path = proceed.apply(this, [].slice.call(arguments, 1));
|
685
|
+
|
686
|
+
// Do not do this if the chart is not 3D
|
687
|
+
if (!this.axis.chart.is3d()) {
|
688
|
+
return path;
|
689
|
+
}
|
690
|
+
|
691
|
+
var chart = this.axis.chart,
|
692
|
+
options3d = chart.options.chart.options3d;
|
693
|
+
|
694
|
+
var origin = {
|
695
|
+
x: chart.plotLeft + (chart.plotWidth / 2),
|
696
|
+
y: chart.plotTop + (chart.plotHeight / 2),
|
697
|
+
z: options3d.depth,
|
698
|
+
vd: options3d.viewDistance
|
699
|
+
};
|
700
|
+
|
701
|
+
var pArr = [
|
702
|
+
{x: path[1], y: path[2], z: 0},
|
703
|
+
{x: path[4], y: path[5], z: 0}
|
704
|
+
];
|
705
|
+
|
706
|
+
var alpha = chart.inverted ? options3d.beta : options3d.alpha,
|
707
|
+
beta = chart.inverted ? options3d.alpha : options3d.beta;
|
708
|
+
|
709
|
+
beta *= (chart.yAxis[0].opposite ? -1 : 1);
|
710
|
+
|
711
|
+
pArr = perspective(pArr, alpha, beta, origin);
|
712
|
+
path = [
|
713
|
+
'M', pArr[0].x, pArr[0].y,
|
714
|
+
'L', pArr[1].x, pArr[1].y
|
715
|
+
];
|
716
|
+
return path;
|
717
|
+
});
|
718
|
+
|
719
|
+
Highcharts.wrap(Highcharts.Tick.prototype, 'getLabelPosition', function (proceed) {
|
720
|
+
var pos = proceed.apply(this, [].slice.call(arguments, 1));
|
721
|
+
|
722
|
+
// Do not do this if the chart is not 3D
|
723
|
+
if (!this.axis.chart.is3d()) {
|
724
|
+
return pos;
|
725
|
+
}
|
726
|
+
|
727
|
+
var chart = this.axis.chart,
|
728
|
+
options3d = chart.options.chart.options3d;
|
729
|
+
|
730
|
+
var origin = {
|
731
|
+
x: chart.plotLeft + (chart.plotWidth / 2),
|
732
|
+
y: chart.plotTop + (chart.plotHeight / 2),
|
733
|
+
z: options3d.depth,
|
734
|
+
vd: options3d.viewDistance
|
735
|
+
};
|
736
|
+
|
737
|
+
var alpha = chart.inverted ? options3d.beta : options3d.alpha,
|
738
|
+
beta = chart.inverted ? options3d.alpha : options3d.beta;
|
739
|
+
|
740
|
+
beta *= (chart.yAxis[0].opposite ? -1 : 1);
|
741
|
+
|
742
|
+
pos = perspective([{x: pos.x, y: pos.y, z: 0}], alpha, beta, origin)[0];
|
743
|
+
return pos;
|
744
|
+
});
|
745
|
+
|
746
|
+
Highcharts.wrap(Highcharts.Axis.prototype, 'drawCrosshair', function (proceed) {
|
747
|
+
var args = arguments;
|
748
|
+
if (this.chart.is3d()) {
|
749
|
+
if (args[2]) {
|
750
|
+
args[2] = {
|
751
|
+
plotX: args[2].plotXold || args[2].plotX,
|
752
|
+
plotY: args[2].plotYold || args[2].plotY
|
753
|
+
};
|
754
|
+
}
|
755
|
+
}
|
756
|
+
proceed.apply(this, [].slice.call(args, 1));
|
757
|
+
});/***
|
758
|
+
EXTENSION FOR 3D COLUMNS
|
759
|
+
***/
|
760
|
+
Highcharts.wrap(Highcharts.seriesTypes.column.prototype, 'translate', function (proceed) {
|
761
|
+
proceed.apply(this, [].slice.call(arguments, 1));
|
762
|
+
|
763
|
+
// Do not do this if the chart is not 3D
|
764
|
+
if (!this.chart.is3d()) {
|
765
|
+
return;
|
766
|
+
}
|
767
|
+
|
768
|
+
var type = this.chart.options.chart.type,
|
769
|
+
series = this,
|
770
|
+
chart = series.chart,
|
771
|
+
options = chart.options,
|
772
|
+
typeOptions = options.plotOptions[type],
|
773
|
+
options3d = options.chart.options3d,
|
774
|
+
|
775
|
+
depth = typeOptions.depth || 25,
|
776
|
+
origin = {
|
777
|
+
x: chart.plotWidth / 2,
|
778
|
+
y: chart.plotHeight / 2,
|
779
|
+
z: options3d.depth,
|
780
|
+
vd: options3d.viewDistance
|
781
|
+
},
|
782
|
+
alpha = options3d.alpha,
|
783
|
+
beta = options3d.beta * (chart.yAxis[0].opposite ? -1 : 1);
|
784
|
+
|
785
|
+
var stack = typeOptions.stacking ? (this.options.stack || 0) : series._i;
|
786
|
+
var z = stack * (depth + (typeOptions.groupZPadding || 1));
|
787
|
+
|
788
|
+
if (typeOptions.grouping !== false) { z = 0; }
|
789
|
+
|
790
|
+
z += (typeOptions.groupZPadding || 1);
|
791
|
+
|
792
|
+
Highcharts.each(series.data, function (point) {
|
793
|
+
var shapeArgs = point.shapeArgs,
|
794
|
+
tooltipPos = point.tooltipPos;
|
795
|
+
|
796
|
+
point.shapeType = 'cuboid';
|
797
|
+
shapeArgs.alpha = alpha;
|
798
|
+
shapeArgs.beta = beta;
|
799
|
+
shapeArgs.z = z;
|
800
|
+
shapeArgs.origin = origin;
|
801
|
+
shapeArgs.depth = depth;
|
802
|
+
|
803
|
+
// Translate the tooltip position in 3d space
|
804
|
+
tooltipPos = perspective([{ x: tooltipPos[0], y: tooltipPos[1], z: z }], alpha, beta, origin)[0];
|
805
|
+
point.tooltipPos = [tooltipPos.x, tooltipPos.y];
|
806
|
+
|
807
|
+
});
|
808
|
+
});
|
809
|
+
|
810
|
+
Highcharts.wrap(Highcharts.seriesTypes.column.prototype, 'animate', function (proceed) {
|
811
|
+
if (!this.chart.is3d()) {
|
812
|
+
proceed.apply(this, [].slice.call(arguments, 1));
|
813
|
+
} else {
|
814
|
+
var args = arguments,
|
815
|
+
init = args[1],
|
816
|
+
yAxis = this.yAxis,
|
817
|
+
series = this,
|
818
|
+
reversed = this.yAxis.reversed;
|
819
|
+
|
820
|
+
if (Highcharts.svg) { // VML is too slow anyway
|
821
|
+
if (init) {
|
822
|
+
Highcharts.each(series.data, function (point) {
|
823
|
+
point.height = point.shapeArgs.height;
|
824
|
+
point.shapeArgs.height = 1;
|
825
|
+
if (!reversed) {
|
826
|
+
if (point.stackY) {
|
827
|
+
point.shapeArgs.y = point.plotY + yAxis.translate(point.stackY);
|
828
|
+
} else {
|
829
|
+
point.shapeArgs.y = point.plotY + (point.negative ? -point.height : point.height);
|
830
|
+
}
|
831
|
+
}
|
832
|
+
});
|
833
|
+
|
834
|
+
} else { // run the animation
|
835
|
+
Highcharts.each(series.data, function (point) {
|
836
|
+
point.shapeArgs.height = point.height;
|
837
|
+
if (!reversed) {
|
838
|
+
point.shapeArgs.y = point.plotY - (point.negative ? point.height : 0);
|
839
|
+
}
|
840
|
+
// null value do not have a graphic
|
841
|
+
if (point.graphic) {
|
842
|
+
point.graphic.animate(point.shapeArgs, series.options.animation);
|
843
|
+
}
|
844
|
+
});
|
845
|
+
|
846
|
+
// delete this function to allow it only once
|
847
|
+
series.animate = null;
|
848
|
+
}
|
849
|
+
}
|
850
|
+
}
|
851
|
+
});
|
852
|
+
|
853
|
+
|
854
|
+
Highcharts.wrap(Highcharts.seriesTypes.column.prototype, 'init', function (proceed) {
|
855
|
+
proceed.apply(this, [].slice.call(arguments, 1));
|
856
|
+
|
857
|
+
if (this.chart.is3d()) {
|
858
|
+
var grouping = this.chart.options.plotOptions.column.grouping,
|
859
|
+
stacking = this.chart.options.plotOptions.column.stacking,
|
860
|
+
z = this.options.zIndex;
|
861
|
+
if (!z) {
|
862
|
+
if (!(grouping !== undefined && !grouping) && stacking) {
|
863
|
+
var stacks = this.chart.retrieveStacks(),
|
864
|
+
stack = this.options.stack || 0,
|
865
|
+
i;
|
866
|
+
for (i = 0; i < stacks[stack].length; i++) {
|
867
|
+
if (stacks[stack][i] === this) {
|
868
|
+
break;
|
869
|
+
}
|
870
|
+
}
|
871
|
+
z = 100 - 10 * i + this.index;
|
872
|
+
|
873
|
+
this.options.zIndex = z;
|
874
|
+
}
|
875
|
+
}
|
876
|
+
}
|
877
|
+
});
|
878
|
+
function draw3DPoints(proceed) {
|
879
|
+
// Do not do this if the chart is not 3D
|
880
|
+
if (this.chart.is3d()) {
|
881
|
+
var grouping = this.chart.options.plotOptions.column.grouping;
|
882
|
+
if (grouping !== undefined && !grouping && this.group.zIndex !== undefined) {
|
883
|
+
this.group.attr({zIndex : (this.group.zIndex * 10)});
|
884
|
+
}
|
885
|
+
if (this.userOptions.borderColor === undefined) {
|
886
|
+
this.options.borderColor = this.color;
|
887
|
+
}
|
888
|
+
|
889
|
+
// Set the border color to the fill color to provide a smooth edge
|
890
|
+
Highcharts.each(this.data, function (point) {
|
891
|
+
var c = point.options.borderColor || point.color || point.series.userOptions.borderColor;
|
892
|
+
point.options.borderColor = c;
|
893
|
+
point.borderColor = c;
|
894
|
+
point.pointAttr[''].stroke = c;
|
895
|
+
// same bordercolor on hover and select
|
896
|
+
point.pointAttr.hover.stroke = c;
|
897
|
+
point.pointAttr.select.stroke = c;
|
898
|
+
});
|
899
|
+
}
|
900
|
+
|
901
|
+
proceed.apply(this, [].slice.call(arguments, 1));
|
902
|
+
}
|
903
|
+
|
904
|
+
if (Highcharts.seriesTypes.columnrange) {
|
905
|
+
Highcharts.wrap(Highcharts.seriesTypes.columnrange.prototype, 'drawPoints', draw3DPoints);
|
906
|
+
}
|
907
|
+
|
908
|
+
Highcharts.wrap(Highcharts.seriesTypes.column.prototype, 'drawPoints', draw3DPoints);
|
909
|
+
|
910
|
+
/***
|
911
|
+
EXTENSION FOR 3D CYLINDRICAL COLUMNS
|
912
|
+
Not supported
|
913
|
+
***/
|
914
|
+
var defaultOptions = Highcharts.getOptions();
|
915
|
+
defaultOptions.plotOptions.cylinder = Highcharts.merge(defaultOptions.plotOptions.column);
|
916
|
+
var CylinderSeries = Highcharts.extendClass(Highcharts.seriesTypes.column, {
|
917
|
+
type: 'cylinder'
|
918
|
+
});
|
919
|
+
Highcharts.seriesTypes.cylinder = CylinderSeries;
|
920
|
+
|
921
|
+
Highcharts.wrap(Highcharts.seriesTypes.cylinder.prototype, 'translate', function (proceed) {
|
922
|
+
proceed.apply(this, [].slice.call(arguments, 1));
|
923
|
+
|
924
|
+
// Do not do this if the chart is not 3D
|
925
|
+
if (!this.chart.is3d()) {
|
926
|
+
return;
|
927
|
+
}
|
928
|
+
|
929
|
+
var series = this,
|
930
|
+
chart = series.chart,
|
931
|
+
options = chart.options,
|
932
|
+
cylOptions = options.plotOptions.cylinder,
|
933
|
+
options3d = options.chart.options3d,
|
934
|
+
depth = cylOptions.depth || 0,
|
935
|
+
origin = {
|
936
|
+
x: chart.inverted ? chart.plotHeight / 2 : chart.plotWidth / 2,
|
937
|
+
y: chart.inverted ? chart.plotWidth / 2 : chart.plotHeight / 2,
|
938
|
+
z: options3d.depth,
|
939
|
+
vd: options3d.viewDistance
|
940
|
+
},
|
941
|
+
alpha = options3d.alpha;
|
942
|
+
|
943
|
+
var z = cylOptions.stacking ? (this.options.stack || 0) * depth : series._i * depth;
|
944
|
+
z += depth / 2;
|
945
|
+
|
946
|
+
if (cylOptions.grouping !== false) { z = 0; }
|
947
|
+
|
948
|
+
Highcharts.each(series.data, function (point) {
|
949
|
+
var shapeArgs = point.shapeArgs;
|
950
|
+
point.shapeType = 'arc3d';
|
951
|
+
shapeArgs.x += depth / 2;
|
952
|
+
shapeArgs.z = z;
|
953
|
+
shapeArgs.start = 0;
|
954
|
+
shapeArgs.end = 2 * PI;
|
955
|
+
shapeArgs.r = depth * 0.95;
|
956
|
+
shapeArgs.innerR = 0;
|
957
|
+
shapeArgs.depth = shapeArgs.height * (1 / sin((90 - alpha) * deg2rad)) - z;
|
958
|
+
shapeArgs.alpha = 90 - alpha;
|
959
|
+
shapeArgs.beta = 0;
|
960
|
+
shapeArgs.origin = origin;
|
961
|
+
});
|
962
|
+
});
|
963
|
+
/***
|
964
|
+
EXTENSION FOR 3D PIES
|
965
|
+
***/
|
966
|
+
|
967
|
+
Highcharts.wrap(Highcharts.seriesTypes.pie.prototype, 'translate', function (proceed) {
|
968
|
+
proceed.apply(this, [].slice.call(arguments, 1));
|
969
|
+
|
970
|
+
// Do not do this if the chart is not 3D
|
971
|
+
if (!this.chart.is3d()) {
|
972
|
+
return;
|
973
|
+
}
|
974
|
+
|
975
|
+
var series = this,
|
976
|
+
chart = series.chart,
|
977
|
+
options = chart.options,
|
978
|
+
pieOptions = options.plotOptions.pie,
|
979
|
+
depth = pieOptions.depth || 0,
|
980
|
+
options3d = options.chart.options3d,
|
981
|
+
origin = {
|
982
|
+
x: chart.plotWidth / 2,
|
983
|
+
y: chart.plotHeight / 2,
|
984
|
+
z: options3d.depth
|
985
|
+
},
|
986
|
+
alpha = options3d.alpha,
|
987
|
+
beta = options3d.beta;
|
988
|
+
|
989
|
+
var z = pieOptions.stacking ? (this.options.stack || 0) * depth : series._i * depth;
|
990
|
+
z += depth / 2;
|
991
|
+
|
992
|
+
if (pieOptions.grouping !== false) { z = 0; }
|
993
|
+
|
994
|
+
Highcharts.each(series.data, function (point) {
|
995
|
+
point.shapeType = 'arc3d';
|
996
|
+
var shapeArgs = point.shapeArgs;
|
997
|
+
|
998
|
+
shapeArgs.z = z;
|
999
|
+
shapeArgs.depth = depth * 0.75;
|
1000
|
+
shapeArgs.origin = origin;
|
1001
|
+
shapeArgs.alpha = alpha;
|
1002
|
+
shapeArgs.beta = beta;
|
1003
|
+
|
1004
|
+
var angle = (shapeArgs.end + shapeArgs.start) / 2;
|
1005
|
+
|
1006
|
+
point.slicedTranslation = {
|
1007
|
+
translateX : round(cos(angle) * series.options.slicedOffset * cos(alpha * deg2rad)),
|
1008
|
+
translateY : round(sin(angle) * series.options.slicedOffset * cos(alpha * deg2rad))
|
1009
|
+
};
|
1010
|
+
});
|
1011
|
+
});
|
1012
|
+
|
1013
|
+
Highcharts.wrap(Highcharts.seriesTypes.pie.prototype.pointClass.prototype, 'haloPath', function (proceed) {
|
1014
|
+
return this.series.chart.is3d() ? [] : proceed.call(this);
|
1015
|
+
});
|
1016
|
+
|
1017
|
+
Highcharts.wrap(Highcharts.seriesTypes.pie.prototype, 'drawPoints', function (proceed) {
|
1018
|
+
// Do not do this if the chart is not 3D
|
1019
|
+
if (this.chart.is3d()) {
|
1020
|
+
// Set the border color to the fill color to provide a smooth edge
|
1021
|
+
Highcharts.each(this.data, function (point) {
|
1022
|
+
var c = point.options.borderColor || point.color || point.series.userOptions.borderColor || point.series.color;
|
1023
|
+
point.options.borderColor = c;
|
1024
|
+
point.borderColor = c;
|
1025
|
+
point.pointAttr[''].stroke = c;
|
1026
|
+
// same bordercolor on hover and select
|
1027
|
+
point.pointAttr.hover.stroke = c;
|
1028
|
+
point.pointAttr.select.stroke = c;
|
1029
|
+
});
|
1030
|
+
}
|
1031
|
+
|
1032
|
+
proceed.apply(this, [].slice.call(arguments, 1));
|
1033
|
+
});
|
1034
|
+
|
1035
|
+
Highcharts.wrap(Highcharts.seriesTypes.pie.prototype, 'drawDataLabels', function (proceed) {
|
1036
|
+
proceed.apply(this, [].slice.call(arguments, 1));
|
1037
|
+
// Do not do this if the chart is not 3D
|
1038
|
+
if (!this.chart.is3d()) {
|
1039
|
+
return;
|
1040
|
+
}
|
1041
|
+
|
1042
|
+
var series = this;
|
1043
|
+
Highcharts.each(series.data, function (point) {
|
1044
|
+
var shapeArgs = point.shapeArgs;
|
1045
|
+
var r = shapeArgs.r,
|
1046
|
+
d = shapeArgs.depth,
|
1047
|
+
a1 = shapeArgs.alpha * deg2rad,
|
1048
|
+
b1 = shapeArgs.beta * deg2rad,
|
1049
|
+
a2 = (shapeArgs.start + shapeArgs.end) / 2;
|
1050
|
+
|
1051
|
+
if (point.connector) {
|
1052
|
+
point.connector.translate(
|
1053
|
+
(-r * (1 - cos(b1)) * cos(a2)) + (cos(a2) > 0 ? sin(b1) * d : 0),
|
1054
|
+
(-r * (1 - cos(a1)) * sin(a2)) + (sin(a2) > 0 ? sin(a1) * d : 0)
|
1055
|
+
);
|
1056
|
+
}
|
1057
|
+
if (point.dataLabel) {
|
1058
|
+
point.dataLabel.attr({
|
1059
|
+
x: point.dataLabel.connX + (-r * (1 - cos(b1)) * cos(a2)) + (cos(a2) > 0 ? cos(b1) * d : 0) - (point.dataLabel.width / 2),
|
1060
|
+
y: point.dataLabel.connY + (-r * (1 - cos(a1)) * sin(a2)) + (sin(a2) > 0 ? sin(a1) * d : 0) - (point.dataLabel.height / 2)
|
1061
|
+
});
|
1062
|
+
}
|
1063
|
+
});
|
1064
|
+
});
|
1065
|
+
|
1066
|
+
Highcharts.wrap(Highcharts.seriesTypes.pie.prototype, 'addPoint', function (proceed) {
|
1067
|
+
proceed.apply(this, [].slice.call(arguments, 1));
|
1068
|
+
if (this.chart.is3d()) {
|
1069
|
+
// destroy (and rebuild) everything!!!
|
1070
|
+
this.update();
|
1071
|
+
}
|
1072
|
+
});
|
1073
|
+
|
1074
|
+
Highcharts.wrap(Highcharts.seriesTypes.pie.prototype, 'animate', function (proceed) {
|
1075
|
+
if (!this.chart.is3d()) {
|
1076
|
+
proceed.apply(this, [].slice.call(arguments, 1));
|
1077
|
+
} else {
|
1078
|
+
var args = arguments,
|
1079
|
+
init = args[1],
|
1080
|
+
animation = this.options.animation,
|
1081
|
+
attribs,
|
1082
|
+
center = this.center,
|
1083
|
+
group = this.group,
|
1084
|
+
markerGroup = this.markerGroup;
|
1085
|
+
|
1086
|
+
if (Highcharts.svg) { // VML is too slow anyway
|
1087
|
+
|
1088
|
+
if (animation === true) {
|
1089
|
+
animation = {};
|
1090
|
+
}
|
1091
|
+
// Initialize the animation
|
1092
|
+
if (init) {
|
1093
|
+
|
1094
|
+
// Scale down the group and place it in the center
|
1095
|
+
this.oldtranslateX = group.translateX;
|
1096
|
+
this.oldtranslateY = group.translateY;
|
1097
|
+
attribs = {
|
1098
|
+
translateX: center[0],
|
1099
|
+
translateY: center[1],
|
1100
|
+
scaleX: 0.001, // #1499
|
1101
|
+
scaleY: 0.001
|
1102
|
+
};
|
1103
|
+
|
1104
|
+
group.attr(attribs);
|
1105
|
+
if (markerGroup) {
|
1106
|
+
markerGroup.attrSetters = group.attrSetters;
|
1107
|
+
markerGroup.attr(attribs);
|
1108
|
+
}
|
1109
|
+
|
1110
|
+
// Run the animation
|
1111
|
+
} else {
|
1112
|
+
attribs = {
|
1113
|
+
translateX: this.oldtranslateX,
|
1114
|
+
translateY: this.oldtranslateY,
|
1115
|
+
scaleX: 1,
|
1116
|
+
scaleY: 1
|
1117
|
+
};
|
1118
|
+
group.animate(attribs, animation);
|
1119
|
+
if (markerGroup) {
|
1120
|
+
markerGroup.animate(attribs, animation);
|
1121
|
+
}
|
1122
|
+
|
1123
|
+
// Delete this function to allow it only once
|
1124
|
+
this.animate = null;
|
1125
|
+
}
|
1126
|
+
|
1127
|
+
}
|
1128
|
+
}
|
1129
|
+
});/***
|
1130
|
+
EXTENSION FOR 3D SCATTER CHART
|
1131
|
+
***/
|
1132
|
+
Highcharts.wrap(Highcharts.seriesTypes.scatter.prototype, 'translate', function (proceed) {
|
1133
|
+
//function translate3d(proceed) {
|
1134
|
+
proceed.apply(this, [].slice.call(arguments, 1));
|
1135
|
+
|
1136
|
+
if (!this.chart.is3d()) {
|
1137
|
+
return;
|
1138
|
+
}
|
1139
|
+
|
1140
|
+
var series = this,
|
1141
|
+
chart = series.chart,
|
1142
|
+
options3d = series.chart.options.chart.options3d,
|
1143
|
+
alpha = options3d.alpha,
|
1144
|
+
beta = options3d.beta,
|
1145
|
+
origin = {
|
1146
|
+
x: chart.inverted ? chart.plotHeight / 2 : chart.plotWidth / 2,
|
1147
|
+
y: chart.inverted ? chart.plotWidth / 2 : chart.plotHeight / 2,
|
1148
|
+
z: options3d.depth,
|
1149
|
+
vd: options3d.viewDistance
|
1150
|
+
},
|
1151
|
+
depth = options3d.depth,
|
1152
|
+
zAxis = chart.options.zAxis || { min : 0, max: depth };
|
1153
|
+
|
1154
|
+
var rangeModifier = depth / (zAxis.max - zAxis.min);
|
1155
|
+
|
1156
|
+
Highcharts.each(series.data, function (point) {
|
1157
|
+
var pCo = {
|
1158
|
+
x: point.plotX,
|
1159
|
+
y: point.plotY,
|
1160
|
+
z: (point.z - zAxis.min) * rangeModifier
|
1161
|
+
};
|
1162
|
+
|
1163
|
+
pCo = perspective([pCo], alpha, beta, origin)[0];
|
1164
|
+
|
1165
|
+
point.plotXold = point.plotX;
|
1166
|
+
point.plotYold = point.plotY;
|
1167
|
+
|
1168
|
+
point.plotX = pCo.x;
|
1169
|
+
point.plotY = pCo.y;
|
1170
|
+
point.plotZ = pCo.z;
|
1171
|
+
});
|
1172
|
+
});
|
1173
|
+
|
1174
|
+
Highcharts.wrap(Highcharts.seriesTypes.scatter.prototype, 'init', function (proceed) {
|
1175
|
+
var result = proceed.apply(this, [].slice.call(arguments, 1));
|
1176
|
+
|
1177
|
+
if (this.chart.is3d()) {
|
1178
|
+
// Add a third coordinate
|
1179
|
+
this.pointArrayMap = ['x', 'y', 'z'];
|
1180
|
+
|
1181
|
+
// Set a new default tooltip formatter
|
1182
|
+
var default3dScatterTooltip = 'x: <b>{point.x}</b><br/>y: <b>{point.y}</b><br/>z: <b>{point.z}</b><br/>';
|
1183
|
+
if (this.userOptions.tooltip) {
|
1184
|
+
this.tooltipOptions.pointFormat = this.userOptions.tooltip.pointFormat || default3dScatterTooltip;
|
1185
|
+
} else {
|
1186
|
+
this.tooltipOptions.pointFormat = default3dScatterTooltip;
|
1187
|
+
}
|
1188
|
+
}
|
1189
|
+
return result;
|
1190
|
+
});/**
|
1191
|
+
* Extension to the VML Renderer
|
1192
|
+
*/
|
1193
|
+
if (Highcharts.VMLRenderer) {
|
1194
|
+
|
1195
|
+
Highcharts.setOptions({animate: false});
|
1196
|
+
|
1197
|
+
Highcharts.VMLRenderer.prototype.cuboid = Highcharts.SVGRenderer.prototype.cuboid;
|
1198
|
+
Highcharts.VMLRenderer.prototype.cuboidPath = Highcharts.SVGRenderer.prototype.cuboidPath;
|
1199
|
+
|
1200
|
+
Highcharts.VMLRenderer.prototype.toLinePath = Highcharts.SVGRenderer.prototype.toLinePath;
|
1201
|
+
|
1202
|
+
Highcharts.VMLRenderer.prototype.createElement3D = Highcharts.SVGRenderer.prototype.createElement3D;
|
1203
|
+
|
1204
|
+
Highcharts.VMLRenderer.prototype.arc3d = function (shapeArgs) {
|
1205
|
+
var result = Highcharts.SVGRenderer.prototype.arc3d.call(this, shapeArgs);
|
1206
|
+
result.css({zIndex: result.zIndex});
|
1207
|
+
return result;
|
1208
|
+
};
|
1209
|
+
|
1210
|
+
Highcharts.VMLRenderer.prototype.arc3dPath = Highcharts.SVGRenderer.prototype.arc3dPath;
|
1211
|
+
|
1212
|
+
// Draw the series in the reverse order
|
1213
|
+
Highcharts.Chart.prototype.renderSeries = function () {
|
1214
|
+
var serie,
|
1215
|
+
i = this.series.length;
|
1216
|
+
while (i--) {
|
1217
|
+
serie = this.series[i];
|
1218
|
+
serie.translate();
|
1219
|
+
if (serie.setTooltipPoints) {
|
1220
|
+
serie.setTooltipPoints();
|
1221
|
+
}
|
1222
|
+
serie.render();
|
1223
|
+
}
|
1224
|
+
};
|
1225
|
+
|
1226
|
+
Highcharts.wrap(Highcharts.Axis.prototype, 'render', function (proceed) {
|
1227
|
+
proceed.apply(this, [].slice.call(arguments, 1));
|
1228
|
+
// VML doesn't support a negative z-index
|
1229
|
+
if (this.sideFrame) {
|
1230
|
+
this.sideFrame.css({zIndex: 0});
|
1231
|
+
this.sideFrame.front.attr({fill: this.sideFrame.color});
|
1232
|
+
}
|
1233
|
+
if (this.bottomFrame) {
|
1234
|
+
this.bottomFrame.css({zIndex: 1});
|
1235
|
+
this.bottomFrame.front.attr({fill: this.bottomFrame.color});
|
1236
|
+
}
|
1237
|
+
if (this.backFrame) {
|
1238
|
+
this.backFrame.css({zIndex: 0});
|
1239
|
+
this.backFrame.front.attr({fill: this.backFrame.color});
|
1240
|
+
}
|
1241
|
+
});
|
1242
|
+
|
1243
|
+
}
|
1244
|
+
|
1245
|
+
}(Highcharts));
|