【问题标题】:Struts 2 jQuery plugin in Pie Chart with json results带有 json 结果的饼图中的 Struts 2 jQuery 插件
【发布时间】:2014-01-21 13:25:16
【问题描述】:

通过使用 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 属性。我尝试了不同的值,但没有运气。

【问题讨论】:

  • 您能否分享一下 JSON 响应以及您是如何添加列表、数据和标签的,您在该部分保留了 cmets,所以我无法判断您是如何使用它的?

标签: jquery struts2 pie-chart struts2-jquery


【解决方案1】:

如果在你的代码中思考,你需要有 getter 和 setter for myData ,我也看到你错过了@ 987654321@ 为您的树形图。这些是我根据您粘贴的代码指出的,如果您有,请粘贴正确的代码。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-10-24
    • 2013-09-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多