2 回答
TA贡献1804条经验 获得超3个赞
和
<script>
fillData("valTemp", "Temp");
fillData("valHumid", "Hty");
fillData("valFlow1", "FlowRate");
fillData("valFlow2", "FlowRate2");
function fillData(elemID, child){
var data = db.child(child);
data.on('value', function(snap){
document.getElementById(elemID).innerHTML = snap.val();
});
}
</script>
TA贡献1793条经验 获得超6个赞
首先确保您的选择器具有画布 id Like
<canvas id="myChart" width="400" height="400"></canvas>
试试这个
`
var ctx = document.getElementById('myChart');
var myChart = new Chart(ctx, {
type: 'line',
data: {
labels: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
datasets: [{
label: 'Temperature',
data: [40, 48, 51, 45,7,8,40],
borderColor: [
'rgba(255, 0, 0)',
],
},{
label: 'Humidity',
data: [0, 5, 26.8, 25.4,5,8,9],
borderColor: [
'rgba(255, 0, 0)',
],
}]
},
options: {
scales: {
yAxes: [{
ticks: {
beginAtZero: true
}
}]
}
}
});
添加回答
举报