Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

property x0shift, x1shift, y0shift, y1shift for adjusting the shape coordinates #7005

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

Merged
merged 26 commits into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
aa0cd7a
property shape.x_shift/y_shift for adjusting the shape coordinates
my-tien May 27, 2024
44d1858
Add draftlog for PR 7005
my-tien May 27, 2024
7abea61
Add x_shift/y_shift for selections as well, add selection example to …
my-tien May 27, 2024
a617017
baseline images zzz_shape_shift_horizontal and zzz_shape_shift_vertical
my-tien May 27, 2024
c2f7f27
Update shapes_test after adding shift param to getDataToPixel
my-tien May 27, 2024
fdcaa0c
Rename x_shift/y_shift → xshift/yshift
my-tien May 31, 2024
9921522
Replace xshift and yshift with x0shift and y0shift
my-tien Jun 10, 2024
3ac32f3
Only coerce x0/x1/y0/y1shift if referenced axis is category/multicate…
my-tien Jun 10, 2024
6680745
Fix typo in calc_autorange: x/ysizemode "scale" -> "scaled"
my-tien Jun 10, 2024
ada2289
Add scatter to zzz_shape_shift_vertical mock
my-tien Jun 10, 2024
e11f6f6
Merge remote-tracking branch 'origin-plotly/master' into shape_shift
my-tien Jun 10, 2024
1bfb22d
Updated baseline image after adding scatter to zzz_shape_shift_vertic…
my-tien Jun 10, 2024
04466db
getDataToPixel: If shift is undefined, set it to 0
my-tien Jun 10, 2024
91db7c8
Update draftlog with final property names
my-tien Jun 12, 2024
4bbb669
Adjust attribute descriptions with property formatting and mention of…
my-tien Jun 12, 2024
ab935ac
Move calculation of shape shift into a dedicated function
my-tien Jun 18, 2024
82de6b1
Merge remote-tracking branch 'origin-plotly/master' into shape_shift
my-tien Jun 19, 2024
f9c44bf
Update overlooked test after changing xshift/yshift to x0shift,x1shif…
my-tien Jul 3, 2024
b00d4d8
Remove shift properties from selection for now
my-tien Jul 10, 2024
8cf665a
Merge remote-tracking branch 'origin-plotly/master' into shape_shift
my-tien Jul 10, 2024
78a7e5e
Fix getPixelShift for reversed axes, add reversed axis to mock
my-tien Jul 11, 2024
18e7c84
Update baseline image of zzz_shape_shift_vertical
my-tien Jul 11, 2024
5509ee6
Account for shift when dragging a shape
my-tien Jul 15, 2024
6f8e5a6
Support shape shift in texttemplate as well
my-tien Jul 15, 2024
7de45c3
Update baseline image after updated mock for texttemplate shape
my-tien Jul 15, 2024
9ac970a
Refine description for x0shift/x1shift/y0shift/y1shift
my-tien Jul 16, 2024
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
Prev Previous commit
Next Next commit
Remove shift properties from selection for now
  • Loading branch information
