我正在尝试将一些数据集加载到Chart js。我正在向我的服务器执行ajax请求,并且返回的是以这种格式的Laravel Collection:
"23-August-16" => array:3 [▼
"day" => "23-August-16"
"total" => 22
"partial" => 9
]
"24-August-16" => array:3 [▼
"day" => "24-August-16"
"total" => 23
"partial" => 10
]
现在从Chart js我想将键分配给相应的值。
所以我有:
labels: Object.keys(data), //this is ok
datasets: [
{
label: "Total Employees",
backgroundColor: "rgba(38, 185, 154, 0.31)",
/* Chart js options */
data: Object.keys(data).map(key => data[key]) //here is not working
},
]
我想访问总属性,但我找不到获取值的方法。我正在执行映射但在此之后我无法找到获取总数的方法。
由于
PS:这是json输出:
{
23-August-16: {
day: "23-August-16",
total: 22,
partial: 9
},
24-August-16: {
day: "24-August-16",
total: 23,
partial: 10
},
25-August-16: {
day: "25-August-16",
total: 25,
partial: 11
},
26-August-16: {
day: "26-August-16",
total: 33,
partial: 11
},
我正在使用Chartjs