123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488 |
- <template>
- <moduleEnclosure title="趋势图">
- <template v-slot:rightce>
- <div class="classbtns">
- <div
- @click="cindex = 0"
- :class="{
- select: cindex === 0,
- }"
- >
- 浏览量
- </div>
- <div
- @click="cindex = 1"
- :class="{
- select: cindex === 1,
- }"
- >
- 访客量
- </div>
- </div>
- </template>
- <el-carousel
- height="100%"
- style="width: 100%; height: 100%"
- ref="elCarousel"
- :autoplay="false"
- >
- <el-carousel-item v-for="(item, index) in 2" :key="index">
- <div style="width: 100%; height: 100%">
- <div
- :id="`chartmain_${item}`"
- style="width: 100%; height: 100%"
- ></div>
- </div>
- </el-carousel-item>
- </el-carousel>
- </moduleEnclosure>
- </template>
- <script>
- import moduleEnclosure from '@/components/moduleEnclosure.vue';
- import * as echarts from 'echarts';
- import { getQuery12 } from '@/api/bigView.js';
- import { csize } from '@/utils/const.js';
- let myChart, myChart2;
- export default {
- components: {
- moduleEnclosure,
- },
- data() {
- return {
- cindex: -1,
- myChart: null,
- myChart2: null,
- };
- },
- mounted() {
- this.timeId = getQuery12((res) => {
- this.eac(res.data);
- this.init_myChart2(res.data);
- }, 70000);
- this.cindex = 0;
- },
- beforeUnmount() {
- this.timeId();
- },
- watch: {
- cindex(newVal, oldValue) {
- if (oldValue !== -1) {
- this.$refs.elCarousel.next();
- }
- if (this.timed) {
- clearTimeout(this.timed);
- }
- this.timed = setTimeout(() => {
- this.cindex = this.cindex ? 0 : 1;
- }, 30000);
- },
- },
- methods: {
- eac(value) {
- var times = value.map((item) => {
- var str1 = item.ddate.split(' ')[0];
- return str1.slice(5);
- });
- var data = value.map((item) => {
- return item.badapp;
- });
- var option = {
- tooltip: {
- trigger: 'axis',
- formatter: function (params) {
- var res = '' + params[1].name + ' : ' + params[1].value;
- return `<div style="color:#fff;">${res}</div>`;
- },
- transitionDuration: 0,
- backgroundColor: '#092a66',
- borderColor: '#0462b5',
- borderRadius: 8,
- borderWidth: 2,
- padding: [5, 10],
- axisPointer: {
- type: 'line',
- lineStyle: {
- type: 'dashed',
- color: '#8AB1DC',
- },
- },
- },
- title: {
- text: '',
- subtext: '',
- },
- grid: {
- x: csize(65),
- y: csize(40),
- x2: csize(30),
- y2: csize(30),
- },
- xAxis: {
- data: times,
- axisLabel: {
- interval: Math.floor(times.length / 15),
- showMinLabel: true, //是否显示最小 tick 的 label
- showMaxLabel: true, //是否显示最大 tick 的 label
- fontSize: csize(12),
- },
- axisTick: {
- show: false,
- },
- axisLine: {
- show: false,
- symbol: ['none', 'arrow'],
- symbolOffset: 12,
- lineStyle: {
- fontSize: csize(12),
- color: '#8AB1DC',
- },
- },
- },
- yAxis: [
- {
- type: 'value',
- name: '单位(单)',
- nameTextStyle: {
- fontSize: csize(16),
- },
- axisLine: {
- show: false,
- lineStyle: {
- color: '#8AB1DC',
- },
- },
- axisLabel: {
- margin: 10,
- textStyle: {
- fontSize: csize(12),
- },
- },
- splitLine: {
- lineStyle: {
- color: '#364D95',
- },
- },
- axisTick: {
- show: false,
- },
- },
- ],
- dataZoom: [
- {
- type: 'inside',
- },
- ],
- series: [
- {
- // For shadow
- type: 'bar',
- barWidth: 10,
- itemStyle: {
- color: 'rgba(0,0,0,0.05)',
- },
- barGap: '-100%',
- barCategoryGap: '40%',
- data: data,
- animation: false,
- },
- {
- type: 'bar',
- barWidth: 10,
- itemStyle: {
- color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
- { offset: 0, color: '#0efdff' },
- { offset: 0.5, color: '#188df0' },
- { offset: 1, color: '#188df0' },
- ]),
- barBorderRadius: 5,
- },
- emphasis: {
- itemStyle: {
- color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
- { offset: 0, color: '#2378f7' },
- { offset: 0.7, color: '#2378f7' },
- { offset: 1, color: '#0efdff' },
- ]),
- barBorderRadius: 5,
- },
- },
- data: data,
- },
- ],
- };
- if (myChart) {
- myChart.dispose();
- }
- myChart = new echarts.init(document.getElementById('chartmain_1'));
- myChart.setOption(option);
- },
- init_myChart2(value) {
- var times = value.map((item) => {
- var str1 = item.ddate.split(' ')[0];
- return str1.slice(5);
- });
- var data = value.map((item) => {
- return item.goodrate;
- });
- var data1 = value.map((item) => {
- return item.insrate;
- });
- var data2 = value.map((item) => {
- return item.reprate;
- });
- if (myChart2) {
- myChart2.dispose();
- }
- myChart2 = new echarts.init(document.getElementById('chartmain_2'));
- myChart2.setOption({
- tooltip: {
- trigger: 'axis',
- formatter: function (params) {
- var res = '';
- for (var i = 0, l = params.length; i < l; i++) {
- res +=
- '' + params[i].seriesName + ' : ' + params[i].value + '<br>';
- }
- return `<div style="color:#fff;">${res}</div>`;
- },
- transitionDuration: 0,
- backgroundColor: '#092a66',
- borderColor: '#0462b5',
- borderRadius: 8,
- borderWidth: 2,
- padding: [5, 10],
- axisPointer: {
- type: 'line',
- lineStyle: {
- type: 'dashed',
- color: '#8AB1DC',
- },
- },
- },
- legend: {
- icon: 'circle',
- itemWidth: 8,
- itemHeight: 8,
- itemGap: 10,
- top: '16',
- right: '10',
- data: ['好评率', '安装评价率', '维修评价率'],
- textStyle: {
- fontSize: csize(16),
- color: '#8AB1DC',
- },
- },
- grid: {
- x: csize(65),
- y: csize(50),
- x2: csize(30),
- y2: csize(30),
- },
- xAxis: [
- {
- type: 'category',
- boundaryGap: false,
- axisLabel: {
- interval: Math.floor(times.length / 15),
- showMinLabel: true, //是否显示最小 tick 的 label
- showMaxLabel: true, //是否显示最大 tick 的 label
- fontSize: csize(12),
- },
- axisLine: {
- show: false,
- lineStyle: {
- color: '#8AB1DC',
- },
- },
- axisTick: {
- show: false,
- },
- data: times,
- },
- ],
- yAxis: [
- {
- type: 'value',
- name: '单位(%)',
- nameTextStyle: {
- fontSize: csize(16),
- },
- axisLine: {
- show: false,
- lineStyle: {
- color: '#8AB1DC',
- },
- },
- axisLabel: {
- margin: 10,
- textStyle: {
- fontSize: csize(12),
- },
- },
- splitLine: {
- lineStyle: {
- color: '#364D95',
- },
- },
- axisTick: {
- show: false,
- },
- },
- ],
- series: [
- {
- name: '好评率',
- type: 'line',
- smooth: true,
- showSymbol: false,
- lineStyle: {
- normal: {
- width: 2,
- },
- },
- areaStyle: {
- normal: {
- color: new echarts.graphic.LinearGradient(
- 0,
- 0,
- 0,
- 1,
- [
- {
- offset: 0,
- color: 'rgba(137, 189, 27, 0.3)',
- },
- {
- offset: 0.8,
- color: 'rgba(137, 189, 27, 0)',
- },
- ],
- false
- ),
- shadowColor: 'rgba(0, 0, 0, 0.1)',
- shadowBlur: 10,
- },
- },
- itemStyle: {
- normal: {
- color: '#F34799',
- },
- },
- data: data,
- },
- {
- name: '安装评价率',
- type: 'line',
- smooth: true,
- showSymbol: false,
- lineStyle: {
- normal: {
- width: 2,
- },
- },
- areaStyle: {
- normal: {
- color: new echarts.graphic.LinearGradient(
- 0,
- 0,
- 0,
- 1,
- [
- {
- offset: 0,
- color: 'rgba(137, 189, 27, 0.3)',
- },
- {
- offset: 0.8,
- color: 'rgba(137, 189, 27, 0)',
- },
- ],
- false
- ),
- shadowColor: 'rgba(0, 0, 0, 0.1)',
- shadowBlur: 10,
- },
- },
- itemStyle: {
- normal: {
- color: '#1cc840',
- },
- },
- data: data1,
- },
- {
- name: '维修评价率',
- type: 'line',
- smooth: true,
- showSymbol: false,
- lineStyle: {
- normal: {
- width: 2,
- },
- },
- areaStyle: {
- normal: {
- color: new echarts.graphic.LinearGradient(
- 0,
- 0,
- 0,
- 1,
- [
- {
- offset: 0,
- color: 'rgba(0, 136, 212, 0.3)',
- },
- {
- offset: 0.8,
- color: 'rgba(0, 136, 212, 0)',
- },
- ],
- false
- ),
- shadowColor: 'rgba(0, 0, 0, 0.1)',
- shadowBlur: 10,
- },
- },
- itemStyle: {
- normal: {
- color: '#43bbfb',
- },
- },
- data: data2,
- },
- ],
- });
- },
- },
- };
- </script>
- <style scoped lang="scss">
- .classbtns {
- width: 160px;
- height: 28px;
- display: flex;
- flex-direction: row;
- align-items: center;
- border: 2px solid #0e72e6;
- cursor: pointer;
- div {
- width: 50%;
- height: 100%;
- text-align: center;
- line-height: 28px;
- }
- div:nth-child(1) {
- border-right: 2px solid #0e72e6;
- }
- .select {
- background: #0e72e6;
- color: #bbd4ff;
- }
- }
- ::v-deep .el-carousel__arrow,
- ::v-deep .el-carousel__indicators {
- display: none;
- }
- </style>
|