Skip to content

Commit

Permalink
Merge pull request #135 from cooljingle/wasm-hashmap-conversion
Browse files Browse the repository at this point in the history
Fix Wasm HashMap conversion
  • Loading branch information
LukaOber authored Dec 23, 2024
2 parents c893566 + 6e4e32e commit 6a02036
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion charming/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ serde_json = "1.0"
serde_v8 = { version = "0.220", optional = true }
serde_with = "3.11.0"
wasm-bindgen = { version = "0.2", optional = true }
js-sys = { version = "0.3", optional = true }

[dev-dependencies]
assert-json-diff = "2.0.2"
Expand All @@ -39,7 +40,7 @@ features = [
default = ["html"]
html = ["handlebars"]
ssr = ["html", "deno_core", "image", "resvg", "serde_v8"]
wasm = ["serde-wasm-bindgen", "wasm-bindgen", "web-sys"]
wasm = ["serde-wasm-bindgen", "wasm-bindgen", "web-sys", "js-sys"]

[package.metadata.docs.rs]
all-features = true
Expand Down
6 changes: 4 additions & 2 deletions charming/src/renderer/wasm_renderer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ impl WasmRenderer {
})
.unwrap(),
);
echarts.set_option(to_value(chart).unwrap());
Self::update(&echarts, chart);

Ok(echarts)
}
Expand All @@ -66,7 +66,9 @@ impl WasmRenderer {
}

pub fn update(echarts: &Echarts, chart: &Chart) {
echarts.set_option(to_value(chart).unwrap());
let json_str = serde_json::to_string(chart).unwrap();
let option = js_sys::JSON::parse(&json_str).unwrap();
echarts.set_option(option);
}
}

Expand Down

0 comments on commit 6a02036

Please sign in to comment.