var ctx = document.getElementById("accuracy").getContext('2d'); var barChart = new Chart(ctx, { type: 'horizontalBar', data: { labels: ["Meters"], datasets: [{ label: 'Ublox', data: [0, 0], backgroundColor: "rgba(214, 69, 65, 1)" }, { label: 'Smartphone', data: [0, 0], backgroundColor: "rgba(30, 139, 195, 1)" }, { label: 'Dist. Ublox-Smartphone', data: [0], backgroundColor: "rgba(30, 139, 0, 1)" }] }, options: { scales: { xAxes: [{ ticks: { min: 0, max: 10 } }] }, legend: { display: true, enabled: true }, tooltips: { enabled: false, display: false } } }); function addSerialAccuracy(hacc, vacc){ barChart.data.datasets[0].data = [hacc, vacc]; barChart.update(); } function addTCPAccuracy(hacc, vacc){ barChart.data.datasets[1].data = [hacc, vacc]; barChart.update(); } function addDistanceToBarChart(dist){ barChart.data.datasets[2].data = [dist]; barChart.update(); }