From d83609fd58b5d30396866ab540b526e4a1eb9a27 Mon Sep 17 00:00:00 2001
From: xuhuajiao <13476289682@163.com>
Date: Wed, 17 Jul 2024 17:02:14 +0800
Subject: [PATCH] =?UTF-8?q?echarts=E7=9B=B8=E5=85=B3=E8=A1=A8=E5=8C=B9?=
=?UTF-8?q?=E9=85=8D?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.env.development | 2 +-
src/assets/styles/index.scss | 1 +
src/components/echart/barEcharts.vue | 245 ++++++++--------
src/components/echart/todayCircle.vue | 304 +++++++++++---------
src/components/echart/yearCircle.vue | 333 +++++++++++++---------
src/views/map/index.vue | 389 +++++++++++++-------------
src/views/pageThree/index.vue | 2 +
7 files changed, 714 insertions(+), 562 deletions(-)
diff --git a/.env.development b/.env.development
index 41e54d6..22f2394 100644
--- a/.env.development
+++ b/.env.development
@@ -3,7 +3,7 @@ ENV = 'development'
# 接口地址
# 许镇-本地服地址
-VUE_APP_BASE_API = 'http://192.168.99.67:8080'
+VUE_APP_BASE_API = 'http://192.168.99.67:7070'
# VUE_APP_BASE_API = 'http://27.19.209.92:13244'
VUE_APP_LIB_API = 'http://118.253.150.248:8099'
diff --git a/src/assets/styles/index.scss b/src/assets/styles/index.scss
index 2fba1fc..8751d20 100644
--- a/src/assets/styles/index.scss
+++ b/src/assets/styles/index.scss
@@ -7,6 +7,7 @@
color: #fff;
overflow: hidden;
background: url('~@/assets/images/bg2.png') no-repeat top center #02061a;
+ background-size: 100% 100%;
font-family: 'DingTalk_JinBuTi_Regular';
}
diff --git a/src/components/echart/barEcharts.vue b/src/components/echart/barEcharts.vue
index 8716a8f..5012d0d 100644
--- a/src/components/echart/barEcharts.vue
+++ b/src/components/echart/barEcharts.vue
@@ -91,131 +91,158 @@ export default {
}
this.chart.setOption({
- tooltip: {
- trigger: 'axis',
- axisPointer: {
- type: 'shadow'
- }
- },
- legend: { // 图例
- right: 20,
- top: 10,
- icon: 'rect',
- itemHeight: 6,
- itemWidth: 11,
- textStyle: {
- color: '#fff',
- fontSize: 18
+ baseOption: {
+ tooltip: {
+ trigger: 'axis',
+ axisPointer: {
+ type: 'shadow'
+ }
},
- data: [
- {
- name: '借出',
- icon: 'rect',
- textStyle: {
- color: '#41A3FF',
- fontFamily: 'DingTalk_JinBuTi_Regular'
+ legend: { // 图例
+ right: 20,
+ top: 10,
+ icon: 'rect',
+ itemHeight: 6,
+ itemWidth: 11,
+ textStyle: {
+ color: '#fff',
+ fontSize: 18
+ },
+ data: [
+ {
+ name: '借出',
+ icon: 'rect',
+ textStyle: {
+ color: '#41A3FF',
+ fontFamily: 'DingTalk_JinBuTi_Regular'
+ }
+ },
+ {
+ name: '归还',
+ icon: 'rect',
+ textStyle: {
+ color: '#FFD050',
+ fontFamily: 'DingTalk_JinBuTi_Regular'
+ }
+ }
+ ]
+ },
+ grid: {
+ left: '3%',
+ right: '3%',
+ bottom: '8%',
+ top: '17%',
+ containLabel: true
+ },
+ xAxis: [{
+ type: 'category',
+ axisTick: { show: false },
+ data: date,
+ axisLine: { // 轴线的颜色以及宽度
+ lineStyle: {
+ color: '#113D72'
}
},
- {
- name: '归还',
- icon: 'rect',
+ axisLabel: { // x轴文字的配置
+ show: true,
+ interval: 0,
textStyle: {
- color: '#FFD050',
+ color: '#79B8FF',
+ fontSize: 16,
fontFamily: 'DingTalk_JinBuTi_Regular'
}
+ },
+ splitLine: { // 分割线配置
+ lineStyle: {
+ color: '#113D72',
+ type: 'solid'
+ }
}
- ]
- },
- grid: {
- left: '3%',
- right: '3%',
- bottom: '8%',
- top: '17%',
- containLabel: true
- },
- xAxis: [{
- type: 'category',
- axisTick: { show: false },
- data: date,
- axisLine: { // 轴线的颜色以及宽度
- lineStyle: {
- color: '#113D72'
- }
- },
- axisLabel: { // x轴文字的配置
- show: true,
- interval: 0,
- textStyle: {
- color: '#79B8FF',
- fontSize: 16,
- fontFamily: 'DingTalk_JinBuTi_Regular'
- }
- },
- splitLine: { // 分割线配置
- lineStyle: {
- color: '#113D72',
- type: 'solid'
- }
- }
- }],
- yAxis: [{
- min: 0,
- max: function(value) {
- return Math.ceil(value.max + (value.max - value.min) * 0.2)
- },
- minInterval: 1,
- type: 'value',
- axisLine: { // 轴线的颜色以及宽度
- show: false
- },
- axisLabel: { // 轴文字的配置
- show: true,
- interval: 'auto',
- formatter: function(value) {
- // 使用formatter保证即使在缩放时也只显示整数
- return Math.round(value)
+ }],
+ yAxis: [{
+ min: 0,
+ max: function(value) {
+ return Math.ceil(value.max + (value.max - value.min) * 0.2)
},
- textStyle: {
- color: '#79B8FF',
- fontSize: 16,
- fontFamily: 'DingTalk_JinBuTi_Regular'
+ minInterval: 1,
+ type: 'value',
+ axisLine: { // 轴线的颜色以及宽度
+ show: false
+ },
+ axisLabel: { // 轴文字的配置
+ show: true,
+ interval: 'auto',
+ formatter: function(value) {
+ // 使用formatter保证即使在缩放时也只显示整数
+ return Math.round(value)
+ },
+ textStyle: {
+ color: '#79B8FF',
+ fontSize: 16,
+ fontFamily: 'DingTalk_JinBuTi_Regular'
+ }
+ },
+ axisTick: { // 刻度线隐藏
+ show: false
+ },
+ splitLine: { // 分割线配置
+ lineStyle: {
+ color: 'rgba(66, 139, 221, 0.2)',
+ type: 'solid'
+ }
}
- },
- axisTick: { // 刻度线隐藏
- show: false
- },
- splitLine: { // 分割线配置
- lineStyle: {
- color: 'rgba(66, 139, 221, 0.2)',
- type: 'solid'
+ }],
+ series: [
+ {
+ name: '借出',
+ type: 'bar',
+ barWidth: 14, // 柱图宽度
+ barGap: '30%',
+ emphasis: {
+ focus: 'series'
+ },
+ data: outchartWeeklyData,
+ itemStyle: {
+ color: '#41A3FF'
+ }
+ },
+ {
+ name: '归还',
+ type: 'bar',
+ barWidth: 14, // 柱图宽度
+ emphasis: {
+ focus: 'series'
+ },
+ data: inchartWeeklyData,
+ itemStyle: {
+ color: '#FFD14F'
+ }
}
- }
- }],
- series: [
+ ]
+ },
+ media: [
{
- name: '借出',
- type: 'bar',
- barWidth: 14, // 柱图宽度
- barGap: '30%',
- emphasis: {
- focus: 'series'
- },
- data: outchartWeeklyData,
- itemStyle: {
- color: '#41A3FF'
+ option: {
+ series: [
+ {
+ type: 'pie',
+ left: '-50%'
+ }
+ ]
}
},
{
- name: '归还',
- type: 'bar',
- barWidth: 14, // 柱图宽度
- emphasis: {
- focus: 'series'
+ query: {
+ maxWidth: 675
},
- data: inchartWeeklyData,
- itemStyle: {
- color: '#FFD14F'
+ option: {
+ xAxis: [{
+ data: date.map(dateStr => {
+ const parts = dateStr.split('/')
+ return parts.slice(1).join('/') // 只保留月份和日期部分
+ })
+ }]
}
}
]
diff --git a/src/components/echart/todayCircle.vue b/src/components/echart/todayCircle.vue
index b94aac6..0b815c2 100644
--- a/src/components/echart/todayCircle.vue
+++ b/src/components/echart/todayCircle.vue
@@ -54,150 +54,194 @@ export default {
}
var centerImg = require('@/assets/images/circle-bg.png')
const option = {
- tooltip: {
- show: false,
- trigger: 'item',
- position: 'bottom',
- textStyle: {
- color: '#EEF6FF',
- fontSize: '18'
- }
+ baseOption: {
+ tooltip: {
+ show: false,
+ trigger: 'item',
+ position: 'bottom',
+ textStyle: {
+ color: '#EEF6FF',
+ fontSize: '18'
+ }
// backgroundColor: 'rgba(74, 144, 226, 0.84)',
// formatter: (params) => {
// return `
+ baseOption: {
+ // 提示框
+ tooltip: {
+ trigger: 'item',
+ triggerOn: 'click',
+ showContent: true, // 是否显示提示框浮层
+ alwaysShowContent: true, // 是否一直显示提示框内容
+ // hideDelay: 100, // 浮层隐藏的延迟
+ enterable: 'mousemove|click',
+ padding: [0, 0, 0, 0],
+ backgroundColor: null,
+ position: function(point, params, dom, rect, size) {
+ return [point[0] + 14, point[1] - 164]
+ },
+ formatter: (params, ticket, callback) => {
+ if (params.seriesType === 'effectScatter') {
+ const addressLine = params.data.place ? `
地址:${params.data.place}
` : ''
+ return `
${params.data.name}
${addressLine}
`
- } else if (params.seriesType === 'lines') {
- return (
- params.data.fromName +
+ } else if (params.seriesType === 'lines') {
+ return (
+ params.data.fromName +
'>' +
params.data.toName +
'
' +
params.data.value
- )
- } else {
- return params.name
+ )
+ } else {
+ return params.name
+ }
}
- }
- },
- // 设置geo坐标系
- geo: [
- {
- map: 'qiyang',
- aspectScale: 1,
- zoom: 1.1,
- top: '6%', // 距离顶部的位置,每层向下一个百分比
- left: '11%',
- roam: false, // 是否开启平游或缩放
- z: 6, // 可以看成是css的z-index,数字越大图层越高,我这里设置了5个,然后页面有点卡,根据实际需要来添加,3个其实就能看出效果了
- itemStyle: {
- areaColor: {
- type: 'linear',
- x: 0,
- y: 0,
- x2: 1,
- y2: 1,
- colorStops: [{
- offset: 0, color: 'rgba(0,0,0,.1)'
- }, {
- offset: 0.8, color: 'rgba(59,143,248,.6)'
- }],
- global: false
- },
- borderColor: '#9ffcff',
- borderWidth: 1
- },
- emphasis: {
+ },
+ // 设置geo坐标系
+ geo: [
+ {
+ map: 'qiyang',
+ aspectScale: 1,
+ zoom: 1.1,
+ top: '6%', // 距离顶部的位置,每层向下一个百分比
+ left: '11%',
+ roam: false, // 是否开启平游或缩放
+ z: 6, // 可以看成是css的z-index,数字越大图层越高,我这里设置了5个,然后页面有点卡,根据实际需要来添加,3个其实就能看出效果了
itemStyle: {
areaColor: {
type: 'linear',
@@ -593,160 +575,193 @@ export default {
offset: 0.8, color: 'rgba(59,143,248,.6)'
}],
global: false
- } // 鼠标移上去时区域的颜色
- }
- },
- label: {
+ },
+ borderColor: '#9ffcff',
+ borderWidth: 1
+ },
emphasis: {
- show: false,
- color: '#fff'
+ itemStyle: {
+ areaColor: {
+ type: 'linear',
+ x: 0,
+ y: 0,
+ x2: 1,
+ y2: 1,
+ colorStops: [{
+ offset: 0, color: 'rgba(0,0,0,.1)'
+ }, {
+ offset: 0.8, color: 'rgba(59,143,248,.6)'
+ }],
+ global: false
+ } // 鼠标移上去时区域的颜色
+ }
+ },
+ label: {
+ emphasis: {
+ show: false,
+ color: '#fff'
+ }
+ },
+ tooltip: {
+ show: true
}
},
- tooltip: {
- show: true
- }
- },
- {
- map: 'qiyang',
- aspectScale: 1,
- zoom: 1.1,
- top: '6%', // 距离顶部的位置,每层向下一个百分比
- left: '11%',
- roam: false, // 是否开启平游或缩放
- z: 5, // 可以看成是css的z-index,数字越大图层越高,我这里设置了5个,然后页面有点卡,根据实际需要来添加,3个其实就能看出效果了
- itemStyle: {
- areaColor: {
- type: 'pattern',
- image: mapImg,
- repeat: 'repeat'
- }, // 每个图层的背景色,根据需要来调,由亮变暗,下面的几个颜色也一样
- borderColor: '#9ffcff',
- borderWidth: 3,
- shadowColor: '#4cd4eb',
- shadowOffsetX: 0,
- shadowOffsetY: 0,
- shadowBlur: 0,
- emphasis: { // 地图悬停高亮样式
+ {
+ map: 'qiyang',
+ aspectScale: 1,
+ zoom: 1.1,
+ top: '6%', // 距离顶部的位置,每层向下一个百分比
+ left: '11%',
+ roam: false, // 是否开启平游或缩放
+ z: 5, // 可以看成是css的z-index,数字越大图层越高,我这里设置了5个,然后页面有点卡,根据实际需要来添加,3个其实就能看出效果了
+ itemStyle: {
areaColor: {
type: 'pattern',
image: mapImg,
repeat: 'repeat'
+ }, // 每个图层的背景色,根据需要来调,由亮变暗,下面的几个颜色也一样
+ borderColor: '#9ffcff',
+ borderWidth: 3,
+ shadowColor: '#4cd4eb',
+ shadowOffsetX: 0,
+ shadowOffsetY: 0,
+ shadowBlur: 0,
+ emphasis: { // 地图悬停高亮样式
+ areaColor: {
+ type: 'pattern',
+ image: mapImg,
+ repeat: 'repeat'
+ }
}
- }
- },
- emphasis: {
- disabled: true,
- areaColor: '#01215c'
- },
- label: {
+ },
emphasis: {
- show: false,
- color: '#fff'
+ disabled: true,
+ areaColor: '#01215c'
+ },
+ label: {
+ emphasis: {
+ show: false,
+ color: '#fff'
+ }
+ },
+ tooltip: {
+ show: false
}
},
- tooltip: {
- show: false
- }
- },
- {
- map: 'qiyang',
- aspectScale: 1,
- zoom: 1.1,
- top: '7%', // 根据自己需要来设置
- left: '10%',
- roam: false, // 是否开启平游或缩放
- z: 4, // 变小,也就是被压在下面
- itemStyle: {
- areaColor: '#05498f', // 记得改颜色
- borderColor: '#0296cf',
- borderWidth: 2,
- shadowColor: '#0296cf',
- shadowOffsetX: 0,
- shadowOffsetY: 0,
- shadowBlur: 0,
- emphasis: { // 地图悬停高亮样式
- disabled: true,
- areaColor: '#05498f'
+ {
+ map: 'qiyang',
+ aspectScale: 1,
+ zoom: 1.1,
+ top: '7%', // 根据自己需要来设置
+ left: '10%',
+ roam: false, // 是否开启平游或缩放
+ z: 4, // 变小,也就是被压在下面
+ itemStyle: {
+ areaColor: '#05498f', // 记得改颜色
+ borderColor: '#0296cf',
+ borderWidth: 2,
+ shadowColor: '#0296cf',
+ shadowOffsetX: 0,
+ shadowOffsetY: 0,
+ shadowBlur: 0,
+ emphasis: { // 地图悬停高亮样式
+ disabled: true,
+ areaColor: '#05498f'
+ }
+ },
+ tooltip: {
+ show: false
}
},
- tooltip: {
- show: false
- }
- },
- {
- map: 'qiyang',
- aspectScale: 1,
- zoom: 1.1,
- top: '9%', // 根据自己需要来设置
- left: '9%',
- roam: false,
- z: 3, // 变小,也就是被压在下面
- itemStyle: {
- areaColor: 'rgba(3,106,183,.5)', // 记得改颜色
- borderColor: '#025792',
- borderWidth: 2,
- shadowColor: '#025792',
- shadowOffsetX: 0,
- shadowOffsetY: 0,
- shadowBlur: 0,
- emphasis: { // 地图悬停高亮样式
- areaColor: 'rgba(3,106,183,.5)'
+ {
+ map: 'qiyang',
+ aspectScale: 1,
+ zoom: 1.1,
+ top: '9%', // 根据自己需要来设置
+ left: '9%',
+ roam: false,
+ z: 3, // 变小,也就是被压在下面
+ itemStyle: {
+ areaColor: 'rgba(3,106,183,.5)', // 记得改颜色
+ borderColor: '#025792',
+ borderWidth: 2,
+ shadowColor: '#025792',
+ shadowOffsetX: 0,
+ shadowOffsetY: 0,
+ shadowBlur: 0,
+ emphasis: { // 地图悬停高亮样式
+ areaColor: 'rgba(3,106,183,.5)'
+ }
+ },
+ tooltip: {
+ show: false
}
},
- tooltip: {
- show: false
- }
- },
- {
- map: 'qiyang',
- aspectScale: 1,
- zoom: 1.1,
- top: '11%', // 根据自己需要来设置
- left: '8%',
- roam: false,
- z: 2, // 变小,也就是被压在下面
- itemStyle: {
- areaColor: 'rgba(3,106,183,.2)', // 记得改颜色
- borderColor: '#195175',
- borderWidth: 1,
- shadowColor: '#0f4c74',
- shadowOffsetX: 0,
- shadowOffsetY: 4,
- shadowBlur: 10,
- emphasis: { // 地图悬停高亮样式
- areaColor: 'rgba(3,106,183,.2)'
+ {
+ map: 'qiyang',
+ aspectScale: 1,
+ zoom: 1.1,
+ top: '11%', // 根据自己需要来设置
+ left: '8%',
+ roam: false,
+ z: 2, // 变小,也就是被压在下面
+ itemStyle: {
+ areaColor: 'rgba(3,106,183,.2)', // 记得改颜色
+ borderColor: '#195175',
+ borderWidth: 1,
+ shadowColor: '#0f4c74',
+ shadowOffsetX: 0,
+ shadowOffsetY: 4,
+ shadowBlur: 10,
+ emphasis: { // 地图悬停高亮样式
+ areaColor: 'rgba(3,106,183,.2)'
+ }
+ },
+ tooltip: {
+ show: false
}
},
- tooltip: {
- show: false
+ {
+ map: 'qiyang',
+ aspectScale: 1,
+ zoom: 1.1,
+ top: '12%', // 根据自己需要来设置
+ left: '10%',
+ roam: false,
+ z: 1, // 变小,也就是被压在下面
+ itemStyle: {
+ areaColor: 'rgba(0,0,0,.6)', // 记得改颜色
+ borderColor: 'rgba(0,0,0,.6)',
+ borderWidth: 2,
+ shadowColor: 'rgba(0,0,0,.6)',
+ shadowOffsetX: 0,
+ shadowOffsetY: 4,
+ shadowBlur: 10,
+ emphasis: { // 地图悬停高亮样式
+ areaColor: 'rgba(0,0,0,.6)'
+ }
+ },
+ tooltip: {
+ show: false
+ }
}
- },
+ ],
+ series: series
+ },
+ media: [
{
- map: 'qiyang',
- aspectScale: 1,
- zoom: 1.1,
- top: '12%', // 根据自己需要来设置
- left: '10%',
- roam: false,
- z: 1, // 变小,也就是被压在下面
- itemStyle: {
- areaColor: 'rgba(0,0,0,.6)', // 记得改颜色
- borderColor: 'rgba(0,0,0,.6)',
- borderWidth: 2,
- shadowColor: 'rgba(0,0,0,.6)',
- shadowOffsetX: 0,
- shadowOffsetY: 4,
- shadowBlur: 10,
- emphasis: { // 地图悬停高亮样式
- areaColor: 'rgba(0,0,0,.6)'
- }
+ query: {
+ maxWidth: 666
},
- tooltip: {
- show: false
+ option: {
+ tooltip: {
+ position: function(point, params, dom, rect, size) {
+ return [point[0] + 10, point[1] - 122]
+ }
+ }
}
}
- ],
- series: series
+ ]
}
setTimeout(() => {
this.myChart.setOption(initOption)
diff --git a/src/views/pageThree/index.vue b/src/views/pageThree/index.vue
index 0bd54cb..7c003b4 100644
--- a/src/views/pageThree/index.vue
+++ b/src/views/pageThree/index.vue
@@ -383,6 +383,8 @@ export default {
this.chartWeeklyData.inchartWeeklyData = completeData.map(item => item.hccDayTotal)
// // out 借出
this.chartWeeklyData.outchartWeeklyData = completeData.map(item => item.jccDayTotal)
+
+ console.log(this.chartWeeklyData.date)
} else {
this.chartWeeklyData = {
date: [],