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 * Highcharts funnel module 3 * Highcharts funnel 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(Highcharts) { 17 (function(Highcharts) {
18 /** 18 /**
19 * Highcharts funnel module 19 * Highcharts funnel 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 /* eslint indent:0 */ 25 /* eslint indent:0 */
26   26  
27 // create shortcuts 27 // create shortcuts
28 var seriesType = Highcharts.seriesType, 28 var seriesType = Highcharts.seriesType,
29 seriesTypes = Highcharts.seriesTypes, 29 seriesTypes = Highcharts.seriesTypes,
30 noop = Highcharts.noop, 30 noop = Highcharts.noop,
-   31 pick = Highcharts.pick,
31 each = Highcharts.each; 32 each = Highcharts.each;
32   33  
33   34  
34 seriesType('funnel', 'pie', { 35 seriesType('funnel', 'pie', {
35 animation: false, 36 animation: false,
36 center: ['50%', '50%'], 37 center: ['50%', '50%'],
37 width: '90%', 38 width: '90%',
38 neckWidth: '30%', 39 neckWidth: '30%',
39 height: '100%', 40 height: '100%',
40 neckHeight: '25%', 41 neckHeight: '25%',
41 reversed: false, 42 reversed: false,
42 size: true, // to avoid adapting to data label size in Pie.drawDataLabels 43 size: true, // to avoid adapting to data label size in Pie.drawDataLabels
43   44  
44   45  
45 }, 46 },
46   47  
47 // Properties 48 // Properties
48 { 49 {
49 animate: noop, 50 animate: noop,
50   51  
51 /** 52 /**
52 * Overrides the pie translate method 53 * Overrides the pie translate method
53 */ 54 */
54 translate: function() { 55 translate: function() {
55   56  
56 var 57 var
57 // Get positions - either an integer or a percentage string must be given 58 // Get positions - either an integer or a percentage string must be given
58 getLength = function(length, relativeTo) { 59 getLength = function(length, relativeTo) {
59 return (/%$/).test(length) ? 60 return (/%$/).test(length) ?
60 relativeTo * parseInt(length, 10) / 100 : 61 relativeTo * parseInt(length, 10) / 100 :
61 parseInt(length, 10); 62 parseInt(length, 10);
62 }, 63 },
63   64  
64 sum = 0, 65 sum = 0,
65 series = this, 66 series = this,
66 chart = series.chart, 67 chart = series.chart,
67 options = series.options, 68 options = series.options,
68 reversed = options.reversed, 69 reversed = options.reversed,
69 ignoreHiddenPoint = options.ignoreHiddenPoint, 70 ignoreHiddenPoint = options.ignoreHiddenPoint,
70 plotWidth = chart.plotWidth, 71 plotWidth = chart.plotWidth,
71 plotHeight = chart.plotHeight, 72 plotHeight = chart.plotHeight,
72 cumulative = 0, // start at top 73 cumulative = 0, // start at top
73 center = options.center, 74 center = options.center,
74 centerX = getLength(center[0], plotWidth), 75 centerX = getLength(center[0], plotWidth),
75 centerY = getLength(center[1], plotHeight), 76 centerY = getLength(center[1], plotHeight),
76 width = getLength(options.width, plotWidth), 77 width = getLength(options.width, plotWidth),
77 tempWidth, 78 tempWidth,
78 getWidthAt, 79 getWidthAt,
79 height = getLength(options.height, plotHeight), 80 height = getLength(options.height, plotHeight),
80 neckWidth = getLength(options.neckWidth, plotWidth), 81 neckWidth = getLength(options.neckWidth, plotWidth),
81 neckHeight = getLength(options.neckHeight, plotHeight), 82 neckHeight = getLength(options.neckHeight, plotHeight),
82 neckY = (centerY - height / 2) + height - neckHeight, 83 neckY = (centerY - height / 2) + height - neckHeight,
83 data = series.data, 84 data = series.data,
84 path, 85 path,
85 fraction, 86 fraction,
86 half = options.dataLabels.position === 'left' ? 1 : 0, 87 half = options.dataLabels.position === 'left' ? 1 : 0,
87   88  
88 x1, 89 x1,
89 y1, 90 y1,
90 x2, 91 x2,
91 x3, 92 x3,
92 y3, 93 y3,
93 x4, 94 x4,
94 y5; 95 y5;
95   96  
96 // Return the width at a specific y coordinate 97 // Return the width at a specific y coordinate
97 series.getWidthAt = getWidthAt = function(y) { 98 series.getWidthAt = getWidthAt = function(y) {
98 var top = (centerY - height / 2); 99 var top = (centerY - height / 2);
99   100  
100 return y > neckY || height === neckHeight ? 101 return y > neckY || height === neckHeight ?
101 neckWidth : 102 neckWidth :
102 neckWidth + (width - neckWidth) * (1 - (y - top) / (height - neckHeight)); 103 neckWidth + (width - neckWidth) * (1 - (y - top) / (height - neckHeight));
103 }; 104 };
104 series.getX = function(y, half) { 105 series.getX = function(y, half, point) {
105 return centerX + (half ? -1 : 1) * ((getWidthAt(reversed ? 2 * centerY - y : y) / 2) + options.dataLabels.distance); 106 return centerX + (half ? -1 : 1) * ((getWidthAt(reversed ? 2 * centerY - y : y) / 2) + point.labelDistance);
106 }; 107 };
107   108  
108 // Expose 109 // Expose
109 series.center = [centerX, centerY, height]; 110 series.center = [centerX, centerY, height];
110 series.centerX = centerX; 111 series.centerX = centerX;
111   112  
112 /* 113 /*
113 * Individual point coordinate naming: 114 * Individual point coordinate naming:
114 * 115 *
115 * x1,y1 _________________ x2,y1 116 * x1,y1 _________________ x2,y1
116 * \ / 117 * \ /
117 * \ / 118 * \ /
118 * \ / 119 * \ /
119 * \ / 120 * \ /
120 * \ / 121 * \ /
121 * x3,y3 _________ x4,y3 122 * x3,y3 _________ x4,y3
122 * 123 *
123 * Additional for the base of the neck: 124 * Additional for the base of the neck:
124 * 125 *
125 * | | 126 * | |
126 * | | 127 * | |
127 * | | 128 * | |
128 * x3,y5 _________ x4,y5 129 * x3,y5 _________ x4,y5
129 */ 130 */
130   131  
131   132  
132   133  
133   134  
134 // get the total sum 135 // get the total sum
135 each(data, function(point) { 136 each(data, function(point) {
136 if (!ignoreHiddenPoint || point.visible !== false) { 137 if (!ignoreHiddenPoint || point.visible !== false) {
137 sum += point.y; 138 sum += point.y;
138 } 139 }
139 }); 140 });
140   141  
141 each(data, function(point) { 142 each(data, function(point) {
142 // set start and end positions 143 // set start and end positions
143 y5 = null; 144 y5 = null;
144 fraction = sum ? point.y / sum : 0; 145 fraction = sum ? point.y / sum : 0;
145 y1 = centerY - height / 2 + cumulative * height; 146 y1 = centerY - height / 2 + cumulative * height;
146 y3 = y1 + fraction * height; 147 y3 = y1 + fraction * height;
147 //tempWidth = neckWidth + (width - neckWidth) * ((height - neckHeight - y1) / (height - neckHeight)); 148 //tempWidth = neckWidth + (width - neckWidth) * ((height - neckHeight - y1) / (height - neckHeight));
148 tempWidth = getWidthAt(y1); 149 tempWidth = getWidthAt(y1);
149 x1 = centerX - tempWidth / 2; 150 x1 = centerX - tempWidth / 2;
150 x2 = x1 + tempWidth; 151 x2 = x1 + tempWidth;
151 tempWidth = getWidthAt(y3); 152 tempWidth = getWidthAt(y3);
152 x3 = centerX - tempWidth / 2; 153 x3 = centerX - tempWidth / 2;
153 x4 = x3 + tempWidth; 154 x4 = x3 + tempWidth;
154   155  
155 // the entire point is within the neck 156 // the entire point is within the neck
156 if (y1 > neckY) { 157 if (y1 > neckY) {
157 x1 = x3 = centerX - neckWidth / 2; 158 x1 = x3 = centerX - neckWidth / 2;
158 x2 = x4 = centerX + neckWidth / 2; 159 x2 = x4 = centerX + neckWidth / 2;
159   160  
160 // the base of the neck 161 // the base of the neck
161 } else if (y3 > neckY) { 162 } else if (y3 > neckY) {
162 y5 = y3; 163 y5 = y3;
163   164  
164 tempWidth = getWidthAt(neckY); 165 tempWidth = getWidthAt(neckY);
165 x3 = centerX - tempWidth / 2; 166 x3 = centerX - tempWidth / 2;
166 x4 = x3 + tempWidth; 167 x4 = x3 + tempWidth;
167   168  
168 y3 = neckY; 169 y3 = neckY;
169 } 170 }
170   171  
171 if (reversed) { 172 if (reversed) {
172 y1 = 2 * centerY - y1; 173 y1 = 2 * centerY - y1;
173 y3 = 2 * centerY - y3; 174 y3 = 2 * centerY - y3;
174 y5 = (y5 ? 2 * centerY - y5 : null); 175 y5 = (y5 ? 2 * centerY - y5 : null);
175 } 176 }
176 // save the path 177 // save the path
177 path = [ 178 path = [
178 'M', 179 'M',
179 x1, y1, 180 x1, y1,
180 'L', 181 'L',
181 x2, y1, 182 x2, y1,
182 x4, y3 183 x4, y3
183 ]; 184 ];
184 if (y5) { 185 if (y5) {
185 path.push(x4, y5, x3, y5); 186 path.push(x4, y5, x3, y5);
186 } 187 }
187 path.push(x3, y3, 'Z'); 188 path.push(x3, y3, 'Z');
188   189  
189 // prepare for using shared dr 190 // prepare for using shared dr
190 point.shapeType = 'path'; 191 point.shapeType = 'path';
191 point.shapeArgs = { 192 point.shapeArgs = {
192 d: path 193 d: path
193 }; 194 };
194   195  
195   196  
196 // for tooltips and data labels 197 // for tooltips and data labels
197 point.percentage = fraction * 100; 198 point.percentage = fraction * 100;
198 point.plotX = centerX; 199 point.plotX = centerX;
199 point.plotY = (y1 + (y5 || y3)) / 2; 200 point.plotY = (y1 + (y5 || y3)) / 2;
200   201  
201 // Placement of tooltips and data labels 202 // Placement of tooltips and data labels
202 point.tooltipPos = [ 203 point.tooltipPos = [
203 centerX, 204 centerX,
204 point.plotY 205 point.plotY
205 ]; 206 ];
206   207  
207 // Slice is a noop on funnel points 208 // Slice is a noop on funnel points
208 point.slice = noop; 209 point.slice = noop;
209   210  
210 // Mimicking pie data label placement logic 211 // Mimicking pie data label placement logic
211 point.half = half; 212 point.half = half;
212   213  
213 if (!ignoreHiddenPoint || point.visible !== false) { 214 if (!ignoreHiddenPoint || point.visible !== false) {
214 cumulative += fraction; 215 cumulative += fraction;
215 } 216 }
216 }); 217 });
217 }, 218 },
218 /** -  
219 * Draw a single point (wedge) -  
220 * @param {Object} point The point object -  
221 * @param {Object} color The color of the point -  
222 * @param {Number} brightness The brightness relative to the color -  
223 */ -  
224 drawPoints: seriesTypes.column.prototype.drawPoints, -  
225   219  
226 /** 220 /**
227 * Funnel items don't have angles (#2289) 221 * Funnel items don't have angles (#2289)
228 */ 222 */
229 sortByAngle: function(points) { 223 sortByAngle: function(points) {
230 points.sort(function(a, b) { 224 points.sort(function(a, b) {
231 return a.plotY - b.plotY; 225 return a.plotY - b.plotY;
232 }); 226 });
233 }, 227 },
234   228  
235 /** 229 /**
236 * Extend the pie data label method 230 * Extend the pie data label method
237 */ 231 */
238 drawDataLabels: function() { 232 drawDataLabels: function() {
-   233 var series = this,
239 var data = this.data, 234 data = series.data,
240 labelDistance = this.options.dataLabels.distance, 235 labelDistance = series.options.dataLabels.distance,
241 leftSide, 236 leftSide,
242 sign, 237 sign,
243 point, 238 point,
244 i = data.length, 239 i = data.length,
245 x, 240 x,
246 y; 241 y;
247   242  
248 // In the original pie label anticollision logic, the slots are distributed 243 // In the original pie label anticollision logic, the slots are distributed
249 // from one labelDistance above to one labelDistance below the pie. In funnels 244 // from one labelDistance above to one labelDistance below the pie. In funnels
250 // we don't want this. 245 // we don't want this.
251 this.center[2] -= 2 * labelDistance; 246 series.center[2] -= 2 * labelDistance;
252   247  
253 // Set the label position array for each point. 248 // Set the label position array for each point.
254 while (i--) { 249 while (i--) {
255 point = data[i]; 250 point = data[i];
256 leftSide = point.half; 251 leftSide = point.half;
257 sign = leftSide ? 1 : -1; 252 sign = leftSide ? 1 : -1;
258 y = point.plotY; 253 y = point.plotY;
-   254 point.labelDistance = pick(
-   255 point.options.dataLabels && point.options.dataLabels.distance,
-   256 labelDistance
-   257 );
-   258  
-   259 series.maxLabelDistance = Math.max(point.labelDistance, series.maxLabelDistance || 0);
259 x = this.getX(y, leftSide); 260 x = series.getX(y, leftSide, point);
260   261  
261 // set the anchor point for data labels 262 // set the anchor point for data labels
262 point.labelPos = [ 263 point.labelPos = [
263 0, // first break of connector 264 0, // first break of connector
264 y, // a/a 265 y, // a/a
265 x + (labelDistance - 5) * sign, // second break, right outside point shape 266 x + (point.labelDistance - 5) * sign, // second break, right outside point shape
266 y, // a/a 267 y, // a/a
267 x + labelDistance * sign, // landing point for connector 268 x + point.labelDistance * sign, // landing point for connector
268 y, // a/a 269 y, // a/a
269 leftSide ? 'right' : 'left', // alignment 270 leftSide ? 'right' : 'left', // alignment
270 0 // center angle 271 0 // center angle
271 ]; 272 ];
272 } 273 }
273   274  
274 seriesTypes.pie.prototype.drawDataLabels.call(this); 275 seriesTypes.pie.prototype.drawDataLabels.call(this);
275 } 276 }
276   277  
277 }); 278 });
278   279  
279 /** 280 /**
280 * Pyramid series type. 281 * Pyramid series type.
281 * A pyramid series is a special type of funnel, without neck and reversed by default. 282 * A pyramid series is a special type of funnel, without neck and reversed by default.
282 */ 283 */
283 seriesType('pyramid', 'funnel', { 284 seriesType('pyramid', 'funnel', {
284 neckWidth: '0%', 285 neckWidth: '0%',
285 neckHeight: '0%', 286 neckHeight: '0%',
286 reversed: true 287 reversed: true
287 }); 288 });
288   289  
289 }(Highcharts)); 290 }(Highcharts));
290 })); 291 }));
291   292