#324 Pluto Support

Open Mary McGrath mcmcgrath13 Pseudo commit used to compare (6b89f19...0b3d0fa)

Flags

Flags have been temporarily removed from this view while the flagging feature is refactored for better performance and user experience.

You can still use flags when viewing individual files. Flag-level thresholds will also remain on pull and merge requests in your repository provider.

More information can be found in our documentation.


@@ -13,3 +13,17 @@
Loading
13 13
function fileio_save(stream::FileIO.Stream{FileIO.format"vegalite"}, data::VLSpec; include_data=true, kwargs...)
14 14
    Vega.savespec(stream.io, data; include_data=include_data, kwargs...)
15 15
end
16 +
17 +
function fileio_save(file::FileIO.File{FileIO.format"vega"}, data::VLSpec; include_data=true, kwargs...)
18 +
    s = Base64.stringmime(MIME("application/vnd.vega.v5+json"), data)
19 +
    parsed = JSON.parse(s)
20 +
    vgspec = Vega.VGSpec(parsed)
21 +
    Vega.savespec(file.filename, vgspec; include_data=include_data, kwargs...)
22 +
end
23 +
24 +
function fileio_save(stream::FileIO.Stream{FileIO.format"vega"}, data::VLSpec; include_data=true, kwargs...)
25 +
    s = Base64.stringmime(MIME("application/vnd.vega.v5+json"), data)
26 +
    parsed = JSON.parse(s)
27 +
    vgspec = Vega.VGSpec(parsed)
28 +
    Vega.savespec(stream.io, vgspec; include_data=include_data, kwargs...)
29 +
end

@@ -17,6 +17,7 @@
Loading
17 17
using DataStructures
18 18
import TableTraitsUtils
19 19
using Vega
20 +
import Base64
20 21
21 22
export renderer, actionlinks
22 23
export @vl_str, @vlplot, vlplot, @vlfrag, vlfrag

@@ -122,3 +122,7 @@
Loading
122 122
function Base.show(io::IO, m::MIME"application/prs.juno.plotpane+html", v::VLSpec)
123 123
    writehtml_full(io, v)
124 124
end
125 +
126 +
function Base.show(io::IO, m::MIME"text/html", v::VLSpec)
127 +
    writehtml_partial_script(io, v)
128 +
end

@@ -70,3 +70,15 @@
Loading
70 70
function eps(filename::AbstractString, v::VLSpec)
71 71
    savefig(filename, "application/eps", v)
72 72
end
73 +
74 +
function Vega.savespec(io::IO, v::VLSpec; include_data=false, indent=nothing)
75 +
    output_dict = copy(Vega.getparams(v))
76 +
    if !include_data
77 +
        delete!(output_dict, "data")
78 +
    end
79 +
    if indent === nothing
80 +
        JSON.print(io, output_dict)
81 +
    else
82 +
        JSON.print(io, output_dict, indent)
83 +
    end
84 +
end

@@ -70,12 +70,14 @@
Loading
70 70
  tmppath
71 71
end
72 72
73 +
const cdn_versions = (vg="5.6.0", vl="3.4.0", vg_embed="5.1.2")
74 +
73 75
"""
74 76
Creates a HTML script + div block for showing the plot (typically for IJulia).
75 77
VegaLite js files are loaded from the web (to accommodate the security model of
76 78
IJulia) using requirejs.
77 79
"""
78 -
function writehtml_partial(io::IO, spec::String; title="VegaLite plot")
80 +
function writehtml_partial_require(io::IO, spec::String; title="VegaLite plot")
79 81
  divid = "vg" * randstring(3)
80 82
81 83
  println(io,
@@ -98,9 +100,9 @@
Loading
98 100
99 101
    requirejs.config({
100 102
        paths: {
101 -
          vg: "https://cdnjs.cloudflare.com/ajax/libs/vega/5.6.0/vega.min.js?noext",
102 -
          vl: "https://cdnjs.cloudflare.com/ajax/libs/vega-lite/3.4.0/vega-lite.min.js?noext",
103 -
          vg_embed: "https://cdnjs.cloudflare.com/ajax/libs/vega-embed/5.1.2/vega-embed.min.js?noext"
103 +
          vg: "https://cdnjs.cloudflare.com/ajax/libs/vega/$(cdn_versions.vg)/vega.min.js?noext",
104 +
          vl: "https://cdnjs.cloudflare.com/ajax/libs/vega-lite/$(cdn_versions.vl)/vega-lite.min.js?noext",
105 +
          vg_embed: "https://cdnjs.cloudflare.com/ajax/libs/vega-embed/$(cdn_versions.vg_embed)/vega-embed.min.js?noext"
104 106
        },
105 107
        shim: {
106 108
          vg_embed: {deps: ["vg.global", "vl.global"]},
@@ -135,6 +137,43 @@
Loading
135 137
  """)
136 138
end
137 139
140 +
"""
141 +
Creates a HTML script + div block for showing the plot (typically for Pluto).
142 +
VegaLite js files are loaded from the web using script tags.
143 +
"""
144 +
function writehtml_partial_script(io::IO, spec::VLSpec; title="VegaLite plot")
145 +
  divid = "vg" * randstring(3)
146 +
  print(io, """
147 +
    <style media="screen">
148 +
      .vega-actions a {
149 +
        margin-right: 10px;
150 +
        font-family: sans-serif;
151 +
        font-size: x-small;
152 +
        font-style: italic;
153 +
      }
154 +
    </style>
155 +
156 +
    <script src="https://cdn.jsdelivr.net/npm/vega@$(cdn_versions.vg)"></script>
157 +
    <script src="https://cdn.jsdelivr.net/npm/vega-lite@$(cdn_versions.vl)"></script>
158 +
    <script src="https://cdn.jsdelivr.net/npm/vega-embed@$(cdn_versions.vg_embed)"></script>
159 +
160 +
    <div id="$divid"></div>
161 +
162 +
    <script>
163 +
      var spec = """)
164 +
  our_json_print(io, spec)
165 +
  print(io,"""
166 +
      ;
167 +
      var opt = {
168 +
        mode: "vega-lite",
169 +
        renderer: "$(Vega.RENDERER)",
170 +
        actions: $(Vega.ACTIONSLINKS)
171 +
      };
172 +
      vegaEmbed("#$divid", spec, opt);
173 +
    </script>
174 +
  """)
175 +
end
176 +
138 177
function Base.display(d::REPL.REPLDisplay, plt::VLSpec)
139 178
  # checkplot(plt)
140 179
  tmppath = writehtml_full(plt)

Everything is accounted for!

No changes detected that need to be reviewed.
What changes does Codecov check for?
Lines, not adjusted in diff, that have changed coverage data.
Files that introduced coverage data that had none before.
Files that have missing coverage data that once were tracked.
Files Coverage
src -0.46% 76.75%
Project Totals (12 files) 76.75%
Loading