implement contour_labels and partially vector of colors for Plotly(JS)

This commit is contained in:
Daniel Schwabeneder 2018-02-28 22:51:06 +01:00
parent cd4b41a537
commit d8f0612f5a

View File

@ -45,6 +45,7 @@ const _plotly_attr = merge_with_base_supported([
:framestyle, :framestyle,
:tick_direction, :tick_direction,
:camera, :camera,
:contour_labels,
]) ])
const _plotly_seriestype = [ const _plotly_seriestype = [
@ -434,6 +435,14 @@ function plotly_colorscale(grad::ColorGradient, α)
[[grad.values[i], rgba_string(plot_color(grad.colors[i], α))] for i in 1:length(grad.colors)] [[grad.values[i], rgba_string(plot_color(grad.colors[i], α))] for i in 1:length(grad.colors)]
end end
plotly_colorscale(c, α) = plotly_colorscale(cgrad(alpha=α), α) plotly_colorscale(c, α) = plotly_colorscale(cgrad(alpha=α), α)
function plotly_colorscale(c::AbstractVector{<:RGBA}, α)
if length(c) == 1
return [[0.0, rgba_string(plot_color(c[1], α))]]
else
vals = linspace(0.0, 1.0, length(c))
return [[vals[i], rgba_string(plot_color(c[i], α))] for i in eachindex(c)]
end
end
# plotly_colorscale(c, alpha = nothing) = plotly_colorscale(cgrad(), alpha) # plotly_colorscale(c, alpha = nothing) = plotly_colorscale(cgrad(), alpha)
@ -559,7 +568,7 @@ function plotly_series(plt::Plot, series::Series)
d_out[:x], d_out[:y], d_out[:z] = x, y, z d_out[:x], d_out[:y], d_out[:z] = x, y, z
# d_out[:showscale] = series[:colorbar] != :none # d_out[:showscale] = series[:colorbar] != :none
d_out[:ncontours] = series[:levels] d_out[:ncontours] = series[:levels]
d_out[:contours] = KW(:coloring => series[:fillrange] != nothing ? "fill" : "lines") d_out[:contours] = KW(:coloring => series[:fillrange] != nothing ? "fill" : "lines", :showlabels => series[:contour_labels] == true)
d_out[:colorscale] = plotly_colorscale(series[:linecolor], series[:linealpha]) d_out[:colorscale] = plotly_colorscale(series[:linecolor], series[:linealpha])
d_out[:showscale] = hascolorbar(sp) d_out[:showscale] = hascolorbar(sp)