corrade-nucleus-nucleons – Blame information for rev 20

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