Create JSON data NVD3 Chart using Java -
i working on nvd3 chart need create json info chart below:
[{ "key" : "north america" , "values" : [ [ 1025409600000 , 23.041422681023] , [ 1028088000000 , 19.854291255832] ] }, { "key" : "africa" , "values" : [ [ 1025409600000 , 23.041422681023] , [ 1028088000000 , 19.854291255832] ] }, { "key" : "south america" , "values" : [ [ 1025409600000 , 23.041422681023] , [ 1028088000000 , 19.854291255832] ] }] would please help me create above json info using java trying create construction since lastly 3 hours not successful yet.
here plunker link: stacked area chart nvd3
here live json info illustration want create in java: json illustration data
here solution found myself:
import org.json.jsonarray; import org.json.jsonobject; public class createnvd3jsondatajava { public static void main(string[] args) { jsonobject jo = new jsonobject(); jo.put("values", new jsonarray(new long[][]{{1025409600000l,23l},{1028088000000l,19l},{1030766400000l,21l},{1033358400000l,22l}})); jo.put("key", "north america"); jsonarray ja = new jsonarray(); ja.put(jo); ja.put(jo); ja.put(jo); system.out.println(ja); } } java json nvd3.js
No comments:
Post a Comment