0

我收到以下解析错误。我知道 javascript 代码有效,因为我已经用静态 JsonStore 替换了 xml 集成。你能发现我做错了什么吗?

提前感谢您的任何建议。

Error: Problem parsing d="L790,518.887301636L120,518.887301636Z" results-graph3.htm:1111
Error: Problem parsing d="Z" 

XML 文件:

<?xml version="1.0" encoding="utf-8"?>
<fundGrowthData>
    <growthData>
        <Year>1991</Year>
        <asOfDate>December 31, 1991</asOfDate>
        <Dividends>10000</Dividends>
        <Distribution>10000</Distribution>
    </growthData>
    <growthData>
        <Year>1992</Year>
        <asOfDate>December 31, 1992</asOfDate>
        <Dividends>10655</Dividends>
        <Distribution>10740</Distribution>
    </growthData>
    <growthData>
        <Year>1993</Year>
        <asOfDate>December 31, 1993</asOfDate>
        <Dividends>12146</Dividends>
        <Distribution>12297</Distribution>
    </growthData>
</fundGrowthData>

Javascript:

var store = Ext.create('Ext.data.Store',{
    autoLoad: true,
    fields: ['Year','Dividends','Distribution'],
    proxy: {
        type: 'ajax',
        url: 'pathtoXML',
        reader: {
            type: 'xml',
            record: 'growthData'
        }
    }
});

Ext.onReady(function () {

    Ext.create('Ext.chart.Chart', {
        renderTo: Ext.get("js-chart"),
        width: 800,
        height: 600,
        store: store,
        axes: [
            {
                type: 'Numeric',
                grid: true,
                position: 'left',
                fields: ['Dividends', 'Distribution'],
                title: 'Sample Values',
                grid: {
                    odd: {
                        opacity: 1,
                        fill: '#ddd',
                        stroke: '#bbb',
                        'stroke-width': 1
                    }
                },
                minimum: 0,
                adjustMinimumByMajorUnit: 0
            },
            {
                type: 'Category',
                position: 'bottom',
                fields: ['Year'],
                title: 'Sample Metrics',
                grid: true,
                label: {
                    rotate: {
                        degrees: 315
                    }
                }
            }
        ],
        series: [{
            type: 'area',
            highlight: true,
            axis: 'left',
            xField: 'Year',
            yField: ['Dividends', 'Distribution'],
            style: {
                opacity: 0.93
            }
        }]
    });

});
4

1 回答 1

0

由于默认情况下 xml 是一个字符串,我必须将类型属性添加到 Ext.data.Store

var store = Ext.create('Ext.data.Store',{
    autoLoad: true,
    fields: [
        {name : "Year", type: "int"},
        {name : "Dividends", type: "int"},
        {name : "Distribution", type: "int"}
        ],
    proxy: {
        type: 'ajax',
        url: 'pathToXml',
        reader: {
            type: 'xml',
            record: 'growthData'
        }
    }
});
于 2012-10-18T16:06:35.920 回答