AMCharts 中的数据未正确显示(使用 dataLoader 检索的数据)
Data not showing correctly in AMCharts (data retrieved with dataLoader)
我正在将包含数据的 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":""
}
以下是图表中数据显示方式的屏幕截图:
有人可以帮助我吗?我已经找了好几天了。提前致谢!
问题可能是由您的时间戳格式引起的。如 this article 中所述,dataDateFormat
不支持用星号标记的单字母格式代码(特别是 D
和 J
是不允许的 - 您需要 DD
和 JJ
)。您需要对数据中的小时数和天数进行零填充,并相应地调整 dataDateFormat
。
我正在将包含数据的 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":""
}
以下是图表中数据显示方式的屏幕截图:
有人可以帮助我吗?我已经找了好几天了。提前致谢!
问题可能是由您的时间戳格式引起的。如 this article 中所述,dataDateFormat
不支持用星号标记的单字母格式代码(特别是 D
和 J
是不允许的 - 您需要 DD
和 JJ
)。您需要对数据中的小时数和天数进行零填充,并相应地调整 dataDateFormat
。