From a129211e5efde088faf1e6d6ed6bdf91c371b4c5 Mon Sep 17 00:00:00 2001 From: zhangkai <17600160566@163.com> Date: Mon, 4 Nov 2024 11:59:56 +0800 Subject: [PATCH] 1 --- .DS_Store | Bin 10244 -> 10244 bytes build/index.html | 2 +- build/locales/zh/bs.json | 1 + src/components/Chart/index.tsx | 95 ++++++++++++++++++++++++++------- 4 files changed, 79 insertions(+), 19 deletions(-) diff --git a/.DS_Store b/.DS_Store index b9ff8c584e955d803a0398abb09cf0903b415db9..51b485099f972ddd57cea69180da3a768070f9c1 100644 GIT binary patch delta 42 ycmZn(XbIThFEBYqtdzsp*jz`!*wkS1X#ttZU&T~5a|{0F+sv-;i)E82Gcy1yhz*1Q delta 30 mcmZn(XbIThFEBYusC2Tgg!^V5!QXtF*%W@WY-SQ=W(EMO-wEsh diff --git a/build/index.html b/build/index.html index bc9eb26..190ff21 100644 --- a/build/index.html +++ b/build/index.html @@ -8,7 +8,7 @@ NPCs - + diff --git a/build/locales/zh/bs.json b/build/locales/zh/bs.json index b2ff614..ffd11a9 100644 --- a/build/locales/zh/bs.json +++ b/build/locales/zh/bs.json @@ -179,6 +179,7 @@ "machineName": "服务名", "addOne": "加一条" }, + "flow": { "unsavedChangesConfirmation": "您有未保存的更改,确定要离开吗?", "leave": "离开", diff --git a/src/components/Chart/index.tsx b/src/components/Chart/index.tsx index 4f42504..69f20af 100644 --- a/src/components/Chart/index.tsx +++ b/src/components/Chart/index.tsx @@ -6,25 +6,84 @@ function Chart({ options }) { let chartInstance = null; options = eval('('+options.substring(8)+')'); - console.log(options) - - const options1 = { - tooltip: {}, - legend: { - data: [""], - }, - xAxis: { - data: options.data.map(obj => {return obj.name}), - }, - yAxis: {}, - series: [ - { - name: "", - type: options.chartType, - data: options.data.map(obj => {return obj.value}), - }, + options = { + "chartType": "line", + "xData": [ + "江苏", + "浙江", + "广东", + "广州", + "北京", + "山西", + "河北" ], -}; + "data": { + "2023上半年":['120%', '132%', '101%', '134%', '90%', '230%', '210%'], + "2024上半年":['220%', '182%', '191%', '234%', '290%', '330%', '310%'] + }, + "legend": [], + "pieData": [] + } + options.legend = Object.keys(options.data); + options.pieData = []; + options.series = []; + + options.xData.map((data,index) =>{ + options.pieData.push({'name':data,'value':options.data[options.legend[0]][index].split("%").join("")}) + }) + options.legend.map((data,index) =>{ + let list = []; + options.data[data].map(data1 =>{ + list.push(data1.split("%").join("")) + }); + options.series.push({ + name: data, + type: options.chartType, + data: list, + }) + }) + console.log(options) + let options1; + if(options.chartType == "pie"){ + options1 = { + tooltip: {}, + series: [ + { + name: 'Access From', + type: 'pie', + radius: '50%', + label: { + normal: { + + textStyle: { // 提示文字的样式 + color: '#fff', + fontSize: 14 + } + } + }, + data: options.pieData, + emphasis: { + itemStyle: { + shadowBlur: 10, + shadowOffsetX: 0, + shadowColor: 'rgba(0, 0, 0, 0.5)' + } + } + } + ] + }; + }else{ + options1 = { + tooltip: { + trigger: 'axis' + }, + xAxis: { + data: options.xData, + }, + yAxis: {}, + series: options.series, + }; + } // 定义渲染函数 function renderChart() { try {