Skip to content

Commit 7abea61

Browse files
committed
Add x_shift/y_shift for selections as well, add selection example to mock
1 parent 44d1858 commit 7abea61

File tree

5 files changed

+50
-2
lines changed

5 files changed

+50
-2
lines changed

draftlogs/7005_add.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
- Add property shape.x_shift/shape.y_shift for shapes referencing (multi-)category axes [[#7005](https://github.com/plotly/plotly.js/pull/7005)]
1+
- Add property x_shift/y_shift for shapes/selections referencing (multi-)category axes [[#7005](https://github.com/plotly/plotly.js/pull/7005)]

src/components/selections/attributes.js

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,28 @@ module.exports = overrideAll(templatedArray('selection', {
5353
valType: 'any',
5454
description: 'Sets the selection\'s end y position.'
5555
},
56-
56+
x_shift: {
57+
valType: 'number',
58+
dflt: 0,
59+
min: -0.5,
60+
max: 0.5,
61+
editType: 'calc',
62+
description: [
63+
'Only relevant if xref is a (multi-)category axes. Shifts x0 and x1 by a fraction of',
64+
'the reference unit.'
65+
].join(' ')
66+
},
67+
y_shift: {
68+
valType: 'number',
69+
dflt: 0,
70+
min: -0.5,
71+
max: 0.5,
72+
editType: 'calc',
73+
description: [
74+
'Only relevant if yref is a (multi-)category axes. Shifts y0 and y1 by a fraction of',
75+
'the reference unit.'
76+
].join(' ')
77+
},
5778
path: {
5879
valType: 'string',
5980
editType: 'arraydraw',

src/components/selections/defaults.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ function handleSelectionDefaults(selectionIn, selectionOut, fullLayout) {
4949
coerce('line.color');
5050
coerce('line.width');
5151
coerce('line.dash');
52+
coerce('x_shift');
53+
coerce('y_shift');
5254

5355
// positioning
5456
var axLetters = ['x', 'y'];

test/image/mocks/zzz_shape_shift_vertical.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,15 @@
5151
"x_shift": -0.25,
5252
"yref": "paper"
5353
}
54+
],
55+
"selections": [
56+
{
57+
"x0": 0,
58+
"x1": 4,
59+
"y0": 1,
60+
"y1": 3,
61+
"x_shift": -0.5
62+
}
5463
]
5564
}
5665
}

test/plot-schema.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9550,6 +9550,14 @@
95509550
"path"
95519551
]
95529552
},
9553+
"x_shift": {
9554+
"description": "Only relevant if xref is a (multi-)category axes. Shifts x0 and x1 by a fraction of the reference unit.",
9555+
"dflt": 0,
9556+
"editType": "arraydraw",
9557+
"max": 0.5,
9558+
"min": -0.5,
9559+
"valType": "number"
9560+
},
95539561
"x0": {
95549562
"description": "Sets the selection's starting x position.",
95559563
"editType": "arraydraw",
@@ -9569,6 +9577,14 @@
95699577
"/^x([2-9]|[1-9][0-9]+)?( domain)?$/"
95709578
]
95719579
},
9580+
"y_shift": {
9581+
"description": "Only relevant if yref is a (multi-)category axes. Shifts y0 and y1 by a fraction of the reference unit.",
9582+
"dflt": 0,
9583+
"editType": "arraydraw",
9584+
"max": 0.5,
9585+
"min": -0.5,
9586+
"valType": "number"
9587+
},
95729588
"y0": {
95739589
"description": "Sets the selection's starting y position.",
95749590
"editType": "arraydraw",

0 commit comments

Comments
 (0)