Showing 2 of 4 files from the diff.

@@ -4,8 +4,22 @@
Loading
4 4
Base.displayable(d::ElectronDisplayType, ::MIME{Symbol("application/vnd.vega.v4+json")}) = true
5 5
Base.displayable(d::ElectronDisplayType, ::MIME{Symbol("application/vnd.vega.v5+json")}) = true
6 6
7 +
function _maybe_fallback_to(mime, d, x, payload)
8 +
    if sizeof(payload) > d.config.max_json_bytes
9 +
        @warn string(
10 +
            "The size of JSON representation (", sizeof(payload), ")",
11 +
            " exceeds `max_json_bytes = ", d.config.max_json_bytes, "`.",
12 +
            " Falling back to $mime."
13 +
        )
14 +
        return display(d, mime, x)
15 +
    end
16 +
    return nothing
17 +
end
18 +
7 19
function _display_vegalite(d, major_version_vegalite, major_version_vega, x)
8 20
    payload = stringmime(MIME("application/vnd.vegalite.v$major_version_vegalite+json"), x)
21 +
    ans = _maybe_fallback_to(MIME"image/png"(), d, x, payload)
22 +
    ans === nothing || return ans
9 23
10 24
    html_page = """
11 25
    <html>
@@ -49,6 +63,8 @@
Loading
49 63
50 64
function _display_vega(d, major_version, x)
51 65
    payload = stringmime(MIME("application/vnd.vega.v$major_version+json"), x)
66 +
    ans = _maybe_fallback_to(MIME"image/png"(), d, x, payload)
67 +
    ans === nothing || return ans
52 68
53 69
    html_page = """
54 70
    <html>

@@ -10,6 +10,7 @@
Loading
10 10
    showable = electron_showable
11 11
    single_window::Bool = false
12 12
    focus::Bool = true
13 +
    max_json_bytes::Int = 2^20
13 14
end
14 15
15 16
"""
@@ -22,11 +23,13 @@
Loading
22 23
    showable = config.showable,
23 24
    single_window::Bool = config.single_window,
24 25
    focus::Bool = config.focus,
26 +
    max_json_bytes::Int = config.max_json_bytes,
25 27
) =
26 28
    ElectronDisplayConfig(
27 29
        showable = showable,
28 30
        single_window = single_window,
29 31
        focus = focus,
32 +
        max_json_bytes = max_json_bytes,
30 33
    )
31 34
32 35
struct ElectronDisplayType <: Base.AbstractDisplay
@@ -57,6 +60,11 @@
Loading
57 60
58 61
* `focus::Bool = true`: Focus the Electron window on `display` if `true`
59 62
  (default).
63 +
64 +
* `max_json_bytes::Int = $(ElectronDisplayConfig().max_json_bytes)`:
65 +
  Maximum size in bytes for which JSON representation is used.  Otherwise,
66 +
  convert visualization locally in a binary form before sending it to the
67 +
  Electron display.  Currently only Vega and Vega-Lite support this.
60 68
"""
61 69
const CONFIG = ElectronDisplayConfig()
62 70
Files Coverage
src 82.14%
Project Totals (2 files) 82.14%
Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading