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

Consider adding an example for onclick listener #215

Open
chungwong opened this issue Jul 8, 2024 · 2 comments
Open

Consider adding an example for onclick listener #215

chungwong opened this issue Jul 8, 2024 · 2 comments

Comments

@chungwong
Copy link

Given the following Scatter example, it is unclear how to add an onclick listener to the chart.

let mut plot = Plot::new();
let trace = Scatter::new(vec![0, 1, 2], vec![2, 1, 0]);
plot.add_trace(trace);

let layout = plotly::Layout::new().title("Displaying a Chart in Yew");
plot.set_layout(layout);

plotly::bindings::new_plot(id, &plot).await;

In Plotly.js, this can be acheived by capturing the plotly_click event, i.e.

plot.on('plotly_click', function(data) {
  ..
});

Is it supported in plotly.rs?

@andrei-ng
Copy link
Collaborator

Hi @chungwong. This is not supported. Would be nice if you could submit a PR with such a feature.

@FritsHoogland
Copy link

First of all thank you for the marvellous crate!

I would love to have a way to make the browser open a url on clicking on data points (a stacked bar in my case), and was thinking (hoping actually) that that functionality was provided by plotly::layout::ClickMode::Event, and then somehow give it a URL or javascript?

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

No branches or pull requests

3 participants