Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rename axis.breaks to axis.rangebreaks #4641

Merged
merged 2 commits into from
Mar 14, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/components/rangeslider/draw.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ module.exports = function(gd) {
return (v - rl0) / drl * opts._width;
};

if(axisOpts.breaks) {
if(axisOpts.rangebreaks) {
var rsBreaks = axisOpts.locateBreaks(rl0, rl1);

if(rsBreaks.length) {
Expand Down Expand Up @@ -169,7 +169,7 @@ module.exports = function(gd) {
};

// fill pixel (i.e. 'p') min/max here,
// to not have to loop through the _breaks twice during `p2d`
// to not have to loop through the _rangebreaks twice during `p2d`
for(j = 0; j < rsBreaks.length; j++) {
brk = rsBreaks[j];
brk.pmin = opts.d2p(brk.min);
Expand Down Expand Up @@ -455,8 +455,8 @@ function drawRangePlot(rangeSlider, gd, axisOpts, opts) {
_context: gd._context
};

if(axisOpts.breaks) {
mockFigure.layout.xaxis.breaks = axisOpts.breaks;
if(axisOpts.rangebreaks) {
mockFigure.layout.xaxis.rangebreaks = axisOpts.rangebreaks;
}

mockFigure.layout[oppAxisName] = {
Expand All @@ -466,8 +466,8 @@ function drawRangePlot(rangeSlider, gd, axisOpts, opts) {
calendar: oppAxisOpts.calendar
};

if(oppAxisOpts.breaks) {
mockFigure.layout[oppAxisName].breaks = oppAxisOpts.breaks;
if(oppAxisOpts.rangebreaks) {
mockFigure.layout[oppAxisName].rangebreaks = oppAxisOpts.rangebreaks;
}

Plots.supplyDefaults(mockFigure);
Expand Down
10 changes: 5 additions & 5 deletions src/plots/cartesian/autorange.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,13 @@ function getAutoRange(gd, ax) {
// don't allow padding to reduce the data to < 10% of the length
var minSpan = axLen / 10;

// find axis breaks in [v0,v1] and compute its length in value space
// find axis rangebreaks in [v0,v1] and compute its length in value space
var calcBreaksLength = function(v0, v1) {
var lBreaks = 0;
if(ax.breaks) {
var breaksOut = ax.locateBreaks(v0, v1);
for(var i = 0; i < breaksOut.length; i++) {
var brk = breaksOut[i];
if(ax.rangebreaks) {
var rangebreaksOut = ax.locateBreaks(v0, v1);
for(var i = 0; i < rangebreaksOut.length; i++) {
var brk = rangebreaksOut[i];
lBreaks += brk.max - brk.min;
}
}
Expand Down
14 changes: 7 additions & 7 deletions src/plots/cartesian/axes.js
Original file line number Diff line number Diff line change
Expand Up @@ -610,17 +610,17 @@ axes.calcTicks = function calcTicks(ax) {

generateTicks();

if(ax.breaks) {
if(ax.rangebreaks) {
var nTicksBefore = tickVals.length;

// remove ticks falling inside breaks
// remove ticks falling inside rangebreaks
tickVals = tickVals.filter(function(d) {
return ax.maskBreaks(d.value) !== BADNUM;
});

// if 'numerous' ticks get placed into breaks,
// if 'numerous' ticks get placed into rangebreaks,
// increase dtick to generate more ticks,
// so that some hopefully fall between breaks
// so that some hopefully fall between rangebreaks
if(ax.tickmode === 'auto' && tickVals.length < nTicksBefore / 6) {
axes.autoTicks(ax, ax._roughDTick / 3);
autoTickRound(ax);
Expand Down Expand Up @@ -706,8 +706,8 @@ function arrayTicks(ax) {

if(j < vals.length) ticksOut.splice(j, vals.length - j);

if(ax.breaks) {
// remove ticks falling inside breaks
if(ax.rangebreaks) {
// remove ticks falling inside rangebreaks
ticksOut = ticksOut.filter(function(d) {
return ax.maskBreaks(d.x) !== BADNUM;
});
Expand Down Expand Up @@ -2871,7 +2871,7 @@ axes.shouldShowZeroLine = function(gd, ax, counterAxis) {
(rng[0] * rng[1] <= 0) &&
ax.zeroline &&
(ax.type === 'linear' || ax.type === '-') &&
!(ax.breaks && ax.maskBreaks(0) === BADNUM) &&
!(ax.rangebreaks && ax.maskBreaks(0) === BADNUM) &&
(
clipEnds(ax, 0) ||
!anyCounterAxLineAtZero(gd, ax, counterAxis, rng) ||
Expand Down
14 changes: 7 additions & 7 deletions src/plots/cartesian/axis_defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,12 @@ module.exports = function handleAxisDefaults(containerIn, containerOut, coerce,
}

if(containerOut.type === 'date') {
var breaks = containerIn.breaks;
if(Array.isArray(breaks) && breaks.length) {
var rangebreaks = containerIn.rangebreaks;
if(Array.isArray(rangebreaks) && rangebreaks.length) {
handleArrayContainerDefaults(containerIn, containerOut, {
name: 'breaks',
name: 'rangebreaks',
inclusionAttr: 'enabled',
handleItemDefaults: breaksDefaults
handleItemDefaults: rangebreaksDefaults
});
setConvert(containerOut, layoutOut);

Expand All @@ -135,7 +135,7 @@ module.exports = function handleAxisDefaults(containerIn, containerOut, coerce,
if(trace.type === 'scattergl' || trace.type === 'splom') {
trace.visible = false;
Lib.warn(trace.type +
' traces do not work on axes with breaks.' +
' traces do not work on axes with rangebreaks.' +
' Setting trace ' + trace.index + ' to `visible: false`.');
}
}
Expand All @@ -146,9 +146,9 @@ module.exports = function handleAxisDefaults(containerIn, containerOut, coerce,
return containerOut;
};

function breaksDefaults(itemIn, itemOut, containerOut) {
function rangebreaksDefaults(itemIn, itemOut, containerOut) {
function coerce(attr, dflt) {
return Lib.coerce(itemIn, itemOut, layoutAttributes.breaks, attr, dflt);
return Lib.coerce(itemIn, itemOut, layoutAttributes.rangebreaks, attr, dflt);
}

var enabled = coerce('enabled');
Expand Down
4 changes: 2 additions & 2 deletions src/plots/cartesian/dragbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -986,7 +986,7 @@ function zoomAxRanges(axList, r0Fraction, r1Fraction, updates, linkedAxes) {
var axi = axList[i];
if(axi.fixedrange) continue;

if(axi.breaks) {
if(axi.rangebreaks) {
var isY = axi._id.charAt(0) === 'y';
var r0F = isY ? (1 - r0Fraction) : r0Fraction;
var r1F = isY ? (1 - r1Fraction) : r1Fraction;
Expand All @@ -1012,7 +1012,7 @@ function dragAxList(axList, pix) {
for(var i = 0; i < axList.length; i++) {
var axi = axList[i];
if(!axi.fixedrange) {
if(axi.breaks) {
if(axi.rangebreaks) {
var p0 = 0;
var p1 = axi._length;
var d0 = axi.p2l(p0 + pix) - axi.p2l(p0);
Expand Down
24 changes: 12 additions & 12 deletions src/plots/cartesian/layout_attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -249,15 +249,15 @@ module.exports = {
].join(' ')
},

breaks: templatedArray('break', {
rangebreaks: templatedArray('rangebreak', {
enabled: {
valType: 'boolean',
role: 'info',
dflt: true,
editType: 'calc',
description: [
'Determines whether this axis break is enabled or disabled.',
'Please note that `breaks` only work for *date* axis type.'
'Determines whether this axis rangebreak is enabled or disabled.',
'Please note that `rangebreaks` only work for *date* axis type.'
].join(' ')
},

Expand All @@ -270,7 +270,7 @@ module.exports = {
],
editType: 'calc',
description: [
'Sets the lower and upper bounds of this axis break.',
'Sets the lower and upper bounds of this axis rangebreak.',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm somehow as a noun I'm ambivalent about it - probably I'd change the noun usages in descriptions back to break(s) but it's not as clear to me as when break is a verb...

'Can be used with `operation` to determine the behavior at the bounds.',
'Can be used with `pattern`.'
].join(' ')
Expand All @@ -284,17 +284,17 @@ module.exports = {
role: 'info',
editType: 'calc',
description: [
'Determines a pattern on the time line that generates breaks.',
'Determines a pattern on the time line that generates rangebreaks.',
alexcjohnson marked this conversation as resolved.
Show resolved Hide resolved
'If *%w* - Sunday-based weekday as a decimal number [0, 6].',
'If *%H* - hour (24-hour clock) as a decimal number [0, 23].',
'These are the same directive as in `tickformat`, see',
'https://github.com/d3/d3-time-format#locale_format',
'for more info.',
'Examples:',
'- { pattern: \'%w\', bounds: [6, 0], operation: \'[]\' }',
' breaks from Saturday to Monday (i.e. skips the weekends).',
' rangebreaks from Saturday to Monday (i.e. skips the weekends).',
alexcjohnson marked this conversation as resolved.
Show resolved Hide resolved
'- { pattern: \'%H\', bounds: [17, 8] }',
' breaks from 5pm to 8am (i.e. skips non-work hours).'
' rangebreaks from 5pm to 8am (i.e. skips non-work hours).'
alexcjohnson marked this conversation as resolved.
Show resolved Hide resolved
].join(' ')
},

Expand All @@ -308,7 +308,7 @@ module.exports = {
editType: 'calc'
},
description: [
'Sets the coordinate values corresponding to the breaks.',
'Sets the coordinate values corresponding to the rangebreaks.',
'An alternative to `bounds`.',
'Use `dvalue` to set the size of the values along the axis.'
].join(' ')
Expand All @@ -333,12 +333,12 @@ module.exports = {
role: 'info',
editType: 'calc',
description: [
'Determines if we include or not the bound values within the break.',
'Determines if we include or not the bound values within the rangebreak.',
'Closed interval bounds (i.e. starting with *[* or ending with *]*)',
'include the bound value within the break and thus make coordinates',
'include the bound value within the rangebreak and thus make coordinates',
'equal to the bound disappear.',
'Open interval bounds (i.e. starting with *(* or ending with *)*)',
'does not include the bound value within the break and thus keep coordinates',
'does not include the bound value within the rangebreak and thus keep coordinates',
'equal to the bound on the axis.'
].join(' ')
},
Expand All @@ -351,7 +351,7 @@ module.exports = {
editType: 'calc',
role: 'info',
description: [
'Sets the gap distance between the start and the end of this break.',
'Sets the gap distance between the start and the end of this rangebreak.',
'Use with `gapmode` to set the unit of measurement.'
].join(' ')
},
Expand Down
Loading