qauMaWeb/node_modules/.cache/babel-loader/e105327d5019d084e45a3e97f3b...

1 line
13 KiB
JSON
Raw Normal View History

2024-10-13 18:02:27 +08:00
{"ast":null,"code":"import \"core-js/modules/es.function.name.js\";\nimport \"core-js/modules/es.array.map.js\";\nimport \"core-js/modules/es.object.to-string.js\";\nimport \"core-js/modules/web.dom-collections.for-each.js\";\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\nimport * as echarts from 'echarts';\nexport default {\n name: \"IncomeChart\",\n data: function data() {\n return {\n sumIncome: 0,\n categoryIncomes: [],\n categoryNames: [],\n incomes: [],\n activeName: 'bar',\n totalAll: 0,\n totalWeek: 0,\n totalMonth: 0,\n total: 0\n };\n },\n methods: {\n handleClick: function handleClick(tab) {\n switch (tab.name) {\n case 'bar':\n this.total = this.totalAll;\n break;\n\n case 'pie':\n this.total = this.totalAll;\n break;\n\n case 'line1':\n this.total = this.totalWeek;\n break;\n\n case 'line2':\n this.total = this.totalMonth;\n break;\n }\n }\n },\n mounted: function mounted() {\n var _this = this;\n\n var barChart = echarts.init(document.getElementById('bar'));\n var pieChart = echarts.init(document.getElementById('pie'));\n var lineChart1 = echarts.init(document.getElementById('weekLine'));\n var lineChart2 = echarts.init(document.getElementById('monthLine'));\n var barOption = {\n tooltip: {\n trigger: 'item'\n },\n title: {\n text: '收入统计柱状图',\n x: 'center'\n },\n label: {\n show: true,\n //是否显示\n position: \"top\"\n },\n xAxis: {\n type: 'category',\n data: []\n },\n yAxis: {\n type: 'value'\n },\n series: [{\n data: [],\n type: 'bar'\n }]\n };\n var pieOption = {\n tooltip: {\n trigger: 'item'\n },\n title: {\n text: '收入统计饼图',\n x: 'center'\n },\n series: [{\n type: 'pie',\n data: []\n }]\n };\n var lineOption1 = {\n tooltip: {\n trigger: 'item'\n },\n label: {\n show: true //是否显示\n\n },\n title: {\n text: '本周收入',\n x: 'center'\n },\n xAxis: {\n type: 'category',\n data: ['周一', '周二', '周三', '周四', '周五', '周六', '周日']\n },\n yAxis: {\n type: 'value'\n },\n series: [{\n data: [],\n type: 'line'\n }]\n };\n var lineOption2 = {\n tooltip: {\n trigger: 'item'\n },\n label: {\n show: true //是否显示\n\n },\n title: {\n text: '本月收入',\n x: 'center'\n },\n xAxis: {\n type: 'category',\n data: []\n },\n yAxis: {\n type: 'value'\n },\n series: [{\n data: [],\n type: 'line'\n }]\n }; //渲染柱状图和饼图\n\n this.request.get(\"/api/income/chart\").then(function (res) {\n if (res.code === '200') {\n var categoryIncomes = res.data.categoryIncomes;\n var categoryNames = categoryIncomes.map(function (item) {\n return item.categoryName;\n });\n var incomes = categoryIncomes.map(function (item) {\n return item.categoryIncome;\n });\n barOption.xAxis.data = categoryNames;\n barOption.series[0].data = incomes;\n barChart.setOption(barOption);\n\n for (var i = 0; i < categoryNames.length; i++) {\n var item = {\n value: incomes[i],\n name: categoryNames[i]\n };\n pieOption.series[0].data.push(item);\n }\n\n pieChart.setOption(pieOption); //计算总和\n\n var sum = 0;\n incomes.forEach(function (item) {\n sum += item;\n });\n _this.total = sum;\n _this.totalAll = sum;\n }\n }); //渲染本周折线图\n\n this.request.get(\"