2 charts on one website

Hello, I am testing with your charts and I can display one chart easily with the code attached.

When I duplicate this chart and replace “chart1” with “chart2” in order to get two times the same chart on the screen I am getting only one chart anyway. He shows me the 2nd chart but without any line, it’s just an empty block.

What is the problem?

Thank you, Reg

[code]

Statistic

[/code]

You are using window.onload = function(){ for both blocks, and second one will replace first one.

to exec both blocks, instead of

 window.onload = function(){ ... };

you can use

dhtmlxEvent(window, "load", function(){ ... });

with second syntax you can define as much code blocks as necessary.

Hello Stanislav, now I am getting two empty blocks. Pls see the code. What’s wrong? Tku, Reg

[code]

2 Charts
</head>
<body >

Charttest - 2 Charts

<link rel="STYLESHEET" type="text/css" href="codebase/dhtmlxchart.css">

Chart #1

<table>
	<tr>
		<td><div id="chart1" style="width:600px;height:250px;border:1px solid #A4BED4;"></div></td>
	</tr>
</table>

Chart #2

<table>
	<tr>
		<td><div id="chart2" style="width:600px;height:250px;border:1px solid #A4BED4;"></div></td>
	</tr>
</table>



		
		
     </div>
     

</body>
[/code]

dhtmlxEvent function is defined only in dhtmlxcommon.js (the library that is required for almost all our components, except Dataview, Chart and Calendar). dhtmlx.js (a compiled version from the Suite package) also contains it.

dhtmlxEvent function looks like so:

function dhtmlxEvent(el, event, handler){
if (el.addEventListener)
el.addEventListener(event, handler, false);

else if (el.attachEvent)
	el.attachEvent("on"+event, handler);

}

Therefore, if you are using only Chart component, you may define this function and do not include dhtmlxcommon.js

Cool, thank you, that works.

Here the whole thing in case somebody else wants to see it.

Best, R

[code]

2 Charts
  <script type="text/javascript">
    function dhtmlxEvent(el, event, handler){
    if (el.addEventListener)
    el.addEventListener(event, handler, false);
    else if (el.attachEvent)
    el.attachEvent("on"+event, handler);
    }
  </script>

</head>
<body >

Charttest - 2 Charts

<link rel="STYLESHEET" type="text/css" href="codebase/dhtmlxchart.css">

Chart #1

<table>
	<tr>
		<td><div id="chart1" style="width:600px;height:250px;border:1px solid #A4BED4;"></div></td>
	</tr>
</table>

Chart #2

<table>
	<tr>
		<td><div id="chart2" style="width:600px;height:250px;border:1px solid #A4BED4;"></div></td>
	</tr>
</table>



		
		
     </div>
     

</body>
[/code]