3

By using struts 2 jQuery plugin ....

I am trying to create a Pie Chart which gets its data dynamically via json.

Is it possible?

All samples mentioned in http://struts.jgeppert.com/struts2-jquery-showcase/index.action and as long as I searched, are using s:iterator or static data.

Here is my codes:

   @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;
      }

And the 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>

The tag is working and an json result is turned back. But the pie is not displayed.

The cjc:chartData has list , data, and label properties which needs to be set. I try different values but no luck.

Alireza Fattahi
  • 42,517
  • 14
  • 123
  • 173
  • Can you share the JSON response also how you are adding list,data and label, you have kept comments in that section so I cannot judge how you are using it? – DarkHorse Feb 21 '14 at 11:41

1 Answers1

1

If think in your code, you need to have getter and setter for myData , and I also see that you have missed out <type1,type2> for your treeMap. These are things I pointed out based on code pasted by you, If you have them, then please paste proper code.

DarkHorse
  • 2,740
  • 19
  • 28