I understand that mobiles have less resources to spare. This is not my exact question.
To clarify more; I used amCharts
and chartjs
on the same device.
- AmCharts had 2 complex charts with a lot of data -more than 900 record.
- Chartjs with 1 chart and very simple data -less than 60 record.
amCharts
run smoothly, but chartjs makes the page scrolling stater, it lags very noticeably and some times shows parts of the page as blank space for about 1/4 of a second -excuse my exact numbers.
Clearly this is not a data set problem, there is a big difference in how each library works. The biggest one I could find was that amChart
uses SVG while chartjs
uses the html Canvas element.
- Could that difference truly be the root of the problem? or is
chartjs
just not optimized for mobile? - If so, is there is any way to overcome this?
Solution: Since the question is more about "cause" than "fix", I didn't submit this as an answer.
I forgot about it but t's almost a rule of thump: "In case of scroll problems; force GPU Acceleration." Most modern browsers can do it, and it's very simple to force, just do any transformation (translate, scale, etc) in 3D space:
body *:not(svg) {
transform: translate3d(0, 0, 0);
-webkit-transform: translate3d(0, 0, 0);
-moz-transform: translate3d(0, 0, 0);
-ms-transform: translate3d(0, 0, 0); /*only in IE10*/
}
- Source: answers from this question.
- With ionic this would break the navbar, so use
ion-content
-or any smaller container- instead ofbody
. - As it seems it would break SVG hence
*:not(svg)
. - Tested on
ios 8.3
andandroid 6
.