<!-- 人口分布 --> <template> <div class="bottom" > <!-- <i class="el-icon-close close-pop" @click="$emit('close')" /> --> <div class="block" style="display: flex;flex-direction: column;justify-content: space-between;"> <div class="title">赣州蓉江新区总览</div> <div class="info-item" v-for="(value,key,index) in data" :key="index"> <div class="info-icon"> <img :src="images[key]"> <span class="info-text">{{value.name}}:</span> </div> <div class="info-value"> {{ value.value }}</div> </div> </div> <div class="block"> <div class="title">潭东镇人口分布</div> <div class="chart-wrapper"> <simple-pie-chart id="tandong" :width="options.width" :height="options.height" :seriesData="options.data1"> </simple-pie-chart> </div> </div> <div class="block"> <div class="title">潭口镇人口分布</div> <div class="chart-wrapper"> <simple-pie-chart id="tankou" :width="options.width" :height="options.height" :seriesData="options.data2"> </simple-pie-chart> </div> </div> <div class="block"> <div class="title">高校园区人口分布</div> <div class="chart-wrapper"> <simple-pie-chart id="gaoxiaoyuanqu" :width="options.width" :height="options.height" :seriesData="options.data3"> </simple-pie-chart> </div> </div> </div> </template> <script> import SimplePieChart from '@/components/pieChart/simplePieChart' import { fetchAreaPopulation } from '@/api/map' export default { name: 'areaPopulation', components: {SimplePieChart}, data () { return { data: { changzhu: {name: '总常住人口', value: '', unit: '人'}, liudong: {name: '户籍人口', value: '', unit: '人'}, huji: {name: '高校师生', value: '', unit: '人'}, zanzhu: {name: '流动人口', value: '', unit: '人'} }, images: { changzhu: require('@/assets/images/city/icon-changzhu.png'), liudong: require('@/assets/images/city/icon-liudong.png'), huji: require('@/assets/images/city/icon-xuncha.png'), liushou: require('@/assets/images/city/icon-shouli.png'), gaoxiao: require('@/assets/images/city/icon-shouli.png') }, options: { id: 'pipe-alarm-pie', width: '100%', height: '100%', data1: [{value: 0, name: '潭东镇'}, {value: 0, name: '潭口镇'}, {value: 0, name: '高校园区管理处'}], data2: [{value: 0, name: '潭东镇'}, {value: 0, name: '潭口镇'}, {value: 0, name: '高校园区管理处'}], data3: [{value: 0, name: '潭东镇'}, {value: 0, name: '潭口镇'}, {value: 0, name: '高校园区管理处'}] } } }, mounted () { this.initData() }, methods: { initData () { console.log('请求区域人口数据') fetchAreaPopulation().then(res => { if (res.code === 200) { console.log('请求区域人口数据', res.data) this.data = res.data.data this.options.data1 = res.data.tandong this.options.data2 = res.data.tankou this.options.data3 = res.data.gaoxiaoyuanqu } }) } } } </script> <style rel="stylesheet/scss" lang="scss" scoped> .bottom { z-index: 111111111111; width: 9rem; height: 1.4rem; position: absolute; bottom: 10px; left: 0px; display: flex; // overflow: hidden; // padding: 0px 0px; gap: 10px; /* 新增:两个盒子之间的间距 */ padding: 0 5px; box-sizing: border-box; /* 新增:避免padding增加总宽度 */ .block { flex: 1; height: 100%; display: flex; flex-direction: column; // flex-wrap: wrap; background: linear-gradient(to top left, rgba(5, 30, 61, 0.62), #0D3F7E9D); border-radius: 5px; box-shadow: 4px 4px 40px rgba(0, 0, 0, .05); border-color: rgba(0, 0, 0, .05); // margin: 0px 5px; margin: 0; /* 移除原margin,用gap控制间距 */ } .chart-wrapper { flex: 1; // padding: 0.1rem; box-sizing: border-box; /* 关键:padding不增加实际高度 */ } .title { text-shadow: 0 0 5px #d1ffff; color: white; font-weight: bold; padding-top: 4px; padding-bottom: 4px; padding-left: 16px; font-family: 黑体; letter-spacing: 1px; } } .block-base { background: linear-gradient(to top left, rgba(5, 30, 61, 0.62), #0D3F7E9D); border-radius: 5px; box-shadow: 4px 4px 40px rgba(0, 0, 0, .05); // border-color: rgba(0, 0, 0, .05); } .ellipsis { white-space: nowrap; /* 防止文本换行 */ overflow: hidden; /* 隐藏溢出的文本 */ text-overflow: ellipsis; /* 用省略号表示溢出的文本 */ } .ellipsis-multiline { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; /* 限制显示的行数 */ overflow: hidden; text-overflow: ellipsis; } .info-item { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid rgba(255, 255, 255, 0.1); color: #fff; padding: 0.05rem 0.02rem; img { width: 0.14rem; height: 0.14rem; } } .info-item:last-child { border-bottom: none; } .info-icon { display: flex; align-items: center; // opacity: 0.8; white-space: nowrap; margin-right: 0.1rem; } .info-text { flex: 1; font-size: 0.1rem; text-align: left; white-space: nowrap; } .info-value { font-weight: 600; font-size: 0.125rem; } </style>