highcharts-rails 3.0.1.5 → 3.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data.tar.gz.asc +13 -13
- data/CHANGELOG.markdown +7 -1
- data/README.markdown +0 -48
- data/app/assets/javascripts/highcharts.js +134 -87
- data/app/assets/javascripts/highcharts/adapters/mootools.js +2 -2
- data/app/assets/javascripts/highcharts/adapters/prototype.js +3 -3
- data/app/assets/javascripts/highcharts/highcharts-more.js +2525 -50
- data/app/assets/javascripts/highcharts/modules/annotations.js +354 -0
- data/app/assets/javascripts/highcharts/modules/canvas-tools.js +1 -1
- data/app/assets/javascripts/highcharts/modules/exporting.js +12 -8
- data/highcharts-rails.gemspec +0 -1
- data/lib/highcharts/version.rb +1 -1
- metadata +3 -19
- metadata.gz.asc +13 -13
- data/lib/highcharts/export_endpoint.rb +0 -127
@@ -0,0 +1,354 @@
|
|
1
|
+
(function (Highcharts, HighchartsAdapter) {
|
2
|
+
|
3
|
+
var UNDEFINED,
|
4
|
+
ALIGN_FACTOR,
|
5
|
+
ALLOWED_SHAPES,
|
6
|
+
Chart = Highcharts.Chart,
|
7
|
+
extend = Highcharts.extend,
|
8
|
+
each = Highcharts.each,
|
9
|
+
defaultOptions;
|
10
|
+
|
11
|
+
defaultOptions = {
|
12
|
+
xAxis: 0,
|
13
|
+
yAxis: 0,
|
14
|
+
title: {
|
15
|
+
style: {},
|
16
|
+
text: "",
|
17
|
+
x: 0,
|
18
|
+
y: 0
|
19
|
+
},
|
20
|
+
shape: {
|
21
|
+
params: {
|
22
|
+
stroke: "#000000",
|
23
|
+
fill: "transparent",
|
24
|
+
strokeWidth: 2
|
25
|
+
}
|
26
|
+
}
|
27
|
+
};
|
28
|
+
|
29
|
+
ALLOWED_SHAPES = ["path", "rect", "circle"];
|
30
|
+
|
31
|
+
ALIGN_FACTOR = {
|
32
|
+
top: 0,
|
33
|
+
left: 0,
|
34
|
+
center: 0.5,
|
35
|
+
middle: 0.5,
|
36
|
+
bottom: 1,
|
37
|
+
right: 1
|
38
|
+
};
|
39
|
+
|
40
|
+
|
41
|
+
// Highcharts helper methods
|
42
|
+
var inArray = HighchartsAdapter.inArray,
|
43
|
+
merge = Highcharts.merge;
|
44
|
+
|
45
|
+
function isArray(obj) {
|
46
|
+
return Object.prototype.toString.call(obj) === '[object Array]';
|
47
|
+
}
|
48
|
+
|
49
|
+
function isNumber(n) {
|
50
|
+
return typeof n === 'number';
|
51
|
+
}
|
52
|
+
|
53
|
+
function defined(obj) {
|
54
|
+
return obj !== UNDEFINED && obj !== null;
|
55
|
+
}
|
56
|
+
|
57
|
+
|
58
|
+
// Define annotation prototype
|
59
|
+
var Annotation = function () {
|
60
|
+
this.init.apply(this, arguments);
|
61
|
+
};
|
62
|
+
Annotation.prototype = {
|
63
|
+
/*
|
64
|
+
* Initialize the annotation
|
65
|
+
*/
|
66
|
+
init: function (chart, options) {
|
67
|
+
this.chart = chart;
|
68
|
+
this.options = merge({}, defaultOptions, options);
|
69
|
+
},
|
70
|
+
|
71
|
+
/*
|
72
|
+
* Render the annotation
|
73
|
+
*/
|
74
|
+
render: function (redraw) {
|
75
|
+
var annotation = this,
|
76
|
+
chart = this.chart,
|
77
|
+
renderer = annotation.chart.renderer,
|
78
|
+
group = annotation.group,
|
79
|
+
title = annotation.title,
|
80
|
+
shape = annotation.shape,
|
81
|
+
options = annotation.options,
|
82
|
+
titleOptions = options.title,
|
83
|
+
shapeOptions = options.shape;
|
84
|
+
|
85
|
+
if (!group) {
|
86
|
+
group = annotation.group = renderer.g();
|
87
|
+
}
|
88
|
+
|
89
|
+
if (!title && titleOptions) {
|
90
|
+
title = annotation.title = renderer.label(titleOptions);
|
91
|
+
title.add(group);
|
92
|
+
}
|
93
|
+
|
94
|
+
if (!shape && shapeOptions && inArray(shapeOptions.type, ALLOWED_SHAPES) !== -1) {
|
95
|
+
shape = annotation.shape = renderer[options.shape.type](shapeOptions.params);
|
96
|
+
shape.add(group);
|
97
|
+
}
|
98
|
+
|
99
|
+
group.add(chart.annotations.group);
|
100
|
+
|
101
|
+
// link annotations to point or series
|
102
|
+
annotation.linkObjects();
|
103
|
+
|
104
|
+
if (redraw !== false) {
|
105
|
+
annotation.redraw();
|
106
|
+
}
|
107
|
+
},
|
108
|
+
|
109
|
+
/*
|
110
|
+
* Redraw the annotation title or shape after options update
|
111
|
+
*/
|
112
|
+
redraw: function () {
|
113
|
+
var options = this.options,
|
114
|
+
chart = this.chart,
|
115
|
+
group = this.group,
|
116
|
+
title = this.title,
|
117
|
+
shape = this.shape,
|
118
|
+
linkedTo = this.linkedObject,
|
119
|
+
xAxis = chart.xAxis[options.xAxis],
|
120
|
+
yAxis = chart.yAxis[options.yAxis],
|
121
|
+
width = options.width,
|
122
|
+
height = options.height,
|
123
|
+
anchorY = ALIGN_FACTOR[options.anchorY],
|
124
|
+
anchorX = ALIGN_FACTOR[options.anchorX],
|
125
|
+
resetBBox = false,
|
126
|
+
shapeParams,
|
127
|
+
linkType,
|
128
|
+
series,
|
129
|
+
param,
|
130
|
+
bbox,
|
131
|
+
x,
|
132
|
+
y;
|
133
|
+
|
134
|
+
if (linkedTo) {
|
135
|
+
linkType = (linkedTo instanceof Highcharts.Point) ? 'point' :
|
136
|
+
(linkedTo instanceof Highcharts.Series) ? 'series' : null;
|
137
|
+
|
138
|
+
if (linkType === 'point') {
|
139
|
+
options.xValue = linkedTo.x;
|
140
|
+
options.yValue = linkedTo.y;
|
141
|
+
series = linkedTo.series;
|
142
|
+
} else if (linkType === 'series') {
|
143
|
+
series = linkedTo;
|
144
|
+
}
|
145
|
+
|
146
|
+
if (group.visibility !== series.group.visibility) {
|
147
|
+
group.attr({
|
148
|
+
visibility: series.group.visibility
|
149
|
+
});
|
150
|
+
}
|
151
|
+
}
|
152
|
+
|
153
|
+
|
154
|
+
// Based on given options find annotation pixel position
|
155
|
+
x = (defined(options.xValue) ? xAxis.toPixels(options.xValue + xAxis.minPointOffset) : options.x) - xAxis.minPixelPadding;
|
156
|
+
y = defined(options.yValue) ? yAxis.toPixels(options.yValue) : options.y;
|
157
|
+
|
158
|
+
|
159
|
+
if (isNaN(x) || isNaN(y) || !isNumber(x) || !isNumber(y)) {
|
160
|
+
return;
|
161
|
+
}
|
162
|
+
|
163
|
+
|
164
|
+
if (title) {
|
165
|
+
title.attr(options.title);
|
166
|
+
title.css(options.title.style);
|
167
|
+
resetBBox = true;
|
168
|
+
}
|
169
|
+
|
170
|
+
if (shape) {
|
171
|
+
shapeParams = extend({}, options.shape.params);
|
172
|
+
|
173
|
+
if (options.units === 'values') {
|
174
|
+
for (param in shapeParams) {
|
175
|
+
if (inArray(param, ['width', 'x']) > -1) {
|
176
|
+
shapeParams[param] = xAxis.translate(shapeParams[param]);
|
177
|
+
} else if (inArray(param, ['height', 'y']) > -1) {
|
178
|
+
shapeParams[param] = yAxis.translate(shapeParams[param]);
|
179
|
+
}
|
180
|
+
}
|
181
|
+
|
182
|
+
if (shapeParams.width) {
|
183
|
+
shapeParams.width -= xAxis.toPixels(0) - xAxis.left;
|
184
|
+
}
|
185
|
+
|
186
|
+
if (shapeParams.x) {
|
187
|
+
shapeParams.x += xAxis.minPixelPadding;
|
188
|
+
}
|
189
|
+
|
190
|
+
}
|
191
|
+
|
192
|
+
resetBBox = true;
|
193
|
+
shape.attr(shapeParams);
|
194
|
+
}
|
195
|
+
|
196
|
+
group.bBox = null;
|
197
|
+
|
198
|
+
// If annotation width or height is not defined in options use bounding box size
|
199
|
+
if (!isNumber(width)) {
|
200
|
+
bbox = group.getBBox();
|
201
|
+
width = bbox.width;
|
202
|
+
}
|
203
|
+
|
204
|
+
if (!isNumber(height)) {
|
205
|
+
// get bbox only if it wasn't set before
|
206
|
+
if (!bbox) {
|
207
|
+
bbox = group.getBBox();
|
208
|
+
}
|
209
|
+
|
210
|
+
height = bbox.height;
|
211
|
+
}
|
212
|
+
|
213
|
+
// Calculate anchor point
|
214
|
+
if (!isNumber(anchorX)) {
|
215
|
+
anchorX = ALIGN_FACTOR.center;
|
216
|
+
}
|
217
|
+
|
218
|
+
if (!isNumber(anchorY)) {
|
219
|
+
anchorY = ALIGN_FACTOR.center;
|
220
|
+
}
|
221
|
+
|
222
|
+
// Translate group according to its dimension and anchor point
|
223
|
+
x = x - width * anchorX;
|
224
|
+
y = y - height * anchorY;
|
225
|
+
|
226
|
+
if (chart.animation && defined(group.translateX) && defined(group.translateY)) {
|
227
|
+
group.animate({
|
228
|
+
translateX: x,
|
229
|
+
translateY: y
|
230
|
+
});
|
231
|
+
} else {
|
232
|
+
group.translate(x, y);
|
233
|
+
}
|
234
|
+
},
|
235
|
+
|
236
|
+
/*
|
237
|
+
* Destroy the annotation
|
238
|
+
*/
|
239
|
+
destroy: function () {
|
240
|
+
var annotation = this,
|
241
|
+
chart = this.chart,
|
242
|
+
allItems = chart.annotations.allItems,
|
243
|
+
index = allItems.indexOf(annotation);
|
244
|
+
|
245
|
+
if (index > -1) {
|
246
|
+
allItems.splice(index, 1);
|
247
|
+
}
|
248
|
+
|
249
|
+
each(['title', 'shape', 'group'], function (element) {
|
250
|
+
if (annotation[element]) {
|
251
|
+
annotation[element].destroy();
|
252
|
+
annotation[element] = null;
|
253
|
+
}
|
254
|
+
});
|
255
|
+
|
256
|
+
annotation.group = annotation.title = annotation.shape = annotation.chart = annotation.options = null;
|
257
|
+
},
|
258
|
+
|
259
|
+
/*
|
260
|
+
* Update the annotation with a given options
|
261
|
+
*/
|
262
|
+
update: function (options, redraw) {
|
263
|
+
extend(this.options, options);
|
264
|
+
|
265
|
+
// update link to point or series
|
266
|
+
this.linkObjects();
|
267
|
+
|
268
|
+
this.render(redraw);
|
269
|
+
},
|
270
|
+
|
271
|
+
linkObjects: function () {
|
272
|
+
var annotation = this,
|
273
|
+
chart = annotation.chart,
|
274
|
+
linkedTo = annotation.linkedObject,
|
275
|
+
linkedId = linkedTo && (linkedTo.id || linkedTo.options.id),
|
276
|
+
options = annotation.options,
|
277
|
+
id = options.linkedTo;
|
278
|
+
|
279
|
+
if (!defined(id)) {
|
280
|
+
annotation.linkedObject = null;
|
281
|
+
} else if (!defined(linkedTo) || id !== linkedId) {
|
282
|
+
annotation.linkedObject = chart.get(id);
|
283
|
+
}
|
284
|
+
}
|
285
|
+
};
|
286
|
+
|
287
|
+
|
288
|
+
// Add annotations methods to chart prototype
|
289
|
+
extend(Chart.prototype, {
|
290
|
+
annotations: {
|
291
|
+
/*
|
292
|
+
* Unified method for adding annotations to the chart
|
293
|
+
*/
|
294
|
+
add: function (options, redraw) {
|
295
|
+
var annotations = this.allItems,
|
296
|
+
chart = this.chart,
|
297
|
+
item,
|
298
|
+
len;
|
299
|
+
|
300
|
+
if (!isArray(options)) {
|
301
|
+
options = [options];
|
302
|
+
}
|
303
|
+
|
304
|
+
len = options.length;
|
305
|
+
|
306
|
+
while (len--) {
|
307
|
+
item = new Annotation(chart, options[len]);
|
308
|
+
annotations.push(item);
|
309
|
+
item.render(redraw);
|
310
|
+
}
|
311
|
+
},
|
312
|
+
|
313
|
+
/**
|
314
|
+
* Redraw all annotations, method used in chart events
|
315
|
+
*/
|
316
|
+
redraw: function () {
|
317
|
+
each(this.allItems, function (annotation) {
|
318
|
+
annotation.redraw();
|
319
|
+
});
|
320
|
+
}
|
321
|
+
}
|
322
|
+
});
|
323
|
+
|
324
|
+
|
325
|
+
// Initialize on chart load
|
326
|
+
Chart.prototype.callbacks.push(function (chart) {
|
327
|
+
var options = chart.options.annotations,
|
328
|
+
group;
|
329
|
+
|
330
|
+
group = chart.renderer.g("annotations");
|
331
|
+
group.attr({
|
332
|
+
zIndex: 7
|
333
|
+
});
|
334
|
+
group.add();
|
335
|
+
|
336
|
+
// initialize empty array for annotations
|
337
|
+
chart.annotations.allItems = [];
|
338
|
+
|
339
|
+
// link chart object to annotations
|
340
|
+
chart.annotations.chart = chart;
|
341
|
+
|
342
|
+
// link annotations group element to the chart
|
343
|
+
chart.annotations.group = group;
|
344
|
+
|
345
|
+
if (isArray(options) && options.length > 0) {
|
346
|
+
chart.annotations.add(chart.options.annotations);
|
347
|
+
}
|
348
|
+
|
349
|
+
// update annotations after chart redraw
|
350
|
+
Highcharts.addEvent(chart, 'redraw', function () {
|
351
|
+
chart.annotations.redraw();
|
352
|
+
});
|
353
|
+
});
|
354
|
+
}(Highcharts, HighchartsAdapter));
|
@@ -2908,7 +2908,7 @@ if (CanvasRenderingContext2D) {
|
|
2908
2908
|
});
|
2909
2909
|
}
|
2910
2910
|
}/**
|
2911
|
-
* @license Highcharts JS v3.0.
|
2911
|
+
* @license Highcharts JS v3.0.2 (2013-06-05)
|
2912
2912
|
* CanVGRenderer Extension module
|
2913
2913
|
*
|
2914
2914
|
* (c) 2011-2012 Torstein Hønsi, Erik Olsson
|
@@ -1,5 +1,5 @@
|
|
1
1
|
/**
|
2
|
-
* @license Highcharts JS v3.0.
|
2
|
+
* @license Highcharts JS v3.0.2 (2013-06-05)
|
3
3
|
* Exporting module
|
4
4
|
*
|
5
5
|
* (c) 2010-2013 Torstein Hønsi
|
@@ -243,8 +243,7 @@ extend(Chart.prototype, {
|
|
243
243
|
height: sourceHeight
|
244
244
|
});
|
245
245
|
options.exporting.enabled = false; // hide buttons in print
|
246
|
-
|
247
|
-
|
246
|
+
|
248
247
|
// prepare for replicating the chart
|
249
248
|
options.series = [];
|
250
249
|
each(chart.series, function (serie) {
|
@@ -310,7 +309,7 @@ extend(Chart.prototype, {
|
|
310
309
|
.replace(/width=([^" ]+)/g, 'width="$1"')
|
311
310
|
.replace(/hc-svg-href="([^"]+)">/g, 'xlink:href="$1"/>')
|
312
311
|
.replace(/id=([^" >]+)/g, 'id="$1"')
|
313
|
-
.replace(/class=([^" ]+)/g, 'class="$1"')
|
312
|
+
.replace(/class=([^" >]+)/g, 'class="$1"')
|
314
313
|
.replace(/ transform /g, ' ')
|
315
314
|
.replace(/:(path|rect)/g, '$1')
|
316
315
|
.replace(/style="([^"]+)"/g, function (s) {
|
@@ -339,11 +338,11 @@ extend(Chart.prototype, {
|
|
339
338
|
chartExportingOptions = chart.options.exporting,
|
340
339
|
svg = chart.getSVG(merge(
|
341
340
|
{ chart: { borderRadius: 0 } },
|
342
|
-
chartExportingOptions,
|
341
|
+
chartExportingOptions.chartOptions,
|
343
342
|
chartOptions,
|
344
343
|
{
|
345
344
|
exporting: {
|
346
|
-
sourceWidth: options.sourceWidth ||
|
345
|
+
sourceWidth: options.sourceWidth || chartExportingOptions.sourceWidth, // docs: option and parameter in exportChart()
|
347
346
|
sourceHeight: options.sourceHeight || chartExportingOptions.sourceHeight // docs
|
348
347
|
}
|
349
348
|
}
|
@@ -465,6 +464,7 @@ extend(Chart.prototype, {
|
|
465
464
|
if (button) {
|
466
465
|
button.setState(0);
|
467
466
|
}
|
467
|
+
chart.openMenu = false;
|
468
468
|
};
|
469
469
|
|
470
470
|
// Hide the menu some time after mouse leave (#1357)
|
@@ -526,6 +526,7 @@ extend(Chart.prototype, {
|
|
526
526
|
}
|
527
527
|
|
528
528
|
css(menu, menuStyle);
|
529
|
+
chart.openMenu = true;
|
529
530
|
},
|
530
531
|
|
531
532
|
/**
|
@@ -645,9 +646,12 @@ extend(Chart.prototype, {
|
|
645
646
|
// Destroy the extra buttons added
|
646
647
|
for (i = 0; i < chart.exportSVGElements.length; i++) {
|
647
648
|
elem = chart.exportSVGElements[i];
|
649
|
+
|
648
650
|
// Destroy and null the svg/vml elements
|
649
|
-
elem
|
650
|
-
|
651
|
+
if (elem) { // #1822
|
652
|
+
elem.onclick = elem.ontouchstart = null;
|
653
|
+
chart.exportSVGElements[i] = elem.destroy();
|
654
|
+
}
|
651
655
|
}
|
652
656
|
|
653
657
|
// Destroy the divs for the menu
|
data/highcharts-rails.gemspec
CHANGED
data/lib/highcharts/version.rb
CHANGED
metadata
CHANGED
@@ -2,14 +2,14 @@
|
|
2
2
|
name: highcharts-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 3.0.
|
5
|
+
version: 3.0.2
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Per Christian B. Viken
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-06-07 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: railties
|
@@ -27,22 +27,6 @@ dependencies:
|
|
27
27
|
- - ! '>='
|
28
28
|
- !ruby/object:Gem::Version
|
29
29
|
version: '3.1'
|
30
|
-
- !ruby/object:Gem::Dependency
|
31
|
-
name: cocaine
|
32
|
-
type: :runtime
|
33
|
-
requirement: !ruby/object:Gem::Requirement
|
34
|
-
none: false
|
35
|
-
requirements:
|
36
|
-
- - ~>
|
37
|
-
- !ruby/object:Gem::Version
|
38
|
-
version: 0.4.0
|
39
|
-
prerelease: false
|
40
|
-
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
|
-
requirements:
|
43
|
-
- - ~>
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
version: 0.4.0
|
46
30
|
- !ruby/object:Gem::Dependency
|
47
31
|
name: bundler
|
48
32
|
type: :development
|
@@ -96,6 +80,7 @@ files:
|
|
96
80
|
- app/assets/javascripts/highcharts/adapters/mootools.js
|
97
81
|
- app/assets/javascripts/highcharts/adapters/prototype.js
|
98
82
|
- app/assets/javascripts/highcharts/highcharts-more.js
|
83
|
+
- app/assets/javascripts/highcharts/modules/annotations.js
|
99
84
|
- app/assets/javascripts/highcharts/modules/canvas-tools.js
|
100
85
|
- app/assets/javascripts/highcharts/modules/data.js
|
101
86
|
- app/assets/javascripts/highcharts/modules/exporting.js
|
@@ -107,7 +92,6 @@ files:
|
|
107
92
|
- app/assets/javascripts/highcharts/themes/skies.js
|
108
93
|
- highcharts-rails.gemspec
|
109
94
|
- lib/highcharts-rails.rb
|
110
|
-
- lib/highcharts/export_endpoint.rb
|
111
95
|
- lib/highcharts/rails.rb
|
112
96
|
- lib/highcharts/version.rb
|
113
97
|
homepage: http://northblue.org/
|