From 7ec54b9c2e41b555aec6bbe8c41778711b331a46 Mon Sep 17 00:00:00 2001 From: Daniel Schwabeneder Date: Sun, 19 Nov 2017 19:54:52 +0100 Subject: [PATCH] update plotly(js) --- src/backends.jl | 6 +++--- src/backends/plotly.jl | 19 ++++++++++++------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/backends.jl b/src/backends.jl index 1dd5d8ad..94199b00 100644 --- a/src/backends.jl +++ b/src/backends.jl @@ -51,8 +51,8 @@ _series_updated(plt::Plot, series::Series) = nothing _before_layout_calcs(plt::Plot) = nothing -title_padding(sp::Subplot) = sp[:title] == "" ? 0mm : sp[:titlefont].pointsize * pt -guide_padding(axis::Axis) = axis[:guide] == "" ? 0mm : axis[:guidefont].pointsize * pt +title_padding(sp::Subplot) = sp[:title] == "" ? 0mm : sp[:titlefontsize] * pt +guide_padding(axis::Axis) = axis[:guide] == "" ? 0mm : axis[:guidefontsize] * pt "Returns the (width,height) of a text label." function text_size(lablen::Int, sz::Number, rot::Number = 0) @@ -93,7 +93,7 @@ function tick_padding(axis::Axis) # hgt # get the height of the rotated label - text_size(longest_label, axis[:tickfont].pointsize, rot)[2] + text_size(longest_label, axis[:tickfontsize], rot)[2] end end diff --git a/src/backends/plotly.jl b/src/backends/plotly.jl index 3b149a20..e58d685c 100644 --- a/src/backends/plotly.jl +++ b/src/backends/plotly.jl @@ -2,7 +2,7 @@ # https://plot.ly/javascript/getting-started @require Revise begin - Revise.track(Plots, joinpath(Pkg.dir("Plots"), "src", "backends", "plotly.jl")) + Revise.track(Plots, joinpath(Pkg.dir("Plots"), "src", "backends", "plotly.jl")) end const _plotly_attr = merge_with_base_supported([ @@ -19,7 +19,12 @@ const _plotly_attr = merge_with_base_supported([ :markerstrokewidth, :markerstrokecolor, :markerstrokealpha, :markerstrokestyle, :fillrange, :fillcolor, :fillalpha, :bins, - :title, :title_location, :titlefont, + :title, :title_location, + :titlefontfamily, :titlefontsize, :titlefonthalign, :titlefontvalign, + :titlefontcolor, + :legendfontfamily, :legendfontsize, :legendfontcolor, + :tickfontfamily, :tickfontsize, :tickfontcolor, + :guidefontfamily, :guidefontsize, :guidefontcolor, :window_title, :guide, :lims, :ticks, :scale, :flip, :rotation, :tickfont, :guidefont, :legendfont, @@ -254,9 +259,9 @@ function plotly_axis(axis::Axis, sp::Subplot) ax[:tickangle] = -axis[:rotation] if !(axis[:ticks] in (nothing, :none)) - ax[:titlefont] = plotly_font(axis[:guidefont], axis[:foreground_color_guide]) + ax[:titlefont] = plotly_font(guidefont(axis)) ax[:type] = plotly_scale(axis[:scale]) - ax[:tickfont] = plotly_font(axis[:tickfont], axis[:foreground_color_text]) + ax[:tickfont] = plotly_font(tickfont(axis)) ax[:tickcolor] = framestyle in (:zerolines, :grid) || !axis[:showaxis] ? rgba_string(invisible()) : rgb_string(axis[:foreground_color_axis]) ax[:linecolor] = rgba_string(axis[:foreground_color_axis]) @@ -334,8 +339,8 @@ function plotly_layout(plt::Plot) 0.5 * (left(bb) + right(bb)) end titlex, titley = xy_mm_to_pcts(xmm, top(bbox(sp)), w*px, h*px) - titlefont = font(sp[:titlefont], :top, sp[:foreground_color_title]) - push!(d_out[:annotations], plotly_annotation_dict(titlex, titley, text(sp[:title], titlefont))) + title_font = font(titlefont(sp), :top) + push!(d_out[:annotations], plotly_annotation_dict(titlex, titley, text(sp[:title], title_font))) end d_out[:plot_bgcolor] = rgba_string(sp[:background_color_inside]) @@ -376,7 +381,7 @@ function plotly_layout(plt::Plot) d_out[:legend] = KW( :bgcolor => rgba_string(sp[:background_color_legend]), :bordercolor => rgba_string(sp[:foreground_color_legend]), - :font => plotly_font(sp[:legendfont], sp[:foreground_color_legend]), + :font => plotly_font(legendfont(sp)), :x => xpos, :y => ypos )