|
@@ -24,10 +24,12 @@ class ChartItem extends Component {
|
|
|
//近一周
|
|
|
switch(type){
|
|
|
case 'week':
|
|
|
- for(let i=0;i<7;i++){
|
|
|
+ arr.push(...this.getDayHours(now,true,1));
|
|
|
+ for(let i=1;i<6;i++){
|
|
|
temp=i*1000*60*60*24;
|
|
|
arr.unshift(...this.getDayHours(now-temp,true));
|
|
|
- }
|
|
|
+ };
|
|
|
+ arr.unshift(...this.getDayHours(now-6*1000*60*60*24,true,2));
|
|
|
break;
|
|
|
case 'month':
|
|
|
for(let i=0;i<30;i++){
|
|
@@ -52,7 +54,7 @@ class ChartItem extends Component {
|
|
|
|
|
|
return arr;
|
|
|
}
|
|
|
- getDayHours(time,isHour){
|
|
|
+ getDayHours(time,isHour,isLimit){
|
|
|
const year = new Date(time).getFullYear();
|
|
|
const month = new Date(time).getMonth()+1;
|
|
|
const date = new Date(time).getDate();
|
|
@@ -60,9 +62,10 @@ class ChartItem extends Component {
|
|
|
let arr=[],temp='';
|
|
|
const str= year+'-'+(month<10?'0'+month:month)+'-'+(date<10?'0'+date:date);
|
|
|
if(isHour){
|
|
|
- for(let i=0;i<24;i++){
|
|
|
- temp = hour-i>-1?hour-i:hour-i+24;
|
|
|
- arr.unshift(str+" "+(temp<10?'0'+temp:temp)+":00:00");
|
|
|
+ const num = isLimit===1?hour+1:24;
|
|
|
+ for(let i=(isLimit===2?hour:0);i<num;i++){
|
|
|
+ //temp = hour-i>-1?hour-i:hour-i+24;
|
|
|
+ arr.push(str+" "+(i<10?'0'+i:i)+":00:00");
|
|
|
}
|
|
|
return arr;
|
|
|
}else{
|
|
@@ -70,14 +73,14 @@ class ChartItem extends Component {
|
|
|
}
|
|
|
}
|
|
|
rangChange(type,i){
|
|
|
- const {initFn,handleChange,data,pindex} = this.props;
|
|
|
+ const {initFn,disName,handleChange,data,pindex} = this.props;
|
|
|
const times = this.getXAxisArr(type);
|
|
|
const startTime=times[0];
|
|
|
const endTime=times[times.length-1];
|
|
|
const range = [startTime,endTime];
|
|
|
const temp=this.props.timeTypes;
|
|
|
if(!data[startTime+endTime]){
|
|
|
- initFn&&initFn({range,rangeType:type,index:i,pindex,getNew:false});
|
|
|
+ initFn&&initFn({range,disName,rangeType:type,index:i,pindex,getNew:false});
|
|
|
}
|
|
|
handleChange&&handleChange(Object.assign(temp,{[i]:type}));
|
|
|
}
|
|
@@ -150,6 +153,7 @@ class Chart extends Component{
|
|
|
let series = [],names=[],inx=-1;
|
|
|
let myChart = echarts.init(document.getElementById(id) ,null, {renderer: 'svg'});
|
|
|
let xAxisArr = [...xAxis];
|
|
|
+ const strNum = type=='week'?13:10;
|
|
|
const interval = {
|
|
|
week:23,
|
|
|
month:4,
|
|
@@ -161,8 +165,8 @@ class Chart extends Component{
|
|
|
let name='';
|
|
|
it&&it.creatTime.map((x,i)=>{
|
|
|
inx=xAxis.findIndex((a)=>{
|
|
|
- name=x.substr(0,13);
|
|
|
- return a.substr(0,13)==name;
|
|
|
+ name=x.substr(0,strNum);
|
|
|
+ return a.substr(0,strNum)==name;
|
|
|
}); //日期对应横坐标的位置
|
|
|
if(inx!=-1){
|
|
|
if(type=='week'){
|