Skip to content

Commit

Permalink
add js_sys
Browse files Browse the repository at this point in the history
  • Loading branch information
[email protected] committed Dec 23, 2024
1 parent 420211f commit 6e4e32e
Show file tree
Hide file tree
Showing 3 changed files with 4 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
3 changes: 1 addition & 2 deletions charming/src/renderer/wasm_renderer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use serde::Serialize;
use serde_wasm_bindgen::to_value;
use wasm_bindgen::prelude::*;
use wasm_bindgen::JsValue;
use web_sys::js_sys::JSON;

pub struct WasmRenderer {
theme: Theme,
Expand Down Expand Up @@ -68,7 +67,7 @@ impl WasmRenderer {

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

0 comments on commit 6e4e32e

Please sign in to comment.