javascript - Formatting dates in HighCharts -


i have following code:

  <script> $.getjson('https://www.quandl.com/api/v3/datasets/opec/orb.json?order=asc', function(json) {     var hijson = json.dataset.data.map(function(d) {       return [new date(d[0]), d[1]]     });      // create chart     $('#container').highcharts('chart', {       rangeselector: {         selected: 1       },       title: {         text: 'opec crude oil price',       },       series: [{         type: 'line',         name: 'opec',         data: hijson,       }]     }); }); 

which prints beautiful chart follows:

opec crude oil price

but can see, dates not in correct format. struggling work out wrong?

all appreciated always!

update:

so holvar's comment solved 1 problem, have on same theme.

my code follows:

<script> $.getjson('https://www.quandl.com/api/v3/datasets/boe/iuaaamih.json?auth_token=pg6fbmvfqazvfdugpqhz&start_date=2003-01-02&order=asc', function(json) {     var hijson = json.dataset.data.map(function(d) {       return [new date(d[0]), d[1]]     });      // create chart     $('#interest').highcharts('chart', {       xaxis: {         type: 'datetime',         datetimelabelformats: {                           day: '%y'                       }         },                   rangeselector: {       selected: 1       },       title: {         text: 'uk interest rates',       },       series: [{         type: 'line',         name: 'interest rate',         data: hijson,       }]     }); }); 

but produces chart without dates on bottom. i'd years 2003-01-02. chart looks this

uk interest rate

i don't understand why it's not showing annual date in solution posed question?!

you appreciated!

i believe issue way data map happening. ending array contains multiple arrays, instead of object "x" , "y" properties. try changing initialization of hijson variable like:

var hijson = json.dataset.data.map(function(d) { return { x: new date(d[0]), y: d[1] }; });

that seems working on local environment.


Comments

Popular posts from this blog

routing - AngularJS State management ->load multiple states in one page -

python - GRASS parser() error -

Swift game error message -