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 <tf.bltg@gmail.com>

Co-authored-by: Simon Christ <SimonChrist@gmx.de>
Co-authored-by: t-bltg <tf.bltg@gmail.com>
This commit is contained in:
Steve Leung 2022-03-29 08:42:01 -07:00 committed by GitHub
parent 65ab68c3b5
commit a33c0205b2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 6 deletions

View File

@ -706,6 +706,10 @@
{ {
"name": "Tom Gillam", "name": "Tom Gillam",
"type": "Other" "type": "Other"
},
{
"name": "Steve Leung",
"type": "Other"
} }
], ],
"upload_type": "software" "upload_type": "software"

View File

@ -752,7 +752,7 @@ function plotly_series(plt::Plot, series::Series)
end end
plotly_polar!(plotattributes_out, series) plotly_polar!(plotattributes_out, series)
plotly_hover!(plotattributes_out, series[:hover]) plotly_adjust_hover_label!(plotattributes_out, series[:hover])
return [plotattributes_out] return [plotattributes_out]
end end
@ -807,7 +807,7 @@ function plotly_series_shapes(plt::Plot, series::Series, clims)
end end
plotattributes_out[:showlegend] = k == 1 ? should_add_to_legend(series) : false plotattributes_out[:showlegend] = k == 1 ? should_add_to_legend(series) : false
plotly_polar!(plotattributes_out, series) 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 plotattributes_outs[k] = plotattributes_out
end end
if series[:fill_z] !== nothing if series[:fill_z] !== nothing
@ -931,7 +931,7 @@ function plotly_series_segments(series::Series, plotattributes_base::KW, x, y, z
end end
plotly_polar!(plotattributes_out, series) 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
# if hasfillrange is true, return two dictionaries (one for original # if hasfillrange is true, return two dictionaries (one for original
@ -1019,14 +1019,16 @@ function plotly_polar!(plotattributes_out::KW, series::Series)
end end
end end
function plotly_hover!(plotattributes_out::KW, hover) function plotly_adjust_hover_label!(plotattributes_out::KW, hover)
# hover text if hover === nothing
if hover === nothing || all(in([:none, false]), hover) return nothing
elseif all(in([:none, false]), hover)
plotattributes_out[:hoverinfo] = "none" plotattributes_out[:hoverinfo] = "none"
elseif any(!isnothing, hover) elseif any(!isnothing, hover)
plotattributes_out[:hoverinfo] = "text" plotattributes_out[:hoverinfo] = "text"
plotattributes_out[:text] = hover plotattributes_out[:text] = hover
end end
return nothing
end end
# get a list of dictionaries, each representing the series params # get a list of dictionaries, each representing the series params