我一直在到处寻找可以帮助我的人,因为我无法展示从我为此目的创建的 JSON 数据存储发送到我的 Sencha 饼图的数据。
我正在显示包含以下值集的变量数组的打印形式的以下结果:
Array ([0] => Array ( [0] => 19 [nombre] => 19 [1] => Chargé de mission [type] => Charge de mission )[1] => Array ( [0] => 204 [nombre] => 204 [1] => Pré-adhérent [type] => Pre-adherent )[2] => Array ( [0] => 1 [nombre] => 1 [1] => Administrateur [type] => Administrateur )[3] => Array ( [0] => 25 [nombre] => 25 [1] => Auto-entrepreneur [type] => Auto-entrepreneur )[4] => Array ( [0] => 1157 [nombre] => 1157 [1] => Adhérent [type] => Adherent )[5] => Array ( [0] => 429 [nombre] => 429 [1] => Salarié [type] => Salarie ))
同时,为了将它发送到我的煎茶派,我使用下面编码的 JSON:
{"success":true,"total":"0","data":[{"0":"19","nombre":"19","1":null,"type":"Charge de mission"},{"0":"204","nombre":"204","1":null,"type":"Pre-adherent"},{"0":"1","nombre":"1","1":"Administrateur","type":"Administrateur"},{"0":"25","nombre":"25","1":"Auto-entrepreneur","type":"Auto-entrepreneur"},{"0":"1157","nombre":"1157","1":null,"type":"Adherent"},{"0":"429","nombre":"429","1":null,"type":"Salarie"}]}
我创建了我的 JSON 存储和饼图,如下所示:
var userStore = new Ext.data.JsonStore({
url: 'rapport/chartTypeProfils.php',
fields: [{name:'nombre', type:'int'},'type'],
root: 'data'
//totalProperty:'total'
});
userPie = Ext.extend( Ext.ux.Portlet,{
constructor: function(config) {
Ext.apply(this, {
//width: 400,
height: 300,
title: 'Utilisateur',
tools: tools,
//renderTo: 'user',
items: {
itemId: 'userStore',
store: userStore,
xtype: 'piechart',
dataField: 'nombre',
categoryField: 'type',
//extra styles get applied to the chart defaults
extraStyle: {
legend: {
display: 'left',
padding: 5,
font: {
family: 'Tahoma',
size: 13
}
}
}
}
});
userPie.superclass.constructor.apply(this, arguments);
}
});
但是,这不会显示饼图。