Skip to content

Differentiate hover and click action when using view #1806

Answered by Fil
farhanreynaldo asked this question in Q&A
Discussion options

You must be logged in to vote

As mentioned in the docs:

the view function displays the given element and returns a corresponding value generator

hover is the value generator, while what you want to listen to is the input events on the chart. You could transform your code by naming the chart:

const chart = Plot.plot({
  marks: [Plot.dot(cars, { x: "power (hp)", y: "economy (mpg)", tip: true })]
});
const hover = view(chart);

and then listen to input events on chart

Replies: 3 comments 3 replies

Comment options

Fil
Nov 8, 2024
Collaborator

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@Fil
Comment options

Fil Nov 9, 2024
Collaborator

Answer selected by farhanreynaldo
Comment options

You must be logged in to vote
2 replies
@Fil
Comment options

Fil Nov 11, 2024
Collaborator

@farhanreynaldo
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants