1 line
14 KiB
JSON
1 line
14 KiB
JSON
|
{"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\";\nimport \"core-js/modules/es.number.to-fixed.js\";\nimport \"core-js/modules/es.number.constructor.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//\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.setOpti
|