<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title>BarChart: Initiazation</title> <script src="../../codebase/dhtmlxchart.js" type="text/javascript"></script> <link rel="STYLESHEET" type="text/css" href="../../codebase/dhtmlxchart.css"> </head> <body > <h1>BarChart: Initialization</h1> <div id="chart1" style="width:950px;height:300px;border:1px solid #A4BED4;"></div></td> <div id="log_div" style="widht:950px; height:300px; font-family:Tahoma;"><div></div></div> <script> var data = [ { sales:"3.0", year:"2000" }, { sales:"3.8", year:"2001" }, { sales:"3.4", year:"2002" }, { sales:"4.1", year:"2003" }, { sales:"4.3", year:"2004" }, { sales:"9.9", year:"2005" }, { sales:"7.4", year:"2006" }, { sales:"9.0", year:"2007" }, { sales:"7.3", year:"2008" }, { sales:"4.8", year:"2009" } ]; var barChart1 = new dhtmlXChart({ view:"bar", container:"chart1", value:"#sales#", label:"#sales#", color:"#66cc33", width:50, tooltip:{ template:"#sales#" }, xAxis:{ title:"Sales per year", template:"#year#" } }); barChart1.parse(data,"json"); barChart1.attachEvent("onMouseMove", function(id){ id = barChart1.get(id).year; log("onMouseMove", id); return true; }) barChart1.attachEvent("onMouseOut", function(id){ log("onMouseOut", id); return true; }) barChart1.attachEvent("onItemClick", function(id){ id = barChart1.get(id).year; log("onItemClick", id); return true; }) barChart1.attachEvent("onItemDblClick", function(id){ id = barChart1.get(id).year; log("onItemDblClick", id); return true; }) function log(name, id){ var t = document.createElement("DIV"); t.innerHTML = name+" for element "+id; var p = document.getElementById("log_div"); p.insertBefore(t, p.firstChild); } </script> </body> </html>