带有json结果的饼图中的Struts 2 jQuery插件

时间:2014-01-21 13:25:17

标签: jquery struts2 pie-chart struts2-jquery

使用struts 2 jQuery插件....

我正在尝试创建一个饼图,它通过json动态获取数据。

有可能吗?

http://struts.jgeppert.com/struts2-jquery-showcase/index.action中提及的所有样本,只要我搜索过,都使用s:iterator或静态数据。

这是我的代码:

   @Action(value = "json-chart-data", results = {
            @Result(name = "success", type = "json")
        })
      public String execute()
      {
        myData = new TreeMap<>();
        myData.put("a", 11);
        myData.put("b", 12);
        myData.put("b", 13);

        return SUCCESS;
      }

和jsp:

<s:url id="chartDataUrl" action="json-chart-data" />
<sjc:chart  id="chartAjax"
        pie="true"
        pieLabel="true"
        cssStyle="width: 600px; height: 400px;" >
    <sjc:chartData      
        id="chartAjaxData"
        href="%{chartDataUrl}"
            //Here we need to set list,data and label!
    />
  </sjc:chart>

标签正在运行,并且返回了json结果。但馅饼没有显示出来。

cjc:chartData包含需要设置的listdatalabel属性。我尝试了不同的价值但没有运气。

1 个答案:

答案 0 :(得分:0)

如果在您的代码中考虑,您需要为 myData 设置 getter和setter ,并且我也看到您错过了{ {1}}用于您的treeMap。这些是我根据您粘贴的代码指出的内容,如果您有,请粘贴正确的代码。

相关问题