lazy_high_charts 1.4.2 → 1.4.3
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +0 -0
- data/.travis.yml +1 -1
- data/CHANGELOG.md +8 -3
- data/GEM_VERSION +1 -1
- data/Gemfile +1 -1
- data/Guardfile +2 -2
- data/README.md +4 -4
- data/Rakefile +36 -1
- data/lazy_high_charts.gemspec +11 -11
- data/lib/lazy_high_charts.rb +4 -2
- data/lib/lazy_high_charts/core_ext/string.rb +4 -4
- data/lib/lazy_high_charts/high_chart.rb +32 -17
- data/lib/lazy_high_charts/layout_helper.rb +9 -9
- data/lib/lazy_high_charts/railtie.rb +6 -6
- data/spec/high_chart_spec.rb +56 -41
- data/spec/lazy_high_charts_spec.rb +49 -43
- data/spec/spec_helper.rb +1 -1
- data/vendor/assets/javascripts/highcharts/adapters/mootools-adapter.js +13 -0
- data/vendor/assets/javascripts/highcharts/adapters/prototype-adapter.js +15 -0
- data/vendor/assets/javascripts/highcharts/highcharts-more.js +51 -0
- data/vendor/assets/javascripts/highcharts/highcharts.js +272 -0
- data/vendor/assets/javascripts/highcharts/highstock.js +334 -0
- data/vendor/assets/javascripts/highcharts/modules/exporting.js +10 -10
- data/vendor/assets/javascripts/highcharts/stock/adapters/mootools-adapter.js +13 -0
- data/vendor/assets/javascripts/highcharts/stock/adapters/prototype-adapter.js +15 -0
- data/vendor/assets/javascripts/highcharts/stock/highcharts-more.js +51 -0
- data/vendor/assets/javascripts/highcharts/stock/modules/exporting.js +22 -0
- metadata +59 -52
- metadata.gz.sig +3 -2
- checksums.yaml +0 -7
- checksums.yaml.gz.sig +0 -2
- data/lib/generators/lazy_high_charts/install/install_generator.rb +0 -31
- data/vendor/assets/javascripts/exporting.js +0 -22
- data/vendor/assets/javascripts/highcharts-more.js +0 -50
- data/vendor/assets/javascripts/highcharts.js +0 -270
- data/vendor/assets/javascripts/highcharts/modules/canvas-tools.js +0 -133
- data/vendor/assets/javascripts/highcharts/modules/canvas-tools.src.js +0 -3113
- data/vendor/assets/javascripts/highcharts/modules/data.js +0 -16
- data/vendor/assets/javascripts/highcharts/modules/data.src.js +0 -537
- data/vendor/assets/javascripts/highcharts/modules/exporting.src.js +0 -703
- data/vendor/assets/javascripts/highcharts/modules/funnel.js +0 -12
- data/vendor/assets/javascripts/highcharts/modules/funnel.src.js +0 -284
- data/vendor/assets/javascripts/highcharts/themes/dark-blue.js +0 -254
- data/vendor/assets/javascripts/highcharts/themes/dark-green.js +0 -255
- data/vendor/assets/javascripts/highcharts/themes/gray.js +0 -257
- data/vendor/assets/javascripts/highcharts/themes/grid.js +0 -103
- data/vendor/assets/javascripts/highcharts/themes/skies.js +0 -89
- data/vendor/assets/javascripts/highstock.js +0 -332
@@ -1,703 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* @license Highcharts JS v3.0.1 (2013-04-09)
|
3
|
-
* Exporting module
|
4
|
-
*
|
5
|
-
* (c) 2010-2013 Torstein Hønsi
|
6
|
-
*
|
7
|
-
* License: www.highcharts.com/license
|
8
|
-
*/
|
9
|
-
|
10
|
-
// JSLint options:
|
11
|
-
/*global Highcharts, document, window, Math, setTimeout */
|
12
|
-
|
13
|
-
(function (Highcharts) { // encapsulate
|
14
|
-
|
15
|
-
// create shortcuts
|
16
|
-
var Chart = Highcharts.Chart,
|
17
|
-
addEvent = Highcharts.addEvent,
|
18
|
-
removeEvent = Highcharts.removeEvent,
|
19
|
-
createElement = Highcharts.createElement,
|
20
|
-
discardElement = Highcharts.discardElement,
|
21
|
-
css = Highcharts.css,
|
22
|
-
merge = Highcharts.merge,
|
23
|
-
each = Highcharts.each,
|
24
|
-
extend = Highcharts.extend,
|
25
|
-
math = Math,
|
26
|
-
mathMax = math.max,
|
27
|
-
doc = document,
|
28
|
-
win = window,
|
29
|
-
isTouchDevice = Highcharts.isTouchDevice,
|
30
|
-
M = 'M',
|
31
|
-
L = 'L',
|
32
|
-
DIV = 'div',
|
33
|
-
HIDDEN = 'hidden',
|
34
|
-
NONE = 'none',
|
35
|
-
PREFIX = 'highcharts-',
|
36
|
-
ABSOLUTE = 'absolute',
|
37
|
-
PX = 'px',
|
38
|
-
UNDEFINED,
|
39
|
-
symbols = Highcharts.Renderer.prototype.symbols,
|
40
|
-
defaultOptions = Highcharts.getOptions(),
|
41
|
-
buttonOffset;
|
42
|
-
|
43
|
-
// Add language
|
44
|
-
extend(defaultOptions.lang, {
|
45
|
-
printChart: 'Print chart',
|
46
|
-
downloadPNG: 'Download PNG image',
|
47
|
-
downloadJPEG: 'Download JPEG image',
|
48
|
-
downloadPDF: 'Download PDF document',
|
49
|
-
downloadSVG: 'Download SVG vector image',
|
50
|
-
contextButtonTitle: 'Chart context menu'
|
51
|
-
});
|
52
|
-
|
53
|
-
// Buttons and menus are collected in a separate config option set called 'navigation'.
|
54
|
-
// This can be extended later to add control buttons like zoom and pan right click menus.
|
55
|
-
defaultOptions.navigation = {
|
56
|
-
menuStyle: {
|
57
|
-
border: '1px solid #A0A0A0',
|
58
|
-
background: '#FFFFFF',
|
59
|
-
padding: '5px 0'
|
60
|
-
},
|
61
|
-
menuItemStyle: {
|
62
|
-
padding: '0 10px',
|
63
|
-
background: NONE,
|
64
|
-
color: '#303030',
|
65
|
-
fontSize: isTouchDevice ? '14px' : '11px'
|
66
|
-
},
|
67
|
-
menuItemHoverStyle: {
|
68
|
-
background: '#4572A5',
|
69
|
-
color: '#FFFFFF'
|
70
|
-
},
|
71
|
-
|
72
|
-
buttonOptions: {
|
73
|
-
symbolFill: '#E0E0E0',
|
74
|
-
symbolSize: 14,
|
75
|
-
symbolStroke: '#666',
|
76
|
-
symbolStrokeWidth: 3,
|
77
|
-
symbolX: 12.5,
|
78
|
-
symbolY: 10.5,
|
79
|
-
align: 'right',
|
80
|
-
buttonSpacing: 3,
|
81
|
-
height: 22,
|
82
|
-
// text: null,
|
83
|
-
theme: {
|
84
|
-
fill: 'white', // capture hover
|
85
|
-
stroke: 'none'
|
86
|
-
},
|
87
|
-
verticalAlign: 'top',
|
88
|
-
width: 24
|
89
|
-
}
|
90
|
-
};
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
// Add the export related options
|
95
|
-
defaultOptions.exporting = {
|
96
|
-
//enabled: true,
|
97
|
-
//filename: 'chart',
|
98
|
-
type: 'image/png',
|
99
|
-
url: 'http://export.highcharts.com/',
|
100
|
-
//width: undefined,
|
101
|
-
//scale: 2
|
102
|
-
buttons: {
|
103
|
-
contextButton: {
|
104
|
-
//x: -10,
|
105
|
-
symbol: 'menu',
|
106
|
-
_titleKey: 'contextButtonTitle',
|
107
|
-
menuItems: [{
|
108
|
-
textKey: 'printChart',
|
109
|
-
onclick: function () {
|
110
|
-
this.print();
|
111
|
-
}
|
112
|
-
}, {
|
113
|
-
separator: true
|
114
|
-
}, {
|
115
|
-
textKey: 'downloadPNG',
|
116
|
-
onclick: function () {
|
117
|
-
this.exportChart();
|
118
|
-
}
|
119
|
-
}, {
|
120
|
-
textKey: 'downloadJPEG',
|
121
|
-
onclick: function () {
|
122
|
-
this.exportChart({
|
123
|
-
type: 'image/jpeg'
|
124
|
-
});
|
125
|
-
}
|
126
|
-
}, {
|
127
|
-
textKey: 'downloadPDF',
|
128
|
-
onclick: function () {
|
129
|
-
this.exportChart({
|
130
|
-
type: 'application/pdf'
|
131
|
-
});
|
132
|
-
}
|
133
|
-
}, {
|
134
|
-
textKey: 'downloadSVG',
|
135
|
-
onclick: function () {
|
136
|
-
this.exportChart({
|
137
|
-
type: 'image/svg+xml'
|
138
|
-
});
|
139
|
-
}
|
140
|
-
}
|
141
|
-
// Enable this block to add "View SVG" to the dropdown menu
|
142
|
-
/*
|
143
|
-
,{
|
144
|
-
|
145
|
-
text: 'View SVG',
|
146
|
-
onclick: function () {
|
147
|
-
var svg = this.getSVG()
|
148
|
-
.replace(/</g, '\n<')
|
149
|
-
.replace(/>/g, '>');
|
150
|
-
|
151
|
-
doc.body.innerHTML = '<pre>' + svg + '</pre>';
|
152
|
-
}
|
153
|
-
} // */
|
154
|
-
]
|
155
|
-
}
|
156
|
-
}
|
157
|
-
};
|
158
|
-
|
159
|
-
// Add the Highcharts.post utility
|
160
|
-
Highcharts.post = function (url, data) {
|
161
|
-
var name,
|
162
|
-
form;
|
163
|
-
|
164
|
-
// create the form
|
165
|
-
form = createElement('form', {
|
166
|
-
method: 'post',
|
167
|
-
action: url,
|
168
|
-
enctype: 'multipart/form-data'
|
169
|
-
}, {
|
170
|
-
display: NONE
|
171
|
-
}, doc.body);
|
172
|
-
|
173
|
-
// add the data
|
174
|
-
for (name in data) {
|
175
|
-
createElement('input', {
|
176
|
-
type: HIDDEN,
|
177
|
-
name: name,
|
178
|
-
value: data[name]
|
179
|
-
}, null, form);
|
180
|
-
}
|
181
|
-
|
182
|
-
// submit
|
183
|
-
form.submit();
|
184
|
-
|
185
|
-
// clean up
|
186
|
-
discardElement(form);
|
187
|
-
};
|
188
|
-
|
189
|
-
extend(Chart.prototype, {
|
190
|
-
|
191
|
-
/**
|
192
|
-
* Return an SVG representation of the chart
|
193
|
-
*
|
194
|
-
* @param additionalOptions {Object} Additional chart options for the generated SVG representation
|
195
|
-
*/
|
196
|
-
getSVG: function (additionalOptions) {
|
197
|
-
var chart = this,
|
198
|
-
chartCopy,
|
199
|
-
sandbox,
|
200
|
-
svg,
|
201
|
-
seriesOptions,
|
202
|
-
sourceWidth,
|
203
|
-
sourceHeight,
|
204
|
-
cssWidth,
|
205
|
-
cssHeight,
|
206
|
-
options = merge(chart.options, additionalOptions); // copy the options and add extra options
|
207
|
-
|
208
|
-
// IE compatibility hack for generating SVG content that it doesn't really understand
|
209
|
-
if (!doc.createElementNS) {
|
210
|
-
/*jslint unparam: true*//* allow unused parameter ns in function below */
|
211
|
-
doc.createElementNS = function (ns, tagName) {
|
212
|
-
return doc.createElement(tagName);
|
213
|
-
};
|
214
|
-
/*jslint unparam: false*/
|
215
|
-
}
|
216
|
-
|
217
|
-
// create a sandbox where a new chart will be generated
|
218
|
-
sandbox = createElement(DIV, null, {
|
219
|
-
position: ABSOLUTE,
|
220
|
-
top: '-9999em',
|
221
|
-
width: chart.chartWidth + PX,
|
222
|
-
height: chart.chartHeight + PX
|
223
|
-
}, doc.body);
|
224
|
-
|
225
|
-
// get the source size
|
226
|
-
cssWidth = chart.renderTo.style.width;
|
227
|
-
cssHeight = chart.renderTo.style.height;
|
228
|
-
sourceWidth = options.exporting.sourceWidth ||
|
229
|
-
options.chart.width ||
|
230
|
-
(/px$/.test(cssWidth) && parseInt(cssWidth, 10)) ||
|
231
|
-
600;
|
232
|
-
sourceHeight = options.exporting.sourceHeight ||
|
233
|
-
options.chart.height ||
|
234
|
-
(/px$/.test(cssHeight) && parseInt(cssHeight, 10)) ||
|
235
|
-
400;
|
236
|
-
|
237
|
-
// override some options
|
238
|
-
extend(options.chart, {
|
239
|
-
animation: false,
|
240
|
-
renderTo: sandbox,
|
241
|
-
forExport: true,
|
242
|
-
width: sourceWidth,
|
243
|
-
height: sourceHeight
|
244
|
-
});
|
245
|
-
options.exporting.enabled = false; // hide buttons in print
|
246
|
-
options.chart.plotBackgroundImage = null; // the converter doesn't handle images
|
247
|
-
|
248
|
-
// prepare for replicating the chart
|
249
|
-
options.series = [];
|
250
|
-
each(chart.series, function (serie) {
|
251
|
-
seriesOptions = merge(serie.options, {
|
252
|
-
animation: false, // turn off animation
|
253
|
-
showCheckbox: false,
|
254
|
-
visible: serie.visible
|
255
|
-
});
|
256
|
-
|
257
|
-
if (!seriesOptions.isInternal) { // used for the navigator series that has its own option set
|
258
|
-
options.series.push(seriesOptions);
|
259
|
-
}
|
260
|
-
});
|
261
|
-
|
262
|
-
// generate the chart copy
|
263
|
-
chartCopy = new Highcharts.Chart(options, chart.callback);
|
264
|
-
|
265
|
-
// reflect axis extremes in the export
|
266
|
-
each(['xAxis', 'yAxis'], function (axisType) {
|
267
|
-
each(chart[axisType], function (axis, i) {
|
268
|
-
var axisCopy = chartCopy[axisType][i],
|
269
|
-
extremes = axis.getExtremes(),
|
270
|
-
userMin = extremes.userMin,
|
271
|
-
userMax = extremes.userMax;
|
272
|
-
|
273
|
-
if (userMin !== UNDEFINED || userMax !== UNDEFINED) {
|
274
|
-
axisCopy.setExtremes(userMin, userMax, true, false);
|
275
|
-
}
|
276
|
-
});
|
277
|
-
});
|
278
|
-
|
279
|
-
// get the SVG from the container's innerHTML
|
280
|
-
svg = chartCopy.container.innerHTML;
|
281
|
-
|
282
|
-
// free up memory
|
283
|
-
options = null;
|
284
|
-
chartCopy.destroy();
|
285
|
-
discardElement(sandbox);
|
286
|
-
|
287
|
-
// sanitize
|
288
|
-
svg = svg
|
289
|
-
.replace(/zIndex="[^"]+"/g, '')
|
290
|
-
.replace(/isShadow="[^"]+"/g, '')
|
291
|
-
.replace(/symbolName="[^"]+"/g, '')
|
292
|
-
.replace(/jQuery[0-9]+="[^"]+"/g, '')
|
293
|
-
.replace(/url\([^#]+#/g, 'url(#')
|
294
|
-
.replace(/<svg /, '<svg xmlns:xlink="http://www.w3.org/1999/xlink" ')
|
295
|
-
.replace(/ href=/g, ' xlink:href=')
|
296
|
-
.replace(/\n/, ' ')
|
297
|
-
.replace(/<\/svg>.*?$/, '</svg>') // any HTML added to the container after the SVG (#894)
|
298
|
-
/* This fails in IE < 8
|
299
|
-
.replace(/([0-9]+)\.([0-9]+)/g, function(s1, s2, s3) { // round off to save weight
|
300
|
-
return s2 +'.'+ s3[0];
|
301
|
-
})*/
|
302
|
-
|
303
|
-
// Replace HTML entities, issue #347
|
304
|
-
.replace(/ /g, '\u00A0') // no-break space
|
305
|
-
.replace(/­/g, '\u00AD') // soft hyphen
|
306
|
-
|
307
|
-
// IE specific
|
308
|
-
.replace(/<IMG /g, '<image ')
|
309
|
-
.replace(/height=([^" ]+)/g, 'height="$1"')
|
310
|
-
.replace(/width=([^" ]+)/g, 'width="$1"')
|
311
|
-
.replace(/hc-svg-href="([^"]+)">/g, 'xlink:href="$1"/>')
|
312
|
-
.replace(/id=([^" >]+)/g, 'id="$1"')
|
313
|
-
.replace(/class=([^" ]+)/g, 'class="$1"')
|
314
|
-
.replace(/ transform /g, ' ')
|
315
|
-
.replace(/:(path|rect)/g, '$1')
|
316
|
-
.replace(/style="([^"]+)"/g, function (s) {
|
317
|
-
return s.toLowerCase();
|
318
|
-
});
|
319
|
-
|
320
|
-
// IE9 beta bugs with innerHTML. Test again with final IE9.
|
321
|
-
svg = svg.replace(/(url\(#highcharts-[0-9]+)"/g, '$1')
|
322
|
-
.replace(/"/g, "'");
|
323
|
-
if (svg.match(/ xmlns="/g).length === 2) {
|
324
|
-
svg = svg.replace(/xmlns="[^"]+"/, '');
|
325
|
-
}
|
326
|
-
|
327
|
-
return svg;
|
328
|
-
},
|
329
|
-
|
330
|
-
/**
|
331
|
-
* Submit the SVG representation of the chart to the server
|
332
|
-
* @param {Object} options Exporting options. Possible members are url, type and width.
|
333
|
-
* @param {Object} chartOptions Additional chart options for the SVG representation of the chart
|
334
|
-
*/
|
335
|
-
exportChart: function (options, chartOptions) {
|
336
|
-
options = options || {};
|
337
|
-
|
338
|
-
var chart = this,
|
339
|
-
chartExportingOptions = chart.options.exporting,
|
340
|
-
svg = chart.getSVG(merge(
|
341
|
-
{ chart: { borderRadius: 0 } },
|
342
|
-
chartExportingOptions,
|
343
|
-
chartOptions,
|
344
|
-
{
|
345
|
-
exporting: {
|
346
|
-
sourceWidth: options.sourceWidth || chartExportingOptions.sourceWidth, // docs: option and parameter in exportChart()
|
347
|
-
sourceHeight: options.sourceHeight || chartExportingOptions.sourceHeight // docs
|
348
|
-
}
|
349
|
-
}
|
350
|
-
));
|
351
|
-
|
352
|
-
// merge the options
|
353
|
-
options = merge(chart.options.exporting, options);
|
354
|
-
|
355
|
-
// do the post
|
356
|
-
Highcharts.post(options.url, {
|
357
|
-
filename: options.filename || 'chart',
|
358
|
-
type: options.type,
|
359
|
-
width: options.width || 0, // IE8 fails to post undefined correctly, so use 0
|
360
|
-
scale: options.scale || 2,
|
361
|
-
svg: svg
|
362
|
-
});
|
363
|
-
|
364
|
-
},
|
365
|
-
|
366
|
-
/**
|
367
|
-
* Print the chart
|
368
|
-
*/
|
369
|
-
print: function () {
|
370
|
-
|
371
|
-
var chart = this,
|
372
|
-
container = chart.container,
|
373
|
-
origDisplay = [],
|
374
|
-
origParent = container.parentNode,
|
375
|
-
body = doc.body,
|
376
|
-
childNodes = body.childNodes;
|
377
|
-
|
378
|
-
if (chart.isPrinting) { // block the button while in printing mode
|
379
|
-
return;
|
380
|
-
}
|
381
|
-
|
382
|
-
chart.isPrinting = true;
|
383
|
-
|
384
|
-
// hide all body content
|
385
|
-
each(childNodes, function (node, i) {
|
386
|
-
if (node.nodeType === 1) {
|
387
|
-
origDisplay[i] = node.style.display;
|
388
|
-
node.style.display = NONE;
|
389
|
-
}
|
390
|
-
});
|
391
|
-
|
392
|
-
// pull out the chart
|
393
|
-
body.appendChild(container);
|
394
|
-
|
395
|
-
// print
|
396
|
-
win.focus(); // #1510
|
397
|
-
win.print();
|
398
|
-
|
399
|
-
// allow the browser to prepare before reverting
|
400
|
-
setTimeout(function () {
|
401
|
-
|
402
|
-
// put the chart back in
|
403
|
-
origParent.appendChild(container);
|
404
|
-
|
405
|
-
// restore all body content
|
406
|
-
each(childNodes, function (node, i) {
|
407
|
-
if (node.nodeType === 1) {
|
408
|
-
node.style.display = origDisplay[i];
|
409
|
-
}
|
410
|
-
});
|
411
|
-
|
412
|
-
chart.isPrinting = false;
|
413
|
-
|
414
|
-
}, 1000);
|
415
|
-
|
416
|
-
},
|
417
|
-
|
418
|
-
/**
|
419
|
-
* Display a popup menu for choosing the export type
|
420
|
-
*
|
421
|
-
* @param {String} name An identifier for the menu
|
422
|
-
* @param {Array} items A collection with text and onclicks for the items
|
423
|
-
* @param {Number} x The x position of the opener button
|
424
|
-
* @param {Number} y The y position of the opener button
|
425
|
-
* @param {Number} width The width of the opener button
|
426
|
-
* @param {Number} height The height of the opener button
|
427
|
-
*/
|
428
|
-
contextMenu: function (name, items, x, y, width, height, button) {
|
429
|
-
var chart = this,
|
430
|
-
navOptions = chart.options.navigation,
|
431
|
-
menuItemStyle = navOptions.menuItemStyle,
|
432
|
-
chartWidth = chart.chartWidth,
|
433
|
-
chartHeight = chart.chartHeight,
|
434
|
-
cacheName = 'cache-' + name,
|
435
|
-
menu = chart[cacheName],
|
436
|
-
menuPadding = mathMax(width, height), // for mouse leave detection
|
437
|
-
boxShadow = '3px 3px 10px #888',
|
438
|
-
innerMenu,
|
439
|
-
hide,
|
440
|
-
hideTimer,
|
441
|
-
menuStyle;
|
442
|
-
|
443
|
-
// create the menu only the first time
|
444
|
-
if (!menu) {
|
445
|
-
|
446
|
-
// create a HTML element above the SVG
|
447
|
-
chart[cacheName] = menu = createElement(DIV, {
|
448
|
-
className: PREFIX + name
|
449
|
-
}, {
|
450
|
-
position: ABSOLUTE,
|
451
|
-
zIndex: 1000,
|
452
|
-
padding: menuPadding + PX
|
453
|
-
}, chart.container);
|
454
|
-
|
455
|
-
innerMenu = createElement(DIV, null,
|
456
|
-
extend({
|
457
|
-
MozBoxShadow: boxShadow,
|
458
|
-
WebkitBoxShadow: boxShadow,
|
459
|
-
boxShadow: boxShadow
|
460
|
-
}, navOptions.menuStyle), menu);
|
461
|
-
|
462
|
-
// hide on mouse out
|
463
|
-
hide = function () {
|
464
|
-
css(menu, { display: NONE });
|
465
|
-
if (button) {
|
466
|
-
button.setState(0);
|
467
|
-
}
|
468
|
-
};
|
469
|
-
|
470
|
-
// Hide the menu some time after mouse leave (#1357)
|
471
|
-
addEvent(menu, 'mouseleave', function () {
|
472
|
-
hideTimer = setTimeout(hide, 500);
|
473
|
-
});
|
474
|
-
addEvent(menu, 'mouseenter', function () {
|
475
|
-
clearTimeout(hideTimer);
|
476
|
-
});
|
477
|
-
|
478
|
-
|
479
|
-
// create the items
|
480
|
-
each(items, function (item) {
|
481
|
-
if (item) {
|
482
|
-
var element = item.separator ?
|
483
|
-
createElement('hr', null, null, innerMenu) :
|
484
|
-
createElement(DIV, {
|
485
|
-
onmouseover: function () {
|
486
|
-
css(this, navOptions.menuItemHoverStyle);
|
487
|
-
},
|
488
|
-
onmouseout: function () {
|
489
|
-
css(this, menuItemStyle);
|
490
|
-
},
|
491
|
-
onclick: function () {
|
492
|
-
hide();
|
493
|
-
item.onclick.apply(chart, arguments);
|
494
|
-
},
|
495
|
-
innerHTML: item.text || chart.options.lang[item.textKey]
|
496
|
-
}, extend({
|
497
|
-
cursor: 'pointer'
|
498
|
-
}, menuItemStyle), innerMenu);
|
499
|
-
|
500
|
-
|
501
|
-
// Keep references to menu divs to be able to destroy them
|
502
|
-
chart.exportDivElements.push(element);
|
503
|
-
}
|
504
|
-
});
|
505
|
-
|
506
|
-
// Keep references to menu and innerMenu div to be able to destroy them
|
507
|
-
chart.exportDivElements.push(innerMenu, menu);
|
508
|
-
|
509
|
-
chart.exportMenuWidth = menu.offsetWidth;
|
510
|
-
chart.exportMenuHeight = menu.offsetHeight;
|
511
|
-
}
|
512
|
-
|
513
|
-
menuStyle = { display: 'block' };
|
514
|
-
|
515
|
-
// if outside right, right align it
|
516
|
-
if (x + chart.exportMenuWidth > chartWidth) {
|
517
|
-
menuStyle.right = (chartWidth - x - width - menuPadding) + PX;
|
518
|
-
} else {
|
519
|
-
menuStyle.left = (x - menuPadding) + PX;
|
520
|
-
}
|
521
|
-
// if outside bottom, bottom align it
|
522
|
-
if (y + height + chart.exportMenuHeight > chartHeight) {
|
523
|
-
menuStyle.bottom = (chartHeight - y - menuPadding) + PX;
|
524
|
-
} else {
|
525
|
-
menuStyle.top = (y + height - menuPadding) + PX;
|
526
|
-
}
|
527
|
-
|
528
|
-
css(menu, menuStyle);
|
529
|
-
},
|
530
|
-
|
531
|
-
/**
|
532
|
-
* Add the export button to the chart
|
533
|
-
*/
|
534
|
-
addButton: function (options) {
|
535
|
-
var chart = this,
|
536
|
-
renderer = chart.renderer,
|
537
|
-
btnOptions = merge(chart.options.navigation.buttonOptions, options),
|
538
|
-
onclick = btnOptions.onclick,
|
539
|
-
menuItems = btnOptions.menuItems,
|
540
|
-
symbol,
|
541
|
-
button,
|
542
|
-
symbolAttr = {
|
543
|
-
stroke: btnOptions.symbolStroke,
|
544
|
-
fill: btnOptions.symbolFill
|
545
|
-
},
|
546
|
-
symbolSize = btnOptions.symbolSize || 12,
|
547
|
-
menuKey;
|
548
|
-
|
549
|
-
if (!chart.btnCount) {
|
550
|
-
chart.btnCount = 0;
|
551
|
-
}
|
552
|
-
menuKey = chart.btnCount++;
|
553
|
-
|
554
|
-
// Keeps references to the button elements
|
555
|
-
if (!chart.exportDivElements) {
|
556
|
-
chart.exportDivElements = [];
|
557
|
-
chart.exportSVGElements = [];
|
558
|
-
}
|
559
|
-
|
560
|
-
if (btnOptions.enabled === false) {
|
561
|
-
return;
|
562
|
-
}
|
563
|
-
|
564
|
-
|
565
|
-
var attr = btnOptions.theme,
|
566
|
-
states = attr.states,
|
567
|
-
hover = states && states.hover,
|
568
|
-
select = states && states.select,
|
569
|
-
callback;
|
570
|
-
|
571
|
-
delete attr.states;
|
572
|
-
|
573
|
-
if (onclick) {
|
574
|
-
callback = function () {
|
575
|
-
onclick.apply(chart, arguments);
|
576
|
-
};
|
577
|
-
|
578
|
-
} else if (menuItems) {
|
579
|
-
callback = function () {
|
580
|
-
chart.contextMenu(
|
581
|
-
'contextmenu',
|
582
|
-
menuItems,
|
583
|
-
button.translateX,
|
584
|
-
button.translateY,
|
585
|
-
button.width,
|
586
|
-
button.height,
|
587
|
-
button
|
588
|
-
);
|
589
|
-
button.setState(2);
|
590
|
-
};
|
591
|
-
}
|
592
|
-
|
593
|
-
|
594
|
-
if (btnOptions.text && btnOptions.symbol) {
|
595
|
-
attr.paddingLeft = Highcharts.pick(attr.paddingLeft, 25);
|
596
|
-
|
597
|
-
} else if (!btnOptions.text) {
|
598
|
-
extend(attr, {
|
599
|
-
width: btnOptions.width,
|
600
|
-
height: btnOptions.height,
|
601
|
-
padding: 0
|
602
|
-
});
|
603
|
-
}
|
604
|
-
|
605
|
-
button = renderer.button(btnOptions.text, 0, 0, callback, attr, hover, select)
|
606
|
-
.attr({
|
607
|
-
title: chart.options.lang[btnOptions._titleKey],
|
608
|
-
'stroke-linecap': 'round'
|
609
|
-
});
|
610
|
-
|
611
|
-
if (btnOptions.symbol) {
|
612
|
-
symbol = renderer.symbol(
|
613
|
-
btnOptions.symbol,
|
614
|
-
btnOptions.symbolX - (symbolSize / 2),
|
615
|
-
btnOptions.symbolY - (symbolSize / 2),
|
616
|
-
symbolSize,
|
617
|
-
symbolSize
|
618
|
-
)
|
619
|
-
.attr(extend(symbolAttr, {
|
620
|
-
'stroke-width': btnOptions.symbolStrokeWidth || 1,
|
621
|
-
zIndex: 1
|
622
|
-
})).add(button);
|
623
|
-
}
|
624
|
-
|
625
|
-
button.add()
|
626
|
-
.align(extend(btnOptions, {
|
627
|
-
width: button.width,
|
628
|
-
x: Highcharts.pick(btnOptions.x, buttonOffset) // #1654
|
629
|
-
}), true, 'spacingBox');
|
630
|
-
|
631
|
-
buttonOffset += (button.width + btnOptions.buttonSpacing) * (btnOptions.align === 'right' ? -1 : 1);
|
632
|
-
|
633
|
-
chart.exportSVGElements.push(button, symbol);
|
634
|
-
|
635
|
-
},
|
636
|
-
|
637
|
-
/**
|
638
|
-
* Destroy the buttons.
|
639
|
-
*/
|
640
|
-
destroyExport: function (e) {
|
641
|
-
var chart = e.target,
|
642
|
-
i,
|
643
|
-
elem;
|
644
|
-
|
645
|
-
// Destroy the extra buttons added
|
646
|
-
for (i = 0; i < chart.exportSVGElements.length; i++) {
|
647
|
-
elem = chart.exportSVGElements[i];
|
648
|
-
// Destroy and null the svg/vml elements
|
649
|
-
elem.onclick = elem.ontouchstart = null;
|
650
|
-
chart.exportSVGElements[i] = elem.destroy();
|
651
|
-
}
|
652
|
-
|
653
|
-
// Destroy the divs for the menu
|
654
|
-
for (i = 0; i < chart.exportDivElements.length; i++) {
|
655
|
-
elem = chart.exportDivElements[i];
|
656
|
-
|
657
|
-
// Remove the event handler
|
658
|
-
removeEvent(elem, 'mouseleave');
|
659
|
-
|
660
|
-
// Remove inline events
|
661
|
-
chart.exportDivElements[i] = elem.onmouseout = elem.onmouseover = elem.ontouchstart = elem.onclick = null;
|
662
|
-
|
663
|
-
// Destroy the div by moving to garbage bin
|
664
|
-
discardElement(elem);
|
665
|
-
}
|
666
|
-
}
|
667
|
-
});
|
668
|
-
|
669
|
-
|
670
|
-
symbols.menu = function (x, y, width, height) {
|
671
|
-
var arr = [
|
672
|
-
M, x, y + 2.5,
|
673
|
-
L, x + width, y + 2.5,
|
674
|
-
M, x, y + height / 2 + 0.5,
|
675
|
-
L, x + width, y + height / 2 + 0.5,
|
676
|
-
M, x, y + height - 1.5,
|
677
|
-
L, x + width, y + height - 1.5
|
678
|
-
];
|
679
|
-
return arr;
|
680
|
-
};
|
681
|
-
|
682
|
-
// Add the buttons on chart load
|
683
|
-
Chart.prototype.callbacks.push(function (chart) {
|
684
|
-
var n,
|
685
|
-
exportingOptions = chart.options.exporting,
|
686
|
-
buttons = exportingOptions.buttons;
|
687
|
-
|
688
|
-
buttonOffset = 0;
|
689
|
-
|
690
|
-
if (exportingOptions.enabled !== false) {
|
691
|
-
|
692
|
-
for (n in buttons) {
|
693
|
-
chart.addButton(buttons[n]);
|
694
|
-
}
|
695
|
-
|
696
|
-
// Destroy the export elements at chart destroy
|
697
|
-
addEvent(chart, 'destroy', chart.destroyExport);
|
698
|
-
}
|
699
|
-
|
700
|
-
});
|
701
|
-
|
702
|
-
|
703
|
-
}(Highcharts));
|