我是EXTJS的新手。我想创建饼图和我想从数据库中检索的饼图的数据。以下是我的代码。某种方式控制器没有从EXTJS控制器调用。有人可以帮我这个。我使用的是EXTJS 4.2。
Ext.onReady(function() {
Ext.define('DashBoard.model.DashBoardModel', {
extend: 'Ext.data.Model',
fields: ['title', 'size']
});
Ext.define('DashBoard.store.DashBoardStore', {
extend : 'Ext.data.Store',
model : 'DashBoard.model.DashBoardModel',
proxy : {
type : 'ajax',
url : '/TechnologyPrortal/dashboard/loadDashBoard.action',
reader : {
type : 'json',
root : 'dashboarddetails'
}
}
});
var chart = Ext.create('Ext.chart.Chart', {
renderTo: Ext.getBody(),
xtype: 'chart',
width: '100%',
height: 410,
padding: '10 0 0 0',
style: 'background: #fff',
animate: true,
shadow: true,
store: 'DashBoardStore',
theme: 'Base:gradients',
legend: {
position: 'bottom'
},
series: [
{
type: 'pie',
angleField: 'size',
showInLegend: true,
label: {
field: 'title',
display: 'outside',
font: '12px Arial',
calloutLine: true
},
highlight: {
segment: {
margin: 20
}
},
label: {
field: 'title',
display: 'rotate',
contrast: true,
font: '18px Arial'
},
tips: {
trackMouse: true,
width: 120,
renderer: function(storeItem, item) {
this.setTitle(storeItem.get('title') + ': ' + storeItem.get('size') + '%');
}
}
}
]
});
Ext.define('DashBoard.view.DashBoardView', {
//var panel1 = Ext.create('widget.panel', {
extend : 'Ext.form.Panel',
width: 800,
height: 600,
title: 'Server',
alias : 'widget.dashBoardView',
renderTo: Ext.getBody(),
layout: 'fit',
tbar: [{
text: 'Save Chart',
handler: function() {
Ext.MessageBox.confirm('Confirm Download', 'Would you like to download the chart as an image?', function(choice){
if(choice == 'yes'){
chart.save({
type: 'image/png'
});
}
});
}
}],
items: chart
});
Ext.define('DashBoard.controller.DashBoardDetails', {
extend : 'Ext.app.Controller',
stores : ['DashBoardStore'],
views : ['DashBoardView'],
refs:[
{
ref: 'dashBoardView',
xtype : 'dashBoardView',
selector: 'dashBoardView',
autoCreate: true
}
]
});
Ext.application({
name : 'DashBoard',
controllers: ['DashBoardDetails'],
launch: function () {
Ext.widget('dashBoardView', {
width : '100%',
height: 400,
renderTo: 'output'
});
}
}
);
});
由于 萨钦