123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481 |
- <template>
- <div id="myChartindex4" style="width: 100%; height: 100%;"></div>
- </template>
- <script>
- import { visitDept, visitPerson, deptCollect, PersonCollect } from '../../api'
- import echarts from 'echarts'
- export default {
- name: "Mz_tx_charts",
- data() {
- return {
- dataArr: [],
- myChart: null
- }
- },
- methods: {
- getArrByKey(data, k) {
- let key = k || "value";
- let res = [];
- if (data) {
- data.forEach(function (t) {
- res.push(t[key]);
- });
- }
- return res;
- },
- getMaxValueOfArray(data) {
- if (data == null || data.length == 0) {
- return 0;
- }
- let maxValue = data[0].value;
- for (let i = 1; i < data.length; i++) {
- if (maxValue < data[i].value) {
- maxValue = data[i].value;
- }
- }
- return maxValue;
- },
- // 地区巡访
- async draw1() {
- const result = await visitDept({}, 'POST');
- this.dataArr = result;
- const seriesArr = [];
- // for(let i = 0; i < this.dataArr.length; i++) {
- // const kkArr = new Array(length).fill({});
- // kkArr[i] = { value: 100, symbolPosition: 'start' };
- // let symbolImage = `image://${require('../../assets/index/y-text-4.png')}`;
- // if(i < 4) {
- // symbolImage = `image://${require('../../assets/index/y-text-' + (i + 1) + '.png')}`
- // }
- // seriesArr.push({
- // type: 'pictorialBar',
- // symbol: symbolImage,
- // symbolSize: [24, 24],
- // symbolOffset: [-40, -8],
- // data: kkArr,
- // label: {
- // show: true,
- // position: 'left',
- // offset: [-19, -6],
- // color: '#fff',
- // fontSize: this.fontSize(0.17),
- // formatter: `${ i + 1 }`
- // },
- // z: 2
- // });
- // }
- if (this.myChart != null) {
- this.myChart.clear();
- }
- this.myChart = this.$echarts.init(document.getElementById('myChartindex4'));
- this.myChart.setOption({
- grid: {
- top: '10%',
- bottom: '-18%',
- right: '0%',
- left: '2%',
- containLabel: true
- },
- xAxis: {
- show: false,
- max: this.getMaxValueOfArray(this.dataArr)
- },
- yAxis: [{
- triggerEvent: true,
- show: true,
- inverse: true,
- data: this.getArrByKey(this.dataArr, 'label'),
- axisLine: {
- show: false
- },
- splitLine: {
- show: false
- },
- axisTick: {
- show: false
- },
- axisLabel: {
- show: false
- }
- }, {
- triggerEvent: true,
- show: true,
- inverse: true,
- data: this.getArrByKey(this.dataArr, 'label'),
- axisLine: {
- show: false
- },
- splitLine: {
- show: false
- },
- axisTick: {
- show: false
- },
- axisLabel: {
- interval: 0,
- // shadowOffsetX: '-0px',
- // align: 'right',
- // verticalAlign: 'bottom',
- lineHeight: 0,
- fontSize: this.fontSize(0.16),
- color: '#fff',
- formatter: (value, index) => {
- return this.dataArr[index].value + '次';
- },
- }
- }],
- series: [{
- type: 'bar',
- showBackground: true,
- barBorderRadius: 50,
- yAxisIndex: 0,
- data: this.dataArr,
- barWidth: 6,
- itemStyle: {
- color: () => {
- return new echarts.graphic.LinearGradient(0, 0, 1, 0, [{
- offset: 0,
- color: '#0071fc'
- }, {
- offset: 1,
- color: '#4be2ec'
- }]);
- },
- barBorderRadius: 30,
- },
- label: {
- normal: {
- color: '#00b8ff',
- show: true,
- position: [0, -this.fontSize(0.18)],
- textStyle: {
- fontSize: this.fontSize(0.16)
- },
- formatter: function (a,) {
- return a.name;
- }
- }
- }
- }, ...seriesArr]
- });
- },
- // 个人巡访
- async draw2() {
- const result = await visitPerson({}, 'POST');
- this.dataArr = result;
- const seriesArr = [];
- if (this.myChart != null) {
- this.myChart.clear();
- }
- this.myChart = this.$echarts.init(document.getElementById('myChartindex4'));
- this.myChart.setOption({
- grid: {
- top: '10%',
- bottom: '-18%',
- right: '0%',
- left: '2%',
- containLabel: true
- },
- xAxis: {
- show: false,
- max: this.getMaxValueOfArray(this.dataArr)
- },
- yAxis: [{
- triggerEvent: true,
- show: true,
- inverse: true,
- data: this.getArrByKey(this.dataArr, 'label'),
- axisLine: {
- show: false
- },
- splitLine: {
- show: false
- },
- axisTick: {
- show: false
- },
- axisLabel: {
- show: false
- }
- }, {
- triggerEvent: true,
- show: true,
- inverse: true,
- data: this.getArrByKey(this.dataArr, 'label'),
- axisLine: {
- show: false
- },
- splitLine: {
- show: false
- },
- axisTick: {
- show: false
- },
- axisLabel: {
- interval: 0,
- // shadowOffsetX: '-50px',
- // align: 'right',
- // verticalAlign: 'bottom',
- // lineHeight: 30,
- fontSize: this.fontSize(0.16),
- color: '#fff',
- formatter: (value, index) => {
- return this.dataArr[index].value + '次';
- },
- }
- }],
- series: [{
- type: 'bar',
- showBackground: true,
- barBorderRadius: 30,
- yAxisIndex: 0,
- data: this.dataArr,
- barWidth: 6,
- itemStyle: {
- color: () => {
- return new echarts.graphic.LinearGradient(0, 0, 1, 0, [{
- offset: 0,
- color: '#0023ff'
- }, {
- offset: 1,
- color: '#75c6ff'
- }]);
- },
- barBorderRadius: 30,
- },
- label: {
- normal: {
- color: '#00b8ff',
- show: true,
- position: [0, -this.fontSize(0.18)],
- textStyle: {
- fontSize: this.fontSize(0.16)
- },
- formatter: function (a,) {
- return a.name;
- }
- }
- }
- }, ...seriesArr]
- });
- },
- // 地区采集
- async draw3() {
- const result = await deptCollect({}, 'POST');
- this.dataArr = result;
- const seriesArr = [];
- if (this.myChart != null) {
- this.myChart.clear();
- }
- this.myChart = this.$echarts.init(document.getElementById('myChartindex4'));
- this.myChart.setOption({
- grid: {
- top: '10%',
- bottom: '-18%',
- right: '0%',
- left: '2%',
- containLabel: true
- },
- xAxis: {
- show: false,
- max: this.getMaxValueOfArray(this.dataArr)
- },
- yAxis: [{
- triggerEvent: true,
- show: true,
- inverse: true,
- data: this.getArrByKey(this.dataArr, 'label'),
- axisLine: {
- show: false
- },
- splitLine: {
- show: false
- },
- axisTick: {
- show: false
- },
- axisLabel: {
- show: false
- }
- }, {
- triggerEvent: true,
- show: true,
- inverse: true,
- data: this.getArrByKey(this.dataArr, 'label'),
- axisLine: {
- show: false
- },
- splitLine: {
- show: false
- },
- axisTick: {
- show: false
- },
- axisLabel: {
- interval: 0,
- // shadowOffsetX: '-50px',
- // align: 'right',
- // verticalAlign: 'bottom',
- // lineHeight: 30,
- fontSize: this.fontSize(0.16),
- color: '#fff',
- formatter: (value, index) => {
- return this.dataArr[index].value + '次';
- },
- }
- }],
- series: [{
- type: 'bar',
- showBackground: true,
- barBorderRadius: 30,
- yAxisIndex: 0,
- data: this.dataArr,
- barWidth: 6,
- itemStyle: {
- color: () => {
- return new echarts.graphic.LinearGradient(0, 0, 1, 0, [{
- offset: 0,
- color: '#0023ff'
- }, {
- offset: 1,
- color: '#75c6ff'
- }]);
- },
- barBorderRadius: 30,
- },
- label: {
- normal: {
- color: '#00b8ff',
- show: true,
- position: [0, -this.fontSize(0.18)],
- textStyle: {
- fontSize: this.fontSize(0.16)
- },
- formatter: function (a,) {
- return a.name;
- }
- }
- }
- }, ...seriesArr]
- });
- },
- // 个人采集
- async draw4() {
- const result = await PersonCollect({}, 'POST');
- this.dataArr = result;
- const seriesArr = [];
- if (this.myChart != null) {
- this.myChart.clear();
- }
- this.myChart = this.$echarts.init(document.getElementById('myChartindex4'));
- this.myChart.setOption({
- grid: {
- top: '10%',
- bottom: '-18%',
- right: '0%',
- left: '2%',
- containLabel: true
- },
- xAxis: {
- show: false,
- max: this.getMaxValueOfArray(this.dataArr)
- },
- yAxis: [{
- triggerEvent: true,
- show: true,
- inverse: true,
- data: this.getArrByKey(this.dataArr, 'label'),
- axisLine: {
- show: false
- },
- splitLine: {
- show: false
- },
- axisTick: {
- show: false
- },
- axisLabel: {
- show: false
- }
- }, {
- triggerEvent: true,
- show: true,
- inverse: true,
- data: this.getArrByKey(this.dataArr, 'label'),
- axisLine: {
- show: false
- },
- splitLine: {
- show: false
- },
- axisTick: {
- show: false
- },
- axisLabel: {
- interval: 0,
- // shadowOffsetX: '-50px',
- // align: 'right',
- // verticalAlign: 'bottom',
- // lineHeight: 30,
- fontSize: this.fontSize(0.16),
- color: '#fff',
- formatter: (value, index) => {
- return this.dataArr[index].value + '次';
- },
- }
- }],
- series: [{
- type: 'bar',
- showBackground: true,
- barBorderRadius: 30,
- yAxisIndex: 0,
- data: this.dataArr,
- barWidth: 6,
- itemStyle: {
- color: () => {
- return new echarts.graphic.LinearGradient(0, 0, 1, 0, [{
- offset: 0,
- color: '#0023ff'
- }, {
- offset: 1,
- color: '#75c6ff'
- }]);
- },
- barBorderRadius: 30,
- },
- label: {
- normal: {
- color: '#00b8ff',
- show: true,
- position: [0, -this.fontSize(0.18)],
- textStyle: {
- fontSize: this.fontSize(0.16)
- },
- formatter: function (a,) {
- return a.name;
- }
- }
- }
- }, ...seriesArr]
- });
- },
- fontSize(res) {
- let clientWidth = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
- if (!clientWidth) return;
- let fontSize = 100 * (clientWidth / 1920);
- return res * fontSize;
- }
- },
- mounted() {
- // this.draw4();
- }
- }
- </script>
- <style scoped>
- </style>
|