highcharts
Version:
JavaScript charting framework
1,371 lines (1,172 loc) • 133 kB
JavaScript
/**
* @license Highcharts JS v5.0.13 (2017-07-27)
*
* (c) 2009-2016 Torstein Honsi
*
* License: www.highcharts.com/license
*/
'use strict';
(function(factory) {
if (typeof module === 'object' && module.exports) {
module.exports = factory;
} else {
factory(Highcharts);
}
}(function(Highcharts) {
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var CenteredSeriesMixin = H.CenteredSeriesMixin,
each = H.each,
extend = H.extend,
merge = H.merge,
splat = H.splat;
/**
* The Pane object allows options that are common to a set of X and Y axes.
*
* In the future, this can be extended to basic Highcharts and Highstock.
*
*/
function Pane(options, chart) {
this.init(options, chart);
}
// Extend the Pane prototype
extend(Pane.prototype, {
coll: 'pane', // Member of chart.pane
/**
* Initiate the Pane object
*/
init: function(options, chart) {
this.chart = chart;
this.background = [];
chart.pane.push(this);
this.setOptions(options);
},
setOptions: function(options) {
// Set options. Angular charts have a default background (#3318)
this.options = options = merge(
this.defaultOptions,
this.chart.angular ? {
background: {}
} : undefined,
options
);
},
/**
* Render the pane with its backgrounds.
*/
render: function() {
var options = this.options,
backgroundOption = this.options.background,
renderer = this.chart.renderer,
len,
i;
if (!this.group) {
this.group = renderer.g('pane-group')
.attr({
zIndex: options.zIndex || 0
})
.add();
}
this.updateCenter();
// Render the backgrounds
if (backgroundOption) {
backgroundOption = splat(backgroundOption);
len = Math.max(
backgroundOption.length,
this.background.length || 0
);
for (i = 0; i < len; i++) {
if (backgroundOption[i] && this.axis) { // #6641 - if axis exists, chart is circular and apply background
this.renderBackground(
merge(
this.defaultBackgroundOptions,
backgroundOption[i]
),
i
);
} else if (this.background[i]) {
this.background[i] = this.background[i].destroy();
this.background.splice(i, 1);
}
}
}
},
/**
* Render an individual pane background.
* @param {Object} backgroundOptions Background options
* @param {number} i The index of the background in this.backgrounds
*/
renderBackground: function(backgroundOptions, i) {
var method = 'animate';
if (!this.background[i]) {
this.background[i] = this.chart.renderer.path()
.add(this.group);
method = 'attr';
}
this.background[i][method]({
'd': this.axis.getPlotBandPath(
backgroundOptions.from,
backgroundOptions.to,
backgroundOptions
)
}).attr({
'class': 'highcharts-pane ' + (backgroundOptions.className || '')
});
},
/**
* The default options object
* @optionparent pane
*/
defaultOptions: {
// background: {conditional},
/**
* The center of a polar chart or angular gauge, given as an array
* of [x, y] positions. Positions can be given as integers that transform
* to pixels, or as percentages of the plot area size.
*
* @type {Array<String|Number>}
* @sample {highcharts} highcharts/demo/gauge-vu-meter/ Two gauges with different center
* @default ["50%", "50%"]
* @since 2.3.0
* @product highcharts
*/
center: ['50%', '50%'],
/**
* The size of the pane, either as a number defining pixels, or a
* percentage defining a percentage of the plot are.
*
* @type {Number|String}
* @sample {highcharts} highcharts/demo/gauge-vu-meter/ Smaller size
* @default 85%
* @product highcharts
*/
size: '85%',
/**
* The start angle of the polar X axis or gauge axis, given in degrees
* where 0 is north. Defaults to 0.
*
* @type {Number}
* @sample {highcharts} highcharts/demo/gauge-vu-meter/ VU-meter with custom start and end angle
* @since 2.3.0
* @product highcharts
*/
startAngle: 0
//endAngle: startAngle + 360
},
/**
* The default background options
* @optionparent pane.background
*/
defaultBackgroundOptions: {
//className: 'highcharts-pane',
/**
* Tha shape of the pane background. When `solid`, the background
* is circular. When `arc`, the background extends only from the min
* to the max of the value axis.
*
* @validvalue ["solid", "arc"]
* @type {String}
* @default solid
* @since 2.3.0
* @product highcharts
*/
shape: 'circle',
/**
*/
from: -Number.MAX_VALUE, // corrected to axis min
/**
* The inner radius of the pane background. Can be either numeric
* (pixels) or a percentage string.
*
* @type {Number|String}
* @default 0
* @since 2.3.0
* @product highcharts
*/
innerRadius: 0,
/**
*/
to: Number.MAX_VALUE, // corrected to axis max
/**
* The outer radius of the circular pane background. Can be either
* numeric (pixels) or a percentage string.
*
* @type {Number|String}
* @default 105%
* @since 2.3.0
* @product highcharts
*/
outerRadius: '105%'
},
/**
* Gets the center for the pane and its axis.
*/
updateCenter: function(axis) {
this.center = (axis || this.axis || {}).center =
CenteredSeriesMixin.getCenter.call(this);
},
/**
* Destroy the pane item
* /
destroy: function () {
H.erase(this.chart.pane, this);
each(this.background, function (background) {
background.destroy();
});
this.background.length = 0;
this.group = this.group.destroy();
},
*/
/**
* Update the pane item with new options
* @param {Object} options New pane options
*/
update: function(options, redraw) {
merge(true, this.options, options);
this.setOptions(this.options);
this.render();
each(this.chart.axes, function(axis) {
if (axis.pane === this) {
axis.pane = null;
axis.update({}, redraw);
}
}, this);
}
});
H.Pane = Pane;
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var Axis = H.Axis,
each = H.each,
extend = H.extend,
map = H.map,
merge = H.merge,
noop = H.noop,
pick = H.pick,
pInt = H.pInt,
Tick = H.Tick,
wrap = H.wrap,
hiddenAxisMixin, // @todo Extract this to a new file
radialAxisMixin, // @todo Extract this to a new file
axisProto = Axis.prototype,
tickProto = Tick.prototype;
/**
* Augmented methods for the x axis in order to hide it completely, used for the X axis in gauges
*/
hiddenAxisMixin = {
getOffset: noop,
redraw: function() {
this.isDirty = false; // prevent setting Y axis dirty
},
render: function() {
this.isDirty = false; // prevent setting Y axis dirty
},
setScale: noop,
setCategories: noop,
setTitle: noop
};
/**
* Augmented methods for the value axis
*/
radialAxisMixin = {
/**
* The default options extend defaultYAxisOptions
*/
defaultRadialGaugeOptions: {
labels: {
align: 'center',
x: 0,
y: null // auto
},
minorGridLineWidth: 0,
minorTickInterval: 'auto',
minorTickLength: 10,
minorTickPosition: 'inside',
minorTickWidth: 1,
tickLength: 10,
tickPosition: 'inside',
tickWidth: 2,
title: {
rotation: 0
},
zIndex: 2 // behind dials, points in the series group
},
// Circular axis around the perimeter of a polar chart
defaultRadialXOptions: {
gridLineWidth: 1, // spokes
labels: {
align: null, // auto
distance: 15,
x: 0,
y: null // auto
},
maxPadding: 0,
minPadding: 0,
showLastLabel: false,
tickLength: 0
},
// Radial axis, like a spoke in a polar chart
defaultRadialYOptions: {
gridLineInterpolation: 'circle',
labels: {
align: 'right',
x: -3,
y: -2
},
showLastLabel: false,
title: {
x: 4,
text: null,
rotation: 90
}
},
/**
* Merge and set options
*/
setOptions: function(userOptions) {
var options = this.options = merge(
this.defaultOptions,
this.defaultRadialOptions,
userOptions
);
// Make sure the plotBands array is instanciated for each Axis (#2649)
if (!options.plotBands) {
options.plotBands = [];
}
},
/**
* Wrap the getOffset method to return zero offset for title or labels in a radial
* axis
*/
getOffset: function() {
// Call the Axis prototype method (the method we're in now is on the instance)
axisProto.getOffset.call(this);
// Title or label offsets are not counted
this.chart.axisOffset[this.side] = 0;
},
/**
* Get the path for the axis line. This method is also referenced in the getPlotLinePath
* method.
*/
getLinePath: function(lineWidth, radius) {
var center = this.center,
end,
chart = this.chart,
r = pick(radius, center[2] / 2 - this.offset),
path;
if (this.isCircular || radius !== undefined) {
path = this.chart.renderer.symbols.arc(
this.left + center[0],
this.top + center[1],
r,
r, {
start: this.startAngleRad,
end: this.endAngleRad,
open: true,
innerR: 0
}
);
} else {
end = this.postTranslate(this.angleRad, r);
path = ['M', center[0] + chart.plotLeft, center[1] + chart.plotTop, 'L', end.x, end.y];
}
return path;
},
/**
* Override setAxisTranslation by setting the translation to the difference
* in rotation. This allows the translate method to return angle for
* any given value.
*/
setAxisTranslation: function() {
// Call uber method
axisProto.setAxisTranslation.call(this);
// Set transA and minPixelPadding
if (this.center) { // it's not defined the first time
if (this.isCircular) {
this.transA = (this.endAngleRad - this.startAngleRad) /
((this.max - this.min) || 1);
} else {
this.transA = (this.center[2] / 2) / ((this.max - this.min) || 1);
}
if (this.isXAxis) {
this.minPixelPadding = this.transA * this.minPointOffset;
} else {
// This is a workaround for regression #2593, but categories still don't position correctly.
this.minPixelPadding = 0;
}
}
},
/**
* In case of auto connect, add one closestPointRange to the max value right before
* tickPositions are computed, so that ticks will extend passed the real max.
*/
beforeSetTickPositions: function() {
// If autoConnect is true, polygonal grid lines are connected, and one closestPointRange
// is added to the X axis to prevent the last point from overlapping the first.
this.autoConnect = this.isCircular && pick(this.userMax, this.options.max) === undefined &&
this.endAngleRad - this.startAngleRad === 2 * Math.PI;
if (this.autoConnect) {
this.max += (this.categories && 1) || this.pointRange || this.closestPointRange || 0; // #1197, #2260
}
},
/**
* Override the setAxisSize method to use the arc's circumference as length. This
* allows tickPixelInterval to apply to pixel lengths along the perimeter
*/
setAxisSize: function() {
axisProto.setAxisSize.call(this);
if (this.isRadial) {
// Set the center array
this.pane.updateCenter(this);
// The sector is used in Axis.translate to compute the translation of reversed axis points (#2570)
if (this.isCircular) {
this.sector = this.endAngleRad - this.startAngleRad;
}
// Axis len is used to lay out the ticks
this.len = this.width = this.height = this.center[2] * pick(this.sector, 1) / 2;
}
},
/**
* Returns the x, y coordinate of a point given by a value and a pixel distance
* from center
*/
getPosition: function(value, length) {
return this.postTranslate(
this.isCircular ? this.translate(value) : this.angleRad, // #2848
pick(this.isCircular ? length : this.translate(value), this.center[2] / 2) - this.offset
);
},
/**
* Translate from intermediate plotX (angle), plotY (axis.len - radius) to final chart coordinates.
*/
postTranslate: function(angle, radius) {
var chart = this.chart,
center = this.center;
angle = this.startAngleRad + angle;
return {
x: chart.plotLeft + center[0] + Math.cos(angle) * radius,
y: chart.plotTop + center[1] + Math.sin(angle) * radius
};
},
/**
* Find the path for plot bands along the radial axis
*/
getPlotBandPath: function(from, to, options) {
var center = this.center,
startAngleRad = this.startAngleRad,
fullRadius = center[2] / 2,
radii = [
pick(options.outerRadius, '100%'),
options.innerRadius,
pick(options.thickness, 10)
],
offset = Math.min(this.offset, 0),
percentRegex = /%$/,
start,
end,
open,
isCircular = this.isCircular, // X axis in a polar chart
ret;
// Polygonal plot bands
if (this.options.gridLineInterpolation === 'polygon') {
ret = this.getPlotLinePath(from).concat(this.getPlotLinePath(to, true));
// Circular grid bands
} else {
// Keep within bounds
from = Math.max(from, this.min);
to = Math.min(to, this.max);
// Plot bands on Y axis (radial axis) - inner and outer radius depend on to and from
if (!isCircular) {
radii[0] = this.translate(from);
radii[1] = this.translate(to);
}
// Convert percentages to pixel values
radii = map(radii, function(radius) {
if (percentRegex.test(radius)) {
radius = (pInt(radius, 10) * fullRadius) / 100;
}
return radius;
});
// Handle full circle
if (options.shape === 'circle' || !isCircular) {
start = -Math.PI / 2;
end = Math.PI * 1.5;
open = true;
} else {
start = startAngleRad + this.translate(from);
end = startAngleRad + this.translate(to);
}
radii[0] -= offset; // #5283
radii[2] -= offset; // #5283
ret = this.chart.renderer.symbols.arc(
this.left + center[0],
this.top + center[1],
radii[0],
radii[0], {
start: Math.min(start, end), // Math is for reversed yAxis (#3606)
end: Math.max(start, end),
innerR: pick(radii[1], radii[0] - radii[2]),
open: open
}
);
}
return ret;
},
/**
* Find the path for plot lines perpendicular to the radial axis.
*/
getPlotLinePath: function(value, reverse) {
var axis = this,
center = axis.center,
chart = axis.chart,
end = axis.getPosition(value),
xAxis,
xy,
tickPositions,
ret;
// Spokes
if (axis.isCircular) {
ret = ['M', center[0] + chart.plotLeft, center[1] + chart.plotTop, 'L', end.x, end.y];
// Concentric circles
} else if (axis.options.gridLineInterpolation === 'circle') {
value = axis.translate(value);
if (value) { // a value of 0 is in the center
ret = axis.getLinePath(0, value);
}
// Concentric polygons
} else {
// Find the X axis in the same pane
each(chart.xAxis, function(a) {
if (a.pane === axis.pane) {
xAxis = a;
}
});
ret = [];
value = axis.translate(value);
tickPositions = xAxis.tickPositions;
if (xAxis.autoConnect) {
tickPositions = tickPositions.concat([tickPositions[0]]);
}
// Reverse the positions for concatenation of polygonal plot bands
if (reverse) {
tickPositions = [].concat(tickPositions).reverse();
}
each(tickPositions, function(pos, i) {
xy = xAxis.getPosition(pos, value);
ret.push(i ? 'L' : 'M', xy.x, xy.y);
});
}
return ret;
},
/**
* Find the position for the axis title, by default inside the gauge
*/
getTitlePosition: function() {
var center = this.center,
chart = this.chart,
titleOptions = this.options.title;
return {
x: chart.plotLeft + center[0] + (titleOptions.x || 0),
y: chart.plotTop + center[1] - ({
high: 0.5,
middle: 0.25,
low: 0
}[titleOptions.align] *
center[2]) + (titleOptions.y || 0)
};
}
};
/**
* Override axisProto.init to mix in special axis instance functions and function overrides
*/
wrap(axisProto, 'init', function(proceed, chart, userOptions) {
var angular = chart.angular,
polar = chart.polar,
isX = userOptions.isX,
isHidden = angular && isX,
isCircular,
options,
chartOptions = chart.options,
paneIndex = userOptions.pane || 0,
pane = this.pane = chart.pane[paneIndex],
paneOptions = pane.options;
// Before prototype.init
if (angular) {
extend(this, isHidden ? hiddenAxisMixin : radialAxisMixin);
isCircular = !isX;
if (isCircular) {
this.defaultRadialOptions = this.defaultRadialGaugeOptions;
}
} else if (polar) {
extend(this, radialAxisMixin);
isCircular = isX;
this.defaultRadialOptions = isX ? this.defaultRadialXOptions : merge(this.defaultYAxisOptions, this.defaultRadialYOptions);
}
// Disable certain features on angular and polar axes
if (angular || polar) {
this.isRadial = true;
chart.inverted = false;
chartOptions.chart.zoomType = null;
} else {
this.isRadial = false;
}
// A pointer back to this axis to borrow geometry
if (isCircular) {
pane.axis = this;
}
// Run prototype.init
proceed.call(this, chart, userOptions);
if (!isHidden && (angular || polar)) {
options = this.options;
// Start and end angle options are
// given in degrees relative to top, while internal computations are
// in radians relative to right (like SVG).
this.angleRad = (options.angle || 0) * Math.PI / 180; // Y axis in polar charts
this.startAngleRad = (paneOptions.startAngle - 90) * Math.PI / 180; // Gauges
this.endAngleRad = (pick(paneOptions.endAngle, paneOptions.startAngle + 360) - 90) * Math.PI / 180; // Gauges
this.offset = options.offset || 0;
this.isCircular = isCircular;
}
});
/**
* Wrap auto label align to avoid setting axis-wide rotation on radial axes (#4920)
* @param {Function} proceed
* @returns {String} Alignment
*/
wrap(axisProto, 'autoLabelAlign', function(proceed) {
if (!this.isRadial) {
return proceed.apply(this, [].slice.call(arguments, 1));
} // else return undefined
});
/**
* Add special cases within the Tick class' methods for radial axes.
*/
wrap(tickProto, 'getPosition', function(proceed, horiz, pos, tickmarkOffset, old) {
var axis = this.axis;
return axis.getPosition ?
axis.getPosition(pos) :
proceed.call(this, horiz, pos, tickmarkOffset, old);
});
/**
* Wrap the getLabelPosition function to find the center position of the label
* based on the distance option
*/
wrap(tickProto, 'getLabelPosition', function(proceed, x, y, label, horiz, labelOptions, tickmarkOffset, index, step) {
var axis = this.axis,
optionsY = labelOptions.y,
ret,
centerSlot = 20, // 20 degrees to each side at the top and bottom
align = labelOptions.align,
angle = ((axis.translate(this.pos) + axis.startAngleRad + Math.PI / 2) / Math.PI * 180) % 360;
if (axis.isRadial) { // Both X and Y axes in a polar chart
ret = axis.getPosition(this.pos, (axis.center[2] / 2) + pick(labelOptions.distance, -25));
// Automatically rotated
if (labelOptions.rotation === 'auto') {
label.attr({
rotation: angle
});
// Vertically centered
} else if (optionsY === null) {
optionsY = axis.chart.renderer.fontMetrics(label.styles.fontSize).b - label.getBBox().height / 2;
}
// Automatic alignment
if (align === null) {
if (axis.isCircular) { // Y axis
if (this.label.getBBox().width > axis.len * axis.tickInterval / (axis.max - axis.min)) { // #3506
centerSlot = 0;
}
if (angle > centerSlot && angle < 180 - centerSlot) {
align = 'left'; // right hemisphere
} else if (angle > 180 + centerSlot && angle < 360 - centerSlot) {
align = 'right'; // left hemisphere
} else {
align = 'center'; // top or bottom
}
} else {
align = 'center';
}
label.attr({
align: align
});
}
ret.x += labelOptions.x;
ret.y += optionsY;
} else {
ret = proceed.call(this, x, y, label, horiz, labelOptions, tickmarkOffset, index, step);
}
return ret;
});
/**
* Wrap the getMarkPath function to return the path of the radial marker
*/
wrap(tickProto, 'getMarkPath', function(proceed, x, y, tickLength, tickWidth, horiz, renderer) {
var axis = this.axis,
endPoint,
ret;
if (axis.isRadial) {
endPoint = axis.getPosition(this.pos, axis.center[2] / 2 + tickLength);
ret = [
'M',
x,
y,
'L',
endPoint.x,
endPoint.y
];
} else {
ret = proceed.call(this, x, y, tickLength, tickWidth, horiz, renderer);
}
return ret;
});
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var each = H.each,
noop = H.noop,
pick = H.pick,
defined = H.defined,
Series = H.Series,
seriesType = H.seriesType,
seriesTypes = H.seriesTypes,
seriesProto = Series.prototype,
pointProto = H.Point.prototype;
// The arearangeseries series type
/**
* @extends plotOptions.area
* @optionparent plotOptions.arearange
*/
seriesType('arearange', 'area', {
/**
*/
threshold: null,
/**
*/
tooltip: {
pointFormat: '<span class="highcharts-color-{series.colorIndex}">\u25CF</span> {series.name}: <b>{point.low}</b> - <b>{point.high}</b><br/>'
},
/**
* Whether the whole area or just the line should respond to mouseover
* tooltips and other mouse or touch events.
*
* @type {Boolean}
* @default true
* @since 2.3.0
* @product highcharts highstock
*/
trackByArea: true,
/**
* Extended data labels for range series types. Range series data labels
* have no `x` and `y` options. Instead, they have `xLow`, `xHigh`,
* `yLow` and `yHigh` options to allow the higher and lower data label
* sets individually.
*
* @type {Object}
* @extends plotOptions.series.dataLabels
* @excluding x,y
* @since 2.3.0
* @product highcharts highstock
*/
dataLabels: {
/**
*/
align: null,
/**
*/
verticalAlign: null,
/**
* X offset of the lower data labels relative to the point value.
*
* @type {Number}
* @sample {highcharts} highcharts/plotoptions/arearange-datalabels/ Data labels on range series
* @sample {highstock} highcharts/plotoptions/arearange-datalabels/ Data labels on range series
* @default 0
* @since 2.3.0
* @product highcharts highstock
*/
xLow: 0,
/**
* X offset of the higher data labels relative to the point value.
*
* @type {Number}
* @sample {highcharts} highcharts/plotoptions/arearange-datalabels/ Data labels on range series
* @sample {highstock} highcharts/plotoptions/arearange-datalabels/ Data labels on range series
* @default 0
* @since 2.3.0
* @product highcharts highstock
*/
xHigh: 0,
/**
* Y offset of the lower data labels relative to the point value.
*
* @type {Number}
* @sample {highcharts} highcharts/plotoptions/arearange-datalabels/ Data labels on range series
* @sample {highstock} highcharts/plotoptions/arearange-datalabels/ Data labels on range series
* @default 16
* @since 2.3.0
* @product highcharts highstock
*/
yLow: 0,
/**
* Y offset of the higher data labels relative to the point value.
*
* @type {Number}
* @sample {highcharts} highcharts/plotoptions/arearange-datalabels/ Data labels on range series
* @sample {highstock} highcharts/plotoptions/arearange-datalabels/ Data labels on range series
* @default -6
* @since 2.3.0
* @product highcharts highstock
*/
yHigh: 0
}
// Prototype members
}, {
pointArrayMap: ['low', 'high'],
dataLabelCollections: ['dataLabel', 'dataLabelUpper'],
toYData: function(point) {
return [point.low, point.high];
},
pointValKey: 'low',
deferTranslatePolar: true,
/**
* Translate a point's plotHigh from the internal angle and radius measures to
* true plotHigh coordinates. This is an addition of the toXY method found in
* Polar.js, because it runs too early for arearanges to be considered (#3419).
*/
highToXY: function(point) {
// Find the polar plotX and plotY
var chart = this.chart,
xy = this.xAxis.postTranslate(point.rectPlotX, this.yAxis.len - point.plotHigh);
point.plotHighX = xy.x - chart.plotLeft;
point.plotHigh = xy.y - chart.plotTop;
point.plotLowX = point.plotX;
},
/**
* Translate data points from raw values x and y to plotX and plotY
*/
translate: function() {
var series = this,
yAxis = series.yAxis,
hasModifyValue = !!series.modifyValue;
seriesTypes.area.prototype.translate.apply(series);
// Set plotLow and plotHigh
each(series.points, function(point) {
var low = point.low,
high = point.high,
plotY = point.plotY;
if (high === null || low === null) {
point.isNull = true;
point.plotY = null;
} else {
point.plotLow = plotY;
point.plotHigh = yAxis.translate(
hasModifyValue ? series.modifyValue(high, point) : high,
0,
1,
0,
1
);
if (hasModifyValue) {
point.yBottom = point.plotHigh;
}
}
});
// Postprocess plotHigh
if (this.chart.polar) {
each(this.points, function(point) {
series.highToXY(point);
point.tooltipPos = [
(point.plotHighX + point.plotLowX) / 2,
(point.plotHigh + point.plotLow) / 2
];
});
}
},
/**
* Extend the line series' getSegmentPath method by applying the segment
* path to both lower and higher values of the range
*/
getGraphPath: function(points) {
var highPoints = [],
highAreaPoints = [],
i,
getGraphPath = seriesTypes.area.prototype.getGraphPath,
point,
pointShim,
linePath,
lowerPath,
options = this.options,
connectEnds = this.chart.polar && options.connectEnds !== false,
connectNulls = options.connectNulls,
step = options.step,
higherPath,
higherAreaPath;
points = points || this.points;
i = points.length;
// Create the top line and the top part of the area fill. The area fill compensates for
// null points by drawing down to the lower graph, moving across the null gap and
// starting again at the lower graph.
i = points.length;
while (i--) {
point = points[i];
if (!point.isNull &&
!connectEnds &&
!connectNulls &&
(!points[i + 1] || points[i + 1].isNull)
) {
highAreaPoints.push({
plotX: point.plotX,
plotY: point.plotY,
doCurve: false // #5186, gaps in areasplinerange fill
});
}
pointShim = {
polarPlotY: point.polarPlotY,
rectPlotX: point.rectPlotX,
yBottom: point.yBottom,
plotX: pick(point.plotHighX, point.plotX), // plotHighX is for polar charts
plotY: point.plotHigh,
isNull: point.isNull
};
highAreaPoints.push(pointShim);
highPoints.push(pointShim);
if (!point.isNull &&
!connectEnds &&
!connectNulls &&
(!points[i - 1] || points[i - 1].isNull)
) {
highAreaPoints.push({
plotX: point.plotX,
plotY: point.plotY,
doCurve: false // #5186, gaps in areasplinerange fill
});
}
}
// Get the paths
lowerPath = getGraphPath.call(this, points);
if (step) {
if (step === true) {
step = 'left';
}
options.step = {
left: 'right',
center: 'center',
right: 'left'
}[step]; // swap for reading in getGraphPath
}
higherPath = getGraphPath.call(this, highPoints);
higherAreaPath = getGraphPath.call(this, highAreaPoints);
options.step = step;
// Create a line on both top and bottom of the range
linePath = [].concat(lowerPath, higherPath);
// For the area path, we need to change the 'move' statement into 'lineTo' or 'curveTo'
if (!this.chart.polar && higherAreaPath[0] === 'M') {
higherAreaPath[0] = 'L'; // this probably doesn't work for spline
}
this.graphPath = linePath;
this.areaPath = this.areaPath.concat(lowerPath, higherAreaPath);
// Prepare for sideways animation
linePath.isArea = true;
linePath.xMap = lowerPath.xMap;
this.areaPath.xMap = lowerPath.xMap;
return linePath;
},
/**
* Extend the basic drawDataLabels method by running it for both lower and higher
* values.
*/
drawDataLabels: function() {
var data = this.data,
length = data.length,
i,
originalDataLabels = [],
dataLabelOptions = this.options.dataLabels,
align = dataLabelOptions.align,
verticalAlign = dataLabelOptions.verticalAlign,
inside = dataLabelOptions.inside,
point,
up,
inverted = this.chart.inverted;
if (dataLabelOptions.enabled || this._hasPointLabels) {
// Step 1: set preliminary values for plotY and dataLabel and draw the upper labels
i = length;
while (i--) {
point = data[i];
if (point) {
up = inside ? point.plotHigh < point.plotLow : point.plotHigh > point.plotLow;
// Set preliminary values
point.y = point.high;
point._plotY = point.plotY;
point.plotY = point.plotHigh;
// Store original data labels and set preliminary label objects to be picked up
// in the uber method
originalDataLabels[i] = point.dataLabel;
point.dataLabel = point.dataLabelUpper;
// Set the default offset
point.below = up;
if (inverted) {
if (!align) {
dataLabelOptions.align = up ? 'right' : 'left';
}
} else {
if (!verticalAlign) {
dataLabelOptions.verticalAlign = up ? 'top' : 'bottom';
}
}
dataLabelOptions.x = dataLabelOptions.xHigh;
dataLabelOptions.y = dataLabelOptions.yHigh;
}
}
if (seriesProto.drawDataLabels) {
seriesProto.drawDataLabels.apply(this, arguments); // #1209
}
// Step 2: reorganize and handle data labels for the lower values
i = length;
while (i--) {
point = data[i];
if (point) {
up = inside ? point.plotHigh < point.plotLow : point.plotHigh > point.plotLow;
// Move the generated labels from step 1, and reassign the original data labels
point.dataLabelUpper = point.dataLabel;
point.dataLabel = originalDataLabels[i];
// Reset values
point.y = point.low;
point.plotY = point._plotY;
// Set the default offset
point.below = !up;
if (inverted) {
if (!align) {
dataLabelOptions.align = up ? 'left' : 'right';
}
} else {
if (!verticalAlign) {
dataLabelOptions.verticalAlign = up ? 'bottom' : 'top';
}
}
dataLabelOptions.x = dataLabelOptions.xLow;
dataLabelOptions.y = dataLabelOptions.yLow;
}
}
if (seriesProto.drawDataLabels) {
seriesProto.drawDataLabels.apply(this, arguments);
}
}
dataLabelOptions.align = align;
dataLabelOptions.verticalAlign = verticalAlign;
},
alignDataLabel: function() {
seriesTypes.column.prototype.alignDataLabel.apply(this, arguments);
},
drawPoints: function() {
var series = this,
pointLength = series.points.length,
point,
i;
// Draw bottom points
seriesProto.drawPoints.apply(series, arguments);
i = 0;
while (i < pointLength) {
point = series.points[i];
point.lowerGraphic = point.graphic;
point.graphic = point.upperGraphic;
point._plotY = point.plotY;
point._plotX = point.plotX;
point.plotY = point.plotHigh;
if (defined(point.plotHighX)) {
point.plotX = point.plotHighX;
}
i++;
}
// Draw top points
seriesProto.drawPoints.apply(series, arguments);
i = 0;
while (i < pointLength) {
point = series.points[i];
point.upperGraphic = point.graphic;
point.graphic = point.lowerGraphic;
point.plotY = point._plotY;
point.plotX = point._plotX;
i++;
}
},
setStackedPoints: noop
}, {
setState: function() {
var prevState = this.state,
series = this.series,
isPolar = series.chart.polar;
if (!defined(this.plotHigh)) {
// Boost doesn't calculate plotHigh
this.plotHigh = series.yAxis.toPixels(this.high, true);
}
if (!defined(this.plotLow)) {
// Boost doesn't calculate plotLow
this.plotLow = this.plotY = series.yAxis.toPixels(this.low, true);
}
// Bottom state:
pointProto.setState.apply(this, arguments);
// Change state also for the top marker
this.graphic = this.upperGraphic;
this.plotY = this.plotHigh;
if (isPolar) {
this.plotX = this.plotHighX;
}
this.state = prevState;
if (series.stateMarkerGraphic) {
series.lowerStateMarkerGraphic = series.stateMarkerGraphic;
series.stateMarkerGraphic = series.upperStateMarkerGraphic;
}
pointProto.setState.apply(this, arguments);
// Now restore defaults
this.plotY = this.plotLow;
this.graphic = this.lowerGraphic;
if (isPolar) {
this.plotX = this.plotLowX;
}
if (series.stateMarkerGraphic) {
series.upperStateMarkerGraphic = series.stateMarkerGraphic;
series.stateMarkerGraphic = series.lowerStateMarkerGraphic;
}
},
haloPath: function() {
var isPolar = this.series.chart.polar,
path = [];
// Bottom halo
this.plotY = this.plotLow;
if (isPolar) {
this.plotX = this.plotLowX;
}
path = pointProto.haloPath.apply(this, arguments);
// Top halo
this.plotY = this.plotHigh;
if (isPolar) {
this.plotX = this.plotHighX;
}
path = path.concat(
pointProto.haloPath.apply(this, arguments)
);
return path;
},
destroy: function() {
if (this.upperGraphic) {
this.upperGraphic = this.upperGraphic.destroy();
}
return pointProto.destroy.apply(this, arguments);
}
});
}(Highcharts));
(function(H) {
/**
* (c) 20