|
@@ -81,17 +81,28 @@ class ChartItem extends Component {
|
|
|
}
|
|
|
handleChange&&handleChange(Object.assign(temp,{[i]:type}));
|
|
|
}
|
|
|
- getContainers(){
|
|
|
+ getContainers(obj){
|
|
|
const timeTypes = this.props.timeTypes;
|
|
|
- const range = this.getXAxisArr(config.chartDismen);
|
|
|
- const obj = this.props.data[range[0]+range[range.length-1]];
|
|
|
const {endDate} = this.props;
|
|
|
- let arr = [];
|
|
|
+ let len = 1,idx=0; //单个图表第一条线的在所有线中的index,用于显示不同的形状,打印使用
|
|
|
+ let arr = [],keys = Object.keys(obj||{});
|
|
|
for(let i in obj){
|
|
|
- arr.push(<Chart data={obj[i]} endDate={endDate} type={timeTypes&&timeTypes[i]} index={i} getXAxisArr={this.getXAxisArr} handleRangeChange={this.rangChange}/>)
|
|
|
+ idx = keys.findIndex((t)=>{return t==i});
|
|
|
+ len = idx==0?0:len+obj[keys[idx-1]].length;
|
|
|
+ arr.push(<Chart data={obj[i]} len={len} endDate={endDate} type={timeTypes&&timeTypes[i]} index={i} getXAxisArr={this.getXAxisArr} handleRangeChange={this.rangChange}/>)
|
|
|
}
|
|
|
return arr.length>0?arr:<p style={{color:'#acacac'}}>该模块暂无数据</p>;
|
|
|
}
|
|
|
+ getLegends(obj){
|
|
|
+ let arr = [],temp='',doms=[];
|
|
|
+ for(let i in obj){
|
|
|
+ arr = [...arr,...obj[i]];
|
|
|
+ }
|
|
|
+ arr.map((it,ix)=>{
|
|
|
+ doms.push(<div><img src={require('@common/images/'+(ix+1)+'.png')} /><span>{it}</span></div>);
|
|
|
+ });
|
|
|
+ return doms;
|
|
|
+ }
|
|
|
componentDidMount(){
|
|
|
const {initFn,pindex} = this.props;
|
|
|
const type = config.chartDismen;
|
|
@@ -102,11 +113,17 @@ class ChartItem extends Component {
|
|
|
initFn&&initFn({range,rangeType:type,pindex,getNew:true});
|
|
|
}
|
|
|
render() {
|
|
|
- const {title} = this.props;
|
|
|
+ const {title,data,names} = this.props;
|
|
|
+ const range = this.getXAxisArr(config.chartDismen);
|
|
|
+ const obj = data[range[0]+range[range.length-1]];
|
|
|
+ const nameObj = names[range[0]+range[range.length-1]];
|
|
|
return <div className={style['assess-item']}>
|
|
|
<h2>{title}</h2>
|
|
|
+ <div className={style['legend']}>
|
|
|
+ {this.getLegends(nameObj)}
|
|
|
+ </div>
|
|
|
<div className={style['item-content']}>
|
|
|
- {this.getContainers()}
|
|
|
+ {this.getContainers(obj)}
|
|
|
</div>
|
|
|
</div>;
|
|
|
}
|
|
@@ -127,7 +144,7 @@ class Chart extends Component{
|
|
|
this.timeSwitch = this.timeSwitch.bind(this);
|
|
|
}
|
|
|
drawChart(){
|
|
|
- const {index,data,getXAxisArr,type,endDate} = this.props;
|
|
|
+ const {index,data,getXAxisArr,type,endDate,len} = this.props;
|
|
|
const xAxis = getXAxisArr(type);
|
|
|
const id = endDate?'chart'+endDate+index:'chart'+index;
|
|
|
let series = [],names=[],inx=-1;
|
|
@@ -139,7 +156,6 @@ class Chart extends Component{
|
|
|
sixMonth:9,
|
|
|
year:60
|
|
|
};
|
|
|
-
|
|
|
data&&data.map((it,j)=>{
|
|
|
let values=new Array();
|
|
|
let name='';
|
|
@@ -161,10 +177,10 @@ class Chart extends Component{
|
|
|
type: 'line',
|
|
|
data: values,
|
|
|
showAllSymbol:true,
|
|
|
- symbol:config.chartSymbols[j%7],
|
|
|
+ symbol:config.chartSymbols[(len+j)%8],
|
|
|
symbolSize:7,
|
|
|
itemStyle:{
|
|
|
- color:config.chartColors[j%7]
|
|
|
+ color:config.chartColors[(len+j)%8]
|
|
|
}
|
|
|
});
|
|
|
});
|