Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Wasm HashMap conversion #135

Merged
merged 3 commits into from
Dec 23, 2024

Conversation

cooljingle
Copy link

We can set the selected state of legends using a HashMap:

    selected: Option<HashMap<String, bool>>,

This works fine using the HtmlRenderer, which sets the chart option using to_string:

        let data = Handlebars::new()
            .render_template(
                template,
                &serde_json::json!({
                    "title": self.title,
                    "theme": theme,
                    "theme_source": theme_source,
                    "width": self.width,
                    "height": self.height,
                    "chart_id": "chart",
                    "canvas_type": canvas_type,
                    "chart_option": chart.to_string(), // <- here
                }),
            )

But this param is currently not working using the WasmRenderer, because it uses to_value which converts the HashMap to a Map object which is not compatible with the echarts config.

I've replaced the to_value call with js_sys::JSON::parse which generates a compatible option object.

@LukaOber LukaOber merged commit 6a02036 into yuankunzhang:main Dec 23, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants