<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: 1000px;
height: 800px;
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}/change_requests.json`, changeRequestsData => {
$.getJSON(`${baseUrl}${repoName}/change_requests_accepted.json`, changeRequestsAcceptData => {
$.getJSON(`${baseUrl}${repoName}/change_requests_reviews.json`, changeRequestReviewData => {
var monthes = Object.keys(changeRequestsData).filter(k => k.length === 7);
var crsNew = monthes.map(m => changeRequestsData[m] ?? 0);
var crsAccepted = monthes.map(m => changeRequestsAcceptData[m] ?? 0);
var crReviews = monthes.map(m => changeRequestReviewData[m] ?? 0);
var crsNewBase = [0];
var crxAcceptedBase = [];
for (var i = 1; i < crsNew.length; i++)
crsNewBase.push(crsNew[i - 1] - crsAccepted[i - 1] + crsNewBase[i - 1]);
for (var i = 0; i < crsNew.length; i++)
crxAcceptedBase.push(crsNewBase[i] + crsNew[i] - crsAccepted[i]);
option = {
title: {
text: `Change requests status for ${repoName}`,
left: 'center'
},
legend: {
data: ['New', 'Accpeted', 'Reviews'],
padding: 40,
},
xAxis: {
type: 'category',
data: monthes,
},
yAxis: [{ type: 'value' }, { type: 'value' }],
series: [
{
type: 'bar',
stack: 'Total',
silent: true,
itemStyle: {
borderColor: 'transparent',
color: 'transparent'
},
emphasis: {
itemStyle: {
borderColor: 'transparent',
color: 'transparent'
}
},
// data: crsNewBase,
},
{
type: 'bar',
stack: 'CloseTotal',
silent: true,
itemStyle: {
borderColor: 'transparent',
color: 'transparent'
},
emphasis: {
itemStyle: {
borderColor: 'transparent',
color: 'transparent'
}
},
// data: crxAcceptedBase,
},
{
name: 'New',
type: 'bar',
stack: 'Total',
itemStyle: {
color: 'green',
},
data: crsNew,
},
{
name: 'Accpeted',
type: 'bar',
itemStyle: {
color: 'red',
},
stack: 'CloseTotal',
data: crsAccepted,
},
{
name: 'Reviews',
type: 'line',
data: crReviews,
yAxisIndex: 1,
}
]
};
chart.setOption(option);
});
});
});
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.