highcharts_rails 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +10 -0
- data/.rspec +2 -0
- data/.travis.yml +5 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +106 -0
- data/Rakefile +6 -0
- data/highcharts_rails.gemspec +27 -0
- data/lib/highcharts_rails/version.rb +3 -0
- data/lib/highcharts_rails.rb +8 -0
- data/vendor/assets/javascripts/highcharts-3d.src.js +2139 -0
- data/vendor/assets/javascripts/highcharts-more.src.js +2982 -0
- data/vendor/assets/javascripts/highcharts.src.js +22947 -0
- data/vendor/assets/javascripts/js/highcharts-3d.src.js +2085 -0
- data/vendor/assets/javascripts/js/highcharts-more.src.js +2820 -0
- data/vendor/assets/javascripts/js/highcharts.src.js +20917 -0
- data/vendor/assets/javascripts/js/modules/accessibility.src.js +1072 -0
- data/vendor/assets/javascripts/js/modules/annotations.src.js +408 -0
- data/vendor/assets/javascripts/js/modules/boost.src.js +652 -0
- data/vendor/assets/javascripts/js/modules/broken-axis.src.js +338 -0
- data/vendor/assets/javascripts/js/modules/data.src.js +981 -0
- data/vendor/assets/javascripts/js/modules/drilldown.src.js +756 -0
- data/vendor/assets/javascripts/js/modules/exporting.src.js +953 -0
- data/vendor/assets/javascripts/js/modules/funnel.src.js +290 -0
- data/vendor/assets/javascripts/js/modules/gantt.src.js +791 -0
- data/vendor/assets/javascripts/js/modules/grid-axis.src.js +545 -0
- data/vendor/assets/javascripts/js/modules/heatmap.src.js +798 -0
- data/vendor/assets/javascripts/js/modules/no-data-to-display.src.js +150 -0
- data/vendor/assets/javascripts/js/modules/offline-exporting.src.js +492 -0
- data/vendor/assets/javascripts/js/modules/overlapping-datalabels.src.js +164 -0
- data/vendor/assets/javascripts/js/modules/series-label.src.js +606 -0
- data/vendor/assets/javascripts/js/modules/solid-gauge.src.js +305 -0
- data/vendor/assets/javascripts/js/modules/treemap.src.js +881 -0
- data/vendor/assets/javascripts/js/modules/xrange-series.src.js +254 -0
- data/vendor/assets/javascripts/js/themes/dark-blue.js +317 -0
- data/vendor/assets/javascripts/js/themes/dark-green.js +314 -0
- data/vendor/assets/javascripts/js/themes/dark-unica.js +243 -0
- data/vendor/assets/javascripts/js/themes/gray.js +326 -0
- data/vendor/assets/javascripts/js/themes/grid-light.js +99 -0
- data/vendor/assets/javascripts/js/themes/grid.js +131 -0
- data/vendor/assets/javascripts/js/themes/sand-signika.js +129 -0
- data/vendor/assets/javascripts/js/themes/skies.js +112 -0
- data/vendor/assets/javascripts/lib/canvg.src.js +3073 -0
- data/vendor/assets/javascripts/lib/jspdf.src.js +3031 -0
- data/vendor/assets/javascripts/lib/rgbcolor.src.js +299 -0
- data/vendor/assets/javascripts/lib/svg2pdf.src.js +1451 -0
- data/vendor/assets/javascripts/modules/accessibility.src.js +1072 -0
- data/vendor/assets/javascripts/modules/annotations.src.js +408 -0
- data/vendor/assets/javascripts/modules/boost.src.js +652 -0
- data/vendor/assets/javascripts/modules/broken-axis.src.js +338 -0
- data/vendor/assets/javascripts/modules/data.src.js +981 -0
- data/vendor/assets/javascripts/modules/drilldown.src.js +797 -0
- data/vendor/assets/javascripts/modules/exporting.src.js +882 -0
- data/vendor/assets/javascripts/modules/funnel.src.js +304 -0
- data/vendor/assets/javascripts/modules/gantt.src.js +815 -0
- data/vendor/assets/javascripts/modules/grid-axis.src.js +547 -0
- data/vendor/assets/javascripts/modules/heatmap.src.js +810 -0
- data/vendor/assets/javascripts/modules/no-data-to-display.src.js +161 -0
- data/vendor/assets/javascripts/modules/offline-exporting.src.js +492 -0
- data/vendor/assets/javascripts/modules/overlapping-datalabels.src.js +164 -0
- data/vendor/assets/javascripts/modules/series-label.src.js +606 -0
- data/vendor/assets/javascripts/modules/solid-gauge.src.js +316 -0
- data/vendor/assets/javascripts/modules/treemap.src.js +935 -0
- data/vendor/assets/javascripts/modules/xrange-series.src.js +276 -0
- data/vendor/assets/javascripts/themes/dark-blue.js +317 -0
- data/vendor/assets/javascripts/themes/dark-green.js +314 -0
- data/vendor/assets/javascripts/themes/dark-unica.js +243 -0
- data/vendor/assets/javascripts/themes/gray.js +326 -0
- data/vendor/assets/javascripts/themes/grid-light.js +99 -0
- data/vendor/assets/javascripts/themes/grid.js +131 -0
- data/vendor/assets/javascripts/themes/sand-signika.js +129 -0
- data/vendor/assets/javascripts/themes/skies.js +112 -0
- data/vendor/assets/stylesheets/highcharts.scss +610 -0
- metadata +161 -0
@@ -0,0 +1,798 @@
|
|
1
|
+
/**
|
2
|
+
* @license Highcharts JS v5.0.6 (2016-12-07)
|
3
|
+
*
|
4
|
+
* (c) 2009-2016 Torstein Honsi
|
5
|
+
*
|
6
|
+
* License: www.highcharts.com/license
|
7
|
+
*/
|
8
|
+
(function(factory) {
|
9
|
+
if (typeof module === 'object' && module.exports) {
|
10
|
+
module.exports = factory;
|
11
|
+
} else {
|
12
|
+
factory(Highcharts);
|
13
|
+
}
|
14
|
+
}(function(Highcharts) {
|
15
|
+
(function(H) {
|
16
|
+
/**
|
17
|
+
* (c) 2010-2016 Torstein Honsi
|
18
|
+
*
|
19
|
+
* License: www.highcharts.com/license
|
20
|
+
*/
|
21
|
+
'use strict';
|
22
|
+
var Axis = H.Axis,
|
23
|
+
Chart = H.Chart,
|
24
|
+
color = H.color,
|
25
|
+
ColorAxis,
|
26
|
+
each = H.each,
|
27
|
+
extend = H.extend,
|
28
|
+
isNumber = H.isNumber,
|
29
|
+
Legend = H.Legend,
|
30
|
+
LegendSymbolMixin = H.LegendSymbolMixin,
|
31
|
+
noop = H.noop,
|
32
|
+
merge = H.merge,
|
33
|
+
pick = H.pick,
|
34
|
+
wrap = H.wrap;
|
35
|
+
|
36
|
+
/**
|
37
|
+
* The ColorAxis object for inclusion in gradient legends
|
38
|
+
*/
|
39
|
+
ColorAxis = H.ColorAxis = function() {
|
40
|
+
this.init.apply(this, arguments);
|
41
|
+
};
|
42
|
+
extend(ColorAxis.prototype, Axis.prototype);
|
43
|
+
extend(ColorAxis.prototype, {
|
44
|
+
defaultColorAxisOptions: {
|
45
|
+
lineWidth: 0,
|
46
|
+
minPadding: 0,
|
47
|
+
maxPadding: 0,
|
48
|
+
gridLineWidth: 1,
|
49
|
+
tickPixelInterval: 72,
|
50
|
+
startOnTick: true,
|
51
|
+
endOnTick: true,
|
52
|
+
offset: 0,
|
53
|
+
marker: {
|
54
|
+
animation: {
|
55
|
+
duration: 50
|
56
|
+
},
|
57
|
+
width: 0.01
|
58
|
+
|
59
|
+
},
|
60
|
+
labels: {
|
61
|
+
overflow: 'justify'
|
62
|
+
},
|
63
|
+
minColor: '#e6ebf5',
|
64
|
+
maxColor: '#003399',
|
65
|
+
tickLength: 5,
|
66
|
+
showInLegend: true
|
67
|
+
},
|
68
|
+
|
69
|
+
// Properties to preserve after destroy, for Axis.update (#5881)
|
70
|
+
keepProps: ['legendGroup', 'legendItem', 'legendSymbol']
|
71
|
+
.concat(Axis.prototype.keepProps),
|
72
|
+
|
73
|
+
/**
|
74
|
+
* Initialize the color axis
|
75
|
+
*/
|
76
|
+
init: function(chart, userOptions) {
|
77
|
+
var horiz = chart.options.legend.layout !== 'vertical',
|
78
|
+
options;
|
79
|
+
|
80
|
+
this.coll = 'colorAxis';
|
81
|
+
|
82
|
+
// Build the options
|
83
|
+
options = merge(this.defaultColorAxisOptions, {
|
84
|
+
side: horiz ? 2 : 1,
|
85
|
+
reversed: !horiz
|
86
|
+
}, userOptions, {
|
87
|
+
opposite: !horiz,
|
88
|
+
showEmpty: false,
|
89
|
+
title: null
|
90
|
+
});
|
91
|
+
|
92
|
+
Axis.prototype.init.call(this, chart, options);
|
93
|
+
|
94
|
+
// Base init() pushes it to the xAxis array, now pop it again
|
95
|
+
//chart[this.isXAxis ? 'xAxis' : 'yAxis'].pop();
|
96
|
+
|
97
|
+
// Prepare data classes
|
98
|
+
if (userOptions.dataClasses) {
|
99
|
+
this.initDataClasses(userOptions);
|
100
|
+
}
|
101
|
+
this.initStops(userOptions);
|
102
|
+
|
103
|
+
// Override original axis properties
|
104
|
+
this.horiz = horiz;
|
105
|
+
this.zoomEnabled = false;
|
106
|
+
|
107
|
+
// Add default values
|
108
|
+
this.defaultLegendLength = 200;
|
109
|
+
},
|
110
|
+
|
111
|
+
/*
|
112
|
+
* Return an intermediate color between two colors, according to pos where 0
|
113
|
+
* is the from color and 1 is the to color.
|
114
|
+
* NOTE: Changes here should be copied
|
115
|
+
* to the same function in drilldown.src.js and solid-gauge-src.js.
|
116
|
+
*/
|
117
|
+
tweenColors: function(from, to, pos) {
|
118
|
+
// Check for has alpha, because rgba colors perform worse due to lack of
|
119
|
+
// support in WebKit.
|
120
|
+
var hasAlpha,
|
121
|
+
ret;
|
122
|
+
|
123
|
+
// Unsupported color, return to-color (#3920)
|
124
|
+
if (!to.rgba.length || !from.rgba.length) {
|
125
|
+
ret = to.input || 'none';
|
126
|
+
|
127
|
+
// Interpolate
|
128
|
+
} else {
|
129
|
+
from = from.rgba;
|
130
|
+
to = to.rgba;
|
131
|
+
hasAlpha = (to[3] !== 1 || from[3] !== 1);
|
132
|
+
ret = (hasAlpha ? 'rgba(' : 'rgb(') +
|
133
|
+
Math.round(to[0] + (from[0] - to[0]) * (1 - pos)) + ',' +
|
134
|
+
Math.round(to[1] + (from[1] - to[1]) * (1 - pos)) + ',' +
|
135
|
+
Math.round(to[2] + (from[2] - to[2]) * (1 - pos)) +
|
136
|
+
(hasAlpha ? (',' + (to[3] + (from[3] - to[3]) * (1 - pos))) : '') + ')';
|
137
|
+
}
|
138
|
+
return ret;
|
139
|
+
},
|
140
|
+
|
141
|
+
initDataClasses: function(userOptions) {
|
142
|
+
var axis = this,
|
143
|
+
chart = this.chart,
|
144
|
+
dataClasses,
|
145
|
+
colorCounter = 0,
|
146
|
+
colorCount = chart.options.chart.colorCount,
|
147
|
+
options = this.options,
|
148
|
+
len = userOptions.dataClasses.length;
|
149
|
+
this.dataClasses = dataClasses = [];
|
150
|
+
this.legendItems = [];
|
151
|
+
|
152
|
+
each(userOptions.dataClasses, function(dataClass, i) {
|
153
|
+
var colors;
|
154
|
+
|
155
|
+
dataClass = merge(dataClass);
|
156
|
+
dataClasses.push(dataClass);
|
157
|
+
if (!dataClass.color) {
|
158
|
+
if (options.dataClassColor === 'category') {
|
159
|
+
|
160
|
+
dataClass.colorIndex = colorCounter;
|
161
|
+
|
162
|
+
// increase and loop back to zero
|
163
|
+
colorCounter++;
|
164
|
+
if (colorCounter === colorCount) {
|
165
|
+
colorCounter = 0;
|
166
|
+
}
|
167
|
+
} else {
|
168
|
+
dataClass.color = axis.tweenColors(
|
169
|
+
color(options.minColor),
|
170
|
+
color(options.maxColor),
|
171
|
+
len < 2 ? 0.5 : i / (len - 1) // #3219
|
172
|
+
);
|
173
|
+
}
|
174
|
+
}
|
175
|
+
});
|
176
|
+
},
|
177
|
+
|
178
|
+
initStops: function(userOptions) {
|
179
|
+
this.stops = userOptions.stops || [
|
180
|
+
[0, this.options.minColor],
|
181
|
+
[1, this.options.maxColor]
|
182
|
+
];
|
183
|
+
each(this.stops, function(stop) {
|
184
|
+
stop.color = color(stop[1]);
|
185
|
+
});
|
186
|
+
},
|
187
|
+
|
188
|
+
/**
|
189
|
+
* Extend the setOptions method to process extreme colors and color
|
190
|
+
* stops.
|
191
|
+
*/
|
192
|
+
setOptions: function(userOptions) {
|
193
|
+
Axis.prototype.setOptions.call(this, userOptions);
|
194
|
+
|
195
|
+
this.options.crosshair = this.options.marker;
|
196
|
+
},
|
197
|
+
|
198
|
+
setAxisSize: function() {
|
199
|
+
var symbol = this.legendSymbol,
|
200
|
+
chart = this.chart,
|
201
|
+
legendOptions = chart.options.legend || {},
|
202
|
+
x,
|
203
|
+
y,
|
204
|
+
width,
|
205
|
+
height;
|
206
|
+
|
207
|
+
if (symbol) {
|
208
|
+
this.left = x = symbol.attr('x');
|
209
|
+
this.top = y = symbol.attr('y');
|
210
|
+
this.width = width = symbol.attr('width');
|
211
|
+
this.height = height = symbol.attr('height');
|
212
|
+
this.right = chart.chartWidth - x - width;
|
213
|
+
this.bottom = chart.chartHeight - y - height;
|
214
|
+
|
215
|
+
this.len = this.horiz ? width : height;
|
216
|
+
this.pos = this.horiz ? x : y;
|
217
|
+
} else {
|
218
|
+
// Fake length for disabled legend to avoid tick issues and such (#5205)
|
219
|
+
this.len = (this.horiz ? legendOptions.symbolWidth : legendOptions.symbolHeight) || this.defaultLegendLength;
|
220
|
+
}
|
221
|
+
},
|
222
|
+
|
223
|
+
/**
|
224
|
+
* Translate from a value to a color
|
225
|
+
*/
|
226
|
+
toColor: function(value, point) {
|
227
|
+
var pos,
|
228
|
+
stops = this.stops,
|
229
|
+
from,
|
230
|
+
to,
|
231
|
+
color,
|
232
|
+
dataClasses = this.dataClasses,
|
233
|
+
dataClass,
|
234
|
+
i;
|
235
|
+
|
236
|
+
if (dataClasses) {
|
237
|
+
i = dataClasses.length;
|
238
|
+
while (i--) {
|
239
|
+
dataClass = dataClasses[i];
|
240
|
+
from = dataClass.from;
|
241
|
+
to = dataClass.to;
|
242
|
+
if ((from === undefined || value >= from) && (to === undefined || value <= to)) {
|
243
|
+
color = dataClass.color;
|
244
|
+
if (point) {
|
245
|
+
point.dataClass = i;
|
246
|
+
point.colorIndex = dataClass.colorIndex;
|
247
|
+
}
|
248
|
+
break;
|
249
|
+
}
|
250
|
+
}
|
251
|
+
|
252
|
+
} else {
|
253
|
+
|
254
|
+
if (this.isLog) {
|
255
|
+
value = this.val2lin(value);
|
256
|
+
}
|
257
|
+
pos = 1 - ((this.max - value) / ((this.max - this.min) || 1));
|
258
|
+
i = stops.length;
|
259
|
+
while (i--) {
|
260
|
+
if (pos > stops[i][0]) {
|
261
|
+
break;
|
262
|
+
}
|
263
|
+
}
|
264
|
+
from = stops[i] || stops[i + 1];
|
265
|
+
to = stops[i + 1] || from;
|
266
|
+
|
267
|
+
// The position within the gradient
|
268
|
+
pos = 1 - (to[0] - pos) / ((to[0] - from[0]) || 1);
|
269
|
+
|
270
|
+
color = this.tweenColors(
|
271
|
+
from.color,
|
272
|
+
to.color,
|
273
|
+
pos
|
274
|
+
);
|
275
|
+
}
|
276
|
+
return color;
|
277
|
+
},
|
278
|
+
|
279
|
+
/**
|
280
|
+
* Override the getOffset method to add the whole axis groups inside the legend.
|
281
|
+
*/
|
282
|
+
getOffset: function() {
|
283
|
+
var group = this.legendGroup,
|
284
|
+
sideOffset = this.chart.axisOffset[this.side];
|
285
|
+
|
286
|
+
if (group) {
|
287
|
+
|
288
|
+
// Hook for the getOffset method to add groups to this parent group
|
289
|
+
this.axisParent = group;
|
290
|
+
|
291
|
+
// Call the base
|
292
|
+
Axis.prototype.getOffset.call(this);
|
293
|
+
|
294
|
+
// First time only
|
295
|
+
if (!this.added) {
|
296
|
+
|
297
|
+
this.added = true;
|
298
|
+
|
299
|
+
this.labelLeft = 0;
|
300
|
+
this.labelRight = this.width;
|
301
|
+
}
|
302
|
+
// Reset it to avoid color axis reserving space
|
303
|
+
this.chart.axisOffset[this.side] = sideOffset;
|
304
|
+
}
|
305
|
+
},
|
306
|
+
|
307
|
+
/**
|
308
|
+
* Create the color gradient
|
309
|
+
*/
|
310
|
+
setLegendColor: function() {
|
311
|
+
var grad,
|
312
|
+
horiz = this.horiz,
|
313
|
+
options = this.options,
|
314
|
+
reversed = this.reversed,
|
315
|
+
one = reversed ? 1 : 0,
|
316
|
+
zero = reversed ? 0 : 1;
|
317
|
+
|
318
|
+
grad = horiz ? [one, 0, zero, 0] : [0, zero, 0, one]; // #3190
|
319
|
+
this.legendColor = {
|
320
|
+
linearGradient: {
|
321
|
+
x1: grad[0],
|
322
|
+
y1: grad[1],
|
323
|
+
x2: grad[2],
|
324
|
+
y2: grad[3]
|
325
|
+
},
|
326
|
+
stops: options.stops || [
|
327
|
+
[0, options.minColor],
|
328
|
+
[1, options.maxColor]
|
329
|
+
]
|
330
|
+
};
|
331
|
+
},
|
332
|
+
|
333
|
+
/**
|
334
|
+
* The color axis appears inside the legend and has its own legend symbol
|
335
|
+
*/
|
336
|
+
drawLegendSymbol: function(legend, item) {
|
337
|
+
var padding = legend.padding,
|
338
|
+
legendOptions = legend.options,
|
339
|
+
horiz = this.horiz,
|
340
|
+
width = pick(legendOptions.symbolWidth, horiz ? this.defaultLegendLength : 12),
|
341
|
+
height = pick(legendOptions.symbolHeight, horiz ? 12 : this.defaultLegendLength),
|
342
|
+
labelPadding = pick(legendOptions.labelPadding, horiz ? 16 : 30),
|
343
|
+
itemDistance = pick(legendOptions.itemDistance, 10);
|
344
|
+
|
345
|
+
this.setLegendColor();
|
346
|
+
|
347
|
+
// Create the gradient
|
348
|
+
item.legendSymbol = this.chart.renderer.rect(
|
349
|
+
0,
|
350
|
+
legend.baseline - 11,
|
351
|
+
width,
|
352
|
+
height
|
353
|
+
).attr({
|
354
|
+
zIndex: 1
|
355
|
+
}).add(item.legendGroup);
|
356
|
+
|
357
|
+
// Set how much space this legend item takes up
|
358
|
+
this.legendItemWidth = width + padding + (horiz ? itemDistance : labelPadding);
|
359
|
+
this.legendItemHeight = height + padding + (horiz ? labelPadding : 0);
|
360
|
+
},
|
361
|
+
/**
|
362
|
+
* Fool the legend
|
363
|
+
*/
|
364
|
+
setState: noop,
|
365
|
+
visible: true,
|
366
|
+
setVisible: noop,
|
367
|
+
getSeriesExtremes: function() {
|
368
|
+
var series;
|
369
|
+
if (this.series.length) {
|
370
|
+
series = this.series[0];
|
371
|
+
this.dataMin = series.valueMin;
|
372
|
+
this.dataMax = series.valueMax;
|
373
|
+
}
|
374
|
+
},
|
375
|
+
drawCrosshair: function(e, point) {
|
376
|
+
var plotX = point && point.plotX,
|
377
|
+
plotY = point && point.plotY,
|
378
|
+
crossPos,
|
379
|
+
axisPos = this.pos,
|
380
|
+
axisLen = this.len;
|
381
|
+
|
382
|
+
if (point) {
|
383
|
+
crossPos = this.toPixels(point[point.series.colorKey]);
|
384
|
+
if (crossPos < axisPos) {
|
385
|
+
crossPos = axisPos - 2;
|
386
|
+
} else if (crossPos > axisPos + axisLen) {
|
387
|
+
crossPos = axisPos + axisLen + 2;
|
388
|
+
}
|
389
|
+
|
390
|
+
point.plotX = crossPos;
|
391
|
+
point.plotY = this.len - crossPos;
|
392
|
+
Axis.prototype.drawCrosshair.call(this, e, point);
|
393
|
+
point.plotX = plotX;
|
394
|
+
point.plotY = plotY;
|
395
|
+
|
396
|
+
if (this.cross) {
|
397
|
+
this.cross
|
398
|
+
.addClass('highcharts-coloraxis-marker')
|
399
|
+
.add(this.legendGroup);
|
400
|
+
|
401
|
+
|
402
|
+
|
403
|
+
}
|
404
|
+
}
|
405
|
+
},
|
406
|
+
getPlotLinePath: function(a, b, c, d, pos) {
|
407
|
+
return isNumber(pos) ? // crosshairs only // #3969 pos can be 0 !!
|
408
|
+
(this.horiz ? ['M', pos - 4, this.top - 6, 'L', pos + 4, this.top - 6, pos, this.top, 'Z'] : ['M', this.left, pos, 'L', this.left - 6, pos + 6, this.left - 6, pos - 6, 'Z']) :
|
409
|
+
Axis.prototype.getPlotLinePath.call(this, a, b, c, d);
|
410
|
+
},
|
411
|
+
|
412
|
+
update: function(newOptions, redraw) {
|
413
|
+
var chart = this.chart,
|
414
|
+
legend = chart.legend;
|
415
|
+
|
416
|
+
each(this.series, function(series) {
|
417
|
+
series.isDirtyData = true; // Needed for Axis.update when choropleth colors change
|
418
|
+
});
|
419
|
+
|
420
|
+
// When updating data classes, destroy old items and make sure new ones are created (#3207)
|
421
|
+
if (newOptions.dataClasses && legend.allItems) {
|
422
|
+
each(legend.allItems, function(item) {
|
423
|
+
if (item.isDataClass) {
|
424
|
+
item.legendGroup.destroy();
|
425
|
+
}
|
426
|
+
});
|
427
|
+
chart.isDirtyLegend = true;
|
428
|
+
}
|
429
|
+
|
430
|
+
// Keep the options structure updated for export. Unlike xAxis and yAxis, the colorAxis is
|
431
|
+
// not an array. (#3207)
|
432
|
+
chart.options[this.coll] = merge(this.userOptions, newOptions);
|
433
|
+
|
434
|
+
Axis.prototype.update.call(this, newOptions, redraw);
|
435
|
+
if (this.legendItem) {
|
436
|
+
this.setLegendColor();
|
437
|
+
legend.colorizeItem(this, true);
|
438
|
+
}
|
439
|
+
},
|
440
|
+
|
441
|
+
/**
|
442
|
+
* Get the legend item symbols for data classes
|
443
|
+
*/
|
444
|
+
getDataClassLegendSymbols: function() {
|
445
|
+
var axis = this,
|
446
|
+
chart = this.chart,
|
447
|
+
legendItems = this.legendItems,
|
448
|
+
legendOptions = chart.options.legend,
|
449
|
+
valueDecimals = legendOptions.valueDecimals,
|
450
|
+
valueSuffix = legendOptions.valueSuffix || '',
|
451
|
+
name;
|
452
|
+
|
453
|
+
if (!legendItems.length) {
|
454
|
+
each(this.dataClasses, function(dataClass, i) {
|
455
|
+
var vis = true,
|
456
|
+
from = dataClass.from,
|
457
|
+
to = dataClass.to;
|
458
|
+
|
459
|
+
// Assemble the default name. This can be overridden by legend.options.labelFormatter
|
460
|
+
name = '';
|
461
|
+
if (from === undefined) {
|
462
|
+
name = '< ';
|
463
|
+
} else if (to === undefined) {
|
464
|
+
name = '> ';
|
465
|
+
}
|
466
|
+
if (from !== undefined) {
|
467
|
+
name += H.numberFormat(from, valueDecimals) + valueSuffix;
|
468
|
+
}
|
469
|
+
if (from !== undefined && to !== undefined) {
|
470
|
+
name += ' - ';
|
471
|
+
}
|
472
|
+
if (to !== undefined) {
|
473
|
+
name += H.numberFormat(to, valueDecimals) + valueSuffix;
|
474
|
+
}
|
475
|
+
// Add a mock object to the legend items
|
476
|
+
legendItems.push(extend({
|
477
|
+
chart: chart,
|
478
|
+
name: name,
|
479
|
+
options: {},
|
480
|
+
drawLegendSymbol: LegendSymbolMixin.drawRectangle,
|
481
|
+
visible: true,
|
482
|
+
setState: noop,
|
483
|
+
isDataClass: true,
|
484
|
+
setVisible: function() {
|
485
|
+
vis = this.visible = !vis;
|
486
|
+
each(axis.series, function(series) {
|
487
|
+
each(series.points, function(point) {
|
488
|
+
if (point.dataClass === i) {
|
489
|
+
point.setVisible(vis);
|
490
|
+
}
|
491
|
+
});
|
492
|
+
});
|
493
|
+
|
494
|
+
chart.legend.colorizeItem(this, vis);
|
495
|
+
}
|
496
|
+
}, dataClass));
|
497
|
+
});
|
498
|
+
}
|
499
|
+
return legendItems;
|
500
|
+
},
|
501
|
+
name: '' // Prevents 'undefined' in legend in IE8
|
502
|
+
});
|
503
|
+
|
504
|
+
/**
|
505
|
+
* Handle animation of the color attributes directly
|
506
|
+
*/
|
507
|
+
each(['fill', 'stroke'], function(prop) {
|
508
|
+
H.Fx.prototype[prop + 'Setter'] = function() {
|
509
|
+
this.elem.attr(
|
510
|
+
prop,
|
511
|
+
ColorAxis.prototype.tweenColors(
|
512
|
+
color(this.start),
|
513
|
+
color(this.end),
|
514
|
+
this.pos
|
515
|
+
),
|
516
|
+
null,
|
517
|
+
true
|
518
|
+
);
|
519
|
+
};
|
520
|
+
});
|
521
|
+
|
522
|
+
/**
|
523
|
+
* Extend the chart getAxes method to also get the color axis
|
524
|
+
*/
|
525
|
+
wrap(Chart.prototype, 'getAxes', function(proceed) {
|
526
|
+
|
527
|
+
var options = this.options,
|
528
|
+
colorAxisOptions = options.colorAxis;
|
529
|
+
|
530
|
+
proceed.call(this);
|
531
|
+
|
532
|
+
this.colorAxis = [];
|
533
|
+
if (colorAxisOptions) {
|
534
|
+
new ColorAxis(this, colorAxisOptions); // eslint-disable-line no-new
|
535
|
+
}
|
536
|
+
});
|
537
|
+
|
538
|
+
|
539
|
+
/**
|
540
|
+
* Wrap the legend getAllItems method to add the color axis. This also removes the
|
541
|
+
* axis' own series to prevent them from showing up individually.
|
542
|
+
*/
|
543
|
+
wrap(Legend.prototype, 'getAllItems', function(proceed) {
|
544
|
+
var allItems = [],
|
545
|
+
colorAxis = this.chart.colorAxis[0];
|
546
|
+
|
547
|
+
if (colorAxis && colorAxis.options) {
|
548
|
+
if (colorAxis.options.showInLegend) {
|
549
|
+
// Data classes
|
550
|
+
if (colorAxis.options.dataClasses) {
|
551
|
+
allItems = allItems.concat(colorAxis.getDataClassLegendSymbols());
|
552
|
+
// Gradient legend
|
553
|
+
} else {
|
554
|
+
// Add this axis on top
|
555
|
+
allItems.push(colorAxis);
|
556
|
+
}
|
557
|
+
}
|
558
|
+
|
559
|
+
// Don't add the color axis' series
|
560
|
+
each(colorAxis.series, function(series) {
|
561
|
+
series.options.showInLegend = false;
|
562
|
+
});
|
563
|
+
}
|
564
|
+
|
565
|
+
return allItems.concat(proceed.call(this));
|
566
|
+
});
|
567
|
+
|
568
|
+
wrap(Legend.prototype, 'colorizeItem', function(proceed, item, visible) {
|
569
|
+
proceed.call(this, item, visible);
|
570
|
+
if (visible && item.legendColor) {
|
571
|
+
item.legendSymbol.attr({
|
572
|
+
fill: item.legendColor
|
573
|
+
});
|
574
|
+
}
|
575
|
+
});
|
576
|
+
|
577
|
+
}(Highcharts));
|
578
|
+
(function(H) {
|
579
|
+
/**
|
580
|
+
* (c) 2010-2016 Torstein Honsi
|
581
|
+
*
|
582
|
+
* License: www.highcharts.com/license
|
583
|
+
*/
|
584
|
+
'use strict';
|
585
|
+
var defined = H.defined,
|
586
|
+
each = H.each,
|
587
|
+
noop = H.noop,
|
588
|
+
seriesTypes = H.seriesTypes;
|
589
|
+
|
590
|
+
/**
|
591
|
+
* Mixin for maps and heatmaps
|
592
|
+
*/
|
593
|
+
H.colorPointMixin = {
|
594
|
+
/**
|
595
|
+
* Color points have a value option that determines whether or not it is a null point
|
596
|
+
*/
|
597
|
+
isValid: function() {
|
598
|
+
return this.value !== null;
|
599
|
+
},
|
600
|
+
|
601
|
+
/**
|
602
|
+
* Set the visibility of a single point
|
603
|
+
*/
|
604
|
+
setVisible: function(vis) {
|
605
|
+
var point = this,
|
606
|
+
method = vis ? 'show' : 'hide';
|
607
|
+
|
608
|
+
// Show and hide associated elements
|
609
|
+
each(['graphic', 'dataLabel'], function(key) {
|
610
|
+
if (point[key]) {
|
611
|
+
point[key][method]();
|
612
|
+
}
|
613
|
+
});
|
614
|
+
},
|
615
|
+
setState: function(state) {
|
616
|
+
H.Point.prototype.setState.call(this, state);
|
617
|
+
if (this.graphic) {
|
618
|
+
this.graphic.attr({
|
619
|
+
zIndex: state === 'hover' ? 1 : 0
|
620
|
+
});
|
621
|
+
}
|
622
|
+
}
|
623
|
+
};
|
624
|
+
|
625
|
+
H.colorSeriesMixin = {
|
626
|
+
pointArrayMap: ['value'],
|
627
|
+
axisTypes: ['xAxis', 'yAxis', 'colorAxis'],
|
628
|
+
optionalAxis: 'colorAxis',
|
629
|
+
trackerGroups: ['group', 'markerGroup', 'dataLabelsGroup'],
|
630
|
+
getSymbol: noop,
|
631
|
+
parallelArrays: ['x', 'y', 'value'],
|
632
|
+
colorKey: 'value',
|
633
|
+
|
634
|
+
|
635
|
+
|
636
|
+
/**
|
637
|
+
* In choropleth maps, the color is a result of the value, so this needs translation too
|
638
|
+
*/
|
639
|
+
translateColors: function() {
|
640
|
+
var series = this,
|
641
|
+
nullColor = this.options.nullColor,
|
642
|
+
colorAxis = this.colorAxis,
|
643
|
+
colorKey = this.colorKey;
|
644
|
+
|
645
|
+
each(this.data, function(point) {
|
646
|
+
var value = point[colorKey],
|
647
|
+
color;
|
648
|
+
|
649
|
+
color = point.options.color ||
|
650
|
+
(point.isNull ? nullColor : (colorAxis && value !== undefined) ? colorAxis.toColor(value, point) : point.color || series.color);
|
651
|
+
|
652
|
+
if (color) {
|
653
|
+
point.color = color;
|
654
|
+
}
|
655
|
+
});
|
656
|
+
},
|
657
|
+
|
658
|
+
/**
|
659
|
+
* Get the color attibutes to apply on the graphic
|
660
|
+
*/
|
661
|
+
colorAttribs: function(point) {
|
662
|
+
var ret = {};
|
663
|
+
if (defined(point.color)) {
|
664
|
+
ret[this.colorProp || 'fill'] = point.color;
|
665
|
+
}
|
666
|
+
return ret;
|
667
|
+
}
|
668
|
+
};
|
669
|
+
|
670
|
+
}(Highcharts));
|
671
|
+
(function(H) {
|
672
|
+
/**
|
673
|
+
* (c) 2010-2016 Torstein Honsi
|
674
|
+
*
|
675
|
+
* License: www.highcharts.com/license
|
676
|
+
*/
|
677
|
+
'use strict';
|
678
|
+
var colorPointMixin = H.colorPointMixin,
|
679
|
+
colorSeriesMixin = H.colorSeriesMixin,
|
680
|
+
each = H.each,
|
681
|
+
LegendSymbolMixin = H.LegendSymbolMixin,
|
682
|
+
merge = H.merge,
|
683
|
+
noop = H.noop,
|
684
|
+
pick = H.pick,
|
685
|
+
Series = H.Series,
|
686
|
+
seriesType = H.seriesType,
|
687
|
+
seriesTypes = H.seriesTypes;
|
688
|
+
|
689
|
+
// The Heatmap series type
|
690
|
+
seriesType('heatmap', 'scatter', {
|
691
|
+
animation: false,
|
692
|
+
borderWidth: 0,
|
693
|
+
|
694
|
+
dataLabels: {
|
695
|
+
formatter: function() { // #2945
|
696
|
+
return this.point.value;
|
697
|
+
},
|
698
|
+
inside: true,
|
699
|
+
verticalAlign: 'middle',
|
700
|
+
crop: false,
|
701
|
+
overflow: false,
|
702
|
+
padding: 0 // #3837
|
703
|
+
},
|
704
|
+
marker: null,
|
705
|
+
pointRange: null, // dynamically set to colsize by default
|
706
|
+
tooltip: {
|
707
|
+
pointFormat: '{point.x}, {point.y}: {point.value}<br/>'
|
708
|
+
},
|
709
|
+
states: {
|
710
|
+
normal: {
|
711
|
+
animation: true
|
712
|
+
},
|
713
|
+
hover: {
|
714
|
+
halo: false, // #3406, halo is not required on heatmaps
|
715
|
+
brightness: 0.2
|
716
|
+
}
|
717
|
+
}
|
718
|
+
}, merge(colorSeriesMixin, {
|
719
|
+
pointArrayMap: ['y', 'value'],
|
720
|
+
hasPointSpecificOptions: true,
|
721
|
+
supportsDrilldown: true,
|
722
|
+
getExtremesFromAll: true,
|
723
|
+
directTouch: true,
|
724
|
+
|
725
|
+
/**
|
726
|
+
* Override the init method to add point ranges on both axes.
|
727
|
+
*/
|
728
|
+
init: function() {
|
729
|
+
var options;
|
730
|
+
seriesTypes.scatter.prototype.init.apply(this, arguments);
|
731
|
+
|
732
|
+
options = this.options;
|
733
|
+
options.pointRange = pick(options.pointRange, options.colsize || 1); // #3758, prevent resetting in setData
|
734
|
+
this.yAxis.axisPointRange = options.rowsize || 1; // general point range
|
735
|
+
},
|
736
|
+
translate: function() {
|
737
|
+
var series = this,
|
738
|
+
options = series.options,
|
739
|
+
xAxis = series.xAxis,
|
740
|
+
yAxis = series.yAxis,
|
741
|
+
between = function(x, a, b) {
|
742
|
+
return Math.min(Math.max(a, x), b);
|
743
|
+
};
|
744
|
+
|
745
|
+
series.generatePoints();
|
746
|
+
|
747
|
+
each(series.points, function(point) {
|
748
|
+
var xPad = (options.colsize || 1) / 2,
|
749
|
+
yPad = (options.rowsize || 1) / 2,
|
750
|
+
x1 = between(Math.round(xAxis.len - xAxis.translate(point.x - xPad, 0, 1, 0, 1)), -xAxis.len, 2 * xAxis.len),
|
751
|
+
x2 = between(Math.round(xAxis.len - xAxis.translate(point.x + xPad, 0, 1, 0, 1)), -xAxis.len, 2 * xAxis.len),
|
752
|
+
y1 = between(Math.round(yAxis.translate(point.y - yPad, 0, 1, 0, 1)), -yAxis.len, 2 * yAxis.len),
|
753
|
+
y2 = between(Math.round(yAxis.translate(point.y + yPad, 0, 1, 0, 1)), -yAxis.len, 2 * yAxis.len);
|
754
|
+
|
755
|
+
// Set plotX and plotY for use in K-D-Tree and more
|
756
|
+
point.plotX = point.clientX = (x1 + x2) / 2;
|
757
|
+
point.plotY = (y1 + y2) / 2;
|
758
|
+
|
759
|
+
point.shapeType = 'rect';
|
760
|
+
point.shapeArgs = {
|
761
|
+
x: Math.min(x1, x2),
|
762
|
+
y: Math.min(y1, y2),
|
763
|
+
width: Math.abs(x2 - x1),
|
764
|
+
height: Math.abs(y2 - y1)
|
765
|
+
};
|
766
|
+
});
|
767
|
+
|
768
|
+
series.translateColors();
|
769
|
+
},
|
770
|
+
drawPoints: function() {
|
771
|
+
seriesTypes.column.prototype.drawPoints.call(this);
|
772
|
+
|
773
|
+
each(this.points, function(point) {
|
774
|
+
|
775
|
+
// In styled mode, use CSS, otherwise the fill used in the style
|
776
|
+
// sheet will take precesence over the fill attribute.
|
777
|
+
point.graphic.css(this.colorAttribs(point));
|
778
|
+
|
779
|
+
}, this);
|
780
|
+
},
|
781
|
+
animate: noop,
|
782
|
+
getBox: noop,
|
783
|
+
drawLegendSymbol: LegendSymbolMixin.drawRectangle,
|
784
|
+
alignDataLabel: seriesTypes.column.prototype.alignDataLabel,
|
785
|
+
getExtremes: function() {
|
786
|
+
// Get the extremes from the value data
|
787
|
+
Series.prototype.getExtremes.call(this, this.valueData);
|
788
|
+
this.valueMin = this.dataMin;
|
789
|
+
this.valueMax = this.dataMax;
|
790
|
+
|
791
|
+
// Get the extremes from the y data
|
792
|
+
Series.prototype.getExtremes.call(this);
|
793
|
+
}
|
794
|
+
|
795
|
+
}), colorPointMixin);
|
796
|
+
|
797
|
+
}(Highcharts));
|
798
|
+
}));
|