diff --git a/src/plots/cartesian/tick_value_defaults.js b/src/plots/cartesian/tick_value_defaults.js index 09082a09b31..8f662757140 100644 --- a/src/plots/cartesian/tick_value_defaults.js +++ b/src/plots/cartesian/tick_value_defaults.js @@ -11,14 +11,25 @@ var cleanTicks = require('./clean_ticks'); module.exports = function handleTickValueDefaults(containerIn, containerOut, coerce, axType) { + function readInput(attr) { + var v = containerIn[attr]; + return ( + v !== undefined + ) ? v : (containerOut._template || {})[attr]; + } + + var _tick0 = readInput('tick0'); + var _dtick = readInput('dtick'); + var _tickvals = readInput('tickvals'); + var _tickmode = readInput('tickmode'); var tickmode; - if(containerIn.tickmode === 'array' && + if(_tickmode === 'array' && (axType === 'log' || axType === 'date')) { tickmode = containerOut.tickmode = 'auto'; } else { - var tickmodeDefault = Array.isArray(containerIn.tickvals) ? 'array' : - containerIn.dtick ? 'linear' : + var tickmodeDefault = Array.isArray(_tickvals) ? 'array' : + _dtick ? 'linear' : 'auto'; tickmode = coerce('tickmode', tickmodeDefault); } @@ -29,9 +40,9 @@ module.exports = function handleTickValueDefaults(containerIn, containerOut, coe // special strings available for log or date axes // tick0 also has special logic var dtick = containerOut.dtick = cleanTicks.dtick( - containerIn.dtick, axType); + _dtick, axType); containerOut.tick0 = cleanTicks.tick0( - containerIn.tick0, axType, containerOut.calendar, dtick); + _tick0, axType, containerOut.calendar, dtick); } else if(axType !== 'multicategory') { var tickvals = coerce('tickvals'); if(tickvals === undefined) containerOut.tickmode = 'auto';