-1
I have a problem in plotting my line chart using google Harts, when he does the search in the flock and populates my chart the same does not remove the oldest value, so keeps inserting and polluting the graph of data.
I used MAX and MIN within Options and nothing was done.
<script type="text/javascript">
google.charts.load('current', {packages: ['corechart']});
google.charts.setOnLoadCallback(draw);
function draw(){
drawBackgroundColor();
drawToolbar();
}
function drawBackgroundColor(){
var data = new google.visualization.DataTable();
var data2 = new google.visualization.DataTable();
data.addColumn('string', 'Horario');
data.addColumn('number', 'Central');
data.addColumn('number', 'Sala Baterias');
data.addColumn('number', 'Nobreak');
data2.addColumn('string', 'Horario');
data2.addColumn('number', 'Central');
data2.addColumn('number', 'Sala Baterias');
data2.addColumn('number', 'Nobreak');
//Captura os dados em JSON e monta o gráfico, de acordo com os dados.
data.addRows( <?php echo $jsonTable ?>);
data2.addRows( <?php echo $jsonTable2 ?>);
//Opções do gráfico:
var options = {
chart: {
title: 'Temperatura',
},
hAxis: {
title: 'Hora',
viewWindow: {
//min: 9,
//max: 16
}
},
vAxis: {
title: 'Temperatura'
},
focusTarget : 'category',
explorer: {
actions: ['dragToZoom', 'rightClickToReset'],
axis: 'horizontal',
keepInBounds: true,
maxZoomIn: 4.0,
maxZoomOut: 4.0
},
animation: {
duration: 1000,
easing: 'in'
},
colors: ['#a52714', '#097138', 'blue'],
//pointsVisible: true
};
var options2 = {
chart: {
title: 'Umidade',
},
hAxis: {
title: 'Hora'
},
vAxis: {
title: 'umidade'
},
colors: ['#a52714', '#097138', 'blue'],
};
var tempChart = new google.visualization.LineChart(document.getElementById('chart_div'));
google.visualization.events.addOneTimeListener(tempChart, 'ready', function () {
var umiChart = new google.visualization.LineChart(document.getElementById('chart_div2'));
umiChart.draw(data2, options2);
});
tempChart.draw(data, options);
}
</script>
I wanted him to have a kind of animation (because there will be no interaction in it, only monitoring), in which, at each select in the database the graph "ran" the lines, I looked at the documentation of adding and eliminating Rows, but I was not successful. Below follows the Javascript I use.
For some lack tompero. For you, I think you’re missing a little bit of how to ask a good question
– riki481