Git Product home page Git Product logo

charming's People

Contributors

dgsantana avatar hpmason avatar koopa1338 avatar mrchypark avatar mtk2xfugaku avatar qknight avatar yuankunzhang avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

charming's Issues

JavaScript V8 engine

The JavaScript V8 engine was too difficult to download during initial compilation, are there any other solutions?

unresolved import charming::ImageRenderer

Compiling charm v0.1.0 (/home/xxx/rust/charm)
error[E0432]: unresolved import charming::ImageRenderer
--> src/main.rs:5:12
|
5 | Chart, ImageRenderer,
| ^^^^^^^^^^^^^ no ImageRenderer in the root

For more information about this error, try rustc --explain E0432.
error: could not compile charm (bin "charm") due to previous error

// here is the code
use charming::{                                                                                                                
    component::Legend,
    element::ItemStyle,
    series::{Pie, PieRoseType},
    Chart, ImageRenderer,
};
 
fn main() {
    let chart = Chart::new().legend(Legend::new().top("bottom")).series(
        Pie::new()
            .name("Nightingale Chart")
            .rose_type(PieRoseType::Radius)
            .radius(vec!["50", "250"])
            .center(vec!["50%", "50%"])
            .item_style(ItemStyle::new().border_radius(8))
            .data(vec![
                (40.0, "rose 1"),
                (38.0, "rose 2"),
                (32.0, "rose 3"),
                (30.0, "rose 4"),
                (28.0, "rose 5"),
                (26.0, "rose 6"),
                (22.0, "rose 7"),
                (18.0, "rose 8"),
            ]),
    );  
 
    let mut renderer = ImageRenderer::new(1000, 800);
    renderer.save(&chart, "/tmp/nightingale.svg");
}

Large candlestick charts not fully plotting

I have converted some polars dataframes into the underlying Vec types to pass into the charming df! macro and managed to build a working pipeline for making charts.
Running into an issue with a chart that starts from YTD for daily bars, and it compiles and saves the data into an html file.
When it comes to opening the file in the web browser it only renders a few bars and then nothing more. Even though the date axis and raw html data is fully available in the file.

Any leads on what I can try changing?
Screenshot 2023-08-07 234453

Screenshot 2023-08-07 231754

test_data.txt

can't zoom by mouse

In JavaScript, if an image is too large, we can use mouse movements to pan and zoom the image. However, this is not possible in charming.

Custom themes by deserializing JSON?

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")]
struct CustomTheme {
    #[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....

Missing license file

The crate has "MIT/Apache-2.0" license but its missing on the repository itself

ChartResize has no pub fields

I may be missing something, but I did not find a way to build a ChartResize structure since all of its fields are private.

Something as simple as

--- a/charming/src/renderer/wasm_renderer.rs
+++ b/charming/src/renderer/wasm_renderer.rs
@@ -76,6 +76,17 @@ pub struct ChartResize {
     animation: Option<Animation>,
 }

+impl ChartResize {
+    pub fn new(width: u32, height: u32, silent: bool, animation: Option<Animation>) -> Self {
+        ChartResize {
+            width,
+            height,
+            silent,
+            animation,
+        }
+    }
+}
+
 #[derive(Serialize)]
 pub struct Animation {

would solve the issue.

NaiveDate compatibility for Chart x-axis

Hey, I've tried implementing a dynamic approach to initializing the x axis with a polars series of "Datetime" objects and my code compiles but panics when unwrapping the result of the chart creation. I screenshotted the ErrString, "expected Date got str"

I will fork and try to fix this issue, hopefully you may have some insight too.
Screenshot 2023-07-28 191807
Screenshot 2023-07-28 191608

`ImageRenderer` only renders the first 400 points in a scatter graph

Reproducer:

use std::iter;

use charming::{component::Axis, element::AxisType, series::Scatter, Chart, ImageRenderer};

fn main() {
    let c = Chart::new()
        .x_axis(Axis::new().type_(AxisType::Value))
        .y_axis(Axis::new().type_(AxisType::Value))
        .series(
            Scatter::new().data(
                (0..=100)
                    .flat_map(|x| iter::zip(iter::repeat(x), 0..=100))
                    .map(|(x, y)| vec![x, y])
                    .collect(),
            ),
        );

    let mut renderer: ImageRenderer = ImageRenderer::new(1200, 1200);
    renderer.save(&c, format!("/tmp/chc.svg")).unwrap();
}

Result:
a scatter graph with 400 points arranged in 4 100 points tall columns

Expected result (a screenshot from html page made by HtmlRenderer):

a scatter graph with 10000 points distributed evenly in x<100, y<100 space

[feature request] Derive some useful traits

I want to suggest deriving Clone and PartialEq for charts and containing structs. Serialize and Deserialize for example could also be feature gated, if necessary. What do you think?

feat: Support decal patterns

Will there be support for decal patterns?

PS: Thank you for the library, it's great to work with. I wanted to use it for plots in publications, but could not find any option for decal patterns. It makes little difference on screen, but the bars are much easier to distinguish in B&W print when using patterns, so I wonder if they will be added later.

use::charming::WasmRenderer

I'm unable to use the renderer (and I can't find it anywhere else)

charming = { version = "0.1.2", feature = "wasm" }

But same for 0.2.1

error[E0432]: unresolved import `charming::WasmRenderer`
 --> src/main.rs:3:5
  |
3 | use charming::WasmRenderer;
  |     ^^^^^^^^^^------------
  |     |         |
  |     |         help: a similar name exists in the module: `HtmlRenderer`
  |     no `WasmRenderer` in the root

roadmap

Hi,

Thanks for your great work! I am looking for rust visualization library for a long time. I have tried plotters (https://github.com/plotters-rs/plotters) and plotly (https://github.com/igiagkiozis/plotly), both of them are disappointing cannot meet my demand. Charming is the best one of all the rust visualization library I have ever seen and worth trying!

Do you have a roadmap of charming and will you maintain this project ? Though I am not a developer, I can test charming for you. And can I convert charming chart to json now using something like Chart.to_json() ? if so, I can send the json to web front end and render it. Besides, can I use charming in vscode jupyter and render them ?

Candlestick Example

if I recall correctly, I remember at one point seeing an example for how to load data for candlesticks, but the example is now gone. Adding this back would be great since there's only the svg examples. I have a Polars Dataframe as my source.

Could Echart be Clone?

I am embedding charming graphs inside leptos components. To handle canvas resizes correctly, I need to keep track of the Echart object in the reactive effect by inserting it in a leptos Read/WriteSignal. This requires Echart to be Clone, unless I am missing a a simpler solution.

Something like this would solve the issue:

--- a/charming/src/renderer/wasm_renderer.rs
+++ b/charming/src/renderer/wasm_renderer.rs
@@ -144,6 +155,8 @@ impl Animation {
 #[wasm_bindgen]
 extern "C" {
     #[wasm_bindgen(js_name = echarts)]
+    #[derive(Clone)]
     pub type Echarts;

     #[wasm_bindgen(js_namespace = echarts, js_name = init)]

Are there any drawbacks with this change?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.