Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

not to hijack too much, but since this is on the topic of timeseries...i'm currently working on a fast* Canvas2D timeseries chart:

https://github.com/leeoniya/uPlot

* ~4,000 pts/ms on an i5 and integrated gpu



This is super interesting and quite relevant to a bunch of stuff I do at work.

Next time I have a project that involves real-time plotting of data, I'll definitely take a look!


Why canvas2d when WebGL is much faster?


a few reasons.

the main one is that i know canvas and can implement everything i need, but would need to learn a lot of webgl to get any further than a basic PoC.

browsers limit how many webgl contexts you can acquire. chrome is capped at 16, so if you need more than 16 charts on a page, you're out of luck.

initializing webgl is actually slower than canvas 2d.

it's difficult to draw lines of different thicknesses in raw webgl - it takes a lot of code.

there are projects which abstract webgl nicely to provide canvas-like ergonomics, like Two.js, Pixi.js, or Canvas2DtoWebGL/litegl [1], but they would make the codebase much larger and more complex.

[1] https://github.com/jagenjo/Canvas2DtoWebGL




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: