plotly / plotly.rs

Plotly for Rust
https://docs.rs/plotly
MIT License
1.11k stars 104 forks source link

Consider adding an example for onclick listener #215

Open chungwong opened 3 months ago

chungwong commented 3 months ago

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 commented 3 months ago

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