|
@@ -68,12 +68,16 @@ class ChartItem extends Component {
|
|
|
}
|
|
|
}
|
|
|
rangChange(type,index){
|
|
|
- const {initFn,handleChange} = this.props;
|
|
|
+ const {initFn,handleChange,data} = this.props;
|
|
|
const times = this.getXAxisArr(type);
|
|
|
- const range = [times[0],times[times.length-1]];
|
|
|
+ const startTime=times[0];
|
|
|
+ const endTime=times[times.length-1];
|
|
|
+ const range = [startTime,endTime];
|
|
|
const temp=this.props.timeTypes;
|
|
|
- initFn&&initFn({range,rangeType:type,index});
|
|
|
- handleChange(Object.assign(temp,{[index]:type}));
|
|
|
+ if(!data[startTime+endTime]){
|
|
|
+ initFn&&initFn({range,rangeType:type,index});
|
|
|
+ }
|
|
|
+ handleChange&&handleChange(Object.assign(temp,{[index]:type}));
|
|
|
}
|
|
|
getContainers(){
|
|
|
const timeTypes = this.props.timeTypes;
|
|
@@ -86,11 +90,15 @@ class ChartItem extends Component {
|
|
|
return arr;
|
|
|
}
|
|
|
componentDidMount(){
|
|
|
- const {initFn} = this.props;
|
|
|
+ const {initFn,data} = this.props;
|
|
|
const type = config.chartDismen;
|
|
|
const times = this.getXAxisArr(config.chartDismen);
|
|
|
- const range = [times[0],times[times.length-1]];
|
|
|
- initFn&&initFn({range,rangeType:type});
|
|
|
+ const startTime=times[0];
|
|
|
+ const endTime=times[times.length-1];
|
|
|
+ const range = [startTime,endTime];
|
|
|
+ if(!data[startTime+endTime]){
|
|
|
+ initFn&&initFn({range,rangeType:type});
|
|
|
+ }
|
|
|
}
|
|
|
render() {
|
|
|
const {title} = this.props;
|
|
@@ -211,7 +219,7 @@ class Chart extends Component{
|
|
|
this.drawChart();
|
|
|
}
|
|
|
render(){
|
|
|
- const {type} = this.props;
|
|
|
+ const {type,index} = this.props;
|
|
|
return <div className={style['cont']}>
|
|
|
<div className={style['time-range']}>
|
|
|
<span className={type=='year'?style['range']+" "+style['on']:style['range']} onClick={()=>this.timeSwitch("year")}>近一年</span>
|
|
@@ -219,7 +227,7 @@ class Chart extends Component{
|
|
|
<span className={type=='month'?style['range']+" "+style['on']:style['range']} onClick={()=>this.timeSwitch("month")}>近一个月</span>
|
|
|
<span className={type=='week'?style['range']+" "+style['on']:style['range']} onClick={()=>this.timeSwitch("week")}>近一周</span>
|
|
|
</div>
|
|
|
- <div className={style["chart-box"]} id={'chart'+this.props.index}></div>
|
|
|
+ <div className={style["chart-box"]} id={'chart'+index}></div>
|
|
|
</div>;
|
|
|
}
|
|
|
}
|