ChartAct / web /Vchart /heatmap /chart_0015_heatmap.html
wumumu's picture
Add files using upload-large-folder tool
7b52e07 verified
Raw History Blame Contribute Delete
6.08 kB
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Heatmap on Cartesian - Apache ECharts Demo</title>
<style>
* { margin: 0; padding: 0; }
#chart-container { position: relative; height: 100vh; overflow: hidden; }
</style>
</head>
<body>
<div id="chart-container"></div>
<!-- ECharts (kept as CDN). If you need a fully-offline single file, tell me and I’ll inline echarts.min.js too. -->
<script src="_deps/cdn.jsdelivr.net/npm/echarts@5.3.2/dist/echarts.min.js"></script>
<script>
var dom = document.getElementById("chart-container");
var myChart = echarts.init(dom, null, {
renderer: "canvas",
useDirtyRect: false
});
var app = {};
var option;
// prettier-ignore
const 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'
];
// prettier-ignore
const days =[
'Monday', 'Tuesday','Wednesday', 'Thursday', 'Friday','Saturday', 'Sunday'
];
// prettier-ignore
const data = [[0,0,53],
[0,1,48],
[0,10,412],
[0,11,406],
[0,12,410],
[0,13,346],
[0,14,320],
[0,15,307],
[0,16,339],
[0,17,329],
[0,18,334],
[0,19,256],
[0,2,80],
[0,20,201],
[0,21,130],
[0,22,84],
[0,23,65],
[0,3,142],
[0,4,232],
[0,5,293],
[0,6,293],
[0,7,379],
[0,8,320],
[0,9,387],
[1,0,44],
[1,1,54],
[1,10,325],
[1,11,297],
[1,12,308],
[1,13,305],
[1,14,323],
[1,15,362],
[1,16,354],
[1,17,527],
[1,18,314],
[1,19,265],
[1,2,87],
[1,20,244],
[1,21,153],
[1,22,99],
[1,23,72],
[1,3,111],
[1,4,167],
[1,5,203],
[1,6,278],
[1,7,314],
[1,8,309],
[1,9,273],
[2,0,68],
[2,1,90],
[2,10,442],
[2,11,433],
[2,12,455],
[2,13,447],
[2,14,357],
[2,15,391],
[2,16,359],
[2,17,318],
[2,18,292],
[2,19,260],
[2,2,123],
[2,20,178],
[2,21,140],
[2,22,136],
[2,23,91],
[2,3,198],
[2,4,255],
[2,5,313],
[2,6,369],
[2,7,363],
[2,8,535],
[2,9,496],
[3,0,63],
[3,1,98],
[3,10,538],
[3,11,467],
[3,12,425],
[3,13,414],
[3,14,382],
[3,15,347],
[3,16,406],
[3,17,397],
[3,18,351],
[3,19,284],
[3,2,158],
[3,20,199],
[3,21,169],
[3,22,128],
[3,23,87],
[3,3,222],
[3,4,283],
[3,5,308],
[3,6,415],
[3,7,541],
[3,8,620],
[3,9,587],
[4,0,94],
[4,1,89],
[4,10,485],
[4,11,583],
[4,12,486],
[4,13,419],
[4,14,396],
[4,15,383],
[4,16,332],
[4,17,285],
[4,18,329],
[4,19,278],
[4,2,111],
[4,20,208],
[4,21,139],
[4,22,113],
[4,23,73],
[4,3,182],
[4,4,312],
[4,5,430],
[4,6,446],
[4,7,473],
[4,8,508],
[4,9,443],
[5,0,55],
[5,1,55],
[5,10,405],
[5,11,392],
[5,12,400],
[5,13,456],
[5,14,388],
[5,15,398],
[5,16,327],
[5,17,349],
[5,18,245],
[5,19,240],
[5,2,74],
[5,20,199],
[5,21,126],
[5,22,78],
[5,23,68],
[5,3,132],
[5,4,226],
[5,5,317],
[5,6,332],
[5,7,403],
[5,8,431],
[5,9,349],
[6,0,69],
[6,1,39],
[6,10,329],
[6,11,334],
[6,12,389],
[6,13,336],
[6,14,330],
[6,15,291],
[6,16,315],
[6,17,306],
[6,18,266],
[6,19,201],
[6,2,67],
[6,20,173],
[6,21,116],
[6,22,78],
[6,23,56],
[6,3,108],
[6,4,197],
[6,5,294],
[6,6,322],
[6,7,346],
[6,8,391],
[6,9,337]]
.map(function (item) {
return [item[1], item[0], item[2] || '-'];
});
option = {
tooltip: { position: "top" },
grid: {
height: "50%",
top: "10%",
margin: ["5px", "10px"]
},
xAxis: {
type: "category",
data: hours,
splitArea: { show: true },
boundaryGap: true
},
yAxis: {
type: "category",
data: days,
splitArea: { show: true },
boundaryGap: true
},
visualMap: {
min: 0,
max: 600,
calculable: true,
orient: "horizontal",
left: "center",
bottom: "15%",
inRange: {
color: ["#D0E4DF", "#4B7468"] // From smaller to bigger value
}
},
series: [
{
name: "Plan",
type: "heatmap",
data: data,
label: { show: false },
emphasis: {
itemStyle: {
shadowBlur: 10,
shadowColor: "rgba(0, 0, 0, 0.5)"
}
},
itemStyle: {
borderWidth: 3,
borderType: "solid",
borderDashOffset: 1,
borderCap: "square",
borderColor: "rgba(255, 255, 255, 1)"
},
markPoint: {
data: [
{
name: "play basketball",
xAxis: 4,
yAxis: 5,
itemStyle: { color: "red", borderColor: "white", opacity: 0.8 },
label: { show: true, formatter: "1" },
symbol: "circle",
symbolSize: 15,
symbolRotate: 180
},
{
name: "have a meeting",
xAxis: 10,
yAxis: 6,
itemStyle: { color: "pink", borderColor: "white", opacity: 0.8 },
label: { show: true, formatter: "2" },
symbol: "circle",
symbolSize: 15,
symbolRotate: 180
}
],
animation: true
}
}
]
};
if (option && typeof option === "object") {
myChart.setOption(option);
}
window.addEventListener("resize", myChart.resize);
</script>
</body>
</html>