corrade-nucleus-nucleons – Diff between revs 1 and 11
?pathlinks?
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 | * X-range series |
3 | * X-range series |
|
4 | * |
4 | * |
|
5 | * (c) 2010-2017 Torstein Honsi, Lars A. V. Cabrera |
5 | * (c) 2010-2017 Torstein Honsi, Lars A. V. Cabrera |
|
6 | * |
6 | * |
|
7 | * --- WORK IN PROGRESS --- |
7 | * --- WORK IN PROGRESS --- |
|
8 | * |
8 | * |
|
9 | * License: www.highcharts.com/license |
9 | * License: www.highcharts.com/license |
|
10 | */ |
10 | */ |
|
11 | 'use strict'; |
11 | 'use strict'; |
|
12 | (function(factory) { |
12 | (function(factory) { |
|
13 | if (typeof module === 'object' && module.exports) { |
13 | if (typeof module === 'object' && module.exports) { |
|
14 | module.exports = factory; |
14 | module.exports = factory; |
|
15 | } else { |
15 | } else { |
|
16 | factory(Highcharts); |
16 | factory(Highcharts); |
|
17 | } |
17 | } |
|
18 | }(function(Highcharts) { |
18 | }(function(Highcharts) { |
|
19 | (function(H) { |
19 | (function(H) { |
|
20 | /** |
20 | /** |
|
21 | * (c) 2014-2017 Highsoft AS |
21 | * (c) 2014-2017 Highsoft AS |
|
22 | * Authors: Torstein Honsi, Lars A. V. Cabrera |
22 | * Authors: Torstein Honsi, Lars A. V. Cabrera |
|
23 | * |
23 | * |
|
24 | * License: www.highcharts.com/license |
24 | * License: www.highcharts.com/license |
|
25 | */ |
25 | */ |
|
26 | |
26 | |
|
27 | var defaultPlotOptions = H.getOptions().plotOptions, |
27 | var defaultPlotOptions = H.getOptions().plotOptions, |
|
28 | color = H.Color, |
28 | color = H.Color, |
|
29 | columnType = H.seriesTypes.column, |
29 | columnType = H.seriesTypes.column, |
|
30 | each = H.each, |
30 | each = H.each, |
|
31 | extendClass = H.extendClass, |
31 | extendClass = H.extendClass, |
|
32 | isNumber = H.isNumber, |
32 | isNumber = H.isNumber, |
|
33 | isObject = H.isObject, |
33 | isObject = H.isObject, |
|
34 | merge = H.merge, |
34 | merge = H.merge, |
|
35 | pick = H.pick, |
35 | pick = H.pick, |
|
36 | seriesTypes = H.seriesTypes, |
36 | seriesTypes = H.seriesTypes, |
|
37 | wrap = H.wrap, |
37 | wrap = H.wrap, |
|
38 | Axis = H.Axis, |
38 | Axis = H.Axis, |
|
39 | Point = H.Point, |
39 | Point = H.Point, |
|
40 | Series = H.Series, |
40 | Series = H.Series, |
|
41 | pointFormat = '<span style="color:{point.color}">' + |
41 | pointFormat = '<span style="color:{point.color}">' + |
|
42 | '\u25CF' + |
42 | '\u25CF' + |
|
43 | '</span> {series.name}: <b>{point.yCategory}</b><br/>', |
43 | '</span> {series.name}: <b>{point.yCategory}</b><br/>', |
|
44 | xrange = 'xrange'; |
44 | xrange = 'xrange'; |
|
45 | |
45 | |
|
46 | defaultPlotOptions.xrange = merge(defaultPlotOptions.column, { |
46 | defaultPlotOptions.xrange = merge(defaultPlotOptions.column, { |
|
47 | tooltip: { |
47 | tooltip: { |
|
48 | pointFormat: pointFormat |
48 | pointFormat: pointFormat |
|
49 | } |
49 | } |
|
50 | }); |
50 | }); |
|
51 | seriesTypes.xrange = extendClass(columnType, { |
51 | seriesTypes.xrange = extendClass(columnType, { |
|
52 | pointClass: extendClass(Point, { |
52 | pointClass: extendClass(Point, { |
|
53 | // Add x2 and yCategory to the available properties for tooltip formats |
53 | // Add x2 and yCategory to the available properties for tooltip formats |
|
54 | getLabelConfig: function() { |
54 | getLabelConfig: function() { |
|
55 | var cfg = Point.prototype.getLabelConfig.call(this); |
55 | var cfg = Point.prototype.getLabelConfig.call(this); |
|
56 | |
56 | |
|
57 | cfg.x2 = this.x2; |
57 | cfg.x2 = this.x2; |
|
58 | cfg.yCategory = this.yCategory = this.series.yAxis.categories && this.series.yAxis.categories[this.y]; |
58 | cfg.yCategory = this.yCategory = this.series.yAxis.categories && this.series.yAxis.categories[this.y]; |
|
59 | return cfg; |
59 | return cfg; |
|
60 | } |
60 | } |
|
61 | }), |
61 | }), |
|
62 | type: xrange, |
62 | type: xrange, |
|
63 | forceDL: true, |
63 | forceDL: true, |
|
64 | parallelArrays: ['x', 'x2', 'y'], |
64 | parallelArrays: ['x', 'x2', 'y'], |
|
65 | requireSorting: false, |
65 | requireSorting: false, |
|
66 | animate: seriesTypes.line.prototype.animate, |
66 | animate: seriesTypes.line.prototype.animate, |
|
67 | |
67 | |
|
68 | /** |
68 | /** |
|
69 | * Borrow the column series metrics, but with swapped axes. This gives free access |
69 | * Borrow the column series metrics, but with swapped axes. This gives free access |
|
70 | * to features like groupPadding, grouping, pointWidth etc. |
70 | * to features like groupPadding, grouping, pointWidth etc. |
|
71 | */ |
71 | */ |
|
72 | getColumnMetrics: function() { |
72 | getColumnMetrics: function() { |
|
73 | var metrics, |
73 | var metrics, |
|
74 | chart = this.chart; |
74 | chart = this.chart; |
|
75 | |
75 | |
|
76 | function swapAxes() { |
76 | function swapAxes() { |
|
77 | each(chart.series, function(s) { |
77 | each(chart.series, function(s) { |
|
78 | var xAxis = s.xAxis; |
78 | var xAxis = s.xAxis; |
|
79 | s.xAxis = s.yAxis; |
79 | s.xAxis = s.yAxis; |
|
80 | s.yAxis = xAxis; |
80 | s.yAxis = xAxis; |
|
81 | }); |
81 | }); |
|
82 | } |
82 | } |
|
83 | |
83 | |
|
84 | swapAxes(); |
84 | swapAxes(); |
|
85 | |
85 | |
|
86 | this.yAxis.closestPointRange = 1; |
86 | this.yAxis.closestPointRange = 1; |
|
87 | metrics = columnType.prototype.getColumnMetrics.call(this); |
87 | metrics = columnType.prototype.getColumnMetrics.call(this); |
|
88 | |
88 | |
|
89 | swapAxes(); |
89 | swapAxes(); |
|
90 | |
90 | |
|
91 | return metrics; |
91 | return metrics; |
|
92 | }, |
92 | }, |
|
93 | |
93 | |
|
94 | /** |
94 | /** |
|
95 | * Override cropData to show a point where x is outside visible range |
95 | * Override cropData to show a point where x is outside visible range |
|
96 | * but x2 is outside. |
96 | * but x2 is outside. |
|
97 | */ |
97 | */ |
|
98 | cropData: function(xData, yData, min, max) { |
98 | cropData: function(xData, yData, min, max) { |
|
99 | |
99 | |
|
100 | // Replace xData with x2Data to find the appropriate cropStart |
100 | // Replace xData with x2Data to find the appropriate cropStart |
|
101 | var cropData = Series.prototype.cropData, |
101 | var cropData = Series.prototype.cropData, |
|
102 | crop = cropData.call(this, this.x2Data, yData, min, max); |
102 | crop = cropData.call(this, this.x2Data, yData, min, max); |
|
103 | |
103 | |
|
104 | // Re-insert the cropped xData |
104 | // Re-insert the cropped xData |
|
105 | crop.xData = xData.slice(crop.start, crop.end); |
105 | crop.xData = xData.slice(crop.start, crop.end); |
|
106 | |
106 | |
|
107 | return crop; |
107 | return crop; |
|
108 | }, |
108 | }, |
|
109 | |
109 | |
|
110 | translate: function() { |
110 | translate: function() { |
|
111 | columnType.prototype.translate.apply(this, arguments); |
111 | columnType.prototype.translate.apply(this, arguments); |
|
112 | var series = this, |
112 | var series = this, |
|
113 | xAxis = series.xAxis, |
113 | xAxis = series.xAxis, |
|
114 | metrics = series.columnMetrics, |
114 | metrics = series.columnMetrics, |
|
115 | minPointLength = series.options.minPointLength || 0; |
115 | minPointLength = series.options.minPointLength || 0; |
|
116 | |
116 | |
|
117 | each(series.points, function(point) { |
117 | each(series.points, function(point) { |
|
118 | var plotX = point.plotX, |
118 | var plotX = point.plotX, |
|
119 | posX = pick(point.x2, point.x + (point.len || 0)), |
119 | posX = pick(point.x2, point.x + (point.len || 0)), |
|
120 | plotX2 = xAxis.toPixels(posX, true), |
120 | plotX2 = xAxis.toPixels(posX, true), |
|
121 | width = plotX2 - plotX, |
121 | width = plotX2 - plotX, |
|
122 | widthDifference, |
122 | widthDifference, |
|
123 | shapeArgs, |
123 | shapeArgs, |
|
124 | partialFill; |
124 | partialFill; |
|
125 | |
125 | |
|
126 | if (minPointLength) { |
126 | if (minPointLength) { |
|
127 | widthDifference = minPointLength - width; |
127 | widthDifference = minPointLength - width; |
|
128 | if (widthDifference < 0) { |
128 | if (widthDifference < 0) { |
|
129 | widthDifference = 0; |
129 | widthDifference = 0; |
|
130 | } |
130 | } |
|
131 | plotX -= widthDifference / 2; |
131 | plotX -= widthDifference / 2; |
|
132 | plotX2 += widthDifference / 2; |
132 | plotX2 += widthDifference / 2; |
|
133 | } |
133 | } |
|
134 | |
134 | |
|
135 | plotX = Math.max(plotX, -10); |
135 | plotX = Math.max(plotX, -10); |
|
136 | plotX2 = Math.min(Math.max(plotX2, -10), xAxis.len + 10); |
136 | plotX2 = Math.min(Math.max(plotX2, -10), xAxis.len + 10); |
|
137 | |
137 | |
|
138 | if (plotX2 < plotX) { // #6107 |
138 | if (plotX2 < plotX) { // #6107 |
|
139 | plotX2 = plotX; |
139 | plotX2 = plotX; |
|
140 | } |
140 | } |
|
141 | |
141 | |
|
142 | point.shapeArgs = { |
142 | point.shapeArgs = { |
|
143 | x: plotX, |
143 | x: plotX, |
|
144 | y: point.plotY + metrics.offset, |
144 | y: point.plotY + metrics.offset, |
|
145 | width: plotX2 - plotX, |
145 | width: plotX2 - plotX, |
|
146 | height: metrics.width |
146 | height: metrics.width |
|
147 | }; |
147 | }; |
|
148 | point.tooltipPos[0] += width / 2; |
148 | point.tooltipPos[0] += width / 2; |
|
149 | point.tooltipPos[1] -= metrics.width / 2; |
149 | point.tooltipPos[1] -= metrics.width / 2; |
|
150 | |
150 | |
|
151 | // Add a partShapeArgs to the point, based on the shapeArgs property |
151 | // Add a partShapeArgs to the point, based on the shapeArgs property |
|
152 | partialFill = point.partialFill; |
152 | partialFill = point.partialFill; |
|
153 | if (partialFill) { |
153 | if (partialFill) { |
|
154 | // Get the partial fill amount |
154 | // Get the partial fill amount |
|
155 | if (isObject(partialFill)) { |
155 | if (isObject(partialFill)) { |
|
156 | partialFill = partialFill.amount; |
156 | partialFill = partialFill.amount; |
|
157 | } |
157 | } |
|
158 | // If it was not a number, assume 0 |
158 | // If it was not a number, assume 0 |
|
159 | if (!isNumber(partialFill)) { |
159 | if (!isNumber(partialFill)) { |
|
160 | partialFill = 0; |
160 | partialFill = 0; |
|
161 | } |
161 | } |
|
162 | shapeArgs = point.shapeArgs; |
162 | shapeArgs = point.shapeArgs; |
|
163 | point.partShapeArgs = { |
163 | point.partShapeArgs = { |
|
164 | x: shapeArgs.x, |
164 | x: shapeArgs.x, |
|
165 | y: shapeArgs.y + 1, |
165 | y: shapeArgs.y + 1, |
|
166 | width: shapeArgs.width * partialFill, |
166 | width: shapeArgs.width * partialFill, |
|
167 | height: shapeArgs.height - 2 |
167 | height: shapeArgs.height - 2 |
|
168 | }; |
168 | }; |
|
169 | } |
169 | } |
|
170 | }); |
170 | }); |
|
171 | }, |
171 | }, |
|
172 | |
172 | |
|
173 | drawPoints: function() { |
173 | drawPoints: function() { |
|
174 | var series = this, |
174 | var series = this, |
|
175 | chart = this.chart, |
175 | chart = this.chart, |
|
176 | options = series.options, |
176 | options = series.options, |
|
177 | renderer = chart.renderer, |
177 | renderer = chart.renderer, |
|
178 | animationLimit = options.animationLimit || 250, |
178 | animationLimit = options.animationLimit || 250, |
|
179 | verb = chart.pointCount < animationLimit ? 'animate' : 'attr'; |
179 | verb = chart.pointCount < animationLimit ? 'animate' : 'attr'; |
|
180 | |
180 | |
|
181 | // draw the columns |
181 | // draw the columns |
|
182 | each(series.points, function(point) { |
182 | each(series.points, function(point) { |
|
183 | var plotY = point.plotY, |
183 | var plotY = point.plotY, |
|
184 | graphic = point.graphic, |
184 | graphic = point.graphic, |
|
185 | type = point.shapeType, |
185 | type = point.shapeType, |
|
186 | shapeArgs = point.shapeArgs, |
186 | shapeArgs = point.shapeArgs, |
|
187 | partShapeArgs = point.partShapeArgs, |
187 | partShapeArgs = point.partShapeArgs, |
|
188 | seriesOpts = series.options, |
188 | seriesOpts = series.options, |
|
189 | pfOptions = point.partialFill, |
189 | pfOptions = point.partialFill, |
|
190 | fill, |
190 | fill, |
|
191 | state = point.selected && 'select', |
191 | state = point.selected && 'select', |
|
192 | cutOff = options.stacking && !options.borderRadius; |
192 | cutOff = options.stacking && !options.borderRadius; |
|
193 | |
193 | |
|
194 | if (isNumber(plotY) && point.y !== null) { |
194 | if (isNumber(plotY) && point.y !== null) { |
|
195 | if (graphic) { // update |
195 | if (graphic) { // update |
|
196 | point.graphicOriginal[verb]( |
196 | point.graphicOriginal[verb]( |
|
197 | merge(shapeArgs) |
197 | merge(shapeArgs) |
|
198 | ); |
198 | ); |
|
199 | if (partShapeArgs) { |
199 | if (partShapeArgs) { |
|
200 | point.graphicOverlay[verb]( |
200 | point.graphicOverlay[verb]( |
|
201 | merge(partShapeArgs) |
201 | merge(partShapeArgs) |
|
202 | ); |
202 | ); |
|
203 | } |
203 | } |
|
204 | |
204 | |
|
205 | } else { |
205 | } else { |
|
206 | point.graphic = graphic = renderer.g('point') |
206 | point.graphic = graphic = renderer.g('point') |
|
207 | .attr({ |
207 | .attr({ |
|
208 | 'class': point.getClassName() |
208 | 'class': point.getClassName() |
|
209 | }) |
209 | }) |
|
210 | .add(point.group || series.group); |
210 | .add(point.group || series.group); |
|
211 | |
211 | |
|
212 | point.graphicOriginal = renderer[type](shapeArgs) |
212 | point.graphicOriginal = renderer[type](shapeArgs) |
|
213 | .addClass('highcharts-partfill-original') |
213 | .addClass('highcharts-partfill-original') |
|
214 | .add(graphic); |
214 | .add(graphic); |
|
215 | if (partShapeArgs) { |
215 | if (partShapeArgs) { |
|
216 | point.graphicOverlay = renderer[type](partShapeArgs) |
216 | point.graphicOverlay = renderer[type](partShapeArgs) |
|
217 | .addClass('highcharts-partfill-overlay') |
217 | .addClass('highcharts-partfill-overlay') |
|
218 | .add(graphic); |
218 | .add(graphic); |
|
219 | } |
219 | } |
|
220 | } |
220 | } |
|
221 | |
221 | |
|
222 | |
222 | |
|
223 | |
223 | |
|
224 | } else if (graphic) { |
224 | } else if (graphic) { |
|
225 | point.graphic = graphic.destroy(); // #1269 |
225 | point.graphic = graphic.destroy(); // #1269 |
|
226 | } |
226 | } |
|
227 | }); |
227 | }); |
|
228 | } |
228 | } |
|
229 | }); |
229 | }); |
|
230 | |
230 | |
|
231 | /** |
231 | /** |
|
232 | * Max x2 should be considered in xAxis extremes |
232 | * Max x2 should be considered in xAxis extremes |
|
233 | */ |
233 | */ |
|
234 | wrap(Axis.prototype, 'getSeriesExtremes', function(proceed) { |
234 | wrap(Axis.prototype, 'getSeriesExtremes', function(proceed) { |
|
235 | var axis = this, |
235 | var axis = this, |
|
236 | series = axis.series, |
236 | series = axis.series, |
|
237 | dataMax, |
237 | dataMax, |
|
238 | modMax; |
238 | modMax; |
|
239 | |
239 | |
|
240 | proceed.call(this); |
240 | proceed.call(this); |
|
241 | if (axis.isXAxis && series.type === xrange) { |
241 | if (axis.isXAxis && series.type === xrange) { |
|
242 | dataMax = pick(axis.dataMax, Number.MIN_VALUE); |
242 | dataMax = pick(axis.dataMax, Number.MIN_VALUE); |
|
243 | each(this.series, function(series) { |
243 | each(this.series, function(series) { |
|
244 | each(series.x2Data || [], function(val) { |
244 | each(series.x2Data || [], function(val) { |
|
245 | if (val > dataMax) { |
245 | if (val > dataMax) { |
|
246 | dataMax = val; |
246 | dataMax = val; |
|
247 | modMax = true; |
247 | modMax = true; |
|
248 | } |
248 | } |
|
249 | }); |
249 | }); |
|
250 | }); |
250 | }); |
|
251 | if (modMax) { |
251 | if (modMax) { |
|
252 | axis.dataMax = dataMax; |
252 | axis.dataMax = dataMax; |
|
253 | } |
253 | } |
|
254 | } |
254 | } |
|
255 | }); |
255 | }); |
|
256 | |
256 | |
|
257 | }(Highcharts)); |
257 | }(Highcharts)); |
|
258 | })); |
258 | })); |
|
259 | |
259 | |