From ef80e5486f39623e6041c163a03ac852be4bab53 Mon Sep 17 00:00:00 2001
From: lwh <2679599887@qq.com>
Date: Thu, 11 May 2023 09:52:11 +0800
Subject: [PATCH] =?UTF-8?q?fix:=20=E5=AF=B9=E6=8E=A5=E5=90=8E=E5=8F=B0?=
=?UTF-8?q?=E9=A6=96=E9=A1=B5?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/components/Echarts/CountBox.vue | 185 +++++++++----
src/pages/index/index.vue | 386 ++++++----------------------
src/service/home.js | 15 ++
3 files changed, 233 insertions(+), 353 deletions(-)
create mode 100644 src/service/home.js
diff --git a/src/components/Echarts/CountBox.vue b/src/components/Echarts/CountBox.vue
index 6902765..b77a7d7 100644
--- a/src/components/Echarts/CountBox.vue
+++ b/src/components/Echarts/CountBox.vue
@@ -9,8 +9,8 @@
-
{{props.text}}
-
{{props.count}}
+
{{ props.text }}
+
{{ props.count }}
@@ -19,7 +19,7 @@

-
{{props.percentage}}%
+
{{ props.percentage }}%
同昨日对比
@@ -38,66 +38,165 @@ import * as echarts from 'echarts';
const props = defineProps({
- // 数据
- option: {
- type: Object,
- default: null,
- },
- img: {
- type: String,
- default: null,
- },
- text: {
- type: String,
- default: null,
- },
- count: {
- type: Number,
- default: 0,
- },
- percentage: {
- type: Number,
- default: 0,
- },
- idx: {
- type: Number,
- default: 0,
- },
+ // 数据
+ data: {
+ type: Array,
+ default: [
+ ['1', 500],
+ ['2', 900],
+ ['3', 460],
+ ['4', 1150],
+ ['5', 300],
+ ['6', 1000],
+ ['7', 400],
+ ],
+ },
+ img: {
+ type: String,
+ default: null,
+ },
+ text: {
+ type: String,
+ default: null,
+ },
+ count: {
+ type: Number,
+ default: 0,
+ },
+ percentage: {
+ type: Number,
+ default: 0,
+ },
+ idx: {
+ type: Number,
+ default: 0,
+ },
})
-
+console.log(props.data,'this is data');
onMounted(async () => {
- await echartsInit()
+ await echartsInit()
})
onBeforeUnmount(() => {
- echarts.dispose(document.getElementById('mainBox' + props.idx));
+ echarts.dispose(document.getElementById('mainBox' + props.idx));
});
+// 数据预览 echarts 参数
+let options = ref({
+ xAxis: {
+ type: 'category',
+ boundaryGap: false,
+ show: false,
+ axisTick: {
+ show: false // 不显示坐标轴刻度线
+ },
+ axisLine: {
+ show: false, // 不显示坐标轴线
+ },
+ axisLabel: {
+ show: false, // 不显示坐标轴上的文字
+ },
+ splitLine: {
+ show: false // 不显示网格线
+ },
+ },
+ yAxis: {
+ type: 'value',
+ boundaryGap: [0, '30%'],
+ show: false,
+ },
+ visualMap: {
+ type: 'piecewise',
+ show: false,
+ // 淡化效果
+ dimension: 0.1,
+ // 最小值
+ min: 0,
+ seriesIndex: 1,
+ pieces: [
+ {
+ gt: 1,
+ lt: 3,
+ color: 'rgba(0, 0, 180, 0.4)'
+ },
+ {
+ gt: 5,
+ lt: 7,
+ color: 'rgba(0, 0, 180, 0.4)'
+ }
+ ]
+ },
+ series: [
+ {
+ type: 'line',
+ smooth: 0.6,
+ symbol: 'none',
+ showSymbol: true,
+
+ lineStyle: {
+ color: {
+ type: 'linear', // 线性渐变
+ x: 0.7,
+ y: 0,
+ x2: 0,
+ y2: 0,
+ colorStops: [{
+ offset: 0,
+ color: '#a5b9fe' // 0%处的颜色为淡橙色
+ }, {
+ offset: 1,
+ color: '#4e70df' // 100%处的颜色为橙色
+ }]
+ },
+ width: 3,
+ },
+ itemStyle: {
+ color: {
+ type: 'linear', // 线性渐变
+ x: 0,
+ y: 0.8,
+ x2: 0,
+ y2: 0.4,
+ colorStops: [{
+ offset: 0,
+ color: '#ffffff' // 0%处的颜色为淡橙色
+ }, {
+ offset: 1,
+ color: '#e7f1ff' // 100%处的颜色为橙色
+ }]
+ }
+ },
+ areaStyle: {},
+ data: props.data
+ }
+ ]
+})
+
+
// 顶部第一个盒子
async function echartsInit() {
- console.log(document.getElementById('mainBox' + props.idx));
- let myChart = echarts.getInstanceByDom(document.getElementById('mainBox' + props.idx)); //有的话就获取已有echarts实例的DOM节点。
-
- if (myChart == null) { // 如果不存在,就进行初始化。
- myChart = echarts.init(document.getElementById('mainBox' + props.idx));
- }
+ let myChart = echarts.getInstanceByDom(document.getElementById('mainBox' + props.idx)); //有的话就获取已有echarts实例的DOM节点。
- props.option && myChart.setOption(props.option);
+ if (myChart == null) { // 如果不存在,就进行初始化。
+ myChart = echarts.init(document.getElementById('mainBox' + props.idx));
+ }
+
+ options.value && myChart.setOption(options.value);
}
+
@@ -297,20 +100,20 @@
-
+
-
+
-
+
-
+
@@ -348,10 +151,58 @@