获取整月的总价值

时间:2013-01-04 16:26:12

标签: xml parsing charts

我的highCharts的xml图表有问题。 我试着制作一张图表,在那里我可以看到我每月赚到的钱。但是我无法弄清楚我是如何从12月开始一起从2012年开始的。等等。

这是我的XML文件

的测试
<invoices>
    <invoice>
        <ID>0000152</ID>
        <Date>2012 17 12</Date>
        <Client>Wunderman</Client>
        <Amount>9,171.87</Amount>
        <Status>Sent</Status>
    </invoice>
    <invoice>
        <ID>0000151</ID>
        <Date>2012 19 12</Date>
        <Client>Valtech</Client>
        <Amount>83,281.25</Amount>
        <Status>Paid</Status>
    </invoice>
    <invoice>
        <ID>0000150</ID>
        <Date>2011 16 11</Date>
        <Client>Skanlog</Client>
        <Amount>3,125.00</Amount>
        <Status>Due</Status>
    </invoice>
</invoices>

这是我的JS档案。

$.get('includes/invoices.xml', function(xml) {

    // Split the lines
    var $xml = $(xml);
    var yearArray = new Array();

    // Push Years
     $xml.find('invoice').each(function(i, invoices) {
         var seriesOptions = {
         name : $(invoices).find('Date').text().substring(0, 4),
         data : []
     };

     if(jQuery.inArray(seriesOptions.name, yearArray) == -1) {
            $('<p></p>').html(seriesOptions.name).appendTo('body');
            yearArray.push(seriesOptions.name);             
        }


        // Push Amount ?        
        $(invoices).find('Amount').each(function(i, amounts) {
            var thisYear = $(invoices).find('Date').text().substring(0, 4)
            var thisMonth = $(invoices).find('Date').text().substring(8, 10)


            if($(invoices).find("Date").indexOf('2012') > -1){
                alert("sss");                   
            }
         });

        // add it to the options
        options.series.push(seriesOptions);
    });

    var chart = new Highcharts.Chart(options);
}); 

});

希望你能提供帮助,所以我可以继续:(

0 个答案:

没有答案
相关问题