Skip to content

Commit

Permalink
Locally provide echarts.js library
Browse files Browse the repository at this point in the history
Works if offline
  • Loading branch information
mofeing committed Sep 25, 2024
1 parent 55a5070 commit 99d7833
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 2 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ version = "0.8.0-DEV"
AbstractTrees = "1520ce14-60c1-5f80-bbc7-55ef81b5835c"
Combinatorics = "861a8166-3701-5b0c-9a16-15d98fcdc6aa"
DeltaArrays = "10b0fc19-5ccc-4427-889b-d75dd6306188"
ECharts_jll = "ffd69456-1935-58d2-abba-ba12e8909167"
EinExprs = "b1794770-133b-4de1-afb4-526377e9f4c5"
KeywordDispatch = "5888135b-5456-5c80-a1b6-c91ef8180460"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Expand Down Expand Up @@ -60,6 +61,7 @@ ChainRulesTestUtils = "1"
Combinatorics = "1.0"
Dagger = "0.18"
DeltaArrays = "0.1.1"
ECharts_jll = "5"
EinExprs = "0.5, 0.6"
FiniteDifferences = "0.12"
GraphMakie = "0.4,0.5"
Expand Down
8 changes: 4 additions & 4 deletions src/Visualization.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# const echarts = read(joinpath(artifact"echarts", "node_modules", "echarts", "dist", "echarts.js"), String)
const echarts_url = "https://cdn.jsdelivr.net/npm/echarts@5.5.1/dist/echarts.min.js"
using ECharts_jll

Base.show(io::IO, ::MIME"text/html", tn::AbstractTensorNetwork) = show(io, MIME"juliavscode/html", tn)
function Base.show(io::IO, ::MIME"juliavscode/html", @nospecialize(tn::AbstractTensorNetwork))
tn = transform(tn, Tenet.HyperFlatten)
appid = gensym("tenet-graph")
Expand All @@ -12,7 +10,9 @@ function Base.show(io::IO, ::MIME"juliavscode/html", @nospecialize(tn::AbstractT
return print(
io,
"""
<script type="text/javascript" src="$echarts_url"></script>
<script type="text/javascript">$(
read(joinpath(dirname(ECharts_jll.echarts), "echarts.min.js"), String)
)</script>
<div id="$appid" style="width: 600px; height: 600px;"></div>
<script>
var chart = echarts.init(document.getElementById('$appid'));
Expand Down

0 comments on commit 99d7833

Please sign in to comment.