First of all, I have just started learning JavaScript, so please don't bash me if this question is too trivial.
So.. For the last 2 days I am trying to plot x-y graph using dygraph without any success.
Dygrahp takes 'data' as csv input (Official Documentation):
<html>
<head>
<script type="text/javascript"
src="dygraph-combined-dev.js"></script>
</head>
<body>
<div id="graphdiv"></div>
<script type="text/javascript">
g = new Dygraph(
// containing div
document.getElementById("graphdiv"),
// CSV or path to a CSV file.
"Date,Temperature\n" +
"2008-05-07,75\n" +
"2008-05-08,70\n" +
"2008-05-09,80\n"
);
</script>
</body>
</html>
In the jsp file, I am storing the data to a javascript array and then converting that array to comma separated values. Then I pass this csv to Dygraph. But for some reason the graph does not show.
Here is my code:
<div id="graphdiv"></div>
<script type="text/javascript">
$(document).ready(function() {
var list = ${dateAndWaitTimes};
var x = document.write(list);
g = new Dygraph( document.getElementById("graphdiv"), x);
});
</script>
Here's chrome debugger output:
Please help me, I am really frustrated.
Thanks.