【发布时间】:2017-03-20 03:59:40
【问题描述】:
我有一个C3 timeseries chart,我希望在一天中每 15 分钟显示一次,这样一天就占据了整个 X 轴,然后随着一天的进展和数据的到来显示数据。
我有以下设置..
var now = new Date().toISOString();
this.lineChart = generate({
bindto: '#line',
transition: {
duration: 1000
},
data: {
x: 'x',
xFormat: '%Y-%m-%dT%H:%M:%S.%LZ',
columns: [
['x', now],
['data1', 0]
]
},
axis: {
x: {
type: 'timeseries',
localtime: true,
tick: {
format: '%H:%M %p',
culling : true,
rotate : 60
}
}
}
});
然后我按如下方式加载日期..
let shiftStart = new Date(startDateTime);
let endTime = new Date(endDateTime);
let nextDate = shiftStart;
let dates = new Array<string>();
dates.push(nextDate.toISOString());
let data = [];
while (nextDate <= endTime) {
nextDate = moment(nextDate).add(30, 'm').toDate();
dates.push(nextDate.toISOString());
data.push(0); // to make them show up!
}
this.lineChart.load({
columns: [
['x', ...dates],
['myData', ...data]
]
})
看来我必须在上面添加data 才能显示时间的刻度。
我想要..
while (nextDate <= endTime) {
nextDate = moment(nextDate).add(30, 'm').toDate();
dates.push(nextDate.toISOString());
}
this.lineChart.load({
columns: [
['x', ...dates],
]
})
为此只显示 X 轴的时间,而没有 Y 轴的值(还)
这可能吗?
非常感谢任何帮助!
【问题讨论】:
标签: javascript c3.js