c3.js - 如何将 y 线值设置为 url 中的第一个值(json 数据)
c3.js - How can I set the y lines value to the first value from url (json data)
如何将 y 线值设置为 URL 中的第一个值? (JSON 数据)
var chartDisplay = c3.generate({
bindto: '.chart',
data: {
url: '/stats',
mimeType: 'json',
},
grid: {
y: {
lines: [ {
value: data1 <---- this is what I cant figure out
}
]
}
}
});
json 数据如下所示:
{
"data1": 3000,
"data2": [
3000,
3300.0,
3410.0,
4520.0,
]
}
尝试将其添加到您的图表声明中,
onrendered: function () {
this.api.ygrids([
{value: this.data.targets[0].values[0].value, text:'data 1 value'},
]);
},
this.api与'chart'变量基本相同,this.data是指向加载数据集的指针。 targets[0]
将是第一个加载的系列 (data1),values[0].value
将是第一个条目的值
如何将 y 线值设置为 URL 中的第一个值? (JSON 数据)
var chartDisplay = c3.generate({
bindto: '.chart',
data: {
url: '/stats',
mimeType: 'json',
},
grid: {
y: {
lines: [ {
value: data1 <---- this is what I cant figure out
}
]
}
}
});
json 数据如下所示:
{
"data1": 3000,
"data2": [
3000,
3300.0,
3410.0,
4520.0,
]
}
尝试将其添加到您的图表声明中,
onrendered: function () {
this.api.ygrids([
{value: this.data.targets[0].values[0].value, text:'data 1 value'},
]);
},
this.api与'chart'变量基本相同,this.data是指向加载数据集的指针。 targets[0]
将是第一个加载的系列 (data1),values[0].value
将是第一个条目的值