Hello great minds,
I am exploring the new custon html feature, looks really great.
I have a code as below:
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link
href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css"
rel="stylesheet"
integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN"
crossorigin="anonymous"
/>
<style>
body {
padding: 0px;
}
#chart_div {
margin: 0 auto;
width: 250px;
}
h4 {
text-align: center;
}
</style>
<title>Pressure Gauge</title>
<div id="chart_div"></div>
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript">
google.charts.load('current', {'packages':['gauge']});
google.charts.setOnLoadCallback(drawChart);
function drawChart() {
let data = google.visualization.arrayToDataTable([
['Label', 'Value'],
['PSI', 5] // Set initial value
]);
let options = {
width: DashboardBlock.input.size.width - 5,
height: DashboardBlock.input.size.height - 5,
redFrom: 110, redTo: 220,
yellowFrom: -20, yellowTo: 110,
minorTicks: 5,
max: 220,
majorTicks: [
"-20",
"0",
"20",
"40",
"60",
"80",
"100",
"",
"140",
"160",
"180",
"200",
"220",
],
};
let chart = new google.visualization.Gauge(document.getElementById('chart_div'));
chart.draw(data, options);
// Simulate value update
// setInterval(function() {
// data.setValue(0, 1, Math.floor(Math.random() * 220));
// chart.draw(data, options);
// }, 3000); // Update value every 3 seconds
DashboardBlock.on('change', drawChart);
google.charts.load('current', { packages: ['gauge'] })
google.charts.setOnLoadCallback(function() {
googleLoaded = true
drawChart()
})
}
</script>
The widget appears as expected, but never gets updated, it stuck at the initial value 5.
The last value I transmitted is -15 but its not getting it.
Above is my code, I heed help on how to resolve this issue!