informatics-isi-edu / deriva-webapps

Deriva-based web applications
Apache License 2.0
2 stars 1 forks source link

Support hovertemplate_display_pattern in plot app for heatmap type #153

Closed jrchudy closed 1 year ago

jrchudy commented 1 year ago

This issue is to take care of the hovertemplate_display_pattern mentioned in issue #121 . At first we will implement this only for heatmap type in plot app.

This property should be defined in the config object like plots[0].traces[0].hovertemplate_display_pattern. This is being included in the traces object since this display pattern will behave similar to graphic_link_pattern. graphic_link_pattern works for "each" data point in the plot (each bar, pie slice, heatmap square), hovertemplate_display_pattern will be the same. hovertemplate_display_pattern will NOT allow for markdown content to be generated, so the templates this property generates only need to be passed through renderHandlebarsTemplate().

For this to work, we need to modify the following in plotly. Plotly data object expects to have the following contents:

plotly.data[0]: {
  x: [...],
  y: [...],
  z: [ [...], ... ],
  hoverinfo: 'text',
  text: [ [...], ... ]
}

In the case of heatmap, when hoverinfo: 'text' is set, the displayed tooltip when hovering over a specific square (colored z value) is shown as the value displayed in the text array that corresponds with the given x index and y index (text[y][x]).

Note: We want to avoid showing "links" in the tooltip that shows when hovering over the chart. This is not directly related to these changes, but can occur if xaxis.tick_display_markdown_pattern is defined with a markdown pattern that generates a link.

KenyShah24 commented 1 year ago

For customization option of the hover text of violin plot (including the box plot and scatter plot within it): It says plotly doesn't support this customization as of now - https://github.com/ua-snap/iem-webapp/issues/85