[Chartjs]-Why chartjs lags pages on mobile browsers?

3👍

If you graph is constantly changes or changes when the users scroll Canvas will be slower than SVG.

With a canvas you are re-drawing your graph for every little change, there’s not way around it.

With SVG your graph is part of the DOM can be modified without fully re-rendering it.

So if you’re graph is changing a lot and you notice the moments when it lags coincide with those when it’s being re-drawn the library choice of canvas over SVG is the problem. Otherwise, Canvas is actually faster in most cases.

Fixing this could include finding another library, modifying the code of the existing one or finding ways to re-draw your graph less (e.g. have a mandatroy timeout between changes to the graph of a few milliseconds or even seconds).

Leave a comment