This PR adds support for displaying data links in a context menu when clicking on points on the plotly graph.
When transforming the input dataframes into the plot data, we can add a unique id as custom metadata to both the dataframes and the plotly traces. Then when a user clicks on a point, we can use the id from the point object to find the corresponding dataframe. This is necessary because dataframes aren't required to have a name, so we could potentially have no way of telling them apart. We find the field the user clicked on using the plot's name, and then we use Grafana's API to get the links with variables interpolated. The getLinks function is a little bit magical because it actually can calculate variables from the whole dataframe, not just the specific field it's called on. To display the links, we use the context menu in @grafana/ui so it looks and feels like the built-in panels.
I also added the plotly logo to replace the default one!
https://grafana.com/docs/grafana/latest/linking/data-links/ AB#1174194
This PR adds support for displaying data links in a context menu when clicking on points on the plotly graph. When transforming the input dataframes into the plot data, we can add a unique id as custom metadata to both the dataframes and the plotly traces. Then when a user clicks on a point, we can use the id from the point object to find the corresponding dataframe. This is necessary because dataframes aren't required to have a name, so we could potentially have no way of telling them apart. We find the field the user clicked on using the plot's name, and then we use Grafana's API to get the links with variables interpolated. The
getLinks
function is a little bit magical because it actually can calculate variables from the whole dataframe, not just the specific field it's called on. To display the links, we use the context menu in @grafana/ui so it looks and feels like the built-in panels.I also added the plotly logo to replace the default one!