import echarts from 'echarts' export default { name: 'minxisoptions', computed: { getValues() { return (arr) => { const values = [] const names = [] if (arr.length > 0) { const arle = Object.keys(arr[0]).filter((itcv) => itcv !== 'name') arle.forEach((itcs) => { values.push([]) }) arr.forEach((iybv) => { for (const key in iybv) { if (iybv?.name) { if (key === 'name') { names.push(iybv[key]) } else { const fdex = arle.findIndex((itcg) => itcg === key) values[fdex].push(iybv[key]) } } } }) } return { names, values } } }, }, data() { return { chartOne: { tooltip: { trigger: 'axis', axisPointer: { type: 'shadow', }, }, legend: { show: true, }, xAxis: { type: 'category', data: [], axisLine: { lineStyle: { color: 'rgba(0,0,0,0.6)', }, }, axisLabel: { show: true, interval: 0, rotate: 50, inside: false, margin: 6, formatter: (val) => { if (val.length > 5) { return val.split('').splice(0, 5).join('') + '...' } else { return val } }, }, }, grid: { left: 50, right: 30, bottom: 70, top: 30, }, yAxis: { type: 'value', axisLine: { show: false, }, axisTick: { show: false, }, splitLine: { show: true, lineStyle: { color: 'rgba(0,0,0,0.1)', }, }, axisLabel: { textStyle: { fontFamily: 'Microsoft YaHei', // color: '#ccc', }, }, }, series: [], }, chartTwo: { tooltip: { trigger: 'axis', axisPointer: { type: 'shadow', }, }, legend: { show: true, }, grid: { left: 20, right: 20, bottom: 30, top: 30, containLabel: true, }, xAxis: { type: 'category', boundaryGap: false, data: [], }, yAxis: { type: 'value', axisLine: { show: false, }, axisTick: { show: false, }, splitLine: { show: true, lineStyle: { color: 'rgba(0,0,0,0.1)', }, }, axisLabel: { textStyle: { fontFamily: 'Microsoft YaHei', // color: '#ccc', }, }, }, series: [], }, chartThree: { color: ['#bb7ec4', '#ffb74a', '#ff4a55', '#54c5eb', '#8675ff', '#dce0fa'], textStyle: { color: '#8a8a8a', fontSize: 13, }, tooltip: { trigger: 'item', show: false, }, legend: { orient: 'vertical', right: '150px', icon: 'circle', top: 50, textStyle: { color: '#8a8a8a', lineHeight: 10, }, }, series: [], }, chartFour: { legend: { show: false, }, xAxis: { type: 'category', data: [], axisLine: { lineStyle: { color: 'rgba(0,0,0,0.6)', }, }, axisLabel: { show: true, interval: 0, rotate: 0, inside: false, margin: 6, formatter: (val) => { if (val.length > 5) { return val.split('').splice(0, 5).join('') + '...' } else { return val } }, }, }, grid: { left: 50, right: 30, bottom: 50, top: 30, }, yAxis: { type: 'value', axisLine: { show: false, }, axisTick: { show: false, }, splitLine: { show: true, lineStyle: { color: 'rgba(0,0,0,0.1)', }, }, axisLabel: { textStyle: { fontFamily: 'Microsoft YaHei', // color: '#ccc', }, }, }, series: [], }, chartFive: { tooltip: { trigger: 'axis', axisPointer: { type: 'shadow', }, }, legend: { show: true, }, xAxis: [ { type: 'category', data: [], axisLine: { lineStyle: { color: 'rgba(0,0,0,0.6)', }, }, axisLabel: { show: true, interval: 0, rotate: 0, inside: false, margin: 6, formatter: (val) => { if (val.length > 5) { return val.split('').splice(0, 5).join('') + '...' } else { return val } }, }, }, { type: 'value', max: 0, show: false, }, ], grid: { left: 50, right: 30, bottom: 50, top: 30, }, yAxis: { type: 'value', axisLine: { show: false, }, axisTick: { show: false, }, splitLine: { show: true, lineStyle: { color: 'rgba(0,0,0,0.1)', }, }, axisLabel: { textStyle: { fontFamily: 'Microsoft YaHei', // color: '#ccc', }, }, }, series: [], }, chartSex: { color: ['#ff7f5c', '#163bf5', '#f14249', '#2fc666', '#ffd72c'], tooltip: { trigger: 'item', }, legend: { show: true, orient: 'vertical', right: '40%', icon: 'circle', top: '50%', textStyle: { color: '#000', rich: { a: { width: 50, padding: [0, 14, 0, 0], }, b: { align: 'left', width: 40, padding: [0, 10, 0, 0], }, c: { align: 'left', }, }, }, }, series: [], }, chartSeven: { tooltip: { trigger: 'axis', axisPointer: { type: 'shadow', }, }, legend: { show: true, }, xAxis: [ { type: 'category', data: [], axisLine: { lineStyle: { color: 'rgba(0,0,0,0.6)', }, }, axisLabel: { show: true, interval: 0, rotate: 0, inside: false, margin: 6, formatter: (val) => { if (val.length > 5) { return val.split('').splice(0, 5).join('') + '...' } else { return val } }, }, }, { type: 'value', max: 0, show: false, }, ], grid: { left: 50, right: 30, bottom: 50, top: 30, }, yAxis: { type: 'value', axisLine: { show: false, }, axisTick: { show: false, }, splitLine: { show: true, lineStyle: { color: 'rgba(0,0,0,0.1)', }, }, axisLabel: { textStyle: { fontFamily: 'Microsoft YaHei', // color: '#ccc', }, }, }, series: [], }, chartEight: { color: ['#ff7f5c', '#163bf5', '#f14249', '#2fc666', '#ffd72c'], tooltip: { trigger: 'item', }, legend: { show: true, orient: 'vertical', right: '40%', icon: 'circle', top: '50%', textStyle: { color: '#000', rich: { a: { width: 50, padding: [0, 14, 0, 0], }, b: { align: 'left', width: 40, padding: [0, 10, 0, 0], }, c: { align: 'left', }, }, }, }, series: [], }, } }, methods: { oneChartsMap(datas) { const series = [] const { names, values } = this.getValues(datas) const tabline = [ { name: '发现问题数', color: ['#e7474e', '#eb4442'], data: values[0] || 0, }, { name: '到期整改问题数', color: ['#2dc84e', '#2ac689'], data: values[1] || 0, }, { name: '零容忍问题数', color: ['#ffd619', '#f9d632'], data: values[2] || 0, }, ] // console.log(tabline, '数据-------tabline') const styles = [] tabline.forEach((itvb, indexv) => { const styArr = [] itvb.color.forEach((itvn, inde) => { styArr.push({ offset: inde, color: itvn }) }) styles.push(styArr) }) tabline.forEach((itcs, index) => { series.push({ name: itcs.name, type: 'bar', barWidth: '15%', itemStyle: { normal: { color: new echarts.graphic.LinearGradient(0, 0, 0, 1, styles[index]), barBorderRadius: [12, 12, 0, 0], }, }, data: itcs.data, }) }) this.chartOne.xAxis.data = names this.chartOne.series = series // console.log('数据----ce', series) }, twoChartMap(datas) { const tabline = ['年度发现问题数趋势', '零容忍问题数'] const colors = ['rgba(191, 121, 131,1)', 'rgba(225, 217, 68,1)'] // const colors = ['rgba(191, 121, 131,1)', 'rgba(225, 217, 68,1)', 'rgba(103, 152, 183,1)'] const series = [] const { names, values } = this.getValues(datas) values.forEach((itcs, index) => { series.push({ name: tabline[index], type: 'line', showAllSymbol: true, symbol: 'circle', symbolSize: 8, lineStyle: { color: colors[index], // 线条颜色 normal: { color: colors[index], // 线条颜色 }, }, label: { show: false, position: 'top', textStyle: { color: '#fff', }, }, itemStyle: { normal: { color: colors[index], }, }, tooltip: { show: true, }, areaStyle: { // 区域填充样式 normal: { color: { type: 'linear', x: 0, y: 0, x2: 0, y2: 1, colorStops: [ { offset: 0, color: colors[index], // 0% 处的颜色 }, { offset: 0.4, color: colors[index].replace('1)', '0.1)'), // 0% 处的颜色 }, { offset: 1, color: 'rgba(255,255,255,0)', }, ], global: false, // 缺省为 false }, }, }, data: values[index], }) }) this.chartTwo.xAxis.data = names this.chartTwo.series = series }, threeChartMap(datas) { let nums = 0 datas.forEach((itb) => { nums += itb.value * 1 }) const series = [] series.push({ type: 'pie', center: ['25%', '50%'], radius: ['50%', '70%'], label: { show: true, fontSize: 15, fontWeight: '600', // color: '#fff', position: 'outside', formatter: function (item) { return `${((item.value / nums) * 100).toFixed(2)}%` }, }, emphasis: { disabled: true, scale: true, scaleSize: 0, }, tooltip: { show: false, }, labelLine: { show: true, }, data: datas, }) const legend = { show: true, orient: 'vertical', right: '10%', icon: 'circle', formatter: function (name) { const indexs = datas.findIndex((itcs) => itcs.name === name) return `{a|${datas[indexs].name}}{b|${datas[indexs].value}万元}` }, top: '5%', textStyle: { color: '#000', rich: { a: { width: 160, padding: [0, 14, 0, 0], }, b: { align: 'left', width: 60, padding: [0, 10, 0, 0], }, }, }, } // series[0].data = nameArr // 设置总条数 this.chartThree.title = { text: nums.toFixed(2), subtext: '金额总计(万元)', left: '25%', textAlign: 'center', top: 'center', } this.chartThree.series = series this.chartThree.legend = legend }, fourChartMap(datas) { debugger const series = [] const { names, values } = this.getValues(datas) const valuec = values[0] const arrc = [[], [], [], [], []] const arrcName = [[], [], [], [], []] // if (valuec) { // valuec.forEach((itc) => { // itc.forEach((itcv, index) => { // if (itcv.label) { // arrc[index].push(itcv.value || 0) // arrcName[index].push(itcv.label) // } // }) // }) // } if (valuec) { valuec.forEach((itc) => { itc.forEach((itcv, index) => { // if (itcv.label) { arrc[index].push(itcv.value) arrcName[index].push(itcv.label) // } }) }) } const tabline = [] const colorsc = ['#d55d6e', '#edd43e', '#6fa6da', '#5459c1', '#23459c'] arrc.forEach((itcvc, indexc) => { if (itcvc) { tabline.push({ name: `TOP${indexc * 1 + 1}`, data: itcvc, color: colorsc[indexc] }) } }) tabline.forEach((itcs, index) => { series.push({ name: itcs.name, barGap: 0.1, type: 'bar', itemStyle: { normal: { color: itcs.color, barBorderRadius: [12, 12, 0, 0], }, }, data: itcs.data, }) }) this.chartFour.tooltip = { trigger: 'axis', axisPointer: { type: 'shadow', }, formatter: (val) => { let str = '' let searName = [] val.forEach((itc) => { const newArrs = arrcName.filter((itcvc) => itcvc[itc.dataIndex]) searName = newArrs.map((ityv, indx) => { return { name: ityv[itc.dataIndex], value: arrc[indx][itc.dataIndex] } }) }) searName.forEach((itcc, indec) => { if (itcc?.name) { str += `