diff --git a/src/traces/histogram/attributes.js b/src/traces/histogram/attributes.js index d50e8bd6cd3..243a7df93ab 100644 --- a/src/traces/histogram/attributes.js +++ b/src/traces/histogram/attributes.js @@ -30,13 +30,6 @@ module.exports = { ].join(' ') }, - xperiod: barAttrs.xperiod, - yperiod: barAttrs.yperiod, - xperiod0: barAttrs.xperiod0, - yperiod0: barAttrs.yperiod0, - xperiodalignment: barAttrs.xperiodalignment, - yperiodalignment: barAttrs.yperiodalignment, - text: extendFlat({}, barAttrs.text, { description: [ 'Sets hover text elements associated with each bar.', diff --git a/src/traces/histogram/calc.js b/src/traces/histogram/calc.js index 6859a747d12..540813836aa 100644 --- a/src/traces/histogram/calc.js +++ b/src/traces/histogram/calc.js @@ -13,7 +13,6 @@ var isNumeric = require('fast-isnumeric'); var Lib = require('../../lib'); var Registry = require('../../registry'); var Axes = require('../../plots/cartesian/axes'); -var alignPeriod = require('../../plots/cartesian/align_period'); var arraysToCalcdata = require('../bar/arrays_to_calcdata'); var binFunctions = require('./bin_functions'); @@ -24,19 +23,16 @@ var getBinSpanLabelRound = require('./bin_label_vals'); function calc(gd, trace) { var pos = []; var size = []; - var isHorizontal = trace.orientation === 'h'; - var pa = Axes.getFromId(gd, isHorizontal ? trace.yaxis : trace.xaxis); - var mainData = isHorizontal ? 'y' : 'x'; + var pa = Axes.getFromId(gd, trace.orientation === 'h' ? trace.yaxis : trace.xaxis); + var mainData = trace.orientation === 'h' ? 'y' : 'x'; var counterData = {x: 'y', y: 'x'}[mainData]; var calendar = trace[mainData + 'calendar']; - var hasPeriod = trace[mainData + 'periodalignment']; var cumulativeSpec = trace.cumulative; var i; var binsAndPos = calcAllAutoBins(gd, trace, pa, mainData); var binSpec = binsAndPos[0]; var pos0 = binsAndPos[1]; - var origPos = binsAndPos[2]; var nonuniformBins = typeof binSpec.size === 'string'; var binEdges = []; @@ -189,21 +185,13 @@ function calc(gd, trace) { b: 0 }; - if(hasPeriod) { - cdi.orig_p = origPos[i]; - } - // setup hover and event data fields, // N.B. pts and "hover" positions ph0/ph1 don't seem to make much sense // for cumulative distributions if(!cumulativeSpec.enabled) { cdi.pts = inputPoints[i]; if(uniqueValsPerBin) { - if(hasPeriod) { - cdi.ph0 = cdi.ph1 = cdi.pts.length ? origPos[cdi.pts[0]] : cdi.orig_p; - } else { - cdi.ph0 = cdi.ph1 = cdi.pts.length ? pos0[cdi.pts[0]] : cdi.p; - } + cdi.ph0 = cdi.ph1 = (inputPoints[i].length) ? pos0[inputPoints[i][0]] : pos[i]; } else { // Defer evaluation of ph(0|1) in crossTraceCalc trace._computePh = true; @@ -245,7 +233,7 @@ function calcAllAutoBins(gd, trace, pa, mainData, _overlayEdgeCase) { var groupName = trace['_' + mainData + 'bingroup']; var binOpts = fullLayout._histogramBinOpts[groupName]; var isOverlay = fullLayout.barmode === 'overlay'; - var i, traces, tracei, calendar, pos0, origPos, autoVals, cumulativeSpec; + var i, traces, tracei, calendar, pos0, autoVals, cumulativeSpec; var r2c = function(v) { return pa.r2c(v, 0, calendar); }; var c2r = function(v) { return pa.c2r(v, 0, calendar); }; @@ -284,9 +272,7 @@ function calcAllAutoBins(gd, trace, pa, mainData, _overlayEdgeCase) { if(tracei.visible) { var mainDatai = binOpts.dirs[i]; - origPos = pa.makeCalcdata(tracei, mainDatai); - pos0 = alignPeriod(trace, pa, mainData, origPos); - tracei['_' + mainDatai + 'pos0'] = pos0; + pos0 = tracei['_' + mainDatai + 'pos0'] = pa.makeCalcdata(tracei, mainDatai); allPos = Lib.concat(allPos, pos0); delete tracei['_' + mainData + 'autoBinFinished']; @@ -334,7 +320,7 @@ function calcAllAutoBins(gd, trace, pa, mainData, _overlayEdgeCase) { // Several single-valued histograms! Stop infinite recursion, // just return an extra flag that tells handleSingleValueOverlays // to sort out this trace too - if(_overlayEdgeCase) return [newBinSpec, pos0, origPos, true]; + if(_overlayEdgeCase) return [newBinSpec, pos0, true]; newBinSpec = handleSingleValueOverlays(gd, trace, pa, mainData, binAttr); } @@ -421,7 +407,7 @@ function calcAllAutoBins(gd, trace, pa, mainData, _overlayEdgeCase) { delete trace[autoBinAttr]; } - return [traceBinOptsCalc, pos0, origPos, false]; + return [traceBinOptsCalc, pos0]; } /* @@ -455,7 +441,7 @@ function handleSingleValueOverlays(gd, trace, pa, mainData, binAttr) { } else { var resulti = calcAllAutoBins(gd, tracei, pa, mainData, true); var binSpeci = resulti[0]; - var isSingleValued = resulti[3]; + var isSingleValued = resulti[2]; // so we can use this result when we get to tracei in the normal // course of events, mark it as done and put _pos0 back diff --git a/src/traces/histogram/defaults.js b/src/traces/histogram/defaults.js index 0a27f041cc7..0c125945e31 100644 --- a/src/traces/histogram/defaults.js +++ b/src/traces/histogram/defaults.js @@ -12,7 +12,6 @@ var Registry = require('../../registry'); var Lib = require('../../lib'); var Color = require('../../components/color'); -var handlePeriodDefaults = require('../scatter/period_defaults'); var handleStyleDefaults = require('../bar/style_defaults'); var attributes = require('./attributes'); @@ -47,8 +46,6 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout return; } - handlePeriodDefaults(traceIn, traceOut, layout, coerce); - traceOut._length = len; var handleCalendarDefaults = Registry.getComponentMethod('calendars', 'handleTraceDefaults'); diff --git a/src/traces/histogram2d/attributes.js b/src/traces/histogram2d/attributes.js index 974f68f55a9..105b3b8f58e 100644 --- a/src/traces/histogram2d/attributes.js +++ b/src/traces/histogram2d/attributes.js @@ -22,13 +22,6 @@ module.exports = extendFlat( x: histogramAttrs.x, y: histogramAttrs.y, - xperiod: histogramAttrs.xperiod, - yperiod: histogramAttrs.yperiod, - xperiod0: histogramAttrs.xperiod0, - yperiod0: histogramAttrs.yperiod0, - xperiodalignment: histogramAttrs.xperiodalignment, - yperiodalignment: histogramAttrs.yperiodalignment, - z: { valType: 'data_array', editType: 'calc', diff --git a/src/traces/histogram2d/calc.js b/src/traces/histogram2d/calc.js index 99d27590a9c..ef8854be255 100644 --- a/src/traces/histogram2d/calc.js +++ b/src/traces/histogram2d/calc.js @@ -34,21 +34,13 @@ module.exports = function calc(gd, trace) { var xBinsAndPos = calcAllAutoBins(gd, trace, xa, 'x'); var xBinSpec = xBinsAndPos[0]; var xPos0 = xBinsAndPos[1]; - var origX = xBinsAndPos[2]; var yBinsAndPos = calcAllAutoBins(gd, trace, ya, 'y'); var yBinSpec = yBinsAndPos[0]; var yPos0 = yBinsAndPos[1]; - var origY = yBinsAndPos[2]; var serieslen = trace._length; - if(xPos0.length > serieslen) { - xPos0.splice(serieslen, xPos0.length - serieslen); - origX.splice(serieslen, origX.length - serieslen); - } - if(yPos0.length > serieslen) { - yPos0.splice(serieslen, yPos0.length - serieslen); - origY.splice(serieslen, origY.length - serieslen); - } + if(xPos0.length > serieslen) xPos0.splice(serieslen, xPos0.length - serieslen); + if(yPos0.length > serieslen) yPos0.splice(serieslen, yPos0.length - serieslen); // make the empty bin array & scale the map var z = []; @@ -139,8 +131,6 @@ module.exports = function calc(gd, trace) { var uniqueValsPerY = true; var xVals = new Array(nx); var yVals = new Array(ny); - var xOrig = []; - var yOrig = []; var xGapLow = Infinity; var xGapHigh = Infinity; var yGapLow = Infinity; @@ -151,9 +141,6 @@ module.exports = function calc(gd, trace) { n = Lib.findBin(xi, xbins); m = Lib.findBin(yi, ybins); if(n >= 0 && n < nx && m >= 0 && m < ny) { - if(origX) xOrig[n] = origX[i]; - if(origY) yOrig[m] = origY[i]; - total += binfunc(n, i, z[m], rawCounterData, counts[m]); inputPoints[m][n].push(i); @@ -181,18 +168,14 @@ module.exports = function calc(gd, trace) { } return { - orig_x: xOrig, x: xPos0, xRanges: getRanges(xEdges, uniqueValsPerX && xVals, xGapLow, xGapHigh, xa, xcalendar), x0: x0, dx: dx, - - orig_y: yOrig, y: yPos0, yRanges: getRanges(yEdges, uniqueValsPerY && yVals, yGapLow, yGapHigh, ya, ycalendar), y0: y0, dy: dy, - z: z, pts: inputPoints }; diff --git a/src/traces/histogram2d/defaults.js b/src/traces/histogram2d/defaults.js index e32e5eb9a80..6ba52066c9a 100644 --- a/src/traces/histogram2d/defaults.js +++ b/src/traces/histogram2d/defaults.js @@ -11,7 +11,6 @@ var Lib = require('../../lib'); -var handlePeriodDefaults = require('../scatter/period_defaults'); var handleSampleDefaults = require('./sample_defaults'); var handleStyleDefaults = require('../heatmap/style_defaults'); var colorscaleDefaults = require('../../components/colorscale/defaults'); @@ -26,8 +25,6 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout handleSampleDefaults(traceIn, traceOut, coerce, layout); if(traceOut.visible === false) return; - handlePeriodDefaults(traceIn, traceOut, layout, coerce); - handleStyleDefaults(traceIn, traceOut, coerce, layout); colorscaleDefaults(traceIn, traceOut, layout, coerce, {prefix: '', cLetter: 'z'}); coerce('hovertemplate'); diff --git a/src/traces/histogram2d/hover.js b/src/traces/histogram2d/hover.js index f7c6fee0fa4..b2f67b2f4d4 100644 --- a/src/traces/histogram2d/hover.js +++ b/src/traces/histogram2d/hover.js @@ -22,23 +22,11 @@ module.exports = function hoverPoints(pointData, xval, yval, hovermode, hoverLay var ny = indices[0]; var nx = indices[1]; var cd0 = pointData.cd[0]; + var xRange = cd0.xRanges[nx]; + var yRange = cd0.yRanges[ny]; - var trace = cd0.trace; - var hasPeriodX = !!trace.xperiodalignment; - var hasPeriodY = !!trace.yperiodalignment; - - if(hasPeriodX) { - pointData.xLabel = hoverLabelText(pointData.xa, cd0.orig_x[nx]); - } else { - var xRange = cd0.xRanges[nx]; - pointData.xLabel = hoverLabelText(pointData.xa, xRange[0], xRange[1]); - } - if(hasPeriodY) { - pointData.yLabel = hoverLabelText(pointData.ya, cd0.orig_x[ny]); - } else { - var yRange = cd0.yRanges[ny]; - pointData.yLabel = hoverLabelText(pointData.ya, yRange[0], yRange[1]); - } + pointData.xLabel = hoverLabelText(pointData.xa, xRange[0], xRange[1]); + pointData.yLabel = hoverLabelText(pointData.ya, yRange[0], yRange[1]); return pts; }; diff --git a/src/traces/histogram2dcontour/attributes.js b/src/traces/histogram2dcontour/attributes.js index 1395cf664b6..b315b9cde0d 100644 --- a/src/traces/histogram2dcontour/attributes.js +++ b/src/traces/histogram2dcontour/attributes.js @@ -15,13 +15,6 @@ var colorScaleAttrs = require('../../components/colorscale/attributes'); var extendFlat = require('../../lib/extend').extendFlat; module.exports = extendFlat({ - xperiod: histogram2dAttrs.xperiod, - yperiod: histogram2dAttrs.yperiod, - xperiod0: histogram2dAttrs.xperiod0, - yperiod0: histogram2dAttrs.yperiod0, - xperiodalignment: histogram2dAttrs.xperiodalignment, - yperiodalignment: histogram2dAttrs.yperiodalignment, - x: histogram2dAttrs.x, y: histogram2dAttrs.y, z: histogram2dAttrs.z, diff --git a/src/traces/histogram2dcontour/defaults.js b/src/traces/histogram2dcontour/defaults.js index ac11538c0ff..fc3457777d7 100644 --- a/src/traces/histogram2dcontour/defaults.js +++ b/src/traces/histogram2dcontour/defaults.js @@ -11,7 +11,6 @@ var Lib = require('../../lib'); -var handlePeriodDefaults = require('../scatter/period_defaults'); var handleSampleDefaults = require('../histogram2d/sample_defaults'); var handleContoursDefaults = require('../contour/contours_defaults'); var handleStyleDefaults = require('../contour/style_defaults'); @@ -30,8 +29,6 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout handleSampleDefaults(traceIn, traceOut, coerce, layout); if(traceOut.visible === false) return; - handlePeriodDefaults(traceIn, traceOut, layout, coerce); - handleContoursDefaults(traceIn, traceOut, coerce, coerce2); handleStyleDefaults(traceIn, traceOut, coerce, layout); coerce('hovertemplate'); diff --git a/test/image/baselines/period_positioning2.png b/test/image/baselines/period_positioning2.png index 0e414d77290..6cf57840cfd 100644 Binary files a/test/image/baselines/period_positioning2.png and b/test/image/baselines/period_positioning2.png differ diff --git a/test/image/mocks/period_positioning2.json b/test/image/mocks/period_positioning2.json index 727773b4fa4..cca89c9a473 100644 --- a/test/image/mocks/period_positioning2.json +++ b/test/image/mocks/period_positioning2.json @@ -1,37 +1,5 @@ - - { "data": [ - { - "xaxis": "x", - "yaxis": "y", - "name": "histogram(v)", - "type": "histogram", - "x": [ - "2001-01-01", - "2002-01-01", "2002-01-01", - "2003-01-01", "2003-01-01", "2003-01-01", - "2004-01-01", "2004-01-01", "2004-01-01", "2004-01-01" - ], - "xperiod": "M12", - "xperiodalignment": "middle" - }, - - { - "xaxis": "x2", - "yaxis": "y2", - "name": "histogram(h)", - "type": "histogram", - "y": [ - "2001-01-01", - "2002-01-01", "2002-01-01", - "2003-01-01", "2003-01-01", "2003-01-01", - "2004-01-01", "2004-01-01", "2004-01-01", "2004-01-01" - ], - "yperiod": "M12", - "yperiodalignment": "middle" - }, - { "xaxis": "x", "yaxis": "y", @@ -47,8 +15,8 @@ }, { - "xaxis": "x3", - "yaxis": "y3", + "xaxis": "x2", + "yaxis": "y2", "name": "candlestick", "type": "candlestick", "low": [0, 0, 0, 0], @@ -86,94 +54,10 @@ "upperfence": [2, 4, 6, 8], "yperiod": "M12", "yperiodalignment": "middle" - }, - - { - "xaxis": "x5", - "yaxis": "y5", - "name": "histogram2d", - "type": "histogram2d", - "zsmooth": "best", - "showscale": false, - "showlegend": true, - "x": [ - "2001-01-01", - "2002-01-01", "2002-01-01", - "2003-01-01", "2003-01-01", "2003-01-01", - "2004-01-01", "2004-01-01", "2004-01-01", "2004-01-01" - ], - "y": [ - "2001-01-01", - "2002-01-01", "2002-01-01", - "2003-01-01", "2003-01-01", "2003-01-01", - "2004-01-01", "2004-01-01", "2004-01-01", "2004-01-01" - ], - "z": [ - 1, 2, 3, 4, - 5, 6, 7, 8, - 9, 10, 11, 12, - 13, 14, 15, 16 - ], - "xbins": { - "start": "2001-01-01", - "end": "2005-01-01", - "size": 31557600000 - }, - "ybins": { - "start": "2001-01-01", - "end": "2005-01-01", - "size": 31557600000 - }, - "xperiod": "M12", - "xperiodalignment": "middle", - "yperiod": "M12", - "yperiodalignment": "middle" - }, - - { - "xaxis": "x6", - "yaxis": "y6", - "name": "hist2dcontour", - "type": "histogram2dcontour", - "colorscale": "Portland", - "showscale": false, - "showlegend": true, - "x": [ - "2001-01-01", - "2002-01-01", "2002-01-01", - "2003-01-01", "2003-01-01", "2003-01-01", - "2004-01-01", "2004-01-01", "2004-01-01", "2004-01-01" - ], - "y": [ - "2001-01-01", - "2002-01-01", "2002-01-01", - "2003-01-01", "2003-01-01", "2003-01-01", - "2004-01-01", "2004-01-01", "2004-01-01", "2004-01-01" - ], - "z": [ - 1, 2, 3, 4, - 5, 6, 7, 8, - 9, 10, 11, 12, - 13, 14, 15, 16 - ], - "xbins": { - "start": "2001-01-01", - "end": "2005-01-01", - "size": 31557600000 - }, - "ybins": { - "start": "2001-01-01", - "end": "2005-01-01", - "size": 31557600000 - }, - "xperiod": "M12", - "xperiodalignment": "middle", - "yperiod": "M12", - "yperiodalignment": "middle" } ], "layout": { - "width": 1000, + "width": 700, "height": 500, "showlegend": true, "hovermode": "closest", @@ -184,15 +68,16 @@ "tickcolor": "black", "domain": [ 0, - 0.3 + 0.45 ] }, "xaxis2": { + "rangeslider": {"visible": false}, "tickcolor": "black", "anchor": "y2", "domain": [ 0, - 0.3 + 0.45 ] }, "xaxis3": { @@ -201,33 +86,15 @@ "tickcolor": "black", "anchor": "y3", "domain": [ - 0.35, - 0.65 + 0.55, + 1 ] }, "xaxis4": { "tickcolor": "black", "anchor": "y4", "domain": [ - 0.35, - 0.65 - ] - }, - "xaxis5": { - "ticklabelmode": "period", - "tickcolor": "black", - "anchor": "y5", - "domain": [ - 0.7, - 1 - ] - }, - "xaxis6": { - "ticklabelmode": "period", - "tickcolor": "black", - "anchor": "y6", - "domain": [ - 0.7, + 0.55, 1 ] }, @@ -264,24 +131,6 @@ 0.55, 1 ] - }, - "yaxis5": { - "ticklabelmode": "period", - "tickcolor": "black", - "anchor": "x5", - "domain": [ - 0, - 0.45 - ] - }, - "yaxis6": { - "ticklabelmode": "period", - "tickcolor": "black", - "anchor": "x6", - "domain": [ - 0.55, - 1 - ] } } } diff --git a/test/jasmine/tests/hover_label_test.js b/test/jasmine/tests/hover_label_test.js index f550a5b625a..8bf58daf414 100644 --- a/test/jasmine/tests/hover_label_test.js +++ b/test/jasmine/tests/hover_label_test.js @@ -2835,7 +2835,7 @@ describe('hover on traces with (x|y)period positioning', function() { .then(done); }); - it('shows hover info for box, ohlc, candlestick, histogram, histogram2d and histogram2dcontour traces', function(done) { + it('shows hover info for box, ohlc, candlestick traces', function(done) { Plotly.newPlot(gd, require('@mocks/period_positioning2.json')) .then(function() { _hover(110, 390); }) .then(function() { @@ -2863,35 +2863,7 @@ describe('hover on traces with (x|y)period positioning', function() { ].join('\n') }); }) - .then(function() { _hover(110, 410); }) - .then(function() { - assertHoverLabelContent({ - name: 'histogram(v)', - nums: '(Jan 2001, 1)' - }); - }) - .then(function() { _hover(290, 410); }) - .then(function() { - assertHoverLabelContent({ - name: 'histogram(v)', - nums: '(Jan 2004, 4)' - }); - }) - .then(function() { _hover(100, 230); }) - .then(function() { - assertHoverLabelContent({ - name: 'histogram(h)', - nums: '(1, Jan 2001)' - }); - }) - .then(function() { _hover(100, 120); }) - .then(function() { - assertHoverLabelContent({ - name: 'histogram(h)', - nums: '(4, Jan 2004)' - }); - }) - .then(function() { _hover(565, 355); }) + .then(function() { _hover(290, 120); }) .then(function() { assertHoverLabelContent({ name: 'candlestick', @@ -2930,28 +2902,6 @@ describe('hover on traces with (x|y)period positioning', function() { ] }); }) - .then(function() { _hover(665, 365); }) - .then(function() { - assertHoverLabelContent({ - name: 'histogram2d', - nums: [ - 'x: Jan 2001', - 'y: Jan 2002', - 'z: 0' - ].join('\n') - }); - }) - .then(function() { _hover(800, 150); }) - .then(function() { - assertHoverLabelContent({ - name: 'hist2dcontour', - nums: [ - 'x: Jan 2003', - 'y: Jan 2003', - 'z: 3' - ].join('\n') - }); - }) .catch(failTest) .then(done);