corrade-nucleus-nucleons – Diff between revs 1 and 11

Subversion Repositories:
Rev:
Only display areas with differencesIgnore whitespace
Rev 1 Rev 11
1 /** 1 /**
2 * @license Highcharts JS v5.0.10 (2017-03-31) 2 * @license Highcharts JS v5.0.12 (2017-05-24)
3 * Solid angular gauge module 3 * Solid angular gauge module
4 * 4 *
5 * (c) 2010-2017 Torstein Honsi 5 * (c) 2010-2017 Torstein Honsi
6 * 6 *
7 * License: www.highcharts.com/license 7 * License: www.highcharts.com/license
8 */ 8 */
9 'use strict'; 9 'use strict';
10 (function(factory) { 10 (function(factory) {
11 if (typeof module === 'object' && module.exports) { 11 if (typeof module === 'object' && module.exports) {
12 module.exports = factory; 12 module.exports = factory;
13 } else { 13 } else {
14 factory(Highcharts); 14 factory(Highcharts);
15 } 15 }
16 }(function(Highcharts) { 16 }(function(Highcharts) {
17 (function(H) { 17 (function(H) {
18 /** 18 /**
19 * Solid angular gauge module 19 * Solid angular gauge module
20 * 20 *
21 * (c) 2010-2017 Torstein Honsi 21 * (c) 2010-2017 Torstein Honsi
22 * 22 *
23 * License: www.highcharts.com/license 23 * License: www.highcharts.com/license
24 */ 24 */
25   25  
26   26  
27 var pInt = H.pInt, 27 var pInt = H.pInt,
28 pick = H.pick, 28 pick = H.pick,
29 each = H.each, 29 each = H.each,
30 isNumber = H.isNumber, 30 isNumber = H.isNumber,
31 wrap = H.wrap, 31 wrap = H.wrap,
32 Renderer = H.Renderer, 32 Renderer = H.Renderer,
33 colorAxisMethods; 33 colorAxisMethods;
34   34  
35 /** 35 /**
36 * Symbol definition of an arc with round edges. 36 * Symbol definition of an arc with round edges.
37 * 37 *
38 * @param {Number} x - The X coordinate for the top left position. 38 * @param {Number} x - The X coordinate for the top left position.
39 * @param {Number} y - The Y coordinate for the top left position. 39 * @param {Number} y - The Y coordinate for the top left position.
40 * @param {Number} w - The pixel width. 40 * @param {Number} w - The pixel width.
41 * @param {Number} h - The pixel height. 41 * @param {Number} h - The pixel height.
42 * @param {Object} [options] - Additional options, depending on the actual 42 * @param {Object} [options] - Additional options, depending on the actual
43 * symbol drawn. 43 * symbol drawn.
44 * @param {boolean} [options.rounded] - Whether to draw rounded edges. 44 * @param {boolean} [options.rounded] - Whether to draw rounded edges.
45 * @return {Array} Path of the created arc. 45 * @return {Array} Path of the created arc.
46 */ 46 */
47 wrap(Renderer.prototype.symbols, 'arc', function(proceed, x, y, w, h, options) { 47 wrap(Renderer.prototype.symbols, 'arc', function(proceed, x, y, w, h, options) {
48 var arc = proceed, 48 var arc = proceed,
49 path = arc(x, y, w, h, options); 49 path = arc(x, y, w, h, options);
50 if (options.rounded) { 50 if (options.rounded) {
51 var r = options.r || w, 51 var r = options.r || w,
52 smallR = (r - options.innerR) / 2, 52 smallR = (r - options.innerR) / 2,
53 x1 = path[1], 53 x1 = path[1],
54 y1 = path[2], 54 y1 = path[2],
55 x2 = path[12], 55 x2 = path[12],
56 y2 = path[13], 56 y2 = path[13],
57 roundStart = ['A', smallR, smallR, 0, 1, 1, x1, y1], 57 roundStart = ['A', smallR, smallR, 0, 1, 1, x1, y1],
58 roundEnd = ['A', smallR, smallR, 0, 1, 1, x2, y2]; 58 roundEnd = ['A', smallR, smallR, 0, 1, 1, x2, y2];
59 // Insert rounded edge on end, and remove line. 59 // Insert rounded edge on end, and remove line.
60 path.splice.apply(path, [path.length - 1, 0].concat(roundStart)); 60 path.splice.apply(path, [path.length - 1, 0].concat(roundStart));
61 // Insert rounded edge on end, and remove line. 61 // Insert rounded edge on end, and remove line.
62 path.splice.apply(path, [11, 3].concat(roundEnd)); 62 path.splice.apply(path, [11, 3].concat(roundEnd));
63 } 63 }
64 return path; 64 return path;
65 }); 65 });
66   66  
67 // These methods are defined in the ColorAxis object, and copied here. 67 // These methods are defined in the ColorAxis object, and copied here.
68 // If we implement an AMD system we should make ColorAxis a dependency. 68 // If we implement an AMD system we should make ColorAxis a dependency.
69 colorAxisMethods = { 69 colorAxisMethods = {
70   70  
71   71  
72 initDataClasses: function(userOptions) { 72 initDataClasses: function(userOptions) {
73 var axis = this, -  
74 chart = this.chart, 73 var chart = this.chart,
75 dataClasses, 74 dataClasses,
76 colorCounter = 0, 75 colorCounter = 0,
77 options = this.options; 76 options = this.options;
78 this.dataClasses = dataClasses = []; 77 this.dataClasses = dataClasses = [];
79   78  
80 each(userOptions.dataClasses, function(dataClass, i) { 79 each(userOptions.dataClasses, function(dataClass, i) {
81 var colors; 80 var colors;
82   81  
83 dataClass = H.merge(dataClass); 82 dataClass = H.merge(dataClass);
84 dataClasses.push(dataClass); 83 dataClasses.push(dataClass);
85 if (!dataClass.color) { 84 if (!dataClass.color) {
86 if (options.dataClassColor === 'category') { 85 if (options.dataClassColor === 'category') {
87 colors = chart.options.colors; 86 colors = chart.options.colors;
88 dataClass.color = colors[colorCounter++]; 87 dataClass.color = colors[colorCounter++];
89 // loop back to zero 88 // loop back to zero
90 if (colorCounter === colors.length) { 89 if (colorCounter === colors.length) {
91 colorCounter = 0; 90 colorCounter = 0;
92 } 91 }
93 } else { 92 } else {
94 dataClass.color = axis.tweenColors(H.color(options.minColor), H.color(options.maxColor), i / (userOptions.dataClasses.length - 1)); 93 dataClass.color = H.color(options.minColor).tweenTo(
-   94 H.color(options.maxColor),
-   95 i / (userOptions.dataClasses.length - 1)
-   96 );
95 } 97 }
96 } 98 }
97 }); 99 });
98 }, 100 },
99   101  
100 initStops: function(userOptions) { 102 initStops: function(userOptions) {
101 this.stops = userOptions.stops || [ 103 this.stops = userOptions.stops || [
102 [0, this.options.minColor], 104 [0, this.options.minColor],
103 [1, this.options.maxColor] 105 [1, this.options.maxColor]
104 ]; 106 ];
105 each(this.stops, function(stop) { 107 each(this.stops, function(stop) {
106 stop.color = H.color(stop[1]); 108 stop.color = H.color(stop[1]);
107 }); 109 });
108 }, 110 },
109 /** 111 /**
110 * Translate from a value to a color 112 * Translate from a value to a color
111 */ 113 */
112 toColor: function(value, point) { 114 toColor: function(value, point) {
113 var pos, 115 var pos,
114 stops = this.stops, 116 stops = this.stops,
115 from, 117 from,
116 to, 118 to,
117 color, 119 color,
118 dataClasses = this.dataClasses, 120 dataClasses = this.dataClasses,
119 dataClass, 121 dataClass,
120 i; 122 i;
121   123  
122 if (dataClasses) { 124 if (dataClasses) {
123 i = dataClasses.length; 125 i = dataClasses.length;
124 while (i--) { 126 while (i--) {
125 dataClass = dataClasses[i]; 127 dataClass = dataClasses[i];
126 from = dataClass.from; 128 from = dataClass.from;
127 to = dataClass.to; 129 to = dataClass.to;
128 if ((from === undefined || value >= from) && (to === undefined || value <= to)) { 130 if ((from === undefined || value >= from) && (to === undefined || value <= to)) {
129 color = dataClass.color; 131 color = dataClass.color;
130 if (point) { 132 if (point) {
131 point.dataClass = i; 133 point.dataClass = i;
132 } 134 }
133 break; 135 break;
134 } 136 }
135 } 137 }
136   138  
137 } else { 139 } else {
138   140  
139 if (this.isLog) { 141 if (this.isLog) {
140 value = this.val2lin(value); 142 value = this.val2lin(value);
141 } 143 }
142 pos = 1 - ((this.max - value) / (this.max - this.min)); 144 pos = 1 - ((this.max - value) / (this.max - this.min));
143 i = stops.length; 145 i = stops.length;
144 while (i--) { 146 while (i--) {
145 if (pos > stops[i][0]) { 147 if (pos > stops[i][0]) {
146 break; 148 break;
147 } 149 }
148 } 150 }
149 from = stops[i] || stops[i + 1]; 151 from = stops[i] || stops[i + 1];
150 to = stops[i + 1] || from; 152 to = stops[i + 1] || from;
151   153  
152 // The position within the gradient 154 // The position within the gradient
153 pos = 1 - (to[0] - pos) / ((to[0] - from[0]) || 1); 155 pos = 1 - (to[0] - pos) / ((to[0] - from[0]) || 1);
154   156  
155 color = this.tweenColors( -  
156 from.color, 157 color = from.color.tweenTo(
157 to.color, 158 to.color,
158 pos 159 pos
159 ); 160 );
160 } 161 }
161 return color; 162 return color;
162 }, -  
163 /* -  
164 * Return an intermediate color between two colors, according to pos where 0 -  
165 * is the from color and 1 is the to color. -  
166 */ -  
167 tweenColors: function(from, to, pos) { -  
168 // Check for has alpha, because rgba colors perform worse due to lack of -  
169 // support in WebKit. -  
170 var hasAlpha, -  
171 ret; -  
172   -  
173 // Unsupported color, return to-color (#3920) -  
174 if (!to.rgba.length || !from.rgba.length) { -  
175 ret = to.input || 'none'; -  
176   -  
177 // Interpolate -  
178 } else { -  
179 from = from.rgba; -  
180 to = to.rgba; -  
181 hasAlpha = (to[3] !== 1 || from[3] !== 1); -  
182 ret = (hasAlpha ? 'rgba(' : 'rgb(') + -  
183 Math.round(to[0] + (from[0] - to[0]) * (1 - pos)) + ',' + -  
184 Math.round(to[1] + (from[1] - to[1]) * (1 - pos)) + ',' + -  
185 Math.round(to[2] + (from[2] - to[2]) * (1 - pos)) + -  
186 (hasAlpha ? (',' + (to[3] + (from[3] - to[3]) * (1 - pos))) : '') + ')'; -  
187 } -  
188 return ret; -  
189 } 163 }
190 }; 164 };
191   -  
192 /** -  
193 * Handle animation of the color attributes directly -  
194 */ -  
195 each(['fill', 'stroke'], function(prop) { -  
196 H.Fx.prototype[prop + 'Setter'] = function() { -  
197 this.elem.attr( -  
198 prop, -  
199 colorAxisMethods.tweenColors( -  
200 H.color(this.start), -  
201 H.color(this.end), -  
202 this.pos -  
203 ), -  
204 null, -  
205 true -  
206 ); -  
207 }; -  
208 }); -  
209   165  
210 // The solidgauge series type 166 // The solidgauge series type
211 H.seriesType('solidgauge', 'gauge', { 167 H.seriesType('solidgauge', 'gauge', {
212 colorByPoint: true 168 colorByPoint: true
213   169  
214 }, { 170 }, {
215   171  
216 /** 172 /**
217 * Extend the translate function to extend the Y axis with the necessary 173 * Extend the translate function to extend the Y axis with the necessary
218 * decoration (#5895). 174 * decoration (#5895).
219 */ 175 */
220 translate: function() { 176 translate: function() {
221 var axis = this.yAxis; 177 var axis = this.yAxis;
222 H.extend(axis, colorAxisMethods); 178 H.extend(axis, colorAxisMethods);
223   179  
224 // Prepare data classes 180 // Prepare data classes
225 if (!axis.dataClasses && axis.options.dataClasses) { 181 if (!axis.dataClasses && axis.options.dataClasses) {
226 axis.initDataClasses(axis.options); 182 axis.initDataClasses(axis.options);
227 } 183 }
228 axis.initStops(axis.options); 184 axis.initStops(axis.options);
229   185  
230 // Generate points and inherit data label position 186 // Generate points and inherit data label position
231 H.seriesTypes.gauge.prototype.translate.call(this); 187 H.seriesTypes.gauge.prototype.translate.call(this);
232 }, 188 },
233   189  
234 /** 190 /**
235 * Draw the points where each point is one needle 191 * Draw the points where each point is one needle
236 */ 192 */
237 drawPoints: function() { 193 drawPoints: function() {
238 var series = this, 194 var series = this,
239 yAxis = series.yAxis, 195 yAxis = series.yAxis,
240 center = yAxis.center, 196 center = yAxis.center,
241 options = series.options, 197 options = series.options,
242 renderer = series.chart.renderer, 198 renderer = series.chart.renderer,
243 overshoot = options.overshoot, 199 overshoot = options.overshoot,
244 overshootVal = isNumber(overshoot) ? overshoot / 180 * Math.PI : 0, 200 overshootVal = isNumber(overshoot) ? overshoot / 180 * Math.PI : 0,
245 thresholdAngleRad; 201 thresholdAngleRad;
246   202  
247 // Handle the threshold option 203 // Handle the threshold option
248 if (isNumber(options.threshold)) { 204 if (isNumber(options.threshold)) {
249 thresholdAngleRad = yAxis.startAngleRad + yAxis.translate( 205 thresholdAngleRad = yAxis.startAngleRad + yAxis.translate(
250 options.threshold, 206 options.threshold,
251 null, 207 null,
252 null, 208 null,
253 null, 209 null,
254 true 210 true
255 ); 211 );
256 } 212 }
257 this.thresholdAngleRad = pick(thresholdAngleRad, yAxis.startAngleRad); 213 this.thresholdAngleRad = pick(thresholdAngleRad, yAxis.startAngleRad);
258   214  
259   215  
260 each(series.points, function(point) { 216 each(series.points, function(point) {
261 var graphic = point.graphic, 217 var graphic = point.graphic,
262 rotation = yAxis.startAngleRad + yAxis.translate(point.y, null, null, null, true), 218 rotation = yAxis.startAngleRad + yAxis.translate(point.y, null, null, null, true),
263 radius = (pInt(pick(point.options.radius, options.radius, 100)) * center[2]) / 200, 219 radius = (pInt(pick(point.options.radius, options.radius, 100)) * center[2]) / 200,
264 innerRadius = (pInt(pick(point.options.innerRadius, options.innerRadius, 60)) * center[2]) / 200, 220 innerRadius = (pInt(pick(point.options.innerRadius, options.innerRadius, 60)) * center[2]) / 200,
265 shapeArgs, 221 shapeArgs,
266 d, 222 d,
267 toColor = yAxis.toColor(point.y, point), 223 toColor = yAxis.toColor(point.y, point),
268 axisMinAngle = Math.min(yAxis.startAngleRad, yAxis.endAngleRad), 224 axisMinAngle = Math.min(yAxis.startAngleRad, yAxis.endAngleRad),
269 axisMaxAngle = Math.max(yAxis.startAngleRad, yAxis.endAngleRad), 225 axisMaxAngle = Math.max(yAxis.startAngleRad, yAxis.endAngleRad),
270 minAngle, 226 minAngle,
271 maxAngle; 227 maxAngle;
272   228  
273 if (toColor === 'none') { // #3708 229 if (toColor === 'none') { // #3708
274 toColor = point.color || series.color || 'none'; 230 toColor = point.color || series.color || 'none';
275 } 231 }
276 if (toColor !== 'none') { 232 if (toColor !== 'none') {
277 point.color = toColor; 233 point.color = toColor;
278 } 234 }
279   235  
280 // Handle overshoot and clipping to axis max/min 236 // Handle overshoot and clipping to axis max/min
281 rotation = Math.max(axisMinAngle - overshootVal, Math.min(axisMaxAngle + overshootVal, rotation)); 237 rotation = Math.max(axisMinAngle - overshootVal, Math.min(axisMaxAngle + overshootVal, rotation));
282   238  
283 // Handle the wrap option 239 // Handle the wrap option
284 if (options.wrap === false) { 240 if (options.wrap === false) {
285 rotation = Math.max(axisMinAngle, Math.min(axisMaxAngle, rotation)); 241 rotation = Math.max(axisMinAngle, Math.min(axisMaxAngle, rotation));
286 } 242 }
287   243  
288 minAngle = Math.min(rotation, series.thresholdAngleRad); 244 minAngle = Math.min(rotation, series.thresholdAngleRad);
289 maxAngle = Math.max(rotation, series.thresholdAngleRad); 245 maxAngle = Math.max(rotation, series.thresholdAngleRad);
290   246  
291 if (maxAngle - minAngle > 2 * Math.PI) { 247 if (maxAngle - minAngle > 2 * Math.PI) {
292 maxAngle = minAngle + 2 * Math.PI; 248 maxAngle = minAngle + 2 * Math.PI;
293 } 249 }
294   250  
295 point.shapeArgs = shapeArgs = { 251 point.shapeArgs = shapeArgs = {
296 x: center[0], 252 x: center[0],
297 y: center[1], 253 y: center[1],
298 r: radius, 254 r: radius,
299 innerR: innerRadius, 255 innerR: innerRadius,
300 start: minAngle, 256 start: minAngle,
301 end: maxAngle, 257 end: maxAngle,
302 rounded: options.rounded 258 rounded: options.rounded
303 }; 259 };
304 point.startR = radius; // For PieSeries.animate 260 point.startR = radius; // For PieSeries.animate
305   261  
306 if (graphic) { 262 if (graphic) {
307 d = shapeArgs.d; 263 d = shapeArgs.d;
308 graphic.animate(H.extend({ 264 graphic.animate(H.extend({
309 fill: toColor 265 fill: toColor
310 }, shapeArgs)); 266 }, shapeArgs));
311 if (d) { 267 if (d) {
312 shapeArgs.d = d; // animate alters it 268 shapeArgs.d = d; // animate alters it
313 } 269 }
314 } else { 270 } else {
315 point.graphic = renderer.arc(shapeArgs) 271 point.graphic = renderer.arc(shapeArgs)
316 .addClass('highcharts-point') 272 .addClass(point.getClassName(), true)
317 .attr({ 273 .attr({
318 fill: toColor, 274 fill: toColor,
319 'sweep-flag': 0 275 'sweep-flag': 0
320 }) 276 })
321 .add(series.group); 277 .add(series.group);
322   278  
323   279  
324 if (options.linecap !== 'square') { 280 if (options.linecap !== 'square') {
325 point.graphic.attr({ 281 point.graphic.attr({
326 'stroke-linecap': 'round', 282 'stroke-linecap': 'round',
327 'stroke-linejoin': 'round' 283 'stroke-linejoin': 'round'
328 }); 284 });
329 } 285 }
330 point.graphic.attr({ 286 point.graphic.attr({
331 stroke: options.borderColor || 'none', 287 stroke: options.borderColor || 'none',
332 'stroke-width': options.borderWidth || 0 288 'stroke-width': options.borderWidth || 0
333 }); 289 });
334   290  
335 } 291 }
336 }); 292 });
337 }, 293 },
338   294  
339 /** 295 /**
340 * Extend the pie slice animation by animating from start angle and up 296 * Extend the pie slice animation by animating from start angle and up
341 */ 297 */
342 animate: function(init) { 298 animate: function(init) {
343   299  
344 if (!init) { 300 if (!init) {
345 this.startAngleRad = this.thresholdAngleRad; 301 this.startAngleRad = this.thresholdAngleRad;
346 H.seriesTypes.pie.prototype.animate.call(this, init); 302 H.seriesTypes.pie.prototype.animate.call(this, init);
347 } 303 }
348 } 304 }
349 }); 305 });
350   306  
351 }(Highcharts)); 307 }(Highcharts));
352 })); 308 }));
353   309