I am trying to implement a pie chart with struts2 jquery. This pie chart is supposed to be dynamic, calling AJAX method, I googled alot and tried with so many tags. But there were no results as long as the object is not filled and it doesn't go through iterator set in the code.
Although I can create the same chart using samples given in here,
MY ACTION CLASS
private Map<Double, Double> doubleMap;
public String execute()
{
doubleMap = new TreeMap<Double, Double>();
Random generator = new Random();
for (int i = 1; i <= 24; i++)
{
doubleMap.put(Double.valueOf("" + i), generator.nextDouble() * 10.0);
}
public Map<Double, Double> getDoubleMap()
{
return doubleMap;
}
public void setDoubleMap(Map<Double, Double> doubleMap)
{
this.doubleMap = doubleMap;
}
and in my jsp code is as following:
<s:url id="url3" action="account-summary-chart-data-provider"
namespace="account" />
<sjc:chart id="chartPie2" cssStyle="width: 300px; height: 200px;"
legendShow="false">
<sjc:chartData label="Map -Double, Double-" href="%{url3}"
list="doubleMap" />
</sjc:chart>
and while I have another json call in my page it works fine.
but it doesn't seem to work for dynamic pie chart. Static calls according to documentation and samples here is working fine, when I have java code like this:
<sjc:chart
id="chartPie"
cssStyle="width: 600px; height: 400px;"
pie="true"
pieLabel="true"
>
<sjc:chartData
id="pieSerie1"
label="Serie 1"
data="10"
/>
<sjc:chartData
id="pieSerie2"
label="Serie 2"
data="3"
/>
<sjc:chartData
id="pieSerie3"
label="Serie 3"
data="17"
/>
<sjc:chartData
id="pieSerie4"
label="Serie 4"
data="37"
/>
</sjc:chart>
but that doesn't meet my needs. Because I need a dynamic call and my jsp page has another json call within. So the not-working java class is as following:
@Action(value = "account-summary-chart-data-provider", results = { @Result(name = "success", type = "json") })
public String chartDataProvider() throws ClientException {
pieDataMap = new TreeMap<String, Integer>();
pieDataMap.put("Java", 18);
pieDataMap.put("C", 17);
pieDataMap.put("C++", 10);
pieDataMap.put("PHP", 8);
pieDataMap.put("(Visual) Basic", 6);
pieDataMap.put("C#", 5);
return SUCCESS;
}
and in jsp page the call is as follwoing:
<s:iterator value="pieDataMap" href="%{url3}">
<sjc:chartData id="A" label="%{key}" data="10" />
</s:iterator>
and even I tried without iterator like list tags.
<s:url id="url3" action="account-summary-chart-data-provider"
namespace="account" />${url3}
<sjc:chart id="chartPie2" cssStyle="width: 300px; height: 200px;"
legendShow="false" pie="true">
<sjc:chartData href="%{url3}"
list="pieDataMap"/>
</sjc:chart>
I came across to think maybe this kind of call is not supported for pie chart but there are nothing documented about this.
Thanks in advance for your help because I don't want to shift to another plugin.