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

categoryshapeshiftstart and categoryshapeshiftend properties for category axes #7010

Closed
wants to merge 3 commits into from

Conversation

my-tien
Copy link
Contributor

@my-tien my-tien commented Jun 3, 2024

This is an alternative to PR #7005 for adjusting shapes' start and end coordinates (no selection yet)

Introduces categoryshapeshiftstart (influences x0 or y0) and categoryshapeshiftend (influences x1 or y1) for category axes.

image

image

Disclaimer I am required to add that…

the software is provided "as is", without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose and noninfringement. in no event shall the authors or copyright holders be liable for any claim, damages or other liability, whether in an action of contract, tort or otherwise, arising from, out of or in connection with the software or the use or other dealings in the software.

@@ -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) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's drop the isVerticalAxis argument and instead use the ax._id.

   var isY = axi._id.charAt(0) === 'y';

ax = Axes.getFromId(gd, shape.xref);

bounds = shapeBounds(ax, vx0, vx1, shape.path, constants.paramIsX);
bounds = shapeBounds(ax, shape, constants.paramIsX, false);
Copy link
Contributor

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

Suggested change
bounds = shapeBounds(ax, shape, constants.paramIsX, false);
bounds = shapeBounds(ax, shape, constants.paramIsX);

ax = Axes.getFromId(gd, shape.yref);

bounds = shapeBounds(ax, vy0, vy1, shape.path, constants.paramIsY);
bounds = shapeBounds(ax, shape, constants.paramIsY, true);
Copy link
Contributor

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

Suggested change
bounds = shapeBounds(ax, shape, constants.paramIsY, true);
bounds = shapeBounds(ax, shape, constants.paramIsY);

valType: 'number',
dflt: 0,
min: -0.5,
max: 0.5,
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps increasing the range of min and max a bit could be useful to highlight points for cases e.g. histogram and bars with tiny gaps.
I suggest we allow values between -0.7 and 0.7 or maybe even -1 and 1?

"x0": 0,
"x1": 0.25,
"xref": "x3 domain"
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's also test these case using circle.
Thank you!

@archmoj archmoj added feature something new community community contribution status: reviewable labels Jun 4, 2024
description: [
'Only relevant if axis is a (multi-)category axes. Shifts x0/y0 by a fraction of the',
'reference unit.'
]
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
]
].join(' ')

description: [
'Only relevant if axis is a (multi-)category axes. Shifts x1/y1 by a fraction of the',
'reference unit.'
]
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
]
].join(' ')

@archmoj
Copy link
Contributor

archmoj commented Jun 4, 2024

@alexcjohnson
Copy link
Collaborator

To me it feels a little limiting to put these attributes on the axes rather than in each shape. What if you want a rectangle outlining one bar (or bar group), a line going from the middle of one category to the middle of another, and a circle around a single scatter point?

The name is also awfully long. What about just x0shift?

@archmoj
Copy link
Contributor

archmoj commented Jun 4, 2024

To me it feels a little limiting to put these attributes on the axes rather than in each shape. What if you want a rectangle outlining one bar (or bar group), a line going from the middle of one category to the middle of another, and a circle around a single scatter point?

The name is also awfully long. What about just x0shift?

@alexcjohnson
Good call.
I agree with you.
Considering your comment on the other PR https://github.com/plotly/plotly.js/pull/7005/files#r1623049565
it looks like we could/should modify #7005 to have x0shift and x1shift instead of xshift.
So I change the status of this PR to on hold.

@archmoj
Copy link
Contributor

archmoj commented Jun 6, 2024

Closing in favor of #7005.

@archmoj archmoj closed this Jun 6, 2024
@my-tien my-tien deleted the categoryshapeshift branch June 19, 2024 15:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community community contribution feature something new
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants