Hi All,
I am new to HTML and Google Visualization.
My requirement:
I want to add a row to an existing line chart. i.e I want my line chart to
change dynamically based on user input.
Can anyone guide me or share a link of working examples or can anyone help
me to update my code?
The code below takes an input from the user using request.get parameter and
parse it into integer value.
The integer value of humidity along with time stamp are displayed as a line
chart.
But here the graph is displayed as a single point everytime i give new
input. what and where exactly the code need to be updated to get the
desired output?
<html>
<head>
<%
String humid= request.getParameter("humid");
int humid_new = Integer.parseInt(humid);
%>
<script type="text/javascript"
src="https://www.gstatic.com/charts/loader.js"></script>
<script type='text/javascript'>
google.charts.load('current', {'packages':['annotationchart']});
google.charts.setOnLoadCallback(drawChart);
function drawChart() {
var timeInMs = Date.now();
var data = new google.visualization.DataTable();
data.addColumn('datetime', 'Date');
data.addColumn('number','Humidity');
data.addRows([
[new Date(timeInMs), <%=humid_new%>]
]);
var chart = new
google.visualization.AnnotationChart(document.getElementById('chart_div'));
var options = {
displayAnnotations: true
};
chart.draw(data, options);
}
</script>
</head>
<body>
<div id='chart_div' style='width: 900px; height: 500px;'></div>
</body>
</html>
--
You received this message because you are subscribed to the Google Groups
"Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/google-visualization-api/8cd99e66-cc1c-4edd-841d-34a60ce9eb41o%40googlegroups.com.