From 5f75465085edf8060f68ef85995dd00731218888 Mon Sep 17 00:00:00 2001 From: 田源 <lastanimals@163.com> Date: 星期一, 27 十一月 2023 10:39:42 +0800 Subject: [PATCH] 统计分析饼状 bug --- Source/UBCS-WEB/src/views/statistic/statisticPage.vue | 16 +++----- Source/UBCS-WEB/src/components/StatisticsComponent/pieChart.vue | 86 ++++++++++++++++++++++++++---------------- 2 files changed, 59 insertions(+), 43 deletions(-) diff --git a/Source/UBCS-WEB/src/components/StatisticsComponent/pieChart.vue b/Source/UBCS-WEB/src/components/StatisticsComponent/pieChart.vue index 94d451c..9efd832 100644 --- a/Source/UBCS-WEB/src/components/StatisticsComponent/pieChart.vue +++ b/Source/UBCS-WEB/src/components/StatisticsComponent/pieChart.vue @@ -21,6 +21,52 @@ default: "" } }, + watch:{ + pieData:{ + immediate:true, + handler(newval,oldval){ + if (newval) { + // console.log(newval) + const series=[ + { + name: '', + type: 'pie', + radius: ['40%', '70%'], + avoidLabelOverlap:false, + label: { + formatter: '{b}\n{d}%', + fontSize:14 + }, + itemStyle: { + color: function(params) { + // 鏍规嵁鍏蜂綋闇�姹傝缃鑹� + const colorList = ['#5470C6', '#91CC75', '#fac858', '#EE6666', '#3BA272', '#FC8452', '#9A60B4', '#e34d4d', '#b3e9b9', '#eaaaed', '#1bc6e4', '#c6b3e9']; + return colorList[params.dataIndex % colorList.length]; + } + }, + data:newval[0].map((value, index) => { + return { + value: value, + name: this.getMonthName(index), + newValue: newval[1][index] + }; + }), + } + ] + this.chartOptions.series = series; + } + } + }, + chartName:{ + handler(newval,oldval){ + if(newval){ + this.chartOptions.title.text = newval + "鏁版嵁缁熻" + } + }, + immediate:true, + deep:true + } + }, data() { return { chartOptions: { @@ -47,41 +93,15 @@ top: 'middle', data: ['涓�鏈�', '浜屾湀', '涓夋湀', '鍥涙湀', '浜旀湀', '鍏湀', '涓冩湀', '鍏湀', '涔濇湀', '鍗佹湀', '鍗佷竴鏈�', '鍗佷簩鏈�'] }, - series: [ - { - name: '', - type: 'pie', - radius: ['40%', '70%'], - avoidLabelOverlap:false, - label: { - formatter: '{b}\n{d}%', - fontSize:14 - }, - itemStyle: { - color: function(params) { - // 鏍规嵁鍏蜂綋闇�姹傝缃鑹� - const colorList = ['#5470C6', '#91CC75', '#fac858', '#EE6666', '#3BA272', '#FC8452', '#9A60B4', '#e34d4d', '#b3e9b9', '#eaaaed', '#1bc6e4', '#c6b3e9']; - return colorList[params.dataIndex % colorList.length]; - } - }, - data: [ - { value: 110, name: '涓�鏈�', newValue: 10, totalValue: 110 }, - { value: 220, name: '浜屾湀', newValue: 20, totalValue: 220 }, - { value: 330, name: '涓夋湀', newValue: 30, totalValue: 330 }, - { value: 440, name: '鍥涙湀', newValue: 40, totalValue: 440 }, - { value: 550, name: '浜旀湀', newValue: 50, totalValue: 550 }, - { value: 660, name: '鍏湀', newValue: 60, totalValue: 660 }, - { value: 770, name: '涓冩湀', newValue: 70, totalValue: 770 }, - { value: 880, name: '鍏湀', newValue: 80, totalValue: 880 }, - { value: 990, name: '涔濇湀', newValue: 90, totalValue: 990 }, - { value: 1100, name: '鍗佹湀', newValue: 100, totalValue: 1100 }, - { value: 1210, name: '鍗佷竴鏈�', newValue: 110, totalValue: 1210 }, - { value: 1320, name: '鍗佷簩鏈�', newValue: 120, totalValue: 1320 } - ] - } - ] + series: [] }, } + }, + methods:{ + getMonthName(index){ + const monthNames = ['涓�鏈�', '浜屾湀', '涓夋湀', '鍥涙湀', '浜旀湀', '鍏湀', '涓冩湀', '鍏湀', '涔濇湀', '鍗佹湀', '鍗佷竴鏈�', '鍗佷簩鏈�']; + return monthNames[index]; + } } } </script> diff --git a/Source/UBCS-WEB/src/views/statistic/statisticPage.vue b/Source/UBCS-WEB/src/views/statistic/statisticPage.vue index d5b0556..2e9477a 100644 --- a/Source/UBCS-WEB/src/views/statistic/statisticPage.vue +++ b/Source/UBCS-WEB/src/views/statistic/statisticPage.vue @@ -48,13 +48,10 @@ </el-dialog> <!-- echarts缁勪欢--> <div> - <lineChart v-for="(item,index) in lineList" :key="index" :chartName="item.menuName" - :lineData="item.menuData"></lineChart> - <!-- <pieChart :pieData="pieData" :chartName="chartName"></pieChart>--> - <ColumnarChart v-for="(item,index) in columnarList" :key="index" :chartName="item.menuName" - :columnarData="item.menuData"></ColumnarChart> - <mixCart v-for="(item,index) in mixList" :key="index" :chartName="item.menuName" - :mixData="item.menuData"></mixCart> + <lineChart v-for="(item,index) in lineList" :key="index" :chartName="item.menuName" :lineData="item.menuData"></lineChart> + <pieChart v-for="(item,index) in pieList" :key="index" :pieData="item.menuData" :chartName="item.menuName"></pieChart> + <ColumnarChart v-for="(item,index) in columnarList" :key="index" :chartName="item.menuName" :columnarData="item.menuData"></ColumnarChart> + <mixCart v-for="(item,index) in mixList" :key="index" :chartName="item.menuName" :mixData="item.menuData"></mixCart> </div> </div> </template> @@ -93,7 +90,7 @@ }, { menuName: "娴嬭瘯sc", - codeType: "2", + codeType: null, menuData: [ [220, 232, 301, 334, 290, 330, 410, 330, 212, 322, 200, 234], [120, 132, 101, 134, 90, 230, 210, 130, 10, 122, 100, 80], @@ -101,7 +98,7 @@ }, { menuName: "浜у搧鍨嬪彿", - codeType: "0", + codeType: null, menuData: [ [220, 232, 301, 334, 290, 330, 410, 330, 212, 322, 200, 234], [120, 132, 101, 134, 90, 230, 210, 130, 10, 122, 100, 80], @@ -185,7 +182,6 @@ }, //淇濆瓨 addSaveHandler() { - debugger if (this.selectData.length <= 0) { this.$message.warning('璇疯嚦灏戦�夋嫨涓�鏉℃暟鎹紒'); return; -- Gitblit v1.9.3