app/assets/javascripts/highcharts/modules/stock.js in highcharts-rails-5.0.7 vs app/assets/javascripts/highcharts/modules/stock.js in highcharts-rails-5.0.8
- old
+ new
@@ -1,13 +1,14 @@
/**
- * @license Highcharts JS v5.0.7 (2017-01-17)
+ * @license Highcharts JS v5.0.8 (2017-03-08)
* Highstock as a plugin for Highcharts
*
* (c) 2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
+'use strict';
(function(factory) {
if (typeof module === 'object' && module.exports) {
module.exports = factory;
} else {
factory(Highcharts);
@@ -17,11 +18,10 @@
/**
* (c) 2010-2016 Torstein Honsi
*
* License: www.highcharts.com/license
*/
- 'use strict';
var addEvent = H.addEvent,
Axis = H.Axis,
Chart = H.Chart,
css = H.css,
dateFormat = H.dateFormat,
@@ -468,11 +468,12 @@
};
},
options: {
ordinal: true
},
- val2lin: Axis.prototype.val2lin // #2590
+ val2lin: Axis.prototype.val2lin, // #2590
+ ordinal2lin: Axis.prototype.ordinal2lin // #6276
};
// Add the fake series to hold the full data, then apply processData to it
each(axis.series, function(series) {
fakeSeries = {
@@ -726,11 +727,10 @@
/**
* (c) 2009-2016 Torstein Honsi
*
* License: www.highcharts.com/license
*/
- 'use strict';
var pick = H.pick,
wrap = H.wrap,
each = H.each,
extend = H.extend,
@@ -880,10 +880,11 @@
inBrk,
repeat,
brk,
min = axis.userMin || axis.min,
max = axis.userMax || axis.max,
+ pointRangePadding = pick(axis.pointRangePadding, 0),
start,
i,
j;
// Min & max check (#4247)
@@ -955,14 +956,27 @@
}
}
axis.breakArray = breakArray;
+ // Used with staticScale, and below, the actual axis length when
+ // breaks are substracted.
+ axis.unitLength = max - min - length + pointRangePadding;
+
fireEvent(axis, 'afterBreaks');
- axis.transA *= ((max - axis.min) / (max - min - length));
+ if (axis.options.staticScale) {
+ axis.transA = axis.options.staticScale;
+ } else {
+ axis.transA *= (max - axis.min + pointRangePadding) /
+ axis.unitLength;
+ }
+ if (pointRangePadding) {
+ axis.minPixelPadding = axis.transA * axis.minPointOffset;
+ }
+
axis.min = min;
axis.max = max;
};
}
});
@@ -1043,20 +1057,18 @@
wrap(H.Series.prototype, 'drawPoints', drawPointsWrapped);
}(Highcharts));
(function() {
- 'use strict';
}());
(function(H) {
/**
* (c) 2010-2016 Torstein Honsi
*
* License: www.highcharts.com/license
*/
- 'use strict';
var arrayMax = H.arrayMax,
arrayMin = H.arrayMin,
Axis = H.Axis,
defaultPlotOptions = H.defaultPlotOptions,
defined = H.defined,
@@ -1363,13 +1375,12 @@
// run base method
series.forceCrop = groupingEnabled; // #334
series.groupPixelWidth = null; // #2110
series.hasProcessed = true; // #2692
- // skip if processData returns false or if grouping is disabled (in that order) or #5493
- skip = baseProcessData.apply(series, arguments) === false ||
- !groupingEnabled || !visible;
+ // skip if processData returns false or if grouping is disabled (in that order)
+ skip = baseProcessData.apply(series, arguments) === false || !groupingEnabled;
if (!skip) {
series.destroyGroupedData();
var i,
processedXData = series.processedXData,
@@ -1417,11 +1428,12 @@
series.currentDataGrouping = groupPositions.info;
series.closestPointRange = groupPositions.info.totalRange;
series.groupMap = groupedData[2];
// Make sure the X axis extends to show the first group (#2533)
- if (defined(groupedXData[0]) && groupedXData[0] < xAxis.dataMin) {
+ // But only for visible series (#5493, #6393)
+ if (defined(groupedXData[0]) && groupedXData[0] < xAxis.dataMin && visible) {
if (xAxis.min === xAxis.dataMin) {
xAxis.min = groupedXData[0];
}
xAxis.dataMin = groupedXData[0];
}
@@ -1685,11 +1697,10 @@
/**
* (c) 2010-2016 Torstein Honsi
*
* License: www.highcharts.com/license
*/
- 'use strict';
var each = H.each,
Point = H.Point,
seriesType = H.seriesType,
seriesTypes = H.seriesTypes;
@@ -1887,11 +1898,10 @@
/**
* (c) 2010-2016 Torstein Honsi
*
* License: www.highcharts.com/license
*/
- 'use strict';
var defaultPlotOptions = H.defaultPlotOptions,
each = H.each,
merge = H.merge,
seriesType = H.seriesType,
seriesTypes = H.seriesTypes;
@@ -1912,11 +1922,11 @@
threshold: null,
lineColor: '#000000',
lineWidth: 1,
upColor: '#ffffff'
- // upLineColor: null
+ // upLineColor: null
}), /** @lends seriesTypes.candlestick */ {
/**
@@ -2044,11 +2054,10 @@
/**
* (c) 2010-2016 Torstein Honsi
*
* License: www.highcharts.com/license
*/
- 'use strict';
var addEvent = H.addEvent,
each = H.each,
merge = H.merge,
noop = H.noop,
Renderer = H.Renderer,
@@ -2270,23 +2279,23 @@
if (plotY !== undefined && plotX >= 0 && !outsideRight) {
// Create the flag
if (!graphic) {
graphic = point.graphic = renderer.label(
- '',
- null,
- null,
- shape,
- null,
- null,
- options.useHTML
- )
+ '',
+ null,
+ null,
+ shape,
+ null,
+ null,
+ options.useHTML
+ )
- .attr(series.pointAttribs(point))
+ .attr(series.pointAttribs(point))
.css(merge(options.style, point.style))
- .attr({
+ .attr({
align: shape === 'flag' ? 'left' : 'center',
width: options.width,
height: options.height,
'text-align': options.textAlign
})
@@ -2310,11 +2319,11 @@
anchorX: anchorX,
anchorY: anchorY
});
// Set the tooltip anchor position
- point.tooltipPos = chart.inverted ? [yAxis.len + yAxis.pos - chart.plotLeft - plotY, series.xAxis.len - plotX] : [plotX, plotY];
+ point.tooltipPos = chart.inverted ? [yAxis.len + yAxis.pos - chart.plotLeft - plotY, series.xAxis.len - plotX] : [plotX, plotY + yAxis.pos - chart.plotTop]; // #6327
} else if (graphic) {
point.graphic = graphic.destroy();
}
@@ -2430,11 +2439,10 @@
/**
* (c) 2010-2016 Torstein Honsi
*
* License: www.highcharts.com/license
*/
- 'use strict';
var addEvent = H.addEvent,
Axis = H.Axis,
correctFloat = H.correctFloat,
defaultOptions = H.defaultOptions,
defined = H.defined,
@@ -3040,11 +3048,11 @@
if (this[prop] && this[prop].destroy) {
this[prop] = this[prop].destroy();
}
}, this);
- if (scroller) {
+ if (scroller && this === scroller.scrollbar) { // #6421, chart may have more scrollbars
scroller.scrollbar = null;
// Destroy elements in collection
destroyObjectProperties(scroller.scrollbarButtons);
}
@@ -3164,11 +3172,10 @@
/**
* (c) 2010-2016 Torstein Honsi
*
* License: www.highcharts.com/license
*/
- 'use strict';
/* ****************************************************************************
* Start Navigator code *
*****************************************************************************/
var addEvent = H.addEvent,
Axis = H.Axis,
@@ -3258,11 +3265,11 @@
pointRange: 0,
shadow: false,
threshold: null
},
//top: undefined,
- //opposite: undefined, // docs
+ //opposite: undefined,
xAxis: {
className: 'highcharts-navigator-xaxis',
tickLength: 0,
lineWidth: 0,
@@ -3366,27 +3373,28 @@
drawOutline: function(zoomedMin, zoomedMax, inverted, verb) {
var navigator = this,
maskInside = navigator.navigatorOptions.maskInside,
outlineWidth = navigator.outline.strokeWidth(),
halfOutline = outlineWidth / 2,
+ outlineCorrection = (outlineWidth % 2) / 2, // #5800
outlineHeight = navigator.outlineHeight,
scrollbarHeight = navigator.scrollbarHeight,
navigatorSize = navigator.size,
left = navigator.left - scrollbarHeight,
navigatorTop = navigator.top,
verticalMin,
path;
if (inverted) {
left -= halfOutline;
- verticalMin = navigatorTop + zoomedMax + halfOutline;
- zoomedMax = navigatorTop + zoomedMin + halfOutline;
+ verticalMin = navigatorTop + zoomedMax + outlineCorrection;
+ zoomedMax = navigatorTop + zoomedMin + outlineCorrection;
path = [
'M',
left + outlineHeight,
- navigatorTop - scrollbarHeight - halfOutline, // top edge
+ navigatorTop - scrollbarHeight - outlineCorrection, // top edge
'L',
left + outlineHeight,
verticalMin, // top right of zoomed range
'L',
left,
@@ -3407,12 +3415,12 @@
'L',
left + outlineHeight,
zoomedMax + halfOutline // upper right of z.r.
] : []);
} else {
- zoomedMin += left + scrollbarHeight - halfOutline; // #5800 - TO DO, remove halfOutline
- zoomedMax += left + scrollbarHeight - halfOutline; // #5800 - TO DO, remove halfOutline
+ zoomedMin += left + scrollbarHeight - outlineCorrection;
+ zoomedMax += left + scrollbarHeight - outlineCorrection;
navigatorTop += halfOutline;
path = [
'M',
left,
@@ -3529,28 +3537,28 @@
each([!maskInside, maskInside, !maskInside], function(hasMask, index) {
navigator.shades[index] = renderer.rect()
.addClass('highcharts-navigator-mask' +
(index === 1 ? '-inside' : '-outside'))
- .attr({
+ .attr({
fill: hasMask ? navigatorOptions.maskFill : 'transparent'
})
.css(index === 1 && mouseCursor)
- .add(navigatorGroup);
+ .add(navigatorGroup);
});
// Create the outline:
navigator.outline = renderer.path()
.addClass('highcharts-navigator-outline')
- .attr({
- 'stroke-width': navigatorOptions.outlineWidth,
- stroke: navigatorOptions.outlineColor
- })
+ .attr({
+ 'stroke-width': navigatorOptions.outlineWidth,
+ stroke: navigatorOptions.outlineColor
+ })
- .add(navigatorGroup);
+ .add(navigatorGroup);
// Create the handlers:
each([0, 1], function(index) {
navigator.handles[index] = renderer
.path(navigator.getHandlePath(inverted))
@@ -3630,24 +3638,22 @@
}
}
navigator.left = pick(
xAxis.left,
- chart.plotLeft + scrollbarHeight // in case of scrollbar only, without navigator
+ // in case of scrollbar only, without navigator
+ chart.plotLeft + scrollbarHeight + (inverted ? chart.plotWidth : 0)
);
+ navigator.size = zoomedMax = navigatorSize = pick(
+ xAxis.len,
+ (inverted ? chart.plotHeight : chart.plotWidth) - 2 * scrollbarHeight
+ );
+
if (inverted) {
- navigator.size = zoomedMax = navigatorSize = pick(
- xAxis.len,
- chart.plotHeight - 2 * scrollbarHeight
- );
navigatorWidth = scrollbarHeight;
} else {
- navigator.size = zoomedMax = navigatorSize = pick(
- xAxis.len,
- chart.plotWidth - 2 * scrollbarHeight
- );
navigatorWidth = navigatorSize + 2 * scrollbarHeight;
}
// Get the pixel position of the handles
pxMin = pick(pxMin, xAxis.toPixels(min, true));
@@ -3680,10 +3686,11 @@
Math.min(pxMin, pxMax),
0
),
zoomedMax
);
+
navigator.range = navigator.zoomedMax - navigator.zoomedMin;
zoomedMax = Math.round(navigator.zoomedMax);
zoomedMin = Math.round(navigator.zoomedMin);
@@ -3734,11 +3741,14 @@
var navigator = this,
chart = navigator.chart,
container = chart.container,
eventsToUnbind = [],
mouseMoveHandler,
- mouseUpHandler;
+ mouseUpHandler,
+ // iOS calls both events: mousedown+touchstart and mouseup+touchend
+ // So we add them just once, #6187
+ eventNames = hasTouch ? ['touchstart', 'touchmove', 'touchend'] : ['mousedown', 'mousemove', 'mouseup'];
/**
* Create mouse events' handlers.
* Make them as separate functions to enable wrapping them:
*/
@@ -3748,27 +3758,18 @@
navigator.mouseUpHandler = mouseUpHandler = function(e) {
navigator.onMouseUp(e);
};
// Add shades and handles mousedown events
- eventsToUnbind = navigator.getPartsEvents('mousedown');
+ eventsToUnbind = navigator.getPartsEvents(eventNames[0]);
// Add mouse move and mouseup events. These are bind to doc/container,
// because Navigator.grabbedSomething flags are stored in mousedown events:
eventsToUnbind.push(
- addEvent(container, 'mousemove', mouseMoveHandler),
- addEvent(doc, 'mouseup', mouseUpHandler)
+ addEvent(container, eventNames[1], mouseMoveHandler),
+ addEvent(doc, eventNames[2], mouseUpHandler)
);
- // Touch events
- if (hasTouch) {
- eventsToUnbind.push(
- addEvent(container, 'touchmove', mouseMoveHandler),
- addEvent(doc, 'touchend', mouseUpHandler)
- );
- eventsToUnbind.concat(navigator.getPartsEvents('touchstart'));
- }
-
navigator.eventsToUnbind = eventsToUnbind;
// Data events
if (navigator.series && navigator.series[0]) {
eventsToUnbind.push(
@@ -3947,10 +3948,11 @@
if (chartX < dragOffset) { // outside left
chartX = dragOffset;
} else if (chartX > navigatorSize + dragOffset - range) { // outside right
chartX = navigatorSize + dragOffset - range;
}
+
navigator.render(
0,
0,
chartX - dragOffset,
chartX - dragOffset + range
@@ -3971,24 +3973,31 @@
*/
onMouseUp: function(e) {
var navigator = this,
chart = navigator.chart,
xAxis = navigator.xAxis,
+ scrollbar = navigator.scrollbar,
fixedMin,
fixedMax,
ext,
DOMEvent = e.DOMEvent || e;
- if (navigator.hasDragged || e.trigger === 'scrollbar') {
+ if (
+ // MouseUp is called for both, navigator and scrollbar (that order),
+ // which causes calling afterSetExtremes twice. Prevent first call
+ // by checking if scrollbar is going to set new extremes (#6334)
+ (navigator.hasDragged && (!scrollbar || !scrollbar.hasDragged)) ||
+ e.trigger === 'scrollbar'
+ ) {
// When dragging one handle, make sure the other one doesn't change
if (navigator.zoomedMin === navigator.otherHandlePos) {
fixedMin = navigator.fixedExtreme;
} else if (navigator.zoomedMax === navigator.otherHandlePos) {
fixedMax = navigator.fixedExtreme;
}
// Snap to right edge (#4076)
- if (navigator.zoomedMax === navigator.navigatorSize) {
+ if (navigator.zoomedMax === navigator.size) {
fixedMax = navigator.getUnionExtremes().dataMax;
}
ext = xAxis.toFixedRange(
navigator.zoomedMin,
navigator.zoomedMax,
@@ -4073,23 +4082,25 @@
this.navigatorEnabled = navigatorEnabled;
this.navigatorOptions = navigatorOptions;
this.scrollbarOptions = scrollbarOptions;
this.outlineHeight = height + scrollbarHeight;
+ this.opposite = pick(navigatorOptions.opposite, !navigatorEnabled && chart.inverted); // #6262
+
var navigator = this,
baseSeries = navigator.baseSeries,
xAxisIndex = chart.xAxis.length,
yAxisIndex = chart.yAxis.length,
baseXaxis = baseSeries && baseSeries[0] && baseSeries[0].xAxis || chart.xAxis[0];
// Make room for the navigator, can be placed around the chart:
chart.extraMargin = {
- type: navigatorOptions.opposite ? 'plotTop' : 'marginBottom',
- value: navigator.outlineHeight + navigatorOptions.margin
+ type: navigator.opposite ? 'plotTop' : 'marginBottom',
+ value: (navigatorEnabled || !chart.inverted ? navigator.outlineHeight : 0) + navigatorOptions.margin
};
if (chart.inverted) {
- chart.extraMargin.type = navigatorOptions.opposite ? 'marginRight' : 'plotLeft';
+ chart.extraMargin.type = navigator.opposite ? 'marginRight' : 'plotLeft';
}
chart.isDirtyBox = true;
if (navigator.navigatorEnabled) {
// an x axis is required for scrollbar also
@@ -4156,11 +4167,11 @@
} else {
navigator.xAxis = {
translate: function(value, reverse) {
var axis = chart.xAxis[0],
ext = axis.getExtremes(),
- scrollTrackWidth = chart.plotWidth - 2 * scrollbarHeight,
+ scrollTrackWidth = axis.len - 2 * scrollbarHeight,
min = numExt('min', axis.options.min, ext.dataMin),
valueRange = numExt('max', axis.options.max, ext.dataMax) - min;
return reverse ?
// from pixel to value
@@ -4256,11 +4267,11 @@
* this an API method to be called from the outside
* @param {Object} baseSeriesOptions - series options for a navigator
*/
setBaseSeries: function(baseSeriesOptions) {
var chart = this.chart,
- baseSeries = this.baseSeries = [];
+ baseSeries;
baseSeriesOptions = baseSeriesOptions || chart.options && chart.options.navigator.baseSeries || 0;
// If we're resetting, remove the existing series
if (this.series) {
@@ -4268,10 +4279,12 @@
each(this.series, function(s) {
s.destroy();
});
}
+ baseSeries = this.baseSeries = [];
+
// Iterate through series and add the ones that should be shown in navigator
each(chart.series || [], function(series, i) {
if (series.options.showInNavigator || (i === baseSeriesOptions || series.options.id === baseSeriesOptions) &&
series.options.showInNavigator !== false) {
baseSeries.push(series);
@@ -4355,21 +4368,17 @@
// Respond to updated data in the base series.
// Abort if lazy-loading data from the server.
each(baseSeries, function(base) {
if (base.xAxis) {
addEvent(base, 'updatedData', this.updatedDataHandler);
- // Survive Series.update()
- base.userOptions.events = extend(base.userOptions.event, {
- updatedData: this.updatedDataHandler
- });
}
// Handle series removal
addEvent(base, 'remove', function() {
if (this.navigatorSeries) {
erase(navigator.series, this.navigatorSeries);
- this.navigatorSeries.remove();
+ this.navigatorSeries.remove(false);
delete this.navigatorSeries;
}
});
}, this);
}
@@ -4617,11 +4626,11 @@
yAxis = navigator.yAxis;
scrollbarHeight = navigator.scrollbarHeight;
// Compute the top position
if (this.inverted) {
- navigator.left = navigator.navigatorOptions.opposite ?
+ navigator.left = navigator.opposite ?
this.chartWidth - scrollbarHeight - navigator.height :
this.spacing[3] + scrollbarHeight;
navigator.top = this.plotTop + scrollbarHeight;
} else {
navigator.left = this.plotLeft + scrollbarHeight;
@@ -4697,11 +4706,10 @@
/**
* (c) 2010-2016 Torstein Honsi
*
* License: www.highcharts.com/license
*/
- 'use strict';
var addEvent = H.addEvent,
Axis = H.Axis,
Chart = H.Chart,
css = H.css,
createElement = H.createElement,
@@ -5656,11 +5664,10 @@
/**
* (c) 2010-2016 Torstein Honsi
*
* License: www.highcharts.com/license
*/
- 'use strict';
var arrayMax = H.arrayMax,
arrayMin = H.arrayMin,
Axis = H.Axis,
Chart = H.Chart,
defined = H.defined,
@@ -5836,14 +5843,26 @@
labelOptions.x = 0;
}
if (labelOptions.align === undefined) {
labelOptions.align = 'right';
}
- panes[key] = 1;
+ panes[key] = this;
return 'right';
}
}
return proceed.call(this, [].slice.call(arguments, 1));
+ });
+
+ // Clear axis from label panes (#6071)
+ wrap(Axis.prototype, 'destroy', function(proceed) {
+ var chart = this.chart,
+ key = this.options && (this.options.top + ',' + this.options.height);
+
+ if (key && chart._labelPanes && chart._labelPanes[key] === this) {
+ delete chart._labelPanes[key];
+ }
+
+ return proceed.call(this, Array.prototype.slice.call(arguments, 1));
});
// Override getPlotLinePath to allow for multipane charts
wrap(Axis.prototype, 'getPlotLinePath', function(proceed, value, lineWidth, old, force, translatedValue) {
var axis = this,