PDA

View Full Version : How can I display more then one Javascript Graph on the same HTML page



santana
29 Oct 2009, 05:06 AM
How can I display more then one Javascript Graph on the same HTML page. everytime to add another graph, one will work and the rest of the graphs will not. Is there a way to display more then one graph.

Here is the code:


<html>
<head>
<title>Graph</title>
<body>
<title>Data</title>
<p align="center">&nbsp;</p>
<p align="center"><font size="4"><b>test</b></font></p>
<center>
<script type="text/javascript" src=".\JavaFiles\wz_jsgraphics.js"></script>
<script type="text/javascript" src=".\JavaFiles\line.js"></script>
<div id="lineCanvas" style="overflow: auto; position:center;height:300px;width:800px;"></div>
<script type="text/javascript">
var g = new line_graph();
g.add(' 1.0',197);
g.add(' 2.0',721);
g.add(' 3.0',852);

g.render("lineCanvas","test");
</script>
<p align="left"><font size="2"><b>Test </b></font></p>
</body>

is_numeric
30 Oct 2009, 02:17 AM
<script type="text/javascript">


var g = new line_graph();

g.add(' 1.0',197);
g.add(' 2.0',721);
g.add(' 3.0',852);

g.render("lineCanvas","test");

//////////////

var h = new line_graph();

h.add(' 1.0',197);
h.add(' 2.0',721);
h.add(' 3.0',852);

h.render("lineCanvas","test2");

///////////////

var s = new line_graph();

s.add(' 1.0',197);
s.add(' 2.0',721);
s.add(' 3.0',852);

s.render("lineCanvas","test3");

</script>


<p align="left"><font size="2"><b>Test </b></font></p>
<p align="left"><font size="2"><b>Test2 </b></font></p>
<p align="left"><font size="2"><b>Test3 </b></font></p>

Have you looked at the free google chart api

http://code.google.com/apis/chart/