<html>
<body>
<script src="https://cdnjs.cloudflare.com/ajax/libs/echarts/5.3.2/echarts.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>
<div id="main"></div>
</body>
</html>
xxxxxxxxxx
#main {
width: 600px;
height: 400px;
border: 1px solid red;
}
xxxxxxxxxx
var container = document.getElementById('main');
var chart = echarts.init(container);
var baseUrl = 'https://oss.x-lab.info/open_digger/github/';
var repoName = 'X-lab2017/open-digger';
$.getJSON(
`${baseUrl}${repoName}/active_dates_and_times.json`,
data => {
const hours = [Array(24).keys()];
const days = [ 'Sun.', 'Sat.', 'Fri.', 'Thu.', 'Wed.', 'Tue.', 'Mon.' ];
// sum up all the working hour
var values = Object.values(data).reduce((p, c) => {
if (p === null) return c;
return p.map((v, i) => v + c[i]);
}, null);
// use log to smooth the data
// comment this line if you want to use linear data
// values = values.map(v => Math.log(v + 1));
// normalized to 0 - 10
var max = Math.max(values);
values = values.map(v => Math.ceil(v * 10 / max));
var inputData = [];
for (var d = 0; d < 7; d++) {
for (var h = 0; h < 24; h++) {
inputData.push([h, 6 - d, values[d * 24 + h] || '-']);
}
}
option = {
title: {
text: `Active Dates And Times for ${repoName}`,
left: 'center'
},
grid: {
height: '50%',
top: '10%'
},
xAxis: {
type: 'category',
data: hours,
splitArea: {
show: true
}
},
yAxis: {
type: 'category',
data: days,
splitArea: {
show: true
}
},
visualMap: {
min: 0,
max: 10,
calculable: true,
orient: 'horizontal',
left: 'center',
bottom: '15%'
},
series: [
{
type: 'heatmap',
data: inputData,
// label: {
// show: true
// },
emphasis: {
itemStyle: {
shadowBlur: 10,
shadowColor: 'rgba(0, 0, 0, 0.5)'
}
},
}
]
};
chart.setOption(option);
}
)
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.