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