<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="http://echarts.baidu.com/dist/echarts.min.js"></script>
</head>
<body>
<div id="main" style="width: 600px;height:400px;"></div>
<script type="text/javascript">
var myChart = echarts.init(document.getElementById('main'));
var hours = ['12a', '1a', '2a', '3a', '4a', '5a', '6a',
'7a', '8a', '9a','10a','11a',
'12p', '1p', '2p', '3p', '4p', '5p',
'6p', '7p', '8p', '9p', '10p', '11p'];
var days = ['Saturday', 'Friday', 'Thursday',
'Wednesday', 'Tuesday', 'Monday', 'Sunday'];
const c=[]
for(let m=0;m<60;m++){
k=[12,34,5,10,10,1,3,4,5,6,12,34,5,10,10,1,3,4,5,6,12,34,5,10,10,1,3,4,5,6,12,34,5,10,10,1,3,4,5,6,12,34,5,10,10,1,3,4,5,6,12,34,5,10,10,1,3,4,5,6,]
c[m]=[Math.floor(m/10),m%10,k[m]]
}
var data =
data = data.map(function (item) {
return [item[1], item[0], item[2] || '-'];
});
var option = {
tooltip: {
position: 'top'
},
animation: false,
grid: {
height: '50%',
y: '10%'
},
xAxis: {
type: 'category',
data: hours,
splitArea: {
show: true
}
},
yAxis: {
name:'Altitude/Km',
nameLocation: 'middle',
nameGap: 40,
type: 'category',
data: days,
splitArea: {
show: true
},
axisTick:{ //y轴刻度线
"show":false
},
},
visualMap: {
min: 0,
max: 10,
calculable: true,
orient: 'horizontal',
left: 'center',
bottom: '15%'
},
series: [{
name: 'Punch Card',
type: 'heatmap',
data: data,
label: {
normal: {
show: true
}
},
itemStyle: {
emphasis: {
shadowBlur: 10,
shadowColor: 'rgba(0, 0, 0, 0.5)'
}
}
}]
};
myChart.setOption(option);
</script>
</body>
</html>
生成二维数组
最新推荐文章于 2024-06-12 14:31:07 发布