working on plotly

This commit is contained in:
Thomas Breloff 2015-11-20 23:53:19 -05:00
parent b0c9dd44e9
commit 52ba7cdbff
2 changed files with 41 additions and 2 deletions

View File

@ -180,8 +180,46 @@ function get_series_html(plt::Plot{PlotlyPackage})
d_out = Dict()
# TODO: set the fields for each series
for k in (:x, :y)
d_out[k] = collect(d[k])
d_out[:x] = collect(d[:x])
d_out[:y] = collect(d[:y])
d_out[:name] = d[:label]
lt = d[:linetype]
if lt in (:line, :path, :scatter, :steppre, :steppost)
d_out[:type] = "scatter"
end
hasmarker = lt == :scatter || d[:markershape] != :none
hasline = lt != :scatter
d_out[:mode] = if hasmarker
hasline ? "lines+markers" : "markers"
else
hasline ? "lines" : "none"
end
if hasmarker
d_out[:marker] = Dict(
# :symbol => "circle",
# :opacity => d[:markeropacity],
:size => d[:markersize],
:color => webcolor(d[:markercolor], d[:markeralpha]),
:line => Dict(
:color => webcolor(d[:markerstrokecolor], d[:markerstrokealpha]),
:width => d[:markerstrokewidth],
),
)
if d[:zcolor] != nothing
d_out[:marker][:color] = d[:zcolor]
d_out[:marker][:colorscale] = :RdBu # TODO: use the markercolor gradient
end
end
if hasline
d_out[:line] = Dict(
:color => webcolor(d[:linecolor], d[:linealpha]),
:width => d[:linewidth],
# :dash => "solid",
)
end
d_out

View File

@ -332,6 +332,7 @@ function webcolor(c::Colorant)
@sprintf("rgba(%d, %d, %d, %1.3f)", [make255(f(c)) for f in [red,green,blue]]..., alpha(c))
end
webcolor(cs::ColorScheme) = webcolor(getColor(cs))
webcolor(c, α) = webcolor(convertColor(getColor(c), α))
# ----------------------------------------------------------------------------------