highcharts-rails 3.0.6 → 3.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- checksums.yaml.gz.asc +13 -13
- data.tar.gz.asc +13 -13
- data/CHANGELOG.markdown +4 -0
- data/Rakefile +33 -0
- data/app/assets/javascripts/highcharts.js +17024 -283
- data/app/assets/javascripts/highcharts/adapters/mootools-adapter.js +316 -13
- data/app/assets/javascripts/highcharts/adapters/prototype-adapter.js +316 -15
- data/app/assets/javascripts/highcharts/adapters/standalone-framework.js +583 -17
- data/app/assets/javascripts/highcharts/highcharts-more.js +2439 -50
- data/app/assets/javascripts/highcharts/modules/annotations.js +401 -7
- data/app/assets/javascripts/highcharts/modules/canvas-tools.js +3113 -133
- data/app/assets/javascripts/highcharts/modules/data.js +581 -16
- data/app/assets/javascripts/highcharts/modules/drilldown.js +449 -11
- data/app/assets/javascripts/highcharts/modules/exporting.js +709 -22
- data/app/assets/javascripts/highcharts/modules/funnel.js +289 -12
- data/app/assets/javascripts/highcharts/modules/heatmap.js +54 -1
- data/app/assets/javascripts/highcharts/modules/map.js +1273 -27
- data/app/assets/javascripts/highcharts/modules/no-data-to-display.js +128 -12
- data/lib/highcharts/version.rb +1 -1
- metadata +2 -2
- metadata.gz.asc +13 -13
@@ -1,11 +1,449 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
1
|
+
/**
|
2
|
+
* Highcharts Drilldown plugin
|
3
|
+
*
|
4
|
+
* Author: Torstein Honsi
|
5
|
+
* Last revision: 2013-02-18
|
6
|
+
* License: MIT License
|
7
|
+
*
|
8
|
+
* Demo: http://jsfiddle.net/highcharts/Vf3yT/
|
9
|
+
*/
|
10
|
+
|
11
|
+
/*global HighchartsAdapter*/
|
12
|
+
(function (H) {
|
13
|
+
|
14
|
+
"use strict";
|
15
|
+
|
16
|
+
var noop = function () {},
|
17
|
+
defaultOptions = H.getOptions(),
|
18
|
+
each = H.each,
|
19
|
+
extend = H.extend,
|
20
|
+
wrap = H.wrap,
|
21
|
+
Chart = H.Chart,
|
22
|
+
seriesTypes = H.seriesTypes,
|
23
|
+
PieSeries = seriesTypes.pie,
|
24
|
+
ColumnSeries = seriesTypes.column,
|
25
|
+
fireEvent = HighchartsAdapter.fireEvent,
|
26
|
+
inArray = HighchartsAdapter.inArray;
|
27
|
+
|
28
|
+
// Utilities
|
29
|
+
function tweenColors(startColor, endColor, pos) {
|
30
|
+
var rgba = [
|
31
|
+
Math.round(startColor[0] + (endColor[0] - startColor[0]) * pos),
|
32
|
+
Math.round(startColor[1] + (endColor[1] - startColor[1]) * pos),
|
33
|
+
Math.round(startColor[2] + (endColor[2] - startColor[2]) * pos),
|
34
|
+
startColor[3] + (endColor[3] - startColor[3]) * pos
|
35
|
+
];
|
36
|
+
return 'rgba(' + rgba.join(',') + ')';
|
37
|
+
}
|
38
|
+
|
39
|
+
// Add language
|
40
|
+
extend(defaultOptions.lang, {
|
41
|
+
drillUpText: '◁ Back to {series.name}'
|
42
|
+
});
|
43
|
+
defaultOptions.drilldown = {
|
44
|
+
activeAxisLabelStyle: {
|
45
|
+
cursor: 'pointer',
|
46
|
+
color: '#039',
|
47
|
+
fontWeight: 'bold',
|
48
|
+
textDecoration: 'underline'
|
49
|
+
},
|
50
|
+
activeDataLabelStyle: {
|
51
|
+
cursor: 'pointer',
|
52
|
+
color: '#039',
|
53
|
+
fontWeight: 'bold',
|
54
|
+
textDecoration: 'underline'
|
55
|
+
},
|
56
|
+
animation: {
|
57
|
+
duration: 500
|
58
|
+
},
|
59
|
+
drillUpButton: {
|
60
|
+
position: {
|
61
|
+
align: 'right',
|
62
|
+
x: -10,
|
63
|
+
y: 10
|
64
|
+
}
|
65
|
+
// relativeTo: 'plotBox'
|
66
|
+
// theme
|
67
|
+
}
|
68
|
+
};
|
69
|
+
|
70
|
+
/**
|
71
|
+
* A general fadeIn method
|
72
|
+
*/
|
73
|
+
H.SVGRenderer.prototype.Element.prototype.fadeIn = function () {
|
74
|
+
this
|
75
|
+
.attr({
|
76
|
+
opacity: 0.1,
|
77
|
+
visibility: 'visible'
|
78
|
+
})
|
79
|
+
.animate({
|
80
|
+
opacity: 1
|
81
|
+
}, {
|
82
|
+
duration: 250
|
83
|
+
});
|
84
|
+
};
|
85
|
+
|
86
|
+
// Extend the Chart prototype
|
87
|
+
Chart.prototype.drilldownLevels = [];
|
88
|
+
|
89
|
+
Chart.prototype.addSeriesAsDrilldown = function (point, ddOptions) {
|
90
|
+
var oldSeries = point.series,
|
91
|
+
xAxis = oldSeries.xAxis,
|
92
|
+
yAxis = oldSeries.yAxis,
|
93
|
+
newSeries,
|
94
|
+
color = point.color || oldSeries.color,
|
95
|
+
pointIndex,
|
96
|
+
level;
|
97
|
+
|
98
|
+
ddOptions = extend({
|
99
|
+
color: color
|
100
|
+
}, ddOptions);
|
101
|
+
pointIndex = inArray(point, oldSeries.points);
|
102
|
+
|
103
|
+
level = {
|
104
|
+
seriesOptions: oldSeries.userOptions,
|
105
|
+
shapeArgs: point.shapeArgs,
|
106
|
+
bBox: point.graphic.getBBox(),
|
107
|
+
color: color,
|
108
|
+
newSeries: ddOptions,
|
109
|
+
pointOptions: oldSeries.options.data[pointIndex],
|
110
|
+
pointIndex: pointIndex,
|
111
|
+
oldExtremes: {
|
112
|
+
xMin: xAxis && xAxis.userMin,
|
113
|
+
xMax: xAxis && xAxis.userMax,
|
114
|
+
yMin: yAxis && yAxis.userMin,
|
115
|
+
yMax: yAxis && yAxis.userMax
|
116
|
+
}
|
117
|
+
};
|
118
|
+
|
119
|
+
this.drilldownLevels.push(level);
|
120
|
+
|
121
|
+
newSeries = this.addSeries(ddOptions, false);
|
122
|
+
if (xAxis) {
|
123
|
+
xAxis.oldPos = xAxis.pos;
|
124
|
+
xAxis.userMin = xAxis.userMax = null;
|
125
|
+
yAxis.userMin = yAxis.userMax = null;
|
126
|
+
}
|
127
|
+
|
128
|
+
// Run fancy cross-animation on supported and equal types
|
129
|
+
if (oldSeries.type === newSeries.type) {
|
130
|
+
newSeries.animate = newSeries.animateDrilldown || noop;
|
131
|
+
newSeries.options.animation = true;
|
132
|
+
}
|
133
|
+
|
134
|
+
oldSeries.remove(false);
|
135
|
+
|
136
|
+
this.redraw();
|
137
|
+
this.showDrillUpButton();
|
138
|
+
};
|
139
|
+
|
140
|
+
Chart.prototype.getDrilldownBackText = function () {
|
141
|
+
var lastLevel = this.drilldownLevels[this.drilldownLevels.length - 1];
|
142
|
+
|
143
|
+
return this.options.lang.drillUpText.replace('{series.name}', lastLevel.seriesOptions.name);
|
144
|
+
|
145
|
+
};
|
146
|
+
|
147
|
+
Chart.prototype.showDrillUpButton = function () {
|
148
|
+
var chart = this,
|
149
|
+
backText = this.getDrilldownBackText(),
|
150
|
+
buttonOptions = chart.options.drilldown.drillUpButton;
|
151
|
+
|
152
|
+
|
153
|
+
if (!this.drillUpButton) {
|
154
|
+
this.drillUpButton = this.renderer.button(
|
155
|
+
backText,
|
156
|
+
null,
|
157
|
+
null,
|
158
|
+
function () {
|
159
|
+
chart.drillUp();
|
160
|
+
}
|
161
|
+
)
|
162
|
+
.attr(extend({
|
163
|
+
align: buttonOptions.position.align,
|
164
|
+
zIndex: 9
|
165
|
+
}, buttonOptions.theme))
|
166
|
+
.add()
|
167
|
+
.align(buttonOptions.position, false, buttonOptions.relativeTo || 'plotBox');
|
168
|
+
} else {
|
169
|
+
this.drillUpButton.attr({
|
170
|
+
text: backText
|
171
|
+
})
|
172
|
+
.align();
|
173
|
+
}
|
174
|
+
};
|
175
|
+
|
176
|
+
Chart.prototype.drillUp = function () {
|
177
|
+
var chart = this,
|
178
|
+
level = chart.drilldownLevels.pop(),
|
179
|
+
oldSeries = chart.series[0],
|
180
|
+
oldExtremes = level.oldExtremes,
|
181
|
+
newSeries = chart.addSeries(level.seriesOptions, false);
|
182
|
+
|
183
|
+
fireEvent(chart, 'drillup', { seriesOptions: level.seriesOptions });
|
184
|
+
|
185
|
+
if (newSeries.type === oldSeries.type) {
|
186
|
+
newSeries.drilldownLevel = level;
|
187
|
+
newSeries.animate = newSeries.animateDrillupTo || noop;
|
188
|
+
newSeries.options.animation = true;
|
189
|
+
|
190
|
+
if (oldSeries.animateDrillupFrom) {
|
191
|
+
oldSeries.animateDrillupFrom(level);
|
192
|
+
}
|
193
|
+
}
|
194
|
+
|
195
|
+
oldSeries.remove(false);
|
196
|
+
|
197
|
+
// Reset the zoom level of the upper series
|
198
|
+
if (newSeries.xAxis) {
|
199
|
+
newSeries.xAxis.setExtremes(oldExtremes.xMin, oldExtremes.xMax, false);
|
200
|
+
newSeries.yAxis.setExtremes(oldExtremes.yMin, oldExtremes.yMax, false);
|
201
|
+
}
|
202
|
+
|
203
|
+
|
204
|
+
this.redraw();
|
205
|
+
|
206
|
+
if (this.drilldownLevels.length === 0) {
|
207
|
+
this.drillUpButton = this.drillUpButton.destroy();
|
208
|
+
} else {
|
209
|
+
this.drillUpButton.attr({
|
210
|
+
text: this.getDrilldownBackText()
|
211
|
+
})
|
212
|
+
.align();
|
213
|
+
}
|
214
|
+
};
|
215
|
+
|
216
|
+
PieSeries.prototype.animateDrilldown = function (init) {
|
217
|
+
var level = this.chart.drilldownLevels[this.chart.drilldownLevels.length - 1],
|
218
|
+
animationOptions = this.chart.options.drilldown.animation,
|
219
|
+
animateFrom = level.shapeArgs,
|
220
|
+
start = animateFrom.start,
|
221
|
+
angle = animateFrom.end - start,
|
222
|
+
startAngle = angle / this.points.length,
|
223
|
+
startColor = H.Color(level.color).rgba;
|
224
|
+
|
225
|
+
if (!init) {
|
226
|
+
each(this.points, function (point, i) {
|
227
|
+
var endColor = H.Color(point.color).rgba;
|
228
|
+
|
229
|
+
/*jslint unparam: true*/
|
230
|
+
point.graphic
|
231
|
+
.attr(H.merge(animateFrom, {
|
232
|
+
start: start + i * startAngle,
|
233
|
+
end: start + (i + 1) * startAngle
|
234
|
+
}))
|
235
|
+
.animate(point.shapeArgs, H.merge(animationOptions, {
|
236
|
+
step: function (val, fx) {
|
237
|
+
if (fx.prop === 'start') {
|
238
|
+
this.attr({
|
239
|
+
fill: tweenColors(startColor, endColor, fx.pos)
|
240
|
+
});
|
241
|
+
}
|
242
|
+
}
|
243
|
+
}));
|
244
|
+
/*jslint unparam: false*/
|
245
|
+
});
|
246
|
+
}
|
247
|
+
};
|
248
|
+
|
249
|
+
|
250
|
+
/**
|
251
|
+
* When drilling up, keep the upper series invisible until the lower series has
|
252
|
+
* moved into place
|
253
|
+
*/
|
254
|
+
PieSeries.prototype.animateDrillupTo =
|
255
|
+
ColumnSeries.prototype.animateDrillupTo = function (init) {
|
256
|
+
if (!init) {
|
257
|
+
var newSeries = this,
|
258
|
+
level = newSeries.drilldownLevel;
|
259
|
+
|
260
|
+
each(this.points, function (point) {
|
261
|
+
point.graphic.hide();
|
262
|
+
if (point.dataLabel) {
|
263
|
+
point.dataLabel.hide();
|
264
|
+
}
|
265
|
+
if (point.connector) {
|
266
|
+
point.connector.hide();
|
267
|
+
}
|
268
|
+
});
|
269
|
+
|
270
|
+
|
271
|
+
// Do dummy animation on first point to get to complete
|
272
|
+
setTimeout(function () {
|
273
|
+
each(newSeries.points, function (point, i) {
|
274
|
+
// Fade in other points
|
275
|
+
var verb = i === level.pointIndex ? 'show' : 'fadeIn';
|
276
|
+
point.graphic[verb]();
|
277
|
+
if (point.dataLabel) {
|
278
|
+
point.dataLabel[verb]();
|
279
|
+
}
|
280
|
+
if (point.connector) {
|
281
|
+
point.connector[verb]();
|
282
|
+
}
|
283
|
+
});
|
284
|
+
}, Math.max(this.chart.options.drilldown.animation.duration - 50, 0));
|
285
|
+
|
286
|
+
// Reset
|
287
|
+
this.animate = noop;
|
288
|
+
}
|
289
|
+
|
290
|
+
};
|
291
|
+
|
292
|
+
ColumnSeries.prototype.animateDrilldown = function (init) {
|
293
|
+
var animateFrom = this.chart.drilldownLevels[this.chart.drilldownLevels.length - 1].shapeArgs,
|
294
|
+
animationOptions = this.chart.options.drilldown.animation;
|
295
|
+
|
296
|
+
if (!init) {
|
297
|
+
|
298
|
+
animateFrom.x += (this.xAxis.oldPos - this.xAxis.pos);
|
299
|
+
|
300
|
+
each(this.points, function (point) {
|
301
|
+
point.graphic
|
302
|
+
.attr(animateFrom)
|
303
|
+
.animate(point.shapeArgs, animationOptions);
|
304
|
+
});
|
305
|
+
}
|
306
|
+
|
307
|
+
};
|
308
|
+
|
309
|
+
/**
|
310
|
+
* When drilling up, pull out the individual point graphics from the lower series
|
311
|
+
* and animate them into the origin point in the upper series.
|
312
|
+
*/
|
313
|
+
ColumnSeries.prototype.animateDrillupFrom =
|
314
|
+
PieSeries.prototype.animateDrillupFrom =
|
315
|
+
function (level) {
|
316
|
+
var animationOptions = this.chart.options.drilldown.animation,
|
317
|
+
group = this.group;
|
318
|
+
|
319
|
+
delete this.group;
|
320
|
+
each(this.points, function (point) {
|
321
|
+
var graphic = point.graphic,
|
322
|
+
startColor = H.Color(point.color).rgba;
|
323
|
+
|
324
|
+
delete point.graphic;
|
325
|
+
|
326
|
+
/*jslint unparam: true*/
|
327
|
+
graphic.animate(level.shapeArgs, H.merge(animationOptions, {
|
328
|
+
|
329
|
+
step: function (val, fx) {
|
330
|
+
if (fx.prop === 'start') {
|
331
|
+
this.attr({
|
332
|
+
fill: tweenColors(startColor, H.Color(level.color).rgba, fx.pos)
|
333
|
+
});
|
334
|
+
}
|
335
|
+
},
|
336
|
+
complete: function () {
|
337
|
+
graphic.destroy();
|
338
|
+
if (group) {
|
339
|
+
group = group.destroy();
|
340
|
+
}
|
341
|
+
}
|
342
|
+
}));
|
343
|
+
/*jslint unparam: false*/
|
344
|
+
});
|
345
|
+
};
|
346
|
+
|
347
|
+
H.Point.prototype.doDrilldown = function () {
|
348
|
+
var series = this.series,
|
349
|
+
chart = series.chart,
|
350
|
+
drilldown = chart.options.drilldown,
|
351
|
+
i = drilldown.series.length,
|
352
|
+
seriesOptions;
|
353
|
+
|
354
|
+
while (i-- && !seriesOptions) {
|
355
|
+
if (drilldown.series[i].id === this.drilldown) {
|
356
|
+
seriesOptions = drilldown.series[i];
|
357
|
+
}
|
358
|
+
}
|
359
|
+
|
360
|
+
// Fire the event. If seriesOptions is undefined, the implementer can check for
|
361
|
+
// seriesOptions, and call addSeriesAsDrilldown async if necessary.
|
362
|
+
fireEvent(chart, 'drilldown', {
|
363
|
+
point: this,
|
364
|
+
seriesOptions: seriesOptions
|
365
|
+
});
|
366
|
+
|
367
|
+
if (seriesOptions) {
|
368
|
+
chart.addSeriesAsDrilldown(this, seriesOptions);
|
369
|
+
}
|
370
|
+
|
371
|
+
};
|
372
|
+
|
373
|
+
wrap(H.Point.prototype, 'init', function (proceed, series, options, x) {
|
374
|
+
var point = proceed.call(this, series, options, x),
|
375
|
+
chart = series.chart,
|
376
|
+
tick = series.xAxis && series.xAxis.ticks[x],
|
377
|
+
tickLabel = tick && tick.label;
|
378
|
+
|
379
|
+
if (point.drilldown) {
|
380
|
+
|
381
|
+
// Add the click event to the point label
|
382
|
+
H.addEvent(point, 'click', function () {
|
383
|
+
point.doDrilldown();
|
384
|
+
});
|
385
|
+
|
386
|
+
// Make axis labels clickable
|
387
|
+
if (tickLabel) {
|
388
|
+
if (!tickLabel._basicStyle) {
|
389
|
+
tickLabel._basicStyle = tickLabel.element.getAttribute('style');
|
390
|
+
}
|
391
|
+
tickLabel
|
392
|
+
.addClass('highcharts-drilldown-axis-label')
|
393
|
+
.css(chart.options.drilldown.activeAxisLabelStyle)
|
394
|
+
.on('click', function () {
|
395
|
+
if (point.doDrilldown) {
|
396
|
+
point.doDrilldown();
|
397
|
+
}
|
398
|
+
});
|
399
|
+
|
400
|
+
}
|
401
|
+
} else if (tickLabel && tickLabel._basicStyle) {
|
402
|
+
tickLabel.element.setAttribute('style', tickLabel._basicStyle);
|
403
|
+
}
|
404
|
+
|
405
|
+
return point;
|
406
|
+
});
|
407
|
+
|
408
|
+
wrap(H.Series.prototype, 'drawDataLabels', function (proceed) {
|
409
|
+
var css = this.chart.options.drilldown.activeDataLabelStyle;
|
410
|
+
|
411
|
+
proceed.call(this);
|
412
|
+
|
413
|
+
each(this.points, function (point) {
|
414
|
+
if (point.drilldown && point.dataLabel) {
|
415
|
+
point.dataLabel
|
416
|
+
.attr({
|
417
|
+
'class': 'highcharts-drilldown-data-label'
|
418
|
+
})
|
419
|
+
.css(css)
|
420
|
+
.on('click', function () {
|
421
|
+
point.doDrilldown();
|
422
|
+
});
|
423
|
+
}
|
424
|
+
});
|
425
|
+
});
|
426
|
+
|
427
|
+
// Mark the trackers with a pointer
|
428
|
+
ColumnSeries.prototype.supportsDrilldown = true;
|
429
|
+
PieSeries.prototype.supportsDrilldown = true;
|
430
|
+
var type,
|
431
|
+
drawTrackerWrapper = function (proceed) {
|
432
|
+
proceed.call(this);
|
433
|
+
each(this.points, function (point) {
|
434
|
+
if (point.drilldown && point.graphic) {
|
435
|
+
point.graphic
|
436
|
+
.attr({
|
437
|
+
'class': 'highcharts-drilldown-point'
|
438
|
+
})
|
439
|
+
.css({ cursor: 'pointer' });
|
440
|
+
}
|
441
|
+
});
|
442
|
+
};
|
443
|
+
for (type in seriesTypes) {
|
444
|
+
if (seriesTypes[type].prototype.supportsDrilldown) {
|
445
|
+
wrap(seriesTypes[type].prototype, 'drawTracker', drawTrackerWrapper);
|
446
|
+
}
|
447
|
+
}
|
448
|
+
|
449
|
+
}(Highcharts));
|