【问题标题】:Data not showing correctly in AMCharts (data retrieved with dataLoader)数据未在 AMCharts 中正确显示(使用 dataLoader 检索的数据)
【发布时间】:2019-02-25 09:36:51
【问题描述】:

我正在将一个带有数据的 json 文件加载到我的 amcharts 中,并且我将日期时间显示为我的类别轴。它似乎做错了什么,因为它表明有来自 1899 年的数据,而 json 文件中最旧的数据来自 2018 年。我使用 dateParser 以正确的日期结构解析它,但是当我不解析它时,它显示在图表中,但我不能在数据上使用时间函数。所以这是个大问题。以下是我的图表代码:

var chartConfig = {
    "dataLoader": {
        "url": "datafiles/dummyData.json",
        "format": "json",
                "showErrors": true,
        "noStyles": true,
        "async": true
    },
    "type": "serial",
    "theme": "none",
    "marginLeft": 70,
    "dataDateFormat": "D/MM/YYYY J:NN",
    "graphs": [{
        "bullet": "round",
        "bulletBorderAlpha": 1,
        "bulletColor": "#FFFFFF",
        "bulletSize": 5,
        "hideBulletsCount": 50,
        "lineThickness": 2,
        "lineColor": "#000000",
        "title": "red line",
        "useLineColorForBulletBorder": true,
        "valueField": "Historie glucose (mg/dL)"
  }],
    "chartCursor": {
        "categoryBalloonEnabled": false
    },
    "categoryField": "Tijd",
    "categoryAxis": {
        "parseDates" : true,
        "minPeriod" : "hh",
        "dashLength": 1,
        "minorGridEnabled": true,
        "labelsEnabled": true,
        "tickLength": 0
    },
    "valueAxes": [{
        "ignoreAxisWidth": true
  }],
    guides: [{
        //value axis guide
        value: 100,
        toValue: 200,
        fillAlpha: .40,
        fillColor: "#008000"
}, {
        value: 0,
        toValue: 100,
        fillAlpha: 0.40,
        fillColor: "#0000FF"
}, {
        value: 200,
        toValue: 10000,
        fillAlpha: 0.40,
        fillColor: "#FF0000"
}]
};

这是我的 json 文件的示例:

  {
     "ID":75461
    ,"Tijd":"6/11/2018 5:47"
    ,"Type vastlegging":0
    ,"Historie glucose (mg/dL)":122
    ,"Scan glucose (mg/dL)":null
    ,"Niet-numeriek snelwerkende insuline":""
    ,"Snelwerkende insuline (eenheden)":""
    ,"Niet-numeriek voedsel":""
    ,"Koolhydraten (gram)":""
    ,"Niet-numeriek langwerkende insuline":""
    ,"Langwerkende insuline (eenheden)":""
    ,"Notities":""
    ,"Strip glucose (mg/dL)":""
    ,"Keton (mmol/L)":""
    ,"Maaltijdinsuline (eenheden)":""
    ,"Correctieinsuline (eenheden)":""
    ,"Gebruikerswijziging insuline (eenheden)":""
    ,"Vorige tijd":""
    ,"Bijgewerkte tijd":""
  }

以下是图表中数据显示方式的屏幕截图:

有人可以帮帮我吗?我已经找了好几天了。提前致谢!

【问题讨论】:

    标签: javascript json amcharts


    【解决方案1】:

    问题可能是由于您的时间戳格式。如this article 中所述,dataDateFormat 不支持用星号标记的单字母格式代码(尤其是不允许使用DJ - 你需要DDJJ)。您需要将数据中的小时数和天数归零,并相应地调整您的 dataDateFormat

    【讨论】:

    • 谢谢,我现在就试试
    猜你喜欢
    • 2021-12-07
    • 1970-01-01
    • 1970-01-01
    • 2018-10-02
    • 2020-03-10
    • 1970-01-01
    • 1970-01-01
    • 2016-12-04
    • 1970-01-01
    相关资源
    最近更新 更多