echarts [Bug] server side rendering fails when number of points larger than 10000

hrysbysz  于 5个月前  发布在  Echarts
关注(0)|答案(2)|浏览(107)

Version

5.4.2

https://github.com/oriolcx/echartsissue.git

Steps to Reproduce

# using node v18.14.2

# clone repository
git clone https://github.com/oriolcx/echartsissue.git

# install dependencies
npm install

# running
# fine
node debug.scatter.js 9999 

# error
node debug.scatter.js 10000

Current Behavior

Server side render with node-canvas fails if number of points larger or equal than 10000

Expected Behavior

Server side does not fail

Environment

- OS: Ubuntu 22.04.2 LTS
- Browser: node v18.14.2
- Framework:

Any additional comments?

# code that fails if N >= 10000

var echarts = require("echarts");
const { createCanvas } = require("canvas");
const fs = require('fs')

if(process.argv.length !== 3) {
  console.log("Specify number of points.")
  process.exit()
}

N = Number(process.argv[2])

function make_scatter(data) {
  const canvas = createCanvas(1024, 768);
  const chart = echarts.init(canvas);
  
  options = {
    grid: {
      right: 70,
      bottom: 70,
    },
    xAxis: [{}],
    yAxis: [{}],

    animation: false,
    series: [
      {
        type: "scatter",
        data: data,
        dimensions: ["x", "y"],
        symbolSize: 3,
        itemStyle: {
          opacity: 0.4,
        },
        blendMode: "source-over",
        large: true,
        largeThreshold: 500,
      },
    ],
  };

  chart.setOption(options);
  
  const out = fs.createWriteStream("./scatter.png")
  canvas.createPNGStream().pipe(out)
}

make_scatter(Array.from({length: N}, () => [Math.random(), Math.random()]));
q8l4jmvw

q8l4jmvw1#

It seems to be related with the progressive drawing. If I increase the progressiveThreshold to 1000000000 and it seems to work without problems.

1l5u6lss

1l5u6lss2#

It seems to be related with the progressive drawing. If I increase the progressiveThreshold to 1000000000 and it seems to work without problems.

This seems relative. Maybe we should disable progressive rendering when SSR.

相关问题