我使用 ExtJs mvc 在一个页面中创建了 2 个图表(条形柱和雷达)。我希望当我单击图表的列时,雷达会显示变化。我编写了在控制器中单击的功能。这是控制器...
Ext.define('Gamma.controller.ControlFile', {
extend : 'Ext.app.Controller',
//define the stores
stores : ['BarColumn','RadarView','VoiceCallStore','SMSCallStore','MMSCallStore','GPRSUsageStore'],
//define the models
models : ['BarCol','radar','VoiceCallModel','SMSCallModel','MMSCallModel','GPRSUsageModel'],
//define the views
views : ['BarColumnChart','LineChart','RadarChart','VoicePie','SMSPie','MMSPie','GPRSPie'],
initializedEvents: false,
init: function() {
this.control({
'#barColumnChart': {
afterlayout: this.afterChartLayout
}
});
},
afterChartLayout: function(){
var me=this;
if(this.initializedEvents==true) return;
this.initializedEvents=true;
Ext.getCmp('barColumnChart').series.items[0].on('itemmousedown',function(obj){
// alert(obj.storeItem.data['source']+ ' &' + obj.storeItem.data['count']);
// var barData=obj.storeItem.data['source']+ ' &' + obj.storeItem.data['count'];
var source=obj.storeItem.data['source'];
var count=obj.storeItem.data['count'];
me.dataBaseCall(source,count);
});
},
dataBaseCall: function(source,count){
Ext.Ajax.request({
url: "CallRatiosAnalysis?methodName=callDistribution"+"¶m="+source+"¶m1="+count,
method:'GET',
reader: {
type: 'json',
root: 'allCalls',
totalProperty: 'allCallsRatio',
successProperty: 'success'
}
});
}
});
现在在这个函数中,我通过 ajax 调用 servlet.. 这是应该发生这种变化的函数......
private void callDistribution(HttpServletRequest request, HttpServletResponse response) throws IOException {
PrintWriter out = response.getWriter();
response.setContentType("text/html");
String name = request.getParameter("param");
String data = request.getParameter("param1");
if (name == null && data == null) {
ArrayList<IndCallType> radaranalysis = new ArrayList<IndCallType>();
radaranalysis.add(new IndCallType("Voice", "40"));
radaranalysis.add(new IndCallType("SMS", "30"));
radaranalysis.add(new IndCallType("MMS", "5"));
radaranalysis.add(new IndCallType("GPRS", "20"));
radaranalysis.add(new IndCallType("OTHERS", "5"));
JsonObject myObj = new JsonObject();
if (!radaranalysis.isEmpty()) {
JsonArray jsonObj = Utility.wrapToJSONObject(radaranalysis);
myObj.addProperty("success", true);
myObj.add("allCalls", jsonObj);
myObj.addProperty("allCallsRatio", jsonObj.size());
out.println(myObj.toString());
out.close();
} else {
myObj.addProperty("success", false);
out.println(myObj.toString());
out.close();
}
}else{
ArrayList<IndCallType> radarclcikanalysis = new ArrayList<IndCallType>();
radarclcikanalysis.add(new IndCallType("Voice", "10"));
radarclcikanalysis.add(new IndCallType("SMS", "5"));
radarclcikanalysis.add(new IndCallType("MMS", "50"));
radarclcikanalysis.add(new IndCallType("GPRS", "2"));
radarclcikanalysis.add(new IndCallType("OTHERS", "45"));
JsonObject myObj = new JsonObject();
if (!radarclcikanalysis.isEmpty()) {
JsonArray jsonObj = Utility.wrapToJSONObject(radarclcikanalysis);
myObj.addProperty("success", true);
myObj.add("allCalls", jsonObj);
myObj.addProperty("allCallsRatio", jsonObj.size());
out.println(myObj.toString());
out.close();
} else {
myObj.addProperty("success", false);
out.println(myObj.toString());
out.close();
}
}
}
如果我在其他部分写任何要打印的东西,那么它会完美打印。但图表的修改没有发生..请任何人帮助我...