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 * 3 *
4 * (c) 2009-2017 Torstein Honsi 4 * (c) 2009-2017 Torstein Honsi
5 * 5 *
6 * License: www.highcharts.com/license 6 * License: www.highcharts.com/license
7 */ 7 */
8 'use strict'; 8 'use strict';
9 (function(factory) { 9 (function(factory) {
10 if (typeof module === 'object' && module.exports) { 10 if (typeof module === 'object' && module.exports) {
11 module.exports = factory; 11 module.exports = factory;
12 } else { 12 } else {
13 factory(Highcharts); 13 factory(Highcharts);
14 } 14 }
15 }(function(Highcharts) { 15 }(function(Highcharts) {
16 (function(H) { 16 (function(H) {
17 /** 17 /**
18 * (c) 2009-2017 Torstein Honsi 18 * (c) 2009-2017 Torstein Honsi
19 * 19 *
20 * License: www.highcharts.com/license 20 * License: www.highcharts.com/license
21 */ 21 */
22 /** 22 /**
23 * Highcharts module to hide overlapping data labels. This module is included in 23 * Highcharts module to hide overlapping data labels. This module is included in
24 * Highcharts. 24 * Highcharts.
25 */ 25 */
26 var Chart = H.Chart, 26 var Chart = H.Chart,
27 each = H.each, 27 each = H.each,
28 pick = H.pick, 28 pick = H.pick,
29 addEvent = H.addEvent; 29 addEvent = H.addEvent;
30   30  
31 // Collect potensial overlapping data labels. Stack labels probably don't need 31 // Collect potensial overlapping data labels. Stack labels probably don't need
32 // to be considered because they are usually accompanied by data labels that lie 32 // to be considered because they are usually accompanied by data labels that lie
33 // inside the columns. 33 // inside the columns.
34 Chart.prototype.callbacks.push(function(chart) { 34 Chart.prototype.callbacks.push(function(chart) {
35 function collectAndHide() { 35 function collectAndHide() {
36 var labels = []; 36 var labels = [];
37   37  
38 each(chart.series || [], function(series) { 38 each(chart.series || [], function(series) {
39 var dlOptions = series.options.dataLabels, 39 var dlOptions = series.options.dataLabels,
40 // Range series have two collections 40 // Range series have two collections
41 collections = series.dataLabelCollections || ['dataLabel']; 41 collections = series.dataLabelCollections || ['dataLabel'];
42   42  
43 if ( 43 if (
44 (dlOptions.enabled || series._hasPointLabels) && 44 (dlOptions.enabled || series._hasPointLabels) &&
45 !dlOptions.allowOverlap && 45 !dlOptions.allowOverlap &&
46 series.visible 46 series.visible
47 ) { // #3866 47 ) { // #3866
48 each(collections, function(coll) { 48 each(collections, function(coll) {
49 each(series.points, function(point) { 49 each(series.points, function(point) {
50 if (point[coll]) { 50 if (point[coll]) {
51 point[coll].labelrank = pick( 51 point[coll].labelrank = pick(
52 point.labelrank, 52 point.labelrank,
53 point.shapeArgs && point.shapeArgs.height 53 point.shapeArgs && point.shapeArgs.height
54 ); // #4118 54 ); // #4118
55 labels.push(point[coll]); 55 labels.push(point[coll]);
56 } 56 }
57 }); 57 });
58 }); 58 });
59 } 59 }
60 }); 60 });
61 chart.hideOverlappingLabels(labels); 61 chart.hideOverlappingLabels(labels);
62 } 62 }
63   63  
64 // Do it now ... 64 // Do it now ...
65 collectAndHide(); 65 collectAndHide();
66   66  
67 // ... and after each chart redraw 67 // ... and after each chart redraw
68 addEvent(chart, 'redraw', collectAndHide); 68 addEvent(chart, 'redraw', collectAndHide);
69   69  
70 }); 70 });
71   71  
72 /** 72 /**
73 * Hide overlapping labels. Labels are moved and faded in and out on zoom to 73 * Hide overlapping labels. Labels are moved and faded in and out on zoom to
74 * provide a smooth visual imression. 74 * provide a smooth visual imression.
75 */ 75 */
76 Chart.prototype.hideOverlappingLabels = function(labels) { 76 Chart.prototype.hideOverlappingLabels = function(labels) {
77   77  
78 var len = labels.length, 78 var len = labels.length,
79 label, 79 label,
80 i, 80 i,
81 j, 81 j,
82 label1, 82 label1,
83 label2, 83 label2,
84 isIntersecting, 84 isIntersecting,
85 pos1, 85 pos1,
86 pos2, 86 pos2,
87 parent1, 87 parent1,
88 parent2, 88 parent2,
89 padding, 89 padding,
90 intersectRect = function(x1, y1, w1, h1, x2, y2, w2, h2) { 90 intersectRect = function(x1, y1, w1, h1, x2, y2, w2, h2) {
91 return !( 91 return !(
92 x2 > x1 + w1 || 92 x2 > x1 + w1 ||
93 x2 + w2 < x1 || 93 x2 + w2 < x1 ||
94 y2 > y1 + h1 || 94 y2 > y1 + h1 ||
95 y2 + h2 < y1 95 y2 + h2 < y1
96 ); 96 );
97 }; 97 };
98   98  
99 // Mark with initial opacity 99 // Mark with initial opacity
100 for (i = 0; i < len; i++) { 100 for (i = 0; i < len; i++) {
101 label = labels[i]; 101 label = labels[i];
102 if (label) { 102 if (label) {
103 label.oldOpacity = label.opacity; 103 label.oldOpacity = label.opacity;
104 label.newOpacity = 1; 104 label.newOpacity = 1;
105 } 105 }
106 } 106 }
107   107  
108 // Prevent a situation in a gradually rising slope, that each label will 108 // Prevent a situation in a gradually rising slope, that each label will
109 // hide the previous one because the previous one always has lower rank. 109 // hide the previous one because the previous one always has lower rank.
110 labels.sort(function(a, b) { 110 labels.sort(function(a, b) {
111 return (b.labelrank || 0) - (a.labelrank || 0); 111 return (b.labelrank || 0) - (a.labelrank || 0);
112 }); 112 });
113   113  
114 // Detect overlapping labels 114 // Detect overlapping labels
115 for (i = 0; i < len; i++) { 115 for (i = 0; i < len; i++) {
116 label1 = labels[i]; 116 label1 = labels[i];
117   117  
118 for (j = i + 1; j < len; ++j) { 118 for (j = i + 1; j < len; ++j) {
119 label2 = labels[j]; 119 label2 = labels[j];
120 if ( 120 if (
121 label1 && label2 && 121 label1 && label2 &&
122 label1 !== label2 && // #6465, polar chart with connectEnds 122 label1 !== label2 && // #6465, polar chart with connectEnds
123 label1.placed && label2.placed && 123 label1.placed && label2.placed &&
124 label1.newOpacity !== 0 && label2.newOpacity !== 0 124 label1.newOpacity !== 0 && label2.newOpacity !== 0
125 ) { 125 ) {
126 pos1 = label1.alignAttr; 126 pos1 = label1.alignAttr;
127 pos2 = label2.alignAttr; 127 pos2 = label2.alignAttr;
128 // Different panes have different positions 128 // Different panes have different positions
129 parent1 = label1.parentGroup; 129 parent1 = label1.parentGroup;
130 parent2 = label2.parentGroup; 130 parent2 = label2.parentGroup;
131 // Substract the padding if no background or border (#4333) 131 // Substract the padding if no background or border (#4333)
132 padding = 2 * (label1.box ? 0 : label1.padding); 132 padding = 2 * (label1.box ? 0 : label1.padding);
133 isIntersecting = intersectRect( 133 isIntersecting = intersectRect(
134 pos1.x + parent1.translateX, 134 pos1.x + parent1.translateX,
135 pos1.y + parent1.translateY, 135 pos1.y + parent1.translateY,
136 label1.width - padding, 136 label1.width - padding,
137 label1.height - padding, 137 label1.height - padding,
138 pos2.x + parent2.translateX, 138 pos2.x + parent2.translateX,
139 pos2.y + parent2.translateY, 139 pos2.y + parent2.translateY,
140 label2.width - padding, 140 label2.width - padding,
141 label2.height - padding 141 label2.height - padding
142 ); 142 );
143   143  
144 if (isIntersecting) { 144 if (isIntersecting) {
145 (label1.labelrank < label2.labelrank ? label1 : label2) 145 (label1.labelrank < label2.labelrank ? label1 : label2)
146 .newOpacity = 0; 146 .newOpacity = 0;
147 } 147 }
148 } 148 }
149 } 149 }
150 } 150 }
151   151  
152 // Hide or show 152 // Hide or show
153 each(labels, function(label) { 153 each(labels, function(label) {
154 var complete, 154 var complete,
155 newOpacity; 155 newOpacity;
156   156  
157 if (label) { 157 if (label) {
158 newOpacity = label.newOpacity; 158 newOpacity = label.newOpacity;
159   159  
160 if (label.oldOpacity !== newOpacity && label.placed) { 160 if (label.oldOpacity !== newOpacity && label.placed) {
161   161  
162 // Make sure the label is completely hidden to avoid catching 162 // Make sure the label is completely hidden to avoid catching
163 // clicks (#4362) 163 // clicks (#4362)
164 if (newOpacity) { 164 if (newOpacity) {
165 label.show(true); 165 label.show(true);
166 } else { 166 } else {
167 complete = function() { 167 complete = function() {
168 label.hide(); 168 label.hide();
169 }; 169 };
170 } 170 }
171   171  
172 // Animate or set the opacity 172 // Animate or set the opacity
173 label.alignAttr.opacity = newOpacity; 173 label.alignAttr.opacity = newOpacity;
174 label[label.isOld ? 'animate' : 'attr']( 174 label[label.isOld ? 'animate' : 'attr'](
175 label.alignAttr, 175 label.alignAttr,
176 null, 176 null,
177 complete 177 complete
178 ); 178 );
179   179  
180 } 180 }
181 label.isOld = true; 181 label.isOld = true;
182 } 182 }
183 }); 183 });
184 }; 184 };
185   185  
186 }(Highcharts)); 186 }(Highcharts));
187 })); 187 }));
188   188