I have an Android application which uses WebView to load the GUI using HTML. There is a <canvas> element into which i draw charts using Chart.js Javascript library for plotting charts. It was tested on 3 devices. On two of them it works fine (Android 2.2 and 2.6), but on a later vesion of android (4.1.2) the canvas makes it double: all the charts are visible twice in the canvas, one of them is shifted a bit up and to the left.
What is the problem with the canvas? Why does it double the things rendered? How can i made it render only once?
Here's the code:
HTML:
<canvas id="graph_canvas"></canvas>
JavaScript:
var canvas=document.getElementById("graph_canvas");
canvas.height=200;
canvas.width=200;
var graphSelection=document.getElementById("graphSelection");
var ctx = canvas.getContext("2d");
var data_=JSON.parse(JI.getGraphData(graphSelection.value));
var myNewChart = new Chart(ctx).Line(data_);
Where graphSelection is a <select> element with which we select the chart, JI.getGraphData returns JSON data for Chart.js.