diff --git a/src/plots/cartesian/axes.js b/src/plots/cartesian/axes.js index a026da98b2e..4d69a881431 100644 --- a/src/plots/cartesian/axes.js +++ b/src/plots/cartesian/axes.js @@ -611,31 +611,43 @@ axes.calcTicks = function calcTicks(ax) { generateTicks(); if(ax.rangebreaks) { - var nTicksBefore = tickVals.length; + // replace ticks inside breaks that would get a tick + if(ax.tickmode === 'auto') { + for(var t = 0; t < tickVals.length; t++) { + var value = tickVals[t].value; + if(ax.maskBreaks(value) === BADNUM) { + // find which break we are in + for(var k = 0; k < ax._rangebreaks.length; k++) { + var brk = ax._rangebreaks[k]; + if(value >= brk.min && value < brk.max) { + tickVals[t]._realV = tickVals[t].value; + tickVals[t].value = brk.max; // replace with break end + break; + } + } + } + } + } - // remove ticks falling inside rangebreaks - tickVals = tickVals.filter(function(d) { - return ax.maskBreaks(d.value) !== BADNUM; - }); + // reduce ticks + var len = tickVals.length; + if(len > 2) { + var tf2 = 2 * (ax.tickfont ? ax.tickfont.size : 12); - // if 'numerous' ticks get placed into rangebreaks, - // increase dtick to generate more ticks, - // so that some hopefully fall between rangebreaks - if(ax.tickmode === 'auto' && tickVals.length < nTicksBefore / 6) { - axes.autoTicks(ax, ax._roughDTick / 3); - autoTickRound(ax); - ax._tmin = axes.tickFirst(ax); - generateTicks(); - tickVals = tickVals.filter(function(d) { - return ax.maskBreaks(d.value) !== BADNUM; - }); - } + var newTickVals = []; + var prevPos; - // remove "overlapping" ticks (e.g. on either side of a break) - var tf2 = ax.tickfont ? 1.5 * ax.tickfont.size : 0; - tickVals = tickVals.filter(function(d, i, self) { - return !(i && Math.abs(ax.c2p(d.value) - ax.c2p(self[i - 1].value)) < tf2); - }); + var signAx = axrev ? -1 : 1; + for(var q = axrev ? 0 : len - 1; signAx * q >= signAx * (axrev ? len - 1 : 0); q -= signAx) { // apply reverse loop to pick greater values in breaks first + var pos = ax.c2p(tickVals[q].value); + + if(prevPos === undefined || Math.abs(pos - prevPos) > tf2) { + prevPos = pos; + newTickVals.push(tickVals[q]); + } + } + tickVals = newTickVals.reverse(); + } } // If same angle over a full circle, the last tick vals is a duplicate. @@ -663,6 +675,16 @@ axes.calcTicks = function calcTicks(ax) { false, // hover tickVals[i].minor // noSuffixPrefix ); + + if(tickVals[i]._realV) { + // correct label + ticksOut[i].text = axes.tickText( + ax, + tickVals[i]._realV, + false, // hover + tickVals[i].minor // noSuffixPrefix + ).text; + } } ax._inCalcTicks = false; diff --git a/test/image/baselines/axes_breaks-finance.png b/test/image/baselines/axes_breaks-finance.png index b1d0bf56e9f..3242ac1ae8f 100644 Binary files a/test/image/baselines/axes_breaks-finance.png and b/test/image/baselines/axes_breaks-finance.png differ diff --git a/test/image/baselines/axes_breaks-gridlines.png b/test/image/baselines/axes_breaks-gridlines.png new file mode 100644 index 00000000000..af5f4fd649c Binary files /dev/null and b/test/image/baselines/axes_breaks-gridlines.png differ diff --git a/test/image/baselines/axes_breaks-night_autorange-reversed.png b/test/image/baselines/axes_breaks-night_autorange-reversed.png index 2c3e3e4536d..a60758be941 100644 Binary files a/test/image/baselines/axes_breaks-night_autorange-reversed.png and b/test/image/baselines/axes_breaks-night_autorange-reversed.png differ diff --git a/test/image/baselines/axes_breaks-rangeslider.png b/test/image/baselines/axes_breaks-rangeslider.png index 92d31fef552..a71f3fbdd24 100644 Binary files a/test/image/baselines/axes_breaks-rangeslider.png and b/test/image/baselines/axes_breaks-rangeslider.png differ diff --git a/test/image/baselines/axes_breaks-weekends-weeknights.png b/test/image/baselines/axes_breaks-weekends-weeknights.png index 270bf568e4f..51673357cab 100644 Binary files a/test/image/baselines/axes_breaks-weekends-weeknights.png and b/test/image/baselines/axes_breaks-weekends-weeknights.png differ diff --git a/test/image/baselines/axes_breaks-weekends_autorange-reversed.png b/test/image/baselines/axes_breaks-weekends_autorange-reversed.png index 3c36378c7c2..33a32e12aa6 100644 Binary files a/test/image/baselines/axes_breaks-weekends_autorange-reversed.png and b/test/image/baselines/axes_breaks-weekends_autorange-reversed.png differ diff --git a/test/image/baselines/axes_breaks.png b/test/image/baselines/axes_breaks.png index 0b819065907..9c05a8f6e7e 100644 Binary files a/test/image/baselines/axes_breaks.png and b/test/image/baselines/axes_breaks.png differ diff --git a/test/image/mocks/axes_breaks-gridlines.json b/test/image/mocks/axes_breaks-gridlines.json new file mode 100644 index 00000000000..3502147b129 --- /dev/null +++ b/test/image/mocks/axes_breaks-gridlines.json @@ -0,0 +1,1042 @@ +{ + "data": [ + { + "type": "scatter", + "mode": "markers", + "name": "AAPL High", + "x": [ + "2015-02-17", + "2015-02-18", + "2015-02-19", + "2015-02-20", + "2015-02-23", + "2015-02-24", + "2015-02-25", + "2015-02-26", + "2015-02-27", + "2015-03-02", + "2015-03-03", + "2015-03-04", + "2015-03-05", + "2015-03-06", + "2015-03-09", + "2015-03-10", + "2015-03-11", + "2015-03-12", + "2015-03-13", + "2015-03-16", + "2015-03-17", + "2015-03-18", + "2015-03-19", + "2015-03-20", + "2015-03-23", + "2015-03-24", + "2015-03-25", + "2015-03-26", + "2015-03-27", + "2015-03-30", + "2015-03-31", + "2015-04-01", + "2015-04-02", + "2015-04-06", + "2015-04-07", + "2015-04-08", + "2015-04-09", + "2015-04-10", + "2015-04-13", + "2015-04-14", + "2015-04-15", + "2015-04-16", + "2015-04-17", + "2015-04-20", + "2015-04-21", + "2015-04-22", + "2015-04-23", + "2015-04-24", + "2015-04-27", + "2015-04-28", + "2015-04-29", + "2015-04-30", + "2015-05-01", + "2015-05-04", + "2015-05-05", + "2015-05-06", + "2015-05-07", + "2015-05-08", + "2015-05-11", + "2015-05-12", + "2015-05-13", + "2015-05-14", + "2015-05-15", + "2015-05-18", + "2015-05-19", + "2015-05-20", + "2015-05-21", + "2015-05-22", + "2015-05-26", + "2015-05-27", + "2015-05-28", + "2015-05-29", + "2015-06-01", + "2015-06-02", + "2015-06-03", + "2015-06-04", + "2015-06-05", + "2015-06-08", + "2015-06-09", + "2015-06-10", + "2015-06-11", + "2015-06-12", + "2015-06-15", + "2015-06-16", + "2015-06-17", + "2015-06-18", + "2015-06-19", + "2015-06-22", + "2015-06-23", + "2015-06-24", + "2015-06-25", + "2015-06-26", + "2015-06-29", + "2015-06-30", + "2015-07-01", + "2015-07-02", + "2015-07-06", + "2015-07-07", + "2015-07-08", + "2015-07-09", + "2015-07-10", + "2015-07-13", + "2015-07-14", + "2015-07-15", + "2015-07-16", + "2015-07-17", + "2015-07-20", + "2015-07-21", + "2015-07-22", + "2015-07-23", + "2015-07-24", + "2015-07-27", + "2015-07-28", + "2015-07-29", + "2015-07-30", + "2015-07-31", + "2015-08-03", + "2015-08-04", + "2015-08-05", + "2015-08-06", + "2015-08-07", + "2015-08-10", + "2015-08-11", + "2015-08-12", + "2015-08-13", + "2015-08-14", + "2015-08-17", + "2015-08-18", + "2015-08-19", + "2015-08-20", + "2015-08-21", + "2015-08-24", + "2015-08-25", + "2015-08-26", + "2015-08-27", + "2015-08-28", + "2015-08-31", + "2015-09-01", + "2015-09-02", + "2015-09-03", + "2015-09-04", + "2015-09-08", + "2015-09-09", + "2015-09-10", + "2015-09-11", + "2015-09-14", + "2015-09-15", + "2015-09-16", + "2015-09-17", + "2015-09-18", + "2015-09-21", + "2015-09-22", + "2015-09-23", + "2015-09-24", + "2015-09-25", + "2015-09-28", + "2015-09-29", + "2015-09-30", + "2015-10-01", + "2015-10-02", + "2015-10-05", + "2015-10-06", + "2015-10-07", + "2015-10-08", + "2015-10-09", + "2015-10-12", + "2015-10-13", + "2015-10-14", + "2015-10-15", + "2015-10-16", + "2015-10-19", + "2015-10-20", + "2015-10-21", + "2015-10-22", + "2015-10-23", + "2015-10-26", + "2015-10-27", + "2015-10-28", + "2015-10-29", + "2015-10-30", + "2015-11-02", + "2015-11-03", + "2015-11-04", + "2015-11-05", + "2015-11-06", + "2015-11-09", + "2015-11-10", + "2015-11-11", + "2015-11-12", + "2015-11-13", + "2015-11-16", + "2015-11-17", + "2015-11-18", + "2015-11-19", + "2015-11-20", + "2015-11-23", + "2015-11-24", + "2015-11-25", + "2015-11-27", + "2015-11-30", + "2015-12-01", + "2015-12-02", + "2015-12-03", + "2015-12-04", + "2015-12-07", + "2015-12-08", + "2015-12-09", + "2015-12-10", + "2015-12-11", + "2015-12-14", + "2015-12-15", + "2015-12-16", + "2015-12-17", + "2015-12-18", + "2015-12-21", + "2015-12-22", + "2015-12-23", + "2015-12-24", + "2015-12-28", + "2015-12-29", + "2015-12-30", + "2015-12-31", + "2016-01-04", + "2016-01-05", + "2016-01-06", + "2016-01-07", + "2016-01-08", + "2016-01-11", + "2016-01-12", + "2016-01-13", + "2016-01-14", + "2016-01-15", + "2016-01-19", + "2016-01-20", + "2016-01-21", + "2016-01-22", + "2016-01-25", + "2016-01-26", + "2016-01-27", + "2016-01-28", + "2016-01-29", + "2016-02-01", + "2016-02-02", + "2016-02-03", + "2016-02-04", + "2016-02-05", + "2016-02-08", + "2016-02-09", + "2016-02-10", + "2016-02-11", + "2016-02-12", + "2016-02-16", + "2016-02-17", + "2016-02-18", + "2016-02-19", + "2016-02-22", + "2016-02-23", + "2016-02-24", + "2016-02-25", + "2016-02-26", + "2016-02-29", + "2016-03-01", + "2016-03-02", + "2016-03-03", + "2016-03-04", + "2016-03-07", + "2016-03-08", + "2016-03-09", + "2016-03-10", + "2016-03-11", + "2016-03-14", + "2016-03-15", + "2016-03-16", + "2016-03-17", + "2016-03-18", + "2016-03-21", + "2016-03-22", + "2016-03-23", + "2016-03-24", + "2016-03-28", + "2016-03-29", + "2016-03-30", + "2016-03-31", + "2016-04-01", + "2016-04-04", + "2016-04-05", + "2016-04-06", + "2016-04-07", + "2016-04-08", + "2016-04-11", + "2016-04-12", + "2016-04-13", + "2016-04-14", + "2016-04-15", + "2016-04-18", + "2016-04-19", + "2016-04-20", + "2016-04-21", + "2016-04-22", + "2016-04-25", + "2016-04-26", + "2016-04-27", + "2016-04-28", + "2016-04-29", + "2016-05-02", + "2016-05-03", + "2016-05-04", + "2016-05-05", + "2016-05-06", + "2016-05-09", + "2016-05-10", + "2016-05-11", + "2016-05-12", + "2016-05-13", + "2016-05-16", + "2016-05-17", + "2016-05-18", + "2016-05-19", + "2016-05-20", + "2016-05-23", + "2016-05-24", + "2016-05-25", + "2016-05-26", + "2016-05-27", + "2016-05-31", + "2016-06-01", + "2016-06-02", + "2016-06-03", + "2016-06-06", + "2016-06-07", + "2016-06-08", + "2016-06-09", + "2016-06-10", + "2016-06-13", + "2016-06-14", + "2016-06-15", + "2016-06-16", + "2016-06-17", + "2016-06-20", + "2016-06-21", + "2016-06-22", + "2016-06-23", + "2016-06-24", + "2016-06-27", + "2016-06-28", + "2016-06-29", + "2016-06-30", + "2016-07-01", + "2016-07-05", + "2016-07-06", + "2016-07-07", + "2016-07-08", + "2016-07-11", + "2016-07-12", + "2016-07-13", + "2016-07-14", + "2016-07-15", + "2016-07-18", + "2016-07-19", + "2016-07-20", + "2016-07-21", + "2016-07-22", + "2016-07-25", + "2016-07-26", + "2016-07-27", + "2016-07-28", + "2016-07-29", + "2016-08-01", + "2016-08-02", + "2016-08-03", + "2016-08-04", + "2016-08-05", + "2016-08-08", + "2016-08-09", + "2016-08-10", + "2016-08-11", + "2016-08-12", + "2016-08-15", + "2016-08-16", + "2016-08-17", + "2016-08-18", + "2016-08-19", + "2016-08-22", + "2016-08-23", + "2016-08-24", + "2016-08-25", + "2016-08-26", + "2016-08-29", + "2016-08-30", + "2016-08-31", + "2016-09-01", + "2016-09-02", + "2016-09-06", + "2016-09-07", + "2016-09-08", + "2016-09-09", + "2016-09-12", + "2016-09-13", + "2016-09-14", + "2016-09-15", + "2016-09-16", + "2016-09-19", + "2016-09-20", + "2016-09-21", + "2016-09-22", + "2016-09-23", + "2016-09-26", + "2016-09-27", + "2016-09-28", + "2016-09-29", + "2016-09-30", + "2016-10-03", + "2016-10-04", + "2016-10-05", + "2016-10-06", + "2016-10-07", + "2016-10-10", + "2016-10-11", + "2016-10-12", + "2016-10-13", + "2016-10-14", + "2016-10-17", + "2016-10-18", + "2016-10-19", + "2016-10-20", + "2016-10-21", + "2016-10-24", + "2016-10-25", + "2016-10-26", + "2016-10-27", + "2016-10-28", + "2016-10-31", + "2016-11-01", + "2016-11-02", + "2016-11-03", + "2016-11-04", + "2016-11-07", + "2016-11-08", + "2016-11-09", + "2016-11-10", + "2016-11-11", + "2016-11-14", + "2016-11-15", + "2016-11-16", + "2016-11-17", + "2016-11-18", + "2016-11-21", + "2016-11-22", + "2016-11-23", + "2016-11-25", + "2016-11-28", + "2016-11-29", + "2016-11-30", + "2016-12-01", + "2016-12-02", + "2016-12-05", + "2016-12-06", + "2016-12-07", + "2016-12-08", + "2016-12-09", + "2016-12-12", + "2016-12-13", + "2016-12-14", + "2016-12-15", + "2016-12-16", + "2016-12-19", + "2016-12-20", + "2016-12-21", + "2016-12-22", + "2016-12-23", + "2016-12-27", + "2016-12-28", + "2016-12-29", + "2016-12-30", + "2017-01-03", + "2017-01-04", + "2017-01-05", + "2017-01-06", + "2017-01-09", + "2017-01-10", + "2017-01-11", + "2017-01-12", + "2017-01-13", + "2017-01-17", + "2017-01-18", + "2017-01-19", + "2017-01-20", + "2017-01-23", + "2017-01-24", + "2017-01-25", + "2017-01-26", + "2017-01-27", + "2017-01-30", + "2017-01-31", + "2017-02-01", + "2017-02-02", + "2017-02-03", + "2017-02-06", + "2017-02-07", + "2017-02-08", + "2017-02-09", + "2017-02-10", + "2017-02-13", + "2017-02-14", + "2017-02-15", + "2017-02-16" + ], + "y": [ + "128.880005", + "128.779999", + "129.029999", + "129.5", + "133", + "133.600006", + "131.600006", + "130.869995", + "130.570007", + "130.279999", + "129.520004", + "129.559998", + "128.75", + "129.369995", + "129.570007", + "127.220001", + "124.769997", + "124.900002", + "125.400002", + "124.949997", + "127.32", + "129.160004", + "129.25", + "128.399994", + "127.849998", + "128.039993", + "126.82", + "124.879997", + "124.699997", + "126.400002", + "126.489998", + "125.120003", + "125.559998", + "127.510002", + "128.119995", + "126.400002", + "126.580002", + "127.209999", + "128.570007", + "127.290001", + "127.129997", + "127.099998", + "126.139999", + "128.119995", + "128.199997", + "128.869995", + "130.419998", + "130.630005", + "133.130005", + "134.539993", + "131.589996", + "128.639999", + "130.130005", + "130.570007", + "128.449997", + "126.75", + "126.080002", + "127.620003", + "127.559998", + "126.879997", + "127.190002", + "128.949997", + "129.490005", + "130.720001", + "130.880005", + "130.979996", + "131.630005", + "132.970001", + "132.910004", + "132.259995", + "131.949997", + "131.449997", + "131.389999", + "130.660004", + "130.940002", + "130.580002", + "129.690002", + "129.210007", + "128.080002", + "129.339996", + "130.179993", + "128.330002", + "127.239998", + "127.849998", + "127.879997", + "128.309998", + "127.82", + "128.059998", + "127.610001", + "129.800003", + "129.199997", + "127.989998", + "126.470001", + "126.120003", + "126.940002", + "126.690002", + "126.230003", + "126.150002", + "124.639999", + "124.059998", + "123.849998", + "125.760002", + "126.370003", + "127.150002", + "128.570007", + "129.619995", + "132.970001", + "132.919998", + "125.5", + "127.089996", + "125.739998", + "123.610001", + "123.910004", + "123.5", + "122.57", + "122.639999", + "122.57", + "117.699997", + "117.440002", + "116.5", + "116.25", + "119.989998", + "118.18", + "115.419998", + "116.400002", + "116.309998", + "117.650002", + "117.440002", + "116.519997", + "114.349998", + "111.900002", + "108.800003", + "111.110001", + "109.889999", + "113.239998", + "113.309998", + "114.529999", + "111.879997", + "112.339996", + "112.779999", + "110.449997", + "112.559998", + "114.019997", + "113.279999", + "114.209999", + "116.889999", + "116.529999", + "116.540001", + "116.489998", + "114.300003", + "115.370003", + "114.18", + "114.720001", + "115.5", + "116.690002", + "114.57", + "113.510002", + "111.540001", + "109.620003", + "111.010002", + "111.370003", + "111.739998", + "111.769997", + "110.190002", + "112.279999", + "112.75", + "112.449997", + "111.519997", + "112.099998", + "112", + "111.75", + "114.169998", + "115.580002", + "115.5", + "119.230003", + "118.129997", + "116.540001", + "119.300003", + "120.690002", + "121.220001", + "121.360001", + "123.489998", + "123.82", + "122.690002", + "121.809998", + "121.809998", + "118.07", + "117.419998", + "116.82", + "115.57", + "114.239998", + "115.050003", + "117.489998", + "119.75", + "119.919998", + "119.730003", + "119.349998", + "119.230003", + "118.410004", + "119.410004", + "118.809998", + "118.110001", + "116.790001", + "119.25", + "119.860001", + "118.599998", + "117.690002", + "116.940002", + "115.389999", + "112.68", + "112.800003", + "111.989998", + "112.25", + "109.519997", + "107.370003", + "107.720001", + "108.849998", + "109", + "107.690002", + "109.43", + "108.699997", + "107.029999", + "105.370003", + "105.849998", + "102.370003", + "100.129997", + "99.110001", + "99.059998", + "100.690002", + "101.190002", + "100.480003", + "97.709999", + "98.650002", + "98.190002", + "97.879997", + "101.459999", + "101.529999", + "100.879997", + "96.629997", + "94.519997", + "97.339996", + "96.709999", + "96.040001", + "96.839996", + "97.330002", + "96.919998", + "95.699997", + "95.940002", + "96.349998", + "94.720001", + "94.5", + "96.849998", + "98.209999", + "98.889999", + "96.760002", + "96.900002", + "96.5", + "96.379997", + "96.760002", + "98.019997", + "98.230003", + "100.769997", + "100.889999", + "101.709999", + "103.75", + "102.830002", + "101.760002", + "101.580002", + "102.239998", + "102.279999", + "102.910004", + "105.18", + "106.309998", + "106.470001", + "106.5", + "107.650002", + "107.290001", + "107.07", + "106.25", + "106.190002", + "107.790001", + "110.419998", + "109.900002", + "110", + "112.190002", + "110.730003", + "110.980003", + "110.419998", + "109.769997", + "110.610001", + "110.5", + "112.339996", + "112.389999", + "112.300003", + "108.949997", + "108", + "108.089996", + "106.93", + "106.480003", + "105.650002", + "105.300003", + "98.709999", + "97.879997", + "94.720001", + "94.080002", + "95.739998", + "95.900002", + "94.07", + "93.449997", + "93.769997", + "93.57", + "93.57", + "92.779999", + "91.669998", + "94.389999", + "94.699997", + "95.209999", + "94.639999", + "95.43", + "97.190002", + "98.089996", + "99.739998", + "100.730003", + "100.470001", + "100.400002", + "99.540001", + "97.839996", + "98.269997", + "101.889999", + "99.870003", + "99.559998", + "99.989998", + "99.349998", + "99.120003", + "98.480003", + "98.410004", + "97.75", + "96.650002", + "96.57", + "96.349998", + "96.889999", + "96.290001", + "94.660004", + "93.050003", + "93.660004", + "94.550003", + "95.769997", + "96.470001", + "95.400002", + "95.660004", + "96.5", + "96.889999", + "97.650002", + "97.699997", + "97.669998", + "98.989998", + "99.300003", + "100.129997", + "100", + "100.459999", + "101", + "99.300003", + "98.839996", + "97.970001", + "104.349998", + "104.449997", + "104.550003", + "106.150002", + "106.07", + "105.839996", + "106", + "107.650002", + "108.370003", + "108.940002", + "108.900002", + "108.93", + "108.440002", + "109.540001", + "110.230003", + "109.370003", + "109.599998", + "109.690002", + "109.099998", + "109.32", + "108.75", + "107.879997", + "107.949997", + "107.440002", + "106.5", + "106.57", + "106.800003", + "108", + "108.300003", + "108.760002", + "107.269997", + "105.720001", + "105.720001", + "108.790001", + "113.029999", + "115.730003", + "116.129997", + "116.18", + "114.120003", + "113.989998", + "114.940002", + "114.790001", + "113.389999", + "113.18", + "114.639999", + "113.800003", + "113.370003", + "113.050003", + "114.309998", + "113.660004", + "114.339996", + "114.559998", + "116.75", + "118.690002", + "117.980003", + "117.440002", + "118.169998", + "117.839996", + "118.209999", + "117.760002", + "117.379997", + "116.910004", + "117.739998", + "118.360001", + "115.699997", + "115.860001", + "115.209999", + "114.230003", + "113.769997", + "112.349998", + "111.459999", + "110.25", + "110.510002", + "111.720001", + "111.32", + "111.089996", + "108.870003", + "107.809998", + "107.68", + "110.230003", + "110.349998", + "110.540001", + "111.989998", + "112.419998", + "111.510002", + "111.870003", + "112.470001", + "112.029999", + "112.199997", + "110.940002", + "110.089996", + "110.029999", + "110.360001", + "111.190002", + "112.43", + "114.699997", + "115", + "115.919998", + "116.199997", + "116.730003", + "116.5", + "117.379997", + "117.5", + "117.400002", + "116.510002", + "116.519997", + "117.800003", + "118.019997", + "117.110001", + "117.199997", + "116.330002", + "116.510002", + "116.860001", + "118.160004", + "119.43", + "119.379997", + "119.93", + "119.300003", + "119.620003", + "120.239998", + "120.5", + "120.089996", + "120.449997", + "120.809998", + "120.099998", + "122.099998", + "122.440002", + "122.349998", + "121.629997", + "121.389999", + "130.490005", + "129.389999", + "129.190002", + "130.5", + "132.089996", + "132.220001", + "132.449997", + "132.940002", + "133.820007", + "135.089996", + "136.270004", + "135.899994" + ] + } + ], + "layout": { + "width": 800, + "height": 400, + "title": { + "text": "Time Series Without Weekends" + }, + "xaxis": { + "rangebreaks": [ + { + "bounds": [ + "sat", + "mon" + ] + } + ] + } + } +} diff --git a/test/jasmine/tests/axes_test.js b/test/jasmine/tests/axes_test.js index 94887094815..d2ef43bcf5b 100644 --- a/test/jasmine/tests/axes_test.js +++ b/test/jasmine/tests/axes_test.js @@ -4963,7 +4963,7 @@ describe('Test axes', function() { .withContext(msg).toEqual(exp.tickVals); } - it('should not include ticks that fall within rangebreaks', function(done) { + it('should include requested ticks that fall within rangebreaks', function(done) { Plotly.plot(gd, [{ x: [ '1970-01-01 00:00:00.000', @@ -4977,7 +4977,7 @@ describe('Test axes', function() { ] }], { xaxis: {}, - width: 500, + width: 800, height: 400 }) .then(function() { @@ -5002,49 +5002,7 @@ describe('Test axes', function() { }) .then(function() { _assert('with two rangebreaks', { - tickVals: [0, 10, 100, 200] - }); - }) - .catch(failTest) - .then(done); - }); - - it('should increase dtick when too many (auto) ticks fall into rangebreaks', function(done) { - var fig = Lib.extendDeep({}, require('@mocks/axes_breaks-finance.json')); - // break over weekend - fig.layout.xaxis.rangebreaks[0].enabled = false; - // break on a single holiday - fig.layout.xaxis.rangebreaks[1].enabled = false; - - Plotly.plot(gd, fig) - .then(function() { - _assert('base', { - tickVals: [1483833600000, 1485043200000, 1486252800000] - }); - }) - .then(function() { - gd.layout.xaxis.rangebreaks[0].enabled = true; - gd.layout.xaxis.rangebreaks[1].enabled = true; - return Plotly.react(gd, gd.data, gd.layout); - }) - .then(function() { - _assert('with rangebreaks enabled on x-axis', { - tickVals: [ - 1483574400000, 1484092800000, 1484611200000, 1484870400000, - 1485388800000, 1485907200000, 1486425600000, 1486684800000 - ] - }); - }) - .then(function() { - // a Saturday - gd.layout.xaxis.tick0 = '2017-01-02'; - // one week - gd.layout.xaxis.dtick = 7 + 24 * 60 * 60 * 1000; - return Plotly.react(gd, gd.data, gd.layout); - }) - .then(function() { - _assert('honor set tick0/dtick even though they result in few visible ticks', { - tickVals: [1483488000014] + tickVals: [0, 5, 10, 90, 95, 100, 190, 195, 200] }); }) .catch(failTest) diff --git a/test/jasmine/tests/cartesian_interact_test.js b/test/jasmine/tests/cartesian_interact_test.js index 8016d86f4b1..e3f2ea51cb6 100644 --- a/test/jasmine/tests/cartesian_interact_test.js +++ b/test/jasmine/tests/cartesian_interact_test.js @@ -2135,7 +2135,7 @@ describe('axis zoom/pan and main plot zoom', function() { '1970-01-01 00:00:00.2019' ]); }) - .then(doDrag('xy', 'nsew', 0, 50)) + .then(doDrag('xy', 'nsew', 0, -50)) // y range would be ~ [62, 100] w/o rangebreaks .then(function() { _assert('after y-only zoombox', [ @@ -2151,7 +2151,7 @@ describe('axis zoom/pan and main plot zoom', function() { ]); }) .then(function() { return Plotly.relayout(gd, 'dragmode', 'pan'); }) - .then(doDrag('xy', 'nsew', 0, 50)) + .then(doDrag('xy', 'nsew', 0, -50)) // y range would be ~ [35, 239] w/o rangebreaks .then(function() { _assert('after y-only pan', [