fetchAddressProfit() {
this.chartLoading = false
getAddressProfit(this.address, this.date).then(res => {
this.chartLoading = true
this.profitData = res.data.profit
this.TimeData = res.data.time
this.fillData()
})
}
this.TimeData获取后台的时间戳数据,如何转换成日期MM-DD格式,并显示在chart图表的y轴下方
使用了vue-chartjs,数据由后台获取
fillData() {
this.chartdata = {
labels: this.TimeData,
datasets: [
{
label: '收益',
borderColor: 'lightgreen',
backgroundColor: 'lightgreen',
data: this.profitData,
fill: false
}
]
}
this.options = {
responsive: true,
maintainAspectRatio: false,
tooltips: {
enabled: true,
mode: 'nearest',
axis: 'y'
},
scales: {
// y轴
yAxes: [
{
// 设置起止数据和步长
ticks: {
min: 0
}
}
]
}
}
this.chartLoading = true
},
同时怎样为chart提示框的数据添加单位
//formatDate函数方法格式化日期mm-dd es6的方案