How to retrieve/display title, units, copyright along with JSON data in Highcharts -


i have implemented code jsonp request, retrieving data multiple countries , displaying them lines in chart.

however, need title, units, copyright etc. json well, able display elements on graph too.

now, wonder how done.

the json response this:

    [         [             "series",             [                 {                     "data": [                                             [                             2007,                             2239300                         ],                         [                             2008,                             2237490                         ],                         [                             2009,                             2167070                         ],                         [                             2010,                             2204450                         ]                     ],                     "name": "france"                 },                 {                     "data": [                                             [                             2007,                             2324234                         ],                         [                             2008,                             3456352                         ],                         [                             2009,                             1241422                         ],                         [                             2010,                             4543231                         ]                     ],                     "name": "germany"                 }             ]         ],         [             "title",             {                 "text": "title here"             }         ],         [             "yaxis",             {                 "text": "the units here"             }         ]     ] 

my client's code need changed then. moment looks this:

    $.getjson(url, {selectedcountries: "france,germany,switzerland", type: "jsonp"})         .done(function(data)         {             options.series = data;              var chart = new highcharts.chart(options);         })         .fail(function(jqxhr, textstatus, error)          {             var err = textstatus + ", " + error;             console.log( "request failed: " + err );         }) 

and guess must turn this:

            options.series = data['series']['data'];             options.title  = data['title']; 

but doesn't work. give me hint should do? lot!

ok, got going finally. 1 has pass json object (and not array, , neither string (so, no quotes ' or " around object!). works charm here on fiddle.

here code:

    $(function () {         var options = {             chart: {                 renderto: 'container',                 type: 'spline',                 marginbottom: 50             },             series: [{}]         };           data = {                 "title": {                     "text": "here goes title"                 },                 "yaxis": {                     "title": {                         "text": "here go units"                     }                 },                 "series": [{                     "name": "france",                     "data": [[2006,2189260],[2007,2239300],[2008,2237490],[2009,2167070],[2010,2204450]]                 }]             };           options.series  = data["series"];         options.title  = data["title"];         options.yaxis  = data["yaxis"];           var chart = new highcharts.chart(options);      }); 

thanks lot sebastian bochan's great support!


Comments

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -