You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It would be nice to be able to use custom themes defined in a JSON or .toml file by deserialzing these into a custom theme struct.
A possible way to achieve this is by creating a CustomTheme struct with fields corresponding to the settings, while using preexisting structs from the crate. As those struct already has most of (if not all) of the needed fields, e.g the Line struct has line_style which is needed. The problem however is that the Line struct also has fields which are not required, nor wanted (?), for a theme struct - i.e the type_ (?) and the data field.
Is this something that is in the works? If wanted I could try to implement this, however, then there would be need for some guidance what needs to be done.
A small example of what I'm getting at..
use serde::{Serialize,Deserialize};use charming::element::Color;use charming::series::Line;#[derive(Serialize,Deserialize)]#[serde(rename_all = "camelCase")]structCustomTheme{#[serde(skip_serializing_if = "Option::is_none")]color:Option<Vec<Color>>,#[serde(skip_serializing_if = "Option::is_none")]line:Option<Line>,// and then more... }let theme:&str = r#"{ "color": ["\#ff0000", "\#00ff00", "\#0000ff"], "line": { "lineStyle" : { "width": 3 }, "symbolSize": 8 }}"#;let my_custom_theme:CustomTheme = serde_json::from_str(theme).unwrap();// Then set theme....
The text was updated successfully, but these errors were encountered:
I have a similar need, the received parameter is a json string, I can not directly Deserialize json to struct Chart because it does not support Deserialize, if the direct json string is rendered as a parameter, or all classes implement deserialize
Answering this thread for anyone who stumbles upon this in the future. You can use (echarts theme builder)[https://echarts.apache.org/en/theme-builder.html] to create a custom theme and use it with charming::theme::Custom. This library does not support creating a theme from json or toml at this time.
It would be nice to be able to use custom themes defined in a JSON or .toml file by deserialzing these into a custom theme struct.
A possible way to achieve this is by creating a
CustomTheme
struct with fields corresponding to the settings, while using preexisting structs from the crate. As those struct already has most of (if not all) of the needed fields, e.g theLine
struct hasline_style
which is needed. The problem however is that theLine
struct also has fields which are not required, nor wanted (?), for a theme struct - i.e thetype_
(?) and thedata
field.Is this something that is in the works? If wanted I could try to implement this, however, then there would be need for some guidance what needs to be done.
A small example of what I'm getting at..
The text was updated successfully, but these errors were encountered: