简体   繁体   中英

AMCharts Timestamp on x axis

have some problem with AMCharts library. With Java have build a service which return datas in JSON format like this:

[{"datum":"2017-11-05 14:30:00","temperatura":17.2754,"slanost":38.0844},
{"datum":"2017-11-05 14:00:00","temperatura":17.1836,"slanost":38.1}]

What I want is to have datetime on x axis and temperature or / and salinity on y axis..

my html code is like this:

var chart = AmCharts.makeChart( "chartdiv", {
  "type": "serial",
  "dataLoader": {
    "url": "rest/podatki/tempslajson"
  },
  "categoryField": "datum",
  "dataDateFormat": "YYYY-MM-DD JJ:NN:SS",
  "startDuration": 1,
  "rotate": false,
  "categoryAxis": {
    "parseDates": true,
    "minPeriod": "ss"
  },
  "graphs": [ {
    "valueField": "temperatura",
    "bullet": "round",
    "bulletBorderColor": "#FFFFFF",
    "bulletBorderThickness": 2,
    "lineThickness ": 2,
    "lineAlpha": 0.5
  }]
} );

The problem is that I'm not shure if the dataDateFormat is right?!

the result I get is like this (but is wrong)

在此处输入图片说明

what I'am doing wrong?!

Date-based data must be in ascending order in AmCharts, as noted in the parseDates documentation. Per the docs:

Important: If this is set to true , the data points needs to come pre-ordered in ascending order. Data with incorrect order might result in visual and functional glitches on the chart.

Your sample data is in descending order, which is likely causing your issue.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM