-1

在这里,当我单击该条形图时,我必须在雷达图上进行更改

我有一个条形图,我将其值发送到 Servlet,并且基于每个值,我必须在radarChart 上填充一些数据。数据将发送到 Servlet,radarChart 也即将到来。但问题是雷达仅适用于一种情况。它不适用于其他部分。因此无法使雷达和栏交互。这是我的代码...

它是我将数据发送到 Servlet 的控制器。

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'];
        //alert(barData);
        me.dataBaseCall(obj.storeItem.data['source'],obj.storeItem.data['count']);
    });
},
dataBaseCall: function(source,count){
    //alert(barData);

    Ext.Ajax.request({
        url: "CallRatiosAnalysis",
        success: function(response, opts){
            //do what you want with the response here
            console.log("hiiiiiiiiiiii");
        },
        failure: function(response, opts) {
            alert("server-side failure with status code " + response.status);
        },
        params: {
            source: source,
            count:  count
        }

这是 Servlet,radarChart 正在形成的地方......

protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    String mysource = request.getParameter("source");
    String mycount = request.getParameter("count");

    System.out.println(mysource + "\n" + mycount);

    if (mysource != null && mycount != null) {

        PrintWriter out = response.getWriter();
        response.setContentType("text/html");
        ArrayList<IndCallType> ratios = new ArrayList<IndCallType>();
        ratios.add(new IndCallType("Voice", "40"));
        ratios.add(new IndCallType("SMS", "30"));
        ratios.add(new IndCallType("MMS", "5"));
        ratios.add(new IndCallType("GPRS", "20"));
        ratios.add(new IndCallType("Others", "5"));
        Gson gson = new Gson();
        JsonArray arrayObj = new JsonArray();
        for (int i = 0; i < ratios.size(); i++) {
            IndCallType count = ratios.get(i);
            JsonElement linObj = gson.toJsonTree(count);
            arrayObj.add(linObj);
        }

        JsonObject myObj = new JsonObject();
        myObj.addProperty("success", true);
        myObj.add("allCalls", arrayObj);
        myObj.addProperty("allCallsRatio", ratios.size());

        out.println(myObj.toString());
        out.close();
    }else{ //this part is not working 
        PrintWriter out = response.getWriter();
        response.setContentType("text/html");
        ArrayList<IndCallType> ratios = new ArrayList<IndCallType>();
        ratios.add(new IndCallType("Voice", "10"));
        ratios.add(new IndCallType("SMS", "3"));
        ratios.add(new IndCallType("MMS", "50"));
        ratios.add(new IndCallType("GPRS", "80"));
        ratios.add(new IndCallType("Others", "1"));
        Gson gson = new Gson();
        JsonArray arrayObj = new JsonArray();
        for (int i = 0; i < ratios.size(); i++) {
            IndCallType count = ratios.get(i);
            JsonElement linObj = gson.toJsonTree(count);
            arrayObj.add(linObj);
        }

        JsonObject myObj = new JsonObject();
        myObj.addProperty("success", true);
        myObj.add("allCalls", arrayObj);
        myObj.addProperty("allCallsRatio", ratios.size());

        out.println(myObj.toString());
        out.close();
    }
}

只有一个部分,即 if 条件有效。但 else 部分无效。我不明白原因。有人请帮助我。

4

1 回答 1

1

假设您已经渲染了雷达图,并且商店配置了 url: "CallRatiosAnalysis" 而不是调用 Ext.Ajax.request 您应该:

Ext.getCmp(<selector for radar chart>).getStore().load({
    params: {
        source: source,
        count:  count
    }
});

如果你不这样做,那么你的成功回调应该实现图表的呈现,并加载数据。

于 2013-05-13T17:07:46.363 回答