You can easily reach your goal by using Chart.js (more precisely a Bar Chart) and a Firebase Realtime Database listener.
The code below will display a vertical bar that will be adapted each time the value of the arduinoValue
root node changes in the database.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Chart</title>
<script src="https://www.gstatic.com/firebasejs/6.3.5/firebase.js"></script>
<script src="Chart.js"></script>
<script src="https://www.gstatic.com/firebasejs/6.3.5/firebase-app.js"></script>
<script src="https://www.gstatic.com/firebasejs/6.3.5/firebase-database.js"></script>
</head>
<body>
<canvas id="myChart" width="200" height="200"></canvas>
<script>
var ctx = document.getElementById('myChart').getContext('2d');
var myChart = new Chart(ctx, {
type: 'bar',
data: {
labels: ['Value',],
datasets: [{
label: '# of Whatever',
data: [0],
backgroundColor: [
'rgba(255, 99, 132, 0.2)'
],
borderColor: [
'rgba(255, 99, 132, 1)'
],
borderWidth: 1
}]
},
options: {
scales: {
yAxes: [{
ticks: {
beginAtZero: true
}
}]
}
}
});
function addData(chart, label, data) {
chart.data.labels.push(label);
chart.data.datasets.forEach((dataset) => {
dataset.data.push(data);
});
chart.update();
}
function removeData(chart) {
chart.data.labels.pop();
chart.data.datasets.forEach((dataset) => {
dataset.data.pop();
});
chart.update();
}
//Firebase code
//Config values to ba adapted!
var config = {
apiKey: "xxxxx",
authDomain: "xxxxx",
databaseURL: "xxxxx",
projectId: "xxxxx",
storageBucket: "xxxxx",
messagingSenderId: "xxxxx"
};
firebase.initializeApp(config);
var valueRef = firebase.database().ref('arduinoValue');
valueRef.on('value', function(snapshot) {
removeData(myChart);
addData(myChart, "1", snapshot.val());
});
</script>
</body>
</html>
It's up to you to format the chart the way you want!
PS: to manage the size of the chart, see Charts.js graph not scaling to canvas size