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

Show tooltips programmatically #1212

Open
cerealexx opened this issue Mar 17, 2020 · 3 comments
Open

Show tooltips programmatically #1212

cerealexx opened this issue Mar 17, 2020 · 3 comments

Comments

@cerealexx
Copy link

Is there a way to show tooltips programmatically? I've found a way to simulate hover state on vanilla chart.js but can figure out how to do it in Angular...

@Deemetr
Copy link

Deemetr commented Feb 4, 2021

@cerealexx have you found a solution? I have a very similar requirement. Need to programmatically set the hover state for the donut chart segment

@cerealexx
Copy link
Author

chart: BaseChartDirective;

And then I used this method to simulate hover and trigger tip display on demand:

openTip(index: number) {
    let mouseMoveEvent, meta, point, rectangle;

    meta = this.chart.chart.getDatasetMeta(0);
    rectangle = this.chart.chart.canvas.getBoundingClientRect();
    point = meta.data[index].getCenterPoint();

    mouseMoveEvent = new MouseEvent('mousemove', {
      clientX: rectangle.left + point.x,
      clientY: rectangle.top + point.y
    });

    this.chart.chart.canvas.dispatchEvent(mouseMoveEvent);
  }

@Deemetr
Copy link

Deemetr commented Feb 4, 2021

@cerealexx ok, it works for me too. Thanks.

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

No branches or pull requests

2 participants