Chart.js not showing in Android 8.0/Android O

👍:-1

I resolved temporarily with issue #4570 Chart.js but I waiting that help me solve the problem completely, making Chart.js work normally.

Workaround Solution – displays the chart but actions will be lost (mouse click, hover over etc):

1- Wrap your canvas within a Div (add any styles to the div you may need)

<div><canvas height="400" id="myChart" width="400"></canvas></div>

2- Suggest removing any ‘animation’ (although you could alter the code below in item 3/ to use the endAnimation event to track when to carry out the temp fix) – Add into your options:

options: { animation:{duration:0}, ..... }

3- Add the following code – have made this simple, but could be improved re end of animation if required:

(jQuery)

$('#myChart').parent().html('<img style="max-height:100%;height:auto;width:100%;max-width:100%;margin:auto;display:inline;" src="' + chart.toBase64Image() + '" />');

(javascript)

document.getElementById('myChart').parentElement.innerHTML = '<img style="max-height:100%;height:auto;width:100%;max-width:100%;margin:auto;display:inline;" src="' + chart.toBase64Image() + '" />';

Follow issue #5184 Chart.js on Github

Leave a comment