app/assets/javascripts/highcharts/modules/stock.js in highcharts-rails-5.0.9 vs app/assets/javascripts/highcharts/modules/stock.js in highcharts-rails-5.0.10

- old
+ new

@@ -1,7 +1,7 @@ /** - * @license Highcharts JS v5.0.9 (2017-03-08) + * @license Highcharts JS v5.0.10 (2017-03-31) * Highstock as a plugin for Highcharts * * (c) 2017 Torstein Honsi * * License: www.highcharts.com/license @@ -14,11 +14,11 @@ factory(Highcharts); } }(function(Highcharts) { (function(H) { /** - * (c) 2010-2016 Torstein Honsi + * (c) 2010-2017 Torstein Honsi * * License: www.highcharts.com/license */ var addEvent = H.addEvent, Axis = H.Axis, @@ -723,11 +723,11 @@ *****************************************************************************/ }(Highcharts)); (function(H) { /** - * (c) 2009-2016 Torstein Honsi + * (c) 2009-2017 Torstein Honsi * * License: www.highcharts.com/license */ var pick = H.pick, @@ -1061,11 +1061,11 @@ }()); (function(H) { /** - * (c) 2010-2016 Torstein Honsi + * (c) 2010-2017 Torstein Honsi * * License: www.highcharts.com/license */ var arrayMax = H.arrayMax, arrayMin = H.arrayMin, @@ -1693,11 +1693,11 @@ ******************************************************************************/ }(Highcharts)); (function(H) { /** - * (c) 2010-2016 Torstein Honsi + * (c) 2010-2017 Torstein Honsi * * License: www.highcharts.com/license */ var each = H.each, Point = H.Point, @@ -1725,15 +1725,17 @@ states: { hover: { lineWidth: 3 } - } + }, + stickyTracking: true //upColor: undefined }, /** @lends seriesTypes.ohlc */ { + directTouch: false, pointArrayMap: ['open', 'high', 'low', 'close'], // array point configs are mapped to this toYData: function(point) { // return a plain array for speedy calculation return [point.open, point.high, point.low, point.close]; }, pointValKey: 'high', @@ -1773,22 +1775,22 @@ */ translate: function() { var series = this, yAxis = series.yAxis, hasModifyValue = !!series.modifyValue, - translatedOLC = ['plotOpen', 'yBottom', 'plotClose']; + translated = ['plotOpen', 'plotHigh', 'plotLow', 'plotClose', 'yBottom']; // translate OHLC for seriesTypes.column.prototype.translate.apply(series); // Do the translation each(series.points, function(point) { - each([point.open, point.low, point.close], function(value, i) { + each([point.open, point.high, point.low, point.close, point.low], function(value, i) { if (value !== null) { if (hasModifyValue) { value = series.modifyValue(value); } - point[translatedOLC[i]] = yAxis.toPixels(value, true); + point[translated[i]] = yAxis.toPixels(value, true); } }); }); }, @@ -1894,11 +1896,11 @@ *****************************************************************************/ }(Highcharts)); (function(H) { /** - * (c) 2010-2016 Torstein Honsi + * (c) 2010-2017 Torstein Honsi * * License: www.highcharts.com/license */ var defaultPlotOptions = H.defaultPlotOptions, each = H.each, @@ -1921,11 +1923,12 @@ tooltip: defaultPlotOptions.ohlc.tooltip, threshold: null, lineColor: '#000000', lineWidth: 1, - upColor: '#ffffff' + upColor: '#ffffff', + stickyTracking: true // upLineColor: null }), /** @lends seriesTypes.candlestick */ { @@ -2050,11 +2053,11 @@ *****************************************************************************/ }(Highcharts)); (function(H) { /** - * (c) 2010-2016 Torstein Honsi + * (c) 2010-2017 Torstein Honsi * * License: www.highcharts.com/license */ var addEvent = H.addEvent, each = H.each, @@ -2065,11 +2068,12 @@ seriesType = H.seriesType, seriesTypes = H.seriesTypes, SVGRenderer = H.SVGRenderer, TrackerMixin = H.TrackerMixin, VMLRenderer = H.VMLRenderer, - symbols = SVGRenderer.prototype.symbols; + symbols = SVGRenderer.prototype.symbols, + stableSort = H.stableSort; /** * The flags series type. * * @constructor seriesTypes.flags @@ -2158,10 +2162,11 @@ onKey = options.onKey || 'y', step = onSeries && onSeries.options.step, onData = onSeries && onSeries.points, i = onData && onData.length, xAxis = series.xAxis, + yAxis = series.yAxis, xAxisExt = xAxis.getExtremes(), xOffset = 0, leftPoint, lastX, rightPoint, @@ -2172,11 +2177,11 @@ xOffset = (onSeries.pointXOffset || 0) + (onSeries.barW || 0) / 2; currentDataGrouping = onSeries.currentDataGrouping; lastX = onData[i - 1].x + (currentDataGrouping ? currentDataGrouping.totalRange : 0); // #2374 // sort the data points - points.sort(function(a, b) { + stableSort(points, function(a, b) { return (a.x - b.x); }); onKey = 'plot' + onKey[0].toUpperCase() + onKey.substr(1); while (i-- && points[cursor]) { @@ -2209,16 +2214,20 @@ // Add plotY position and handle stacking each(points, function(point, i) { var stackIndex; - // Undefined plotY means the point is either on axis, outside series range or hidden series. - // If the series is outside the range of the x axis it should fall through with - // an undefined plotY, but then we must remove the shapeArgs (#847). + // Undefined plotY means the point is either on axis, outside series + // range or hidden series. If the series is outside the range of the + // x axis it should fall through with an undefined plotY, but then + // we must remove the shapeArgs (#847). if (point.plotY === undefined) { - if (point.x >= xAxisExt.min && point.x <= xAxisExt.max) { // we're inside xAxis range - point.plotY = chart.chartHeight - xAxis.bottom - (xAxis.opposite ? xAxis.height : 0) + xAxis.offset - chart.plotTop; + if (point.x >= xAxisExt.min && point.x <= xAxisExt.max) { + // we're inside xAxis range + point.plotY = chart.chartHeight - xAxis.bottom - + (xAxis.opposite ? xAxis.height : 0) + + xAxis.offset - yAxis.top; // #3517 } else { point.shapeArgs = {}; // 847 } } point.plotX += xOffset; // #2049 @@ -2300,11 +2309,16 @@ 'text-align': options.textAlign }) .addClass('highcharts-point') .add(series.markerGroup); + // Add reference to the point for tracker (#6303) + if (point.graphic.div) { + point.graphic.div.point = point; + } + graphic.shadow(options.shadow); } if (plotX > 0) { // #3119 @@ -2327,10 +2341,19 @@ point.graphic = graphic.destroy(); } } + // Might be a mix of SVG and HTML and we need events for both (#6303) + if (options.useHTML) { + H.wrap(series.markerGroup, 'on', function(proceed) { + return H.SVGElement.prototype.on.apply( + proceed.apply(this, [].slice.call(arguments, 1)), // for HTML + [].slice.call(arguments, 1)); // and for SVG + }); + } + }, /** * Extend the column trackers with listeners to expand and contract stacks */ @@ -2435,11 +2458,11 @@ *****************************************************************************/ }(Highcharts)); (function(H) { /** - * (c) 2010-2016 Torstein Honsi + * (c) 2010-2017 Torstein Honsi * * License: www.highcharts.com/license */ var addEvent = H.addEvent, Axis = H.Axis, @@ -2768,12 +2791,11 @@ if (!defined(fullWidth)) { return; } from = Math.max(from, 0); - - fromPX = fullWidth * from; + fromPX = Math.ceil(fullWidth * from); toPX = fullWidth * Math.min(to, 1); scroller.calculatedWidth = newSize = correctFloat(toPX - fromPX); // We need to recalculate position, if minWidth is used if (newSize < minWidth) { @@ -3062,11 +3084,11 @@ /** * Wrap axis initialization and create scrollbar if enabled: */ wrap(Axis.prototype, 'init', function(proceed) { var axis = this; - proceed.apply(axis, [].slice.call(arguments, 1)); + proceed.apply(axis, Array.prototype.slice.call(arguments, 1)); if (axis.options.scrollbar && axis.options.scrollbar.enabled) { // Predefined options: axis.options.scrollbar.vertical = !axis.horiz; axis.options.startOnTick = axis.options.endOnTick = false; @@ -3100,32 +3122,43 @@ wrap(Axis.prototype, 'render', function(proceed) { var axis = this, scrollMin = Math.min(pick(axis.options.min, axis.min), axis.min, axis.dataMin), scrollMax = Math.max(pick(axis.options.max, axis.max), axis.max, axis.dataMax), scrollbar = axis.scrollbar, + offsetsIndex, from, to; - proceed.apply(axis, [].slice.call(arguments, 1)); + proceed.apply(axis, Array.prototype.slice.call(arguments, 1)); if (scrollbar) { + if (axis.horiz) { scrollbar.position( axis.left, - axis.top + axis.height + axis.offset + 2 + (axis.opposite ? 0 : axis.axisTitleMargin), + axis.top + axis.height + 2 + axis.chart.scrollbarsOffsets[1] + + (axis.opposite ? 0 : axis.axisTitleMargin + axis.offset), axis.width, axis.height ); + offsetsIndex = 1; } else { scrollbar.position( - axis.left + axis.width + 2 + axis.offset + (axis.opposite ? axis.axisTitleMargin : 0), + axis.left + axis.width + 2 + axis.chart.scrollbarsOffsets[0] + + (axis.opposite ? axis.axisTitleMargin + axis.offset : 0), axis.top, axis.width, axis.height ); + offsetsIndex = 0; } + if ((!axis.opposite && !axis.horiz) || (axis.opposite && axis.horiz)) { + axis.chart.scrollbarsOffsets[offsetsIndex] += + axis.scrollbar.size + axis.scrollbar.options.margin; + } + if (isNaN(scrollMin) || isNaN(scrollMax) || !defined(axis.min) || !defined(axis.max)) { scrollbar.setRange(0, 0); // default action: when there is not extremes on the axis, but scrollbar exists, make it full size } else { from = (axis.min - scrollMin) / (scrollMax - scrollMin); to = (axis.max - scrollMin) / (scrollMax - scrollMin); @@ -3145,13 +3178,14 @@ wrap(Axis.prototype, 'getOffset', function(proceed) { var axis = this, index = axis.horiz ? 2 : 1, scrollbar = axis.scrollbar; - proceed.apply(axis, [].slice.call(arguments, 1)); + proceed.apply(axis, Array.prototype.slice.call(arguments, 1)); if (scrollbar) { + axis.chart.scrollbarsOffsets = [0, 0]; // reset scrollbars offsets axis.chart.axisOffset[index] += scrollbar.size + scrollbar.options.margin; } }); /** @@ -3160,19 +3194,19 @@ wrap(Axis.prototype, 'destroy', function(proceed) { if (this.scrollbar) { this.scrollbar = this.scrollbar.destroy(); } - proceed.apply(this, [].slice.call(arguments, 1)); + proceed.apply(this, Array.prototype.slice.call(arguments, 1)); }); H.Scrollbar = Scrollbar; }(Highcharts)); (function(H) { /** - * (c) 2010-2016 Torstein Honsi + * (c) 2010-2017 Torstein Honsi * * License: www.highcharts.com/license */ /* **************************************************************************** * Start Navigator code * @@ -3725,12 +3759,13 @@ navigatorWidth, scrollbarHeight ); // Keep scale 0-1 navigator.scrollbar.setRange( - zoomedMin / navigatorSize, - zoomedMax / navigatorSize + // Use real value, not rounded because range can be very small (#1716) + navigator.zoomedMin / navigatorSize, + navigator.zoomedMax / navigatorSize ); } navigator.rendered = true; }, @@ -3741,14 +3776,11 @@ var navigator = this, chart = navigator.chart, container = chart.container, eventsToUnbind = [], mouseMoveHandler, - 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']; + mouseUpHandler; /** * Create mouse events' handlers. * Make them as separate functions to enable wrapping them: */ @@ -3758,18 +3790,27 @@ navigator.mouseUpHandler = mouseUpHandler = function(e) { navigator.onMouseUp(e); }; // Add shades and handles mousedown events - eventsToUnbind = navigator.getPartsEvents(eventNames[0]); + eventsToUnbind = navigator.getPartsEvents('mousedown'); // 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, eventNames[1], mouseMoveHandler), - addEvent(doc, eventNames[2], mouseUpHandler) + addEvent(container, 'mousemove', mouseMoveHandler), + addEvent(doc, 'mouseup', 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( @@ -4702,11 +4743,11 @@ *****************************************************************************/ }(Highcharts)); (function(H) { /** - * (c) 2010-2016 Torstein Honsi + * (c) 2010-2017 Torstein Honsi * * License: www.highcharts.com/license */ var addEvent = H.addEvent, Axis = H.Axis, @@ -5660,11 +5701,11 @@ *****************************************************************************/ }(Highcharts)); (function(H) { /** - * (c) 2010-2016 Torstein Honsi + * (c) 2010-2017 Torstein Honsi * * License: www.highcharts.com/license */ var arrayMax = H.arrayMax, arrayMin = H.arrayMin, @@ -6185,11 +6226,11 @@ anchorY: horiz ? (this.opposite ? chart.chartHeight : 0) : posy + crossBox.height / 2 }); }); /* **************************************************************************** - * Start value compare logic * + * Start value compare logic * *****************************************************************************/ /** * Extend series.init by adding a method to modify the y value used for plotting * on the y axis. This method is called both from the axis when finding dataMin @@ -6334,10 +6375,10 @@ return pointTooltipFormatter.apply(this, [pointFormat]); }; /* **************************************************************************** - * End value compare logic * + * End value compare logic * *****************************************************************************/ /** * Extend the Series prototype to create a separate series clip box. This is