|
@@ -6,52 +6,46 @@
|
|
|
|
|
|
<script setup>
|
|
|
import * as echarts from 'echarts'
|
|
|
-defineProps({
|
|
|
- title: {
|
|
|
- type: String,
|
|
|
- default: '暂无数据'
|
|
|
+const props = defineProps({
|
|
|
+ resultData: {
|
|
|
+ type: Array,
|
|
|
+ default: []
|
|
|
}
|
|
|
})
|
|
|
+let colorList = [
|
|
|
+ "rgba(255, 38, 38, 1)",
|
|
|
+ "rgba(255, 96, 0, 1)",
|
|
|
+ "rgba(255, 165, 7, 1)",
|
|
|
+ "rgba(0, 234, 255, 1)",
|
|
|
+ "rgba(0, 132, 255, 1)",
|
|
|
+ "#2379FF",
|
|
|
+];
|
|
|
+let colorListA = [
|
|
|
+ "rgba(255, 38, 38, 0.1)",
|
|
|
+ "rgba(255, 96, 0, 0.1)",
|
|
|
+ "rgba(255, 165, 7, 0.1)",
|
|
|
+ "rgba(0, 234, 255, 0.1)",
|
|
|
+ "rgba(0, 132, 255, 0.1)",
|
|
|
+ "#49B1FF",
|
|
|
+];
|
|
|
+let colorListB = [
|
|
|
+ "rgba(249, 136, 136, 1)",
|
|
|
+ "rgba(255, 162, 106, 1)",
|
|
|
+ "rgba(255, 210, 130, 1)",
|
|
|
+ "rgba(142, 255, 206, 1)",
|
|
|
+ "rgba(165, 232, 255, 1)",
|
|
|
+];
|
|
|
+let colorListC = [
|
|
|
+ "rgba(249, 136, 136, 0.1)",
|
|
|
+ "rgba(255, 162, 106, 0.1)",
|
|
|
+ "rgba(255, 210, 130, 0.1)",
|
|
|
+ "rgba(142, 255, 206, 0.1)",
|
|
|
+ "rgba(165, 232, 255, 0.1)",
|
|
|
+];
|
|
|
const chartDistrict = ref(null);
|
|
|
let chartDom = null;
|
|
|
const initAccess = () => {
|
|
|
- let colorList = [
|
|
|
- "rgba(255, 38, 38, 1)",
|
|
|
- "rgba(255, 96, 0, 1)",
|
|
|
- "rgba(255, 165, 7, 1)",
|
|
|
- "rgba(0, 234, 255, 1)",
|
|
|
- "rgba(0, 132, 255, 1)",
|
|
|
- "#2379FF",
|
|
|
- ];
|
|
|
- let colorListA = [
|
|
|
- "rgba(255, 38, 38, 0.1)",
|
|
|
- "rgba(255, 96, 0, 0.1)",
|
|
|
- "rgba(255, 165, 7, 0.1)",
|
|
|
- "rgba(0, 234, 255, 0.1)",
|
|
|
- "rgba(0, 132, 255, 0.1)",
|
|
|
- "#49B1FF",
|
|
|
- ];
|
|
|
- let colorListB = [
|
|
|
- "rgba(249, 136, 136, 1)",
|
|
|
- "rgba(255, 162, 106, 1)",
|
|
|
- "rgba(255, 210, 130, 1)",
|
|
|
- "rgba(142, 255, 206, 1)",
|
|
|
- "rgba(165, 232, 255, 1)",
|
|
|
- ];
|
|
|
- let colorListC = [
|
|
|
- "rgba(249, 136, 136, 0.1)",
|
|
|
- "rgba(255, 162, 106, 0.1)",
|
|
|
- "rgba(255, 210, 130, 0.1)",
|
|
|
- "rgba(142, 255, 206, 0.1)",
|
|
|
- "rgba(165, 232, 255, 0.1)",
|
|
|
- ];
|
|
|
- let result = [
|
|
|
- { name: "天水祥丰农资农贸有限公司", value: 86 },
|
|
|
- { name: "天水花牛苹果", value: 83 },
|
|
|
- { name: "天水红富士", value: 73 },
|
|
|
- { name: "天水金帅苹果", value: 61 },
|
|
|
- { name: "天水黄面皮", value: 61 },
|
|
|
- ];
|
|
|
+ let result = props.resultData
|
|
|
chartDom = echarts.init(chartDistrict.value);
|
|
|
let option = {
|
|
|
color: colorList,
|
|
@@ -71,7 +65,7 @@ const initAccess = () => {
|
|
|
backgroundColor: 'rgba(0, 0, 0, 0.5)',
|
|
|
extraCssText: 'backdrop-filter: blur(6px);',
|
|
|
confine: true,
|
|
|
- formatter: "{b}<br />客流指数: {c}",
|
|
|
+ formatter: "{b}<br />使用场数:{c}",
|
|
|
},
|
|
|
legend: {
|
|
|
show: false,
|
|
@@ -166,7 +160,7 @@ const initAccess = () => {
|
|
|
padding: [0, 5, 10, 0],
|
|
|
inside: true,
|
|
|
formatter: function (value) {
|
|
|
- return `{name|客流指数:}{value|${value}}`;
|
|
|
+ return `{name|使用场数:}{value|${value}}`;
|
|
|
},
|
|
|
rich: {
|
|
|
name: {
|
|
@@ -183,7 +177,7 @@ const initAccess = () => {
|
|
|
},
|
|
|
},
|
|
|
},
|
|
|
- data: result.map((item) => item.value),
|
|
|
+ data: result.map((item) => item.count),
|
|
|
},
|
|
|
],
|
|
|
series: [
|
|
@@ -213,7 +207,7 @@ const initAccess = () => {
|
|
|
data: result.map((item, index) => {
|
|
|
return {
|
|
|
name: item.name,
|
|
|
- value: item.value,
|
|
|
+ value: item.count,
|
|
|
itemStyle: {
|
|
|
barBorderRadius: [3, 0, 0, 3],
|
|
|
color: {
|
|
@@ -250,7 +244,7 @@ const initAccess = () => {
|
|
|
data: result.map((item, index) => {
|
|
|
return {
|
|
|
name: item.name,
|
|
|
- value: item.value,
|
|
|
+ value: item.count,
|
|
|
itemStyle: {
|
|
|
color: colorListB[index],
|
|
|
borderColor: colorListC[index],
|
|
@@ -275,7 +269,7 @@ const initAccess = () => {
|
|
|
data: result.map((item, index) => {
|
|
|
return {
|
|
|
name: item.name,
|
|
|
- value: item.value,
|
|
|
+ value: item.count,
|
|
|
itemStyle: {
|
|
|
color: colorListB[index],
|
|
|
borderColor: colorListC[index],
|
|
@@ -292,6 +286,78 @@ const initAccess = () => {
|
|
|
};
|
|
|
chartDom.setOption(option)
|
|
|
};
|
|
|
+watch(() => props.resultData, (newVal) => {
|
|
|
+ let arrData = newVal
|
|
|
+ if (chartDom) {
|
|
|
+ chartDom = echarts.init(chartDistrict.value);
|
|
|
+ chartDom.setOption({
|
|
|
+ yAxis: [{
|
|
|
+ data: arrData.map((item) => item.name)
|
|
|
+ }, {
|
|
|
+ data: arrData.map((item) => item.count),
|
|
|
+ }],
|
|
|
+ series: [{
|
|
|
+ data: arrData.map((item, index) => {
|
|
|
+ return {
|
|
|
+ name: item.name,
|
|
|
+ value: item.count,
|
|
|
+ itemStyle: {
|
|
|
+ barBorderRadius: [3, 0, 0, 3],
|
|
|
+ color: {
|
|
|
+ type: "linear",
|
|
|
+ x: 0,
|
|
|
+ y: 0,
|
|
|
+ x2: 1,
|
|
|
+ y2: 1,
|
|
|
+ colorStops: [
|
|
|
+ {
|
|
|
+ offset: 0,
|
|
|
+ color: colorListA[index],
|
|
|
+ },
|
|
|
+ {
|
|
|
+ offset: 1,
|
|
|
+ color: colorList[index],
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ },
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }, {
|
|
|
+ data: arrData.map((item, index) => {
|
|
|
+ return {
|
|
|
+ name: item.name,
|
|
|
+ value: item.count,
|
|
|
+ itemStyle: {
|
|
|
+ color: colorListB[index],
|
|
|
+ borderColor: colorListC[index],
|
|
|
+ borderWidth: 12,
|
|
|
+ shadowColor: colorListC[index],
|
|
|
+ shadowBlur: 10,
|
|
|
+ opacity: 1,
|
|
|
+ },
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }, {
|
|
|
+ data: arrData.map((item, index) => {
|
|
|
+ return {
|
|
|
+ name: item.name,
|
|
|
+ value: item.count,
|
|
|
+ itemStyle: {
|
|
|
+ color: colorListB[index],
|
|
|
+ borderColor: colorListC[index],
|
|
|
+ borderWidth: 30,
|
|
|
+ shadowColor: colorListC[index],
|
|
|
+ shadowBlur: 10,
|
|
|
+ opacity: 1,
|
|
|
+ },
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }],
|
|
|
+ })
|
|
|
+ }
|
|
|
+}, { deep: true, immediate: true } // 开启深度监听
|
|
|
+)
|
|
|
// 生命周期
|
|
|
onMounted(() => {
|
|
|
initAccess()
|