leeoniya / uPlot

📈 A small, fast chart for time series, lines, areas, ohlc & bars
MIT License
8.84k stars 385 forks source link

How to deal with very large number of float number? #963

Closed zkycaesar closed 5 months ago

zkycaesar commented 5 months ago

It seems js typed array cannot handle very large number of float number. To be precise, if I run this code:

var loop = 100000000;

let data = [
    Array(loop),
    Array(loop),
];

for (var i = 0; i < loop; i++) {
    let x = 2 * Math.PI * i / loop;
    let y = Math.sin(x);

    data[0][i] = x;
    data[1][i] = y;
}

const rangerOpts = {
    ...
};

let uRanger = new uPlot(rangerOpts, data, document.body);

It will throw an exception "invalid array lengh".

As far as I know, uPlot only takes typed array as its input. So it means uPlot cannot handle 100000000 point. Is this true?

zkycaesar commented 5 months ago

Well, using Float32Array solved this problem...