I’m attempting to build a dynamic xml file with asp and pass it to dhxmlx charts. However the dhtmlxChart script doesn’t seem to recognize the asp generated xml file.
ASP generated XML file (xml_projects.asp):
Response.ContentType = "text/xml"
Response.write("<?xml version='1.0' encoding='ISO-8859-1'?>"&vbcrlf)
SQL = "Select hours, scope FROM projects"
Set rs = oConn.Execute(SQL)
Response.Write( "<data>"&vbCrlf)
itmCnt = 1
while NOT rs.EOF
Response.Write(vbTab& "<item id="""&itmCnt&""">"&vbCrlf)
for i=0 to rs.Fields.Count-1
Response.Write(vbTab&vbTab& "<"&rs(i).Name&">"&rs(i)&"</"&rs(i).Name&">"&vbCrlf)
next
Response.Write(vbTab& "</item>"&vbCrlf)
itmCnt = itmCnt + 1
rs.MoveNext()
wend
Response.Write( "</data>")
Content from the output page
<script>
var barChart;
window.onload=function(){
barChart = new dhtmlXChart({
view:"bar",
container:document.getElementById("chart_container"),
value:"#hours#",
label:"#hours#",
xAxis:{
title:"<%=Request.QueryString("v")%> Hours by Activity <br><%=MonthName(Request.QueryString("m"))%> 2010",
template:"#scope#",
lines: true
},
yAxis: {
start: 0,
end: 300,
step: 25,
title: "Hours"
} ,
tooltip: {
template: "#hours#"
},
padding:{
bottom:60,
},
width:30,
gradient:true,
border:true
})
barChart.load("xml_projects.asp");
}
</script>
<div id="chart_container" style="width:800px;height:400px;border:1px solid #A4BED4;float:left;margin-right:20px"></div>
I’m assuming it’s something wrong with my dynamically generated data, because if I create an xml file from asp with dummy data the chart works fine.
Many Thanks!