-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
categoryshapeshiftstart and categoryshapeshiftend properties for category axes #7010
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -23,22 +23,18 @@ module.exports = function calcAutorange(gd) { | |||||
|
||||||
// paper and axis domain referenced shapes don't affect autorange | ||||||
if(shape.xref !== 'paper' && xRefType !== 'domain') { | ||||||
var vx0 = shape.xsizemode === 'pixel' ? shape.xanchor : shape.x0; | ||||||
var vx1 = shape.xsizemode === 'pixel' ? shape.xanchor : shape.x1; | ||||||
ax = Axes.getFromId(gd, shape.xref); | ||||||
|
||||||
bounds = shapeBounds(ax, vx0, vx1, shape.path, constants.paramIsX); | ||||||
bounds = shapeBounds(ax, shape, constants.paramIsX, false); | ||||||
if(bounds) { | ||||||
shape._extremes[ax._id] = Axes.findExtremes(ax, bounds, calcXPaddingOptions(shape)); | ||||||
} | ||||||
} | ||||||
|
||||||
if(shape.yref !== 'paper' && yRefType !== 'domain') { | ||||||
var vy0 = shape.ysizemode === 'pixel' ? shape.yanchor : shape.y0; | ||||||
var vy1 = shape.ysizemode === 'pixel' ? shape.yanchor : shape.y1; | ||||||
ax = Axes.getFromId(gd, shape.yref); | ||||||
|
||||||
bounds = shapeBounds(ax, vy0, vy1, shape.path, constants.paramIsY); | ||||||
bounds = shapeBounds(ax, shape, constants.paramIsY, true); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. After considering https://github.com/plotly/plotly.js/pull/7010/files#r1626065612
Suggested change
|
||||||
if(bounds) { | ||||||
shape._extremes[ax._id] = Axes.findExtremes(ax, bounds, calcYPaddingOptions(shape)); | ||||||
} | ||||||
|
@@ -77,15 +73,39 @@ function calcPaddingOptions(lineWidth, sizeMode, v0, v1, path, isYAxis) { | |||||
} | ||||||
} | ||||||
|
||||||
function shapeBounds(ax, v0, v1, path, paramsToUse) { | ||||||
var convertVal = (ax.type === 'category' || ax.type === 'multicategory') ? ax.r2c : ax.d2c; | ||||||
function shapeBounds(ax, shape, paramsToUse, isVerticalAxis) { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's drop the
|
||||||
var v0; | ||||||
var v1; | ||||||
var shiftStart = 0; | ||||||
var shiftEnd = 0; | ||||||
if(isVerticalAxis) { | ||||||
var isYSizeModePixel = shape.ysizemode === 'pixel'; | ||||||
v0 = isYSizeModePixel ? shape.yanchor : shape.y0; | ||||||
v1 = isYSizeModePixel ? shape.yanchor : shape.y1; | ||||||
} else { | ||||||
var isXSizeModePixel = shape.xsizemode === 'pixel'; | ||||||
v0 = isXSizeModePixel ? shape.xanchor : shape.x0; | ||||||
v1 = isXSizeModePixel ? shape.xanchor : shape.x1; | ||||||
} | ||||||
|
||||||
var convertVal; | ||||||
|
||||||
if(ax.type === 'category' || ax.type === 'multicategory') { | ||||||
convertVal = ax.r2c; | ||||||
if(shape.xsizemode === 'scale') { | ||||||
shiftStart = ax.categoryshapeshiftstart; | ||||||
shiftEnd = ax.categoryshapeshiftend; | ||||||
} | ||||||
} else { | ||||||
convertVal = ax.d2c; | ||||||
} | ||||||
|
||||||
if(v0 !== undefined) return [convertVal(v0), convertVal(v1)]; | ||||||
if(!path) return; | ||||||
if(v0 !== undefined) return [convertVal(v0) + shiftStart, convertVal(v1) + shiftEnd]; | ||||||
if(!shape.path) return; | ||||||
|
||||||
var min = Infinity; | ||||||
var max = -Infinity; | ||||||
var segments = path.match(constants.segmentRE); | ||||||
var segments = shape.path.match(constants.segmentRE); | ||||||
var i; | ||||||
var segment; | ||||||
var drawnParam; | ||||||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -1190,6 +1190,28 @@ module.exports = { | |||||
'Used with `categoryorder`.' | ||||||
].join(' ') | ||||||
}, | ||||||
categoryshapeshiftstart: { | ||||||
valType: 'number', | ||||||
dflt: 0, | ||||||
min: -0.5, | ||||||
max: 0.5, | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps increasing the range of |
||||||
editType: 'calc', | ||||||
description: [ | ||||||
'Only relevant if axis is a (multi-)category axes. Shifts x0/y0 by a fraction of the', | ||||||
'reference unit.' | ||||||
] | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
}, | ||||||
categoryshapeshiftend: { | ||||||
valType: 'number', | ||||||
dflt: 0, | ||||||
min: -0.5, | ||||||
max: 0.5, | ||||||
editType: 'calc', | ||||||
description: [ | ||||||
'Only relevant if axis is a (multi-)category axes. Shifts x1/y1 by a fraction of the', | ||||||
'reference unit.' | ||||||
] | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
}, | ||||||
uirevision: { | ||||||
valType: 'any', | ||||||
editType: 'none', | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After considering https://github.com/plotly/plotly.js/pull/7010/files#r1626065612