my-tien committed Jul 10, 2024
commit b00d4d806fc2f1a531db414c53365032f537317a
2 changes: 1 addition & 1 deletion 2 draftlogs/7005_add.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
- Add property x0shift, x1shift, y0shift, y1shift for shapes/selections referencing (multi-)category axes [[#7005](https://github.com/plotly/plotly.js/pull/7005)]
- Add property x0shift, x1shift, y0shift, y1shift for shapes referencing (multi-)category axes, with thanks to @my-tien for the contribution! [[#7005](https://github.com/plotly/plotly.js/pull/7005)]
45 changes: 0 additions & 45 deletions 45 src/components/selections/attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,51 +54,6 @@ module.exports = overrideAll(templatedArray('selection', {
description: 'Sets the selection\'s end y position.'
},

x0shift: {
valType: 'number',
dflt: 0,
min: -1,
max: 1,
editType: 'calc',
description: [
'Only relevant if `xref` is a (multi-)category axes. Shifts `x0` by a fraction of the',
'reference unit. E.g. -0.5 corresponds to the start of the category and 0.5 corresponds to the end of the category.'
].join(' ')
},
x1shift: {
valType: 'number',
dflt: 0,
min: -1,
max: 1,
editType: 'calc',
description: [
'Only relevant if `xref` is a (multi-)category axes. Shifts `x1` by a fraction of the',
'reference unit. E.g. -0.5 corresponds to the start of the category and 0.5 corresponds to the end of the category.'
].join(' ')
},
y0shift: {
valType: 'number',
dflt: 0,
min: -1,
max: 1,
editType: 'calc',
description: [
'Only relevant if `yref` is a (multi-)category axes. Shifts `y0` by a fraction of the',
'reference unit. E.g. -0.5 corresponds to the start of the category and 0.5 corresponds to the end of the category.'
].join(' ')
},
y1shift: {
valType: 'number',
dflt: 0,
min: -1,
max: 1,
editType: 'calc',
description: [
'Only relevant if `yref` is a (multi-)category axes. Shifts `y1` by a fraction of the',
'reference unit. E.g. -0.5 corresponds to the start of the category and 0.5 corresponds to the end of the category.'
].join(' ')
},

path: {
valType: 'string',
editType: 'arraydraw',
Expand Down
5 changes: 0 additions & 5 deletions 5 src/components/selections/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,6 @@ function handleSelectionDefaults(selectionIn, selectionOut, fullLayout) {

// Coerce x0, x1, y0, y1
if(noPath) {
if(ax.type === 'category' || ax.type === 'multicategory') {
coerce(axLetter + '0shift');
coerce(axLetter + '1shift');
}

// hack until V3.0 when log has regular range behavior - make it look like other
// ranges to send to coerce, then put it back after
// this is all to give reasonable default position behavior on log axes, which is
Expand Down
2 changes: 1 addition & 1 deletion 2 src/components/shapes/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ function convertPath(options, x2p, y2p) {
function getPixelShift(axis, shift) {
shift = shift || 0;
var shiftPixels = 0;
if(axis) {
if(axis && shift) {
var isVertical = axis._id.charAt(0) === 'y';
if(axis.type === 'category' || axis.type === 'multicategory') {
if(isVertical) {
my-tien marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
10 changes: 0 additions & 10 deletions 10 test/image/mocks/zzz_shape_shift_vertical.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,6 @@
"x1shift": -0.25,
"yref": "paper"
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this also working for a path?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, this should only do something when using x0, x1, y0, y1

],
"selections": [
{
"x0": 0,
"x1": 3,
"y0": 1,
"y1": 3,
"x0shift": -0.5,
"x1shift": 0.5
}
]
}
}
32 changes: 0 additions & 32 deletions 32 test/plot-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -9555,27 +9555,11 @@
"editType": "arraydraw",
"valType": "any"
},
"x0shift": {
"description": "Only relevant if `xref` is a (multi-)category axes. Shifts `x0` by a fraction of the reference unit. E.g. -0.5 corresponds to the start of the category and 0.5 corresponds to the end of the category.",
"dflt": 0,
"editType": "arraydraw",
"max": 1,
"min": -1,
"valType": "number"
},
"x1": {
"description": "Sets the selection's end x position.",
"editType": "arraydraw",
"valType": "any"
},
"x1shift": {
"description": "Only relevant if `xref` is a (multi-)category axes. Shifts `x1` by a fraction of the reference unit. E.g. -0.5 corresponds to the start of the category and 0.5 corresponds to the end of the category.",
"dflt": 0,
"editType": "arraydraw",
"max": 1,
"min": -1,
"valType": "number"
},
"xref": {
"description": "Sets the selection's x coordinate axis. If set to a x axis id (e.g. *x* or *x2*), the `x` position refers to a x coordinate. If set to *paper*, the `x` position refers to the distance from the left of the plotting area in normalized coordinates where *0* (*1*) corresponds to the left (right). If set to a x axis ID followed by *domain* (separated by a space), the position behaves like for *paper*, but refers to the distance in fractions of the domain length from the left of the domain of that axis: e.g., *x2 domain* refers to the domain of the second x axis and a x position of 0.5 refers to the point between the left and the right of the domain of the second x axis.",
"editType": "arraydraw",
Expand All @@ -9590,27 +9574,11 @@
"editType": "arraydraw",
"valType": "any"
},
"y0shift": {
"description": "Only relevant if `yref` is a (multi-)category axes. Shifts `y0` by a fraction of the reference unit. E.g. -0.5 corresponds to the start of the category and 0.5 corresponds to the end of the category.",
"dflt": 0,
"editType": "arraydraw",
"max": 1,
"min": -1,
"valType": "number"
},
"y1": {
"description": "Sets the selection's end y position.",
"editType": "arraydraw",
"valType": "any"
},
"y1shift": {
"description": "Only relevant if `yref` is a (multi-)category axes. Shifts `y1` by a fraction of the reference unit. E.g. -0.5 corresponds to the start of the category and 0.5 corresponds to the end of the category.",
"dflt": 0,
"editType": "arraydraw",
"max": 1,
"min": -1,
"valType": "number"
},
"yref": {
"description": "Sets the selection's x coordinate axis. If set to a y axis id (e.g. *y* or *y2*), the `y` position refers to a y coordinate. If set to *paper*, the `y` position refers to the distance from the bottom of the plotting area in normalized coordinates where *0* (*1*) corresponds to the bottom (top). If set to a y axis ID followed by *domain* (separated by a space), the position behaves like for *paper*, but refers to the distance in fractions of the domain length from the bottom of the domain of that axis: e.g., *y2 domain* refers to the domain of the second y axis and a y position of 0.5 refers to the point between the bottom and the top of the domain of the second y axis.",
"editType": "arraydraw",
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.