Display Chart using count of items in XML

Hi
I have an XML file that looks like this:

<prayers>
   <prayer>
      <Timestamp>19/04/2012 12:15:35</Timestamp>
      <Name>John</Name>
      <PrayerType>Healing</PrayerType>
      <PrayerRequest>Help Me</PrayerType>
      <PrayerID>123</PrayerID</PrayerID>
   </prayer>
   <prayer>
      <Timestamp>19/04/2012 12:15:35</Timestamp>
      <Name>Fred</Name>
      <PrayerType>General</PrayerType>
      <PrayerRequest>Thanks</PrayerType>
      <PrayerID>456</PrayerID</PrayerID>
   </prayer>
</prayers>

There are 4 “PrayerTypes” that I would like to put in a chart (I already have the XML shown in a dhtmlxGrid)

Is there a way to count the number of “PrayerTypes” and display the results in a chart?

Thanks
Neil

Hi,

yes, it’s possible using “group” functionality:

[code] var barChart = new dhtmlXChart({
view:“bar”,
container:“chartDiv”,
value:"#count#",
xAxis:{
template:"’#id#"
},
yAxis:{
},
group:{
by:"#PrayerType#",
map:{
count:[null,setCount]
}
}
});

function setCount(prop,data){
return data.length;
}[/code]

Here are docs about this feature:
docs.dhtmlx.com/doku.php?id=dhtmlxchart:grouping
docs.dhtmlx.com/doku.php?id=dhtmlxchart:functor

Thanks for that… however I’m having some problems… :smiley:

Here’s the full code, I get the div and I can see the x and y axis lines, but no data, I think may may be loading the xml incorrectly…

[code]

[/code]

Thank you for your support
Neil

I’ve tried different things, but still get this…

Here’s the full code listing

[code]

chart test

[/code]

I would be very grateful if you could let me know where I’m going wrong.

Thanks

Here’s an image of what I was hoping for (this is from Google Spreadsheet where my data is actually stored)

Neil

I found the answer…

My xml was using:




but needs to have:




for Chart to work…

Now to change the xml generation program…
:smiley: :smiley: :smiley: :smiley: :smiley:

Try the following:

dhtmlx.DataDriver.xml.records = “/*/prayer”;

barChart.load("./xml/prayerlist.xml", “xml”);