
HTML 代码:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Done</title>
</head>
<body>
<div id="main" style="width: 600px;height:400px;"></div>
</body>
<script src="./plugin/echarts.min.js"></script>
<script src="./js/index.js"></script>
</html>
index.js 文件中代码:
var myChart = echarts.init(document.getElementById('main'));
function getVirtulData() {
var data = [
['2018-12-06', 1],
['2018-12-07', 2],
['2018-12-08', 3],
['2018-12-09', 4],
['2018-12-10', 1],
['2018-12-11', 2],
['2018-12-12', 3],
['2018-12-13', 4],
];
return data;
}
option = {
title: {
top: 30,
left: 'center',
text: 'Done '
},
tooltip : {},
visualMap: {
min: 0,
max: 24,
type: 'piecewise',
orient: 'horizontal',
left: 'center',
top: 65,
color: ['#196127','#239a3b','#7bc96f','#c6e48b'],
textStyle: {
color: '#000'
},
pieces: [
{gt: 3},
{gt: 2, lte: 3},
{gt: 1, lte: 2},
{gt: 0, lte: 1}
]
},
calendar: {
top: 120,
left: 30,
right: 30,
cellSize: ['auto', 13],
range: '2018',
itemStyle: {
normal: {borderWidth: 0.5}
},
yearLabel: {show: false}
},
series: {
type: 'heatmap',
coordinateSystem: 'calendar',
data: getVirtulData()
}
};
myChart.setOption(option);