Morris.js does not correctly show me the X axis

1

I have a graph like the following:

the data of the graph I take from this URL

and my javascript function is the following:

function charts(){
    {% for coin in UserCoins %}
      $.get("https://min-api.cryptocompare.com/data/histoday?aggregate=1&fsym={{coin.short_name}}&tsym=EUR&limit=30&extraParams=CryptoAssistant",function(data){
          //charts
          new Morris.Line({
            element: 'chart_{{coin.name}}',
            data: data['Data'],
            xkey: ['time'],
            ykeys: ['close'],
            labels: ['Close'],
            hideHover: 'auto',
            lineColors: ['#F96332'],
            pointSize: 0,
            postUnits: "€",
            xLabelFormat: function (timestamp) {
                          var date = new Date(timestamp);
                          return date.getDate() + '/' + date.getMonth() + '/' + date.getFullYear();
                        }
          });
      });
    {% endfor %}
  }

I would like to get the days of the month to show up on the X axis, since the json has an entry for each day of the month, however, nothing is shown ...

I've tried playing with the xLabelFormat , xLabels and nothing properties. I have also tried to enlarge the graph and although more labels are shown on the x-axis, not far from day to day is shown.

Currently shows me dates of 1970, when the timestamp received by the json is correct and I do not know why.

Can anyone give me any clue about where I have the fault?

    
asked by XBoss 29.07.2018 в 20:06
source

1 answer

0

I have modified my function to format the timestampt that I get from the get by the formatted file:

function charts(){
        {% for coin in UserCoins %}
          $.get("https://min-api.cryptocompare.com/data/histoday?aggregate=1&fsym={{coin.short_name}}&tsym=EUR&limit=30&extraParams=CryptoAssistant",function(data){
              all_data = []
              for (var act in data['Data']){
                data_ = new Object();
                data_['time'] = new Date(data['Data'][act]["time"]*1000).toLocaleDateString();
                data_['close'] = data['Data'][act]['close'];
                all_data.push(data_);
              }
              //charts
              new Morris.Line({
                element: 'chart_{{coin.name}}',
                data: all_data,
                xkey: 'time',
                ykeys: ['close'],
                labels: ['Close'],
                hideHover: 'auto',
                lineColors: ['#F96332'],
                pointSize: 0,
                postUnits: "€",
                parseTime: false
              });
          });
        {% endfor %}
      }
    
answered by 04.08.2018 / 12:01
source