|
@ -4,9 +4,16 @@ import { useEffect, useRef } from 'react' |
|
|
import Module from '../../../public/module' |
|
|
import Module from '../../../public/module' |
|
|
import * as echarts from 'echarts'; |
|
|
import * as echarts from 'echarts'; |
|
|
|
|
|
|
|
|
const LeftCenter = () => { |
|
|
const LeftCenter = (props) => { |
|
|
const style = { height: "31%", marginTop: "3%" } |
|
|
const style = { height: "31%", marginTop: "3%" } |
|
|
const chartRef = useRef(null); |
|
|
const chartRef = useRef(null); |
|
|
|
|
|
const { roadData } = props |
|
|
|
|
|
const data = roadData?.greenMileage || {} |
|
|
|
|
|
const grad = Object.keys(data).map(g => g + '级可绿化里程') || [] |
|
|
|
|
|
const value = Object.values(data)?.map(s => s.canBeGreen.toFixed(3)) |
|
|
|
|
|
let totalData = value?.reduce((pre, cur) => Number(pre) + Number(cur), 0) || 0 |
|
|
|
|
|
let max = Math.max.apply(Math, value) + 10 || 0 |
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
useEffect(() => { |
|
|
let chartInstance = echarts.init(chartRef.current); |
|
|
let chartInstance = echarts.init(chartRef.current); |
|
|
let colorArray = [ |
|
|
let colorArray = [ |
|
@ -34,9 +41,9 @@ const LeftCenter = () => { |
|
|
grid: { |
|
|
grid: { |
|
|
left: "5%", |
|
|
left: "5%", |
|
|
top: "12%", |
|
|
top: "12%", |
|
|
right: "5%", |
|
|
right: "1%", |
|
|
bottom: "8%", |
|
|
bottom: "8%", |
|
|
width:'92%', |
|
|
width: '100%', |
|
|
containLabel: true, |
|
|
containLabel: true, |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
@ -46,6 +53,7 @@ const LeftCenter = () => { |
|
|
position: "bottom", |
|
|
position: "bottom", |
|
|
axisTick: { |
|
|
axisTick: { |
|
|
show: true, |
|
|
show: true, |
|
|
|
|
|
interval: 2, |
|
|
lineStyle: { |
|
|
lineStyle: { |
|
|
color: "rgba(176,215,255,0.25)", |
|
|
color: "rgba(176,215,255,0.25)", |
|
|
// type: "dashed",
|
|
|
// type: "dashed",
|
|
@ -57,6 +65,10 @@ const LeftCenter = () => { |
|
|
color: "rgba(216,240,255,0.8000)", |
|
|
color: "rgba(216,240,255,0.8000)", |
|
|
}, |
|
|
}, |
|
|
}, |
|
|
}, |
|
|
|
|
|
axisLabel: { |
|
|
|
|
|
interval: 2 |
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
splitLine: { |
|
|
splitLine: { |
|
|
show: true, |
|
|
show: true, |
|
|
lineStyle: { |
|
|
lineStyle: { |
|
@ -85,7 +97,7 @@ const LeftCenter = () => { |
|
|
}, |
|
|
}, |
|
|
}, |
|
|
}, |
|
|
zlevel: 100, |
|
|
zlevel: 100, |
|
|
data: ["县级可绿化里程", "乡级可绿化里程", "村级可绿化里程"], |
|
|
data: grad, |
|
|
}, |
|
|
}, |
|
|
{ |
|
|
{ |
|
|
type: "category", |
|
|
type: "category", |
|
@ -106,12 +118,12 @@ const LeftCenter = () => { |
|
|
width: 70, |
|
|
width: 70, |
|
|
height: 22, |
|
|
height: 22, |
|
|
color: '#D8F0FF', |
|
|
color: '#D8F0FF', |
|
|
margin:50, |
|
|
margin: 40, |
|
|
verticalAlign: 'middle', |
|
|
verticalAlign: 'middle', |
|
|
align: 'center', |
|
|
align: 'center', |
|
|
textShadowColor:'#1AD0FF', |
|
|
textShadowColor: '#1AD0FF', |
|
|
textShadowBlur:6, |
|
|
textShadowBlur: 6, |
|
|
fontSize:14 |
|
|
fontSize: 14 |
|
|
// formatter:(f) =>{console.log('f:',f);}
|
|
|
// formatter:(f) =>{console.log('f:',f);}
|
|
|
}, |
|
|
}, |
|
|
inverse: true, //排序
|
|
|
inverse: true, //排序
|
|
@ -122,7 +134,7 @@ const LeftCenter = () => { |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
}, |
|
|
}, |
|
|
data: [60, 132, 89], |
|
|
data: value, |
|
|
}, |
|
|
}, |
|
|
], |
|
|
], |
|
|
series: [ |
|
|
series: [ |
|
@ -133,7 +145,7 @@ const LeftCenter = () => { |
|
|
barGap: "100%", |
|
|
barGap: "100%", |
|
|
barCategoryGap: "50%", |
|
|
barCategoryGap: "50%", |
|
|
color: "#15356E", |
|
|
color: "#15356E", |
|
|
data: [150, 150, 150, 150], |
|
|
data: [max, max, max], |
|
|
tooltip: { |
|
|
tooltip: { |
|
|
show: false, |
|
|
show: false, |
|
|
}, |
|
|
}, |
|
@ -145,7 +157,7 @@ const LeftCenter = () => { |
|
|
barWidth: 3, |
|
|
barWidth: 3, |
|
|
barGap: "-100%", |
|
|
barGap: "-100%", |
|
|
barCategoryGap: "50%", |
|
|
barCategoryGap: "50%", |
|
|
data: [60, 132, 89], |
|
|
data: value, |
|
|
label: { |
|
|
label: { |
|
|
show: true, |
|
|
show: true, |
|
|
position: 'right', // 位置
|
|
|
position: 'right', // 位置
|
|
@ -201,12 +213,12 @@ const LeftCenter = () => { |
|
|
], |
|
|
], |
|
|
}; |
|
|
}; |
|
|
chartInstance.setOption(option); |
|
|
chartInstance.setOption(option); |
|
|
window.addEventListener('resize',() =>{ |
|
|
window.addEventListener('resize', () => { |
|
|
if(chartInstance) { |
|
|
if (chartInstance) { |
|
|
chartInstance.resize() |
|
|
chartInstance.resize() |
|
|
} |
|
|
} |
|
|
}) |
|
|
}) |
|
|
}, []); |
|
|
}, [roadData]); |
|
|
|
|
|
|
|
|
return ( |
|
|
return ( |
|
|
<> |
|
|
<> |
|
@ -214,12 +226,12 @@ const LeftCenter = () => { |
|
|
|
|
|
|
|
|
<Row align='middle' style={{ padding: '10px 3% 0px 15px' }}> |
|
|
<Row align='middle' style={{ padding: '10px 3% 0px 15px' }}> |
|
|
<Col span={15}> |
|
|
<Col span={15}> |
|
|
<img src='assets/images/quanju/kelvhua_icon.png' alt='icon' /> |
|
|
<img src='assets/images/quanju/kelvhua_icon.png' alt='icon' style={{ width: '26%' }} /> |
|
|
<span style={{ color: '#C2EEFF', marginLeft: 5 }}>可绿化里程总数</span> |
|
|
<span style={{ color: '#C2EEFF', marginLeft: 5 }}>可绿化里程总数</span> |
|
|
</Col> |
|
|
</Col> |
|
|
<Col span={9} style={{ fontSize: 24, fontFamily: 'YouSheBiaoTiHei', color: '#fff' }}>1234</Col> |
|
|
<Col span={9} style={{ fontSize: 24, fontFamily: 'YouSheBiaoTiHei', color: '#fff' }}>{totalData}</Col> |
|
|
</Row> |
|
|
</Row> |
|
|
<div ref={chartRef} style={{ height: "14.5vh", width: "96%" }}></div> |
|
|
<div ref={chartRef} style={{ height: "14.5vh", width: "100%" }}></div> |
|
|
|
|
|
|
|
|
</Module> |
|
|
</Module> |
|
|
</> |
|
|
</> |
|
|