yuankunzhang / charming

A visualization library for Rust
Apache License 2.0
1.85k stars 74 forks source link

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

Closed WaffleLapkin closed 1 month ago

WaffleLapkin commented 1 year ago

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

G2GreenTea commented 11 months ago

I have encountered the same problem. Have you found a solution yet?

WaffleLapkin commented 11 months ago

No

quentusrex commented 5 months ago

I found a workaround locally. Turns out it's related to progressive rendering being 'broken' for SSR mode. Similar to this filed issue: https://github.com/apache/echarts/issues/18788

I was changing echarts versions(up to 5.5.0) and modifying that source locally and found that disabling progressive by changing to these lines(don't recall the original values currently): ` // Configuration for progressive/incremental rendering
progressiveThreshold: 0, progressive: 0,

` the system finally printed all of the points.

What would be helpful would be taking the above reproduction, and then generating a version that can be used to file the issue with echarts, should be able to get this sorted upstream easily.