修改饼图

This commit is contained in:
TS-QD1 2023-12-14 14:22:56 +08:00
parent 27ecdd2ea4
commit 68abd60696
3 changed files with 28 additions and 3 deletions

Binary file not shown.

View File

@ -1,6 +1,11 @@
<template> <template>
<div class="bar-spike"> <div class="bar-spike">
<div :id="domId" :style="{ width: w, height: h }"></div> <div :id="domId" :style="{ width: w, height: h }"></div>
<div class="percent">
<ul>
<li v-for="item in pData" :key="item">{{ item }}</li>
</ul>
</div>
</div> </div>
</template> </template>
@ -25,6 +30,10 @@ const props = defineProps({
type: Array, type: Array,
default: [] default: []
}, },
pData: {
type: Array,
default: []
},
data: { data: {
type: Array, type: Array,
default: [] default: []
@ -45,7 +54,8 @@ const init = () => {
tooltip: {}, tooltip: {},
grid: { grid: {
left: 50, left: 50,
top: 10 top: 10,
right: 100
}, },
xAxis: { xAxis: {
type: 'category', type: 'category',
@ -86,4 +96,17 @@ onMounted(() => {
</script> </script>
<style lang="stylus" scoped> <style lang="stylus" scoped>
.bar-spike
position relative
.percent
font-size 12px
ul
position absolute
list-style none
top 0
right 0
li
width 100px
text-align end
</style> </style>

View File

@ -1,7 +1,7 @@
<template> <template>
<div class="module"> <div class="module">
<ModuleCard1 title="民族分布统计"> <ModuleCard1 title="少数民族分布统计">
<BarSpike id="barSpike" w="440" h="300" :x-data="barChart.xData" :data="barChart.data" title="" :key="keyCount" <BarSpike id="barSpike" w="440" h="300" :x-data="barChart.xData" :p-data="barChart.pData" :data="barChart.data" title="" :key="keyCount"
@click="onClick" /> @click="onClick" />
</ModuleCard1> </ModuleCard1>
</div> </div>
@ -27,12 +27,14 @@ const axios = inject('axios');
const keyCount = ref(0); const keyCount = ref(0);
const barChart = reactive({ const barChart = reactive({
xData: [], xData: [],
pData: [],
data: [] data: []
}); });
axios.get(`app/query/sqlrelease/q419513e`, {}).then(res => { axios.get(`app/query/sqlrelease/q419513e`, {}).then(res => {
let data = res.data; let data = res.data;
data.forEach((item, index) => { data.forEach((item, index) => {
barChart.xData.push(item.name); barChart.xData.push(item.name);
barChart.pData.push(`${item.name}${item.percent}%`)
barChart.data.push(item.value); barChart.data.push(item.value);
}) })
keyCount.value++; keyCount.value++;