Can anyone please help me to understand how should i access json data in js. JSP-struts code to access. i am using struts2 , json, dojo. But getting issue accessing the data.
var chartData = dojo.xhrGet({
url : "getJSONResult",
handleAs : "json",
preventCache : false,
load : function(data) {
//how to process
}
});
my struts.xml
<package name="json" namespace="/" extends="json-default">
<action name="getJSONResult" method="execute"
class="uk.co.bandc.businessmonitor.web.controller.ShowTransactionAction">
<result type="json" />
</action>
</package>
My action class
package uk.co.bandc.businessmonitor.web.controller;
import com.opensymphony.xwork2.ActionSupport;
public class ShowTransactionAction extends ActionSupport {
/**
*
*/
private static final long serialVersionUID = 1L;
int[] numberarray1 = { 10000, 9200, 11811, 12000, 7662, 13887, 14200, 12222, 12000,
10009, 11288, 12099 };
public String execute() {
return SUCCESS;
} // End execute()
public int[] getNumberarray1() {
return numberarray1;
}
public void setNumberarray1(int[] numberarray1) {
this.numberarray1 = numberarray1;
}
} // End class
What kind of chart do you want to draw? your data seems to be one-dimensional. Typically for a cartesian chart (bar, line etc) you will need 2 dimensional data, for example:
var exampleData =
[
{ time: 10, count: 7382 },
{ time: 20, count: 1852 },
{ time: 35, count: 2397 },
{ time: 50, count: 1442 },
{ time: 55, count: 1854 }
];
You can then use the dojox.charting.Chart2D to render the chart
See http://dojotoolkit.org/documentation/tutorials/1.6/charting/ for examples