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

Set cursor to pointer only when hovering over onclick target box #3084

Open
nickgirardo opened this issue Feb 6, 2023 · 2 comments
Open
Labels

Comments

@nickgirardo
Copy link

Description

I have a chart with points which have onclick events attached. I'd like to change the cursor to a pointer only when a point is hovered.

I have seen #220, however this doesn't quite get me where I want to be. The .bb_event_rect seems to cover the entire body of the chart, whereas the hitboxes for the onclick events only cover a small radius around my points. I wouldn't want my users to expect there to be something happening when they click on the body of a chart when in fact my onclick events will not be fired

There are a few other options I've considered which do not seem to work for me either:
Css attached to the point itself. I've attemted to add styles along the lines of

.bb-chart .bb-shapes.bb.circles .bb-circle {
    cursor: pointer;
}

This has a few issues

  • I'm unable to cause these styles to be applied. I'm not sure if the .bb-event-rect is consuming some hover/ move event which causes the browser to never actually be hovering over the point
  • Even if this worked, the onclick event's hitbox seems slightly larger than the point itself, meaning that at some points the cursor would not be a pointer when the user's click would trigger an event

Another approach I briefly considered was changing the cursor to a pointer whenever a point is expanded with css along the lines of

.bb-chart:has(.bb-circle._expanded_) {
    cursor: pointer;
}

Unfortunately, this approach also seems like a non-starter

Is it possible to set the cursor to a pointer when a user hovers over the exact area where an onclick event would be triggered?

Steps to check or reproduce

@nickgirardo
Copy link
Author

As a quick update, it looks like the has() approach does work quite well if tooltip.grouped is set to false. I've enabled this flag for other reasons and it seems to work fairly well for this case, however this is still far from ideal as only 80% of users browsers support this feature.

@netil netil added the question label Feb 7, 2023
@netil
Copy link
Member

netil commented Feb 13, 2023

@nickgirardo, you can add cursor style attribute setting via data.onover and data.onout option.

checkout the online working demo:

data: {
   ...
    onover: function() {
        this.$.main.select("rect").style("cursor", "pointer");
    },
    onout: function() {
        this.$.main.select("rect").style("cursor", null);
    }
}

Feb-13-2023 12-05-06

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants