使用角度图表js自动转储chartjs数据中的缺失日期 我已经尝试过了,这让我很开心。但是,在图表js中需要什么方向选项呢?感谢您的帮助
var ChartData = [55, 10, 5],
labels = ["01-11-2014", "04-11-2014", "05-11-2014"];
for (var i = 0; i < labels.length; i++) {
//make sure we are not checking the last date in the labels array
if (i + 1 < labels.length) {
var date1 = moment(labels[i], "DD-MM-YYYY");
var date2 = moment(labels[i + 1], "DD-MM-YYYY");
//if the current date +1 is not the same as it's next neighbor we have to add in a new one
if (!date1.add(1, "days").isSame(date2)) {
//add the label
labels.splice(i + 1, 0, date1.format("DD-MM-YYYY"));
//add the data
ChartData.splice(i + 1, 0, 0);
}
}
}