javascript
复制代码
function getVirtualData(year) {
const date = +echarts.time.parse(year + '-01-01');
const end = +echarts.time.parse(+year + 1 + '-01-01');
const dayTime = 3600 * 24 * 1000;
const data = [];
for (let time = date; time < end; time += dayTime) {
data.push([
echarts.time.format(time, '{yyyy}-{MM}-{dd}', false),
Math.floor(Math.random() * 10000)
]);
}
return data;
}
option = {
title: {
top: 30,
left: 'center',
text: 'Daily Step Count'
},
tooltip: {},
visualMap: {
min: 0,
max: 10000,
type: 'piecewise',
orient: 'horizontal',
left: 'center',
top: 65,
color:[
'#d16ba5',
'#c777b9',
'#ba83ca',
'#aa8fd8',
'#9a9ae1',
'#8aa7ec',
'#79b3f4',
'#69bff8',
'#52cffe',
'#41dfff',
'#46eefa',
'#5ffbf1'],
},
calendar: {
top: 120,
left: 30,
//right: 30,
cellSize: [16, 16],
range: ['2017-01-01', '2017-01-31'],
itemStyle: {
borderWidth: 0.1,
//borderColor:'yellow',
borderWidth:2,
},
yearLabel: { show: true },
monthLabel:{show:true},
dayLabel:{
show:true,
firstDay:3,
}
},
series: {
type: 'heatmap',
coordinateSystem: 'calendar',
data: getVirtualData('2017')
}
};