From a33c0205b2eb53d6466e7c01dad834ffa4040952 Mon Sep 17 00:00:00 2001 From: Steve Leung <4917419+stevenaleung@users.noreply.github.com> Date: Tue, 29 Mar 2022 08:42:01 -0700 Subject: [PATCH] Restored plotly hover functionality for plots with multidimensional data (#4159) * Restored hover functionality for plots with multidimensional data * Renamed plotly_hover!() to plotly_adjust_hover_label!() * Updated contributors list * Update src/backends/plotly.jl [skip ci] Co-authored-by: t-bltg Co-authored-by: Simon Christ Co-authored-by: t-bltg --- .zenodo.json | 4 ++++ src/backends/plotly.jl | 14 ++++++++------ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/.zenodo.json b/.zenodo.json index d134a749..13667118 100644 --- a/.zenodo.json +++ b/.zenodo.json @@ -706,6 +706,10 @@ { "name": "Tom Gillam", "type": "Other" + }, + { + "name": "Steve Leung", + "type": "Other" } ], "upload_type": "software" diff --git a/src/backends/plotly.jl b/src/backends/plotly.jl index 1b7c8a82..f3f1db44 100644 --- a/src/backends/plotly.jl +++ b/src/backends/plotly.jl @@ -752,7 +752,7 @@ function plotly_series(plt::Plot, series::Series) end plotly_polar!(plotattributes_out, series) - plotly_hover!(plotattributes_out, series[:hover]) + plotly_adjust_hover_label!(plotattributes_out, series[:hover]) return [plotattributes_out] end @@ -807,7 +807,7 @@ function plotly_series_shapes(plt::Plot, series::Series, clims) end plotattributes_out[:showlegend] = k == 1 ? should_add_to_legend(series) : false plotly_polar!(plotattributes_out, series) - plotly_hover!(plotattributes_out, _cycle(series[:hover], i)) + plotly_adjust_hover_label!(plotattributes_out, _cycle(series[:hover], i)) plotattributes_outs[k] = plotattributes_out end if series[:fill_z] !== nothing @@ -931,7 +931,7 @@ function plotly_series_segments(series::Series, plotattributes_base::KW, x, y, z end plotly_polar!(plotattributes_out, series) - plotly_hover!(plotattributes_out, _cycle(series[:hover], rng)) + plotly_adjust_hover_label!(plotattributes_out, _cycle(series[:hover], rng)) if hasfillrange # if hasfillrange is true, return two dictionaries (one for original @@ -1019,14 +1019,16 @@ function plotly_polar!(plotattributes_out::KW, series::Series) end end -function plotly_hover!(plotattributes_out::KW, hover) - # hover text - if hover === nothing || all(in([:none, false]), hover) +function plotly_adjust_hover_label!(plotattributes_out::KW, hover) + if hover === nothing + return nothing + elseif all(in([:none, false]), hover) plotattributes_out[:hoverinfo] = "none" elseif any(!isnothing, hover) plotattributes_out[:hoverinfo] = "text" plotattributes_out[:text] = hover end + return nothing end # get a list of dictionaries, each representing the series params