Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/434.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 使用xtype和Ext.create呈现饼图_Javascript_Extjs_Charts_Highcharts - Fatal编程技术网

Javascript 使用xtype和Ext.create呈现饼图

Javascript 使用xtype和Ext.create呈现饼图,javascript,extjs,charts,highcharts,Javascript,Extjs,Charts,Highcharts,我首先尝试使用xtype将饼图渲染到具有边框布局的面板的中心区域。代码如下: { xtype:'pie', renderTo: Ext.getBody(), width: 200, height: 150, animate: true, layout:'fit', store: store, theme:

我首先尝试使用xtype将饼图渲染到具有边框布局的面板的中心区域。代码如下:

{
            xtype:'pie',
            renderTo: Ext.getBody(),
            width: 200,
            height: 150,
            animate: true,
            layout:'fit',
            store: store,
            theme: 'Base:gradients',
            series: [{
                type: 'pie',
                field: 'salary',
                showInLegend: true,
                highlight: {
                  segment: {
                    margin: 20
                  }
                },
                label: {
                    field: 'name',
                    display: 'rotate',
                    contrast: true,
                    font: '18px Arial'
                }
            }]    

}
我得到以下错误:

Uncaught TypeError: Cannot call method 'substring' of undefined 
但是当我使用相同的代码并使用Ext.create时,它就可以正常工作了

var chart=Ext.create('Ext.chart.Chart', {
renderTo: Ext.getBody(),
width: 200,
height: 150,
animate: true,
layout:'fit',
store: store,
theme: 'Base:gradients',
series: [{
    type: 'pie',
    field: 'salary',
    showInLegend: true,
    highlight: {
      segment: {
        margin: 20
      }
    },
    label: {
        field: 'name',
        display: 'rotate',
        contrast: true,
        font: '18px Arial'
    }
}]    
});
我使用图表作为一个项目,而不是

有什么问题吗

这是商店:

var store=Ext.create('Ext.data.Store',{
model:'Layouts.Person',
autoLoad:true,
data:{'items':[
                {'name':'john','empno':'1111','salary':'1234'},
                {'name':'edward','empno':'1212','salary':'2234'},
                {'name':'frank','empno':'1567','salary':'9774'},
                {'name':'michel','empno':'3456','salary':'8932'},
      ]},
proxy:{
    type:'memory',
    reader:{
        type:'json',
        root:'items'
    }
}
});
饼图的X类型为饼图:

http://www.objis.com/formationextjs/lib/extjs-4.0.0/docs/api/Ext.chart.series.Pie.html

试试这段代码,它会对你有用的

{
    xtype:'chart',
    animate: true,
    width: 500,
    height: 300,
    store: store,
    theme: 'Base:gradients',
    series: [{  
        type: 'pie',
        field: 'data1',
        showInLegend: true,
        tips: {
          trackMouse: true,
          width: 140,
          height: 28,
          renderer: function(storeItem, item) {
            //calculate and display percentage on hover
            var total = 0;
            store.each(function(rec) {
                total += rec.get('data1');
            });
            this.setTitle(storeItem.get('name') + ': ' + Math.round(storeItem.get('data1') / total * 100) + '%');
          }
        },
        highlight: {
          segment: {
            margin: 20
          }
        },
        label: {
            field: 'name',
            display: 'rotate',
            contrast: true,
            font: '18px Arial'
        }
    }]
}

交互:['rotate','itemhighlight'],不使用Extjs charany解决方案解决此问题?