我是海图的新手。我以前使用过Kendo UI图表。在Kendo中,我们可以如下所示告诉我们要在图表中绘制的字段名称:
series: [{
name: "steps",
field: "steps",
categoryField: "createddate"
}]
我们可以告诉dataSource如下:
dataSource: dSource
其中dSource是AJAX URL。
我在本教程的任何地方都找不到这样的东西。我的JSON文件如下:
[{"ActivitySummaryKey":174000,
"id":"kkse2",
"activityscore":-,
"activitycalories":456,
"caloriesBMR":1017,
"caloriesOut":1412,
"distances":1.57828236,
"elevation":0,
"fairlyActiveminutes":34,
"floors":0,
"lightlyActiveMinutes":28,
"marginalCalories":334,
"sedentaryMinutes":827,
"steps":5077,
"veryActiveMinutes":26,
"trackersteps":0,
"trackerdistances":0,
"trackerfloors":0,
"trackerelevation":0,
"trackerActivityCalories":0,
"trackerCaloriesOut":0,
"trackerMinutesSedentary":0,
"trackerminutesLightlyActive":0,
"trackerminutesFairlyActive":0,
"trackerminutesVeryActive":0,
"createddate":"9/17/2014 12:00:00 AM",
"distanceunit":"Miles"
}]
我想在y轴上绘制步骤,在x轴上创建日期。
如何处理?
最佳答案
您应该使用高图表数据格式-> series.data。
为了使您的点可见,必须使用JSON中的值设置x和y(步骤和createddate)。
另外,您还需要解析日期(例如Date.UTC())。
因此,Highcharts所需的结果将是:
[{
"ActivitySummaryKey":174000,
"id":"kkse2",
"activityscore":-,
"activitycalories":456,
"caloriesBMR":1017,
"caloriesOut":1412,
"distances":1.57828236,
"elevation":0,
"fairlyActiveminutes":34,
"floors":0,
"lightlyActiveMinutes":28,
"marginalCalories":334,
"sedentaryMinutes":827,
"steps":5077,
"veryActiveMinutes":26,
"trackersteps":0,
"trackerdistances":0,
"trackerfloors":0,
"trackerelevation":0,
"trackerActivityCalories":0,
"trackerCaloriesOut":0,
"trackerMinutesSedentary":0,
"trackerminutesLightlyActive":0,
"trackerminutesFairlyActive":0,
"trackerminutesVeryActive":0,
"createddate":"9/17/2014 12:00:00 AM",
"distanceunit":"Miles",
"x": 1410904800000, // timestamp in ms for Highcharts, extracted from "createdate"
"y": 5077 // y-value for Highcharts
}]
关于javascript - 如何在高位图中设置字段名称?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/25899536/