个人主页-贡献度无数据时只显示x/y轴的内容

This commit is contained in:
caishi 2021-11-26 10:59:33 +08:00
parent 9299a1667e
commit c8eed99f5d
2 changed files with 19 additions and 8 deletions

View File

@ -25,7 +25,7 @@ if (isDev) {
} }
debugType = window.location.search.indexOf('debug=t') !== -1 ? 'teacher' : debugType = window.location.search.indexOf('debug=t') !== -1 ? 'teacher' :
window.location.search.indexOf('debug=s') !== -1 ? 'student' : window.location.search.indexOf('debug=s') !== -1 ? 'student' :
window.location.search.indexOf('debug=a') !== -1 ? 'admin' : parsed.debug || 'student' window.location.search.indexOf('debug=a') !== -1 ? 'admin' : parsed.debug || 'admin'
} }
window._debugType = debugType; window._debugType = debugType;
export function initAxiosInterceptors(props) { export function initAxiosInterceptors(props) {

View File

@ -35,12 +35,23 @@ function Calendar({ userLogin , time , chooseTime }) {
const url = `/users/${userLogin}/headmaps.json`; const url = `/users/${userLogin}/headmaps.json`;
Axios.get(url).then(result=>{ Axios.get(url).then(result=>{
if(result && result.data){ if(result && result.data){
// result.data.headmaps
let m = []; let m = [];
let flag = true;
if(result.data.headmaps && result.data.headmaps.length>0){
m = result.data.headmaps;
flag = true;
}else{
var date = +echarts.number.parseDate(baginT);
let d = timestampToTime(date);
m=[{
contributions:"",date:d
}]
flag = false;
}
m.sort(compare('contributions')); m.sort(compare('contributions'));
let max = m[m.length -1].contributions; let max = m[m.length -1].contributions;
Init(m,max); Init(m,max,flag);
} }
}).catch(error=>{}) }).catch(error=>{})
} }
@ -54,7 +65,6 @@ function Calendar({ userLogin , time , chooseTime }) {
} }
function getVirtulData(data) { function getVirtulData(data) {
debugger;
var date = +echarts.number.parseDate(baginT); var date = +echarts.number.parseDate(baginT);
var end = +echarts.number.parseDate(endT); var end = +echarts.number.parseDate(endT);
var dayTime = 3600 * 24 * 1000; var dayTime = 3600 * 24 * 1000;
@ -79,7 +89,7 @@ function Calendar({ userLogin , time , chooseTime }) {
return Y+M+D; return Y+M+D;
} }
function Init(data,max) { function Init(data,max,flag) {
var huan_val = document.getElementById("Calendar"); var huan_val = document.getElementById("Calendar");
var myEcharts = echarts.init(huan_val); var myEcharts = echarts.init(huan_val);
let option = { let option = {
@ -99,8 +109,9 @@ function Calendar({ userLogin , time , chooseTime }) {
left: 'center', left: 'center',
bottom: 40, bottom: 40,
inRange:{ inRange:{
color:['#fafafa', '#216e39'] color:flag ? ['#fafafa', '#216e39'] :['#fff','#fff']
} },
show:flag
}, },
calendar: { calendar: {
top: 50, top: 50,