更新大屏
This commit is contained in:
106
src/views/home/echarts/barEcharts.vue
Normal file
106
src/views/home/echarts/barEcharts.vue
Normal file
@ -0,0 +1,106 @@
|
||||
<template>
|
||||
<div style="height:100%;width:100%" :id="echartsId"></div>
|
||||
</template>
|
||||
<script setup>
|
||||
import * as echarts from "echarts";
|
||||
import { onMounted, ref, reactive, defineProps, onUnmounted, watch, nextTick } from "vue";
|
||||
const props = defineProps({
|
||||
echartsId:{
|
||||
type:String,
|
||||
default:'lineId'
|
||||
},
|
||||
data:{
|
||||
type:Object,
|
||||
default:{
|
||||
list:[],
|
||||
colors:[]
|
||||
}
|
||||
}
|
||||
});
|
||||
watch(()=>props.data,val=>{
|
||||
nextTick(()=>{
|
||||
chartFn()
|
||||
})
|
||||
},{immediate:true,deep:true})
|
||||
|
||||
function chartFn() {
|
||||
var myChart = echarts.init(document.getElementById(props.echartsId));
|
||||
var option = {
|
||||
grid: {
|
||||
top: "16%",
|
||||
right: "2%",
|
||||
left: "2%",
|
||||
bottom: "4%",
|
||||
containLabel:true
|
||||
},
|
||||
tooltip: {
|
||||
trigger: "axis",
|
||||
axisPointer: {
|
||||
lineStyle: {
|
||||
color: "#ddd"
|
||||
}
|
||||
},
|
||||
backgroundColor: "rgba(255,255,255,1)",
|
||||
padding: [5, 10],
|
||||
textStyle: {
|
||||
color: "#7588E4"
|
||||
},
|
||||
},
|
||||
xAxis: {
|
||||
type: "category",
|
||||
data:props.data.list.map(v=>{return v.label}),
|
||||
axisTick: { show: false },
|
||||
axisLine: { show: false },
|
||||
axisLabel: { color: "#fff",magin:20 },
|
||||
},
|
||||
yAxis: {
|
||||
type: "value",
|
||||
splitLine: {
|
||||
show:true ,
|
||||
lineStyle: {
|
||||
type:'dashed',
|
||||
color: "rgba(14,95,255,0.5)"
|
||||
}
|
||||
},
|
||||
axisTick: { show: false },
|
||||
axisLine: { show: false },
|
||||
axisLabel: { color: "#fff" },
|
||||
},
|
||||
series: [
|
||||
{
|
||||
type: "bar",
|
||||
barGap:'80%',
|
||||
barWidth: "20px",
|
||||
data: props.data.list.map(v=>{return v.val}),
|
||||
label:{
|
||||
normal:{show:true,position:'top',color:'#EB00FF'}
|
||||
},
|
||||
itemStyle: {
|
||||
normal: {
|
||||
color:function name(params) {
|
||||
let colorList = []
|
||||
if(props.data.colors && props.data.colors.length>0){
|
||||
props.data.colors.forEach(item => {
|
||||
colorList.push(new echarts.graphic.LinearGradient( 0,0,0, 1,[{offset:0,color:item[0]},{offset:1,color:item[1]}]))
|
||||
});
|
||||
}
|
||||
if(colorList.length > 0) return colorList[params.dataIndex]
|
||||
else return new echarts.graphic.LinearGradient( 0,0,0, 1,[{ offset: 0,color: "rgba(0,244,255,1)"},{ offset: 1, color: "rgba(0,77,167,1)" }])
|
||||
},
|
||||
shadowColor: "rgba(0,160,221,1)",
|
||||
shadowBlur: 2
|
||||
}
|
||||
},
|
||||
}
|
||||
]
|
||||
};
|
||||
option && myChart.setOption(option);
|
||||
window.addEventListener('resize',function(){
|
||||
myChart.resize();
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
||||
</style>
|
119
src/views/home/echarts/lineEcharts.vue
Normal file
119
src/views/home/echarts/lineEcharts.vue
Normal file
@ -0,0 +1,119 @@
|
||||
<template>
|
||||
<div style="height:100%;width:100%" :id="echartsId"></div>
|
||||
</template>
|
||||
<script setup>
|
||||
import * as echarts from "echarts";
|
||||
import { onMounted, ref, reactive, defineProps, onUnmounted, watch, nextTick } from "vue";
|
||||
const props = defineProps({
|
||||
echartsId:{
|
||||
type:String,
|
||||
default:'lineId'
|
||||
},
|
||||
data:{
|
||||
type:Array,
|
||||
default:[]
|
||||
}
|
||||
});
|
||||
watch(()=>props.data,val=>{
|
||||
nextTick(()=>{ chartFn() })
|
||||
},{immediate:true,deep:true})
|
||||
|
||||
function chartFn() {
|
||||
var myChart = echarts.init(document.getElementById(props.echartsId));
|
||||
var option;
|
||||
option = {
|
||||
grid: {
|
||||
top: "8%",
|
||||
right: "2%",
|
||||
left: "2%",
|
||||
bottom: "7%",
|
||||
containLabel:true
|
||||
},
|
||||
tooltip: {
|
||||
trigger: "axis",
|
||||
axisPointer: {
|
||||
lineStyle: {
|
||||
color: "#ddd"
|
||||
}
|
||||
},
|
||||
backgroundColor: "rgba(255,255,255,1)",
|
||||
padding: [5, 10],
|
||||
textStyle: {
|
||||
color: "#7588E4"
|
||||
},
|
||||
extraCssText: "box-shadow: 0 0 5px rgba(0,0,0,0.3)"
|
||||
},
|
||||
xAxis: {
|
||||
type: "category",
|
||||
data:props.data.map(v=>{return v.label}),
|
||||
boundaryGap: false,
|
||||
axisTick: {
|
||||
show: false
|
||||
},
|
||||
axisLine: {
|
||||
show: false
|
||||
},
|
||||
axisLabel: {
|
||||
show: false
|
||||
}
|
||||
},
|
||||
yAxis: {
|
||||
type: "value",
|
||||
splitLine: {
|
||||
show:true ,
|
||||
lineStyle: {
|
||||
type:'dashed',
|
||||
color: "rgba(14,95,255,0.5)"
|
||||
}
|
||||
},
|
||||
axisTick: {
|
||||
show: false
|
||||
},
|
||||
axisLine: {
|
||||
show: false
|
||||
},
|
||||
axisLabel: {
|
||||
show:false
|
||||
},
|
||||
},
|
||||
series: [
|
||||
{
|
||||
type: "line",
|
||||
smooth:true,
|
||||
showSymbol:false,
|
||||
data: props.data.map(v=>{return v.val}),
|
||||
areaStyle: {
|
||||
normal: {
|
||||
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
|
||||
offset: 0,
|
||||
color: 'rgba(199, 237, 250,0.5)'
|
||||
}, {
|
||||
offset: 1,
|
||||
color: 'rgba(199, 237, 250,0.2)'
|
||||
}], false)
|
||||
}
|
||||
},
|
||||
itemStyle: {
|
||||
normal: {
|
||||
color: "rgb(4, 145, 216)"
|
||||
}
|
||||
},
|
||||
lineStyle: {
|
||||
normal: {
|
||||
width: 1,
|
||||
color:'#00FFFF'
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
};
|
||||
option && myChart.setOption(option);
|
||||
window.addEventListener('resize',function(){
|
||||
myChart.resize();
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
||||
</style>
|
113
src/views/home/echarts/moreBarEcharts.vue
Normal file
113
src/views/home/echarts/moreBarEcharts.vue
Normal file
@ -0,0 +1,113 @@
|
||||
<template>
|
||||
<div style="height:100%;width:100%" :id="echartsId"></div>
|
||||
</template>
|
||||
<script setup>
|
||||
import * as echarts from "echarts";
|
||||
import { on } from "element-plus/lib/utils";
|
||||
import { onMounted, ref, reactive, defineProps, onUnmounted, watch, nextTick } from "vue";
|
||||
|
||||
const props = defineProps({
|
||||
echartsId:{
|
||||
type:String,
|
||||
default:'moreBarId'
|
||||
},
|
||||
data:{
|
||||
type:Object,
|
||||
default:{
|
||||
xData:[],
|
||||
color:[],
|
||||
list:[]
|
||||
}
|
||||
}
|
||||
});
|
||||
watch(()=>props.data,val=>{
|
||||
nextTick(()=>{ init(val) })
|
||||
},{immediate:true,deep:true})
|
||||
|
||||
|
||||
// 初始化
|
||||
function init (val) {
|
||||
let color = val.color;
|
||||
let list = val.list
|
||||
let total = 0
|
||||
let series = list.map((item ,idx)=>{
|
||||
let obj = {
|
||||
type: "bar",
|
||||
stack:'total',
|
||||
name:item.label,
|
||||
data:item.val,
|
||||
barGap:'80%',
|
||||
barWidth: "30px",
|
||||
itemStyle:{normal: { color: color[idx] }}
|
||||
}
|
||||
if(item.label == '总数'){
|
||||
obj.stack = ''
|
||||
obj.z = -1
|
||||
obj.barGap = '-100%'
|
||||
obj.label = { normal:{show:true,position:'top',color:'#EB00FF'} }
|
||||
}
|
||||
return obj;
|
||||
})
|
||||
chartFn(series)
|
||||
}
|
||||
|
||||
function chartFn(series) {
|
||||
var myChart = echarts.init(document.getElementById(props.echartsId));
|
||||
var option = {
|
||||
grid: {
|
||||
top: "30%",
|
||||
right: "2%",
|
||||
left: "2%",
|
||||
bottom: "3%",
|
||||
containLabel:true
|
||||
},
|
||||
legend:{
|
||||
data:props.data.list.map(v=>{return v.label}),
|
||||
textStyle: { color: "#fff"},
|
||||
icon:'diamond', //arrow,diamond,roundRect,rect,none,circle
|
||||
itemWidth:16,
|
||||
itemHeight:8,
|
||||
itemGap:10
|
||||
},
|
||||
tooltip: {
|
||||
trigger: "axis",
|
||||
axisPointer: {
|
||||
lineStyle: { color: "#ddd" }
|
||||
},
|
||||
backgroundColor: "rgba(255,255,255,1)",
|
||||
padding: [5, 10],
|
||||
textStyle: { color: "#7588E4" },
|
||||
extraCssText: "box-shadow: 0 0 5px rgba(0,0,0,0.3)"
|
||||
},
|
||||
xAxis: {
|
||||
type: "category",
|
||||
data:props.data.xData,
|
||||
axisTick: { show: false },
|
||||
axisLine: { show: false },
|
||||
axisLabel: { color: "#fff",magin:20 },
|
||||
},
|
||||
yAxis: {
|
||||
type: "value",
|
||||
splitLine: {
|
||||
show:true ,
|
||||
lineStyle: {
|
||||
type:'dashed',
|
||||
color: "rgba(14,95,255,0.5)"
|
||||
}
|
||||
},
|
||||
axisTick: { show: false },
|
||||
axisLine: { show: false },
|
||||
axisLabel: { color: "#fff" },
|
||||
},
|
||||
series:series
|
||||
};
|
||||
option && myChart.setOption(option);
|
||||
window.addEventListener('resize',function(){
|
||||
myChart.resize();
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
||||
</style>
|
124
src/views/home/echarts/moreLineEcharts.vue
Normal file
124
src/views/home/echarts/moreLineEcharts.vue
Normal file
@ -0,0 +1,124 @@
|
||||
<template>
|
||||
<div style="height:100%;width:100%" :id="echartsId"></div>
|
||||
</template>
|
||||
<script setup>
|
||||
import * as echarts from "echarts";
|
||||
import { onMounted, ref, reactive, defineProps, onUnmounted, watch, nextTick } from "vue";
|
||||
|
||||
const props = defineProps({
|
||||
echartsId:{
|
||||
type:String,
|
||||
default:'morelineId'
|
||||
},
|
||||
data:{
|
||||
type:Object,
|
||||
default:{
|
||||
color:[], //['#EB00FF','#F57100']
|
||||
list:[], //[{label:'总数',val:[80,70,60,50]}, {label:'已处置',val:[70,40,30,80]}, ]
|
||||
xData:[] ,//['09-01','09-02','09-03','09-04']
|
||||
}
|
||||
}
|
||||
});
|
||||
watch(()=>props.data,val=>{
|
||||
nextTick(()=>{
|
||||
init(val)
|
||||
})
|
||||
},{immediate:true,deep:true})
|
||||
|
||||
|
||||
// 初始化
|
||||
function init (val) {
|
||||
let color = val.color;
|
||||
let list = val.list
|
||||
let series = list.map((item ,idx)=>{
|
||||
return {
|
||||
type: "line",
|
||||
name:item.label,
|
||||
data:item.val,
|
||||
itemStyle:{normal: { color: color[idx] }},
|
||||
smooth:true,
|
||||
showSymbol:false,
|
||||
areaStyle: {
|
||||
normal: {
|
||||
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
|
||||
offset: 0,
|
||||
color: 'rgba(199, 237, 250,0.5)'
|
||||
}, {
|
||||
offset: 1,
|
||||
color: 'rgba(199, 237, 250,0.2)'
|
||||
}], false)
|
||||
}
|
||||
},
|
||||
}
|
||||
})
|
||||
chartFn(series)
|
||||
}
|
||||
|
||||
function chartFn(series) {
|
||||
var myChart = echarts.init(document.getElementById(props.echartsId));
|
||||
var option = {
|
||||
grid: {
|
||||
top: "20%",
|
||||
right: "6%",
|
||||
left: "2%",
|
||||
bottom: "3%",
|
||||
containLabel:true
|
||||
},
|
||||
legend:{
|
||||
data:props.data.list.map(v=>{return v.label}),
|
||||
textStyle: { color: "#fff"},
|
||||
icon:'diamond', //arrow,diamond,roundRect,rect,none,circle
|
||||
itemWidth:16,
|
||||
itemHeight:8,
|
||||
itemGap:5
|
||||
},
|
||||
tooltip: {
|
||||
trigger: "axis",
|
||||
axisPointer: {
|
||||
lineStyle: { color: "#ddd" }
|
||||
},
|
||||
backgroundColor: "rgba(255,255,255,1)",
|
||||
padding: [5, 10],
|
||||
textStyle: { color: "#7588E4" },
|
||||
extraCssText: "box-shadow: 0 0 5px rgba(0,0,0,0.3)"
|
||||
},
|
||||
xAxis: {
|
||||
type: "category",
|
||||
data:props.data.xData,
|
||||
boundaryGap: false,
|
||||
axisTick: { show: false },
|
||||
axisLine: { show: false },
|
||||
axisLabel: { color: "#fff" },
|
||||
axisLabel: {
|
||||
show: true,
|
||||
color: "#fff",
|
||||
interval: 0, // 强制显示所有标签
|
||||
// rotate: 15, // 标签旋转角度
|
||||
// formatter: function(value) { return value.split("").join("\n");}
|
||||
}
|
||||
},
|
||||
yAxis: {
|
||||
type: "value",
|
||||
splitLine: {
|
||||
show:true ,
|
||||
lineStyle: {
|
||||
type:'dashed',
|
||||
color: "rgba(14,95,255,0.5)"
|
||||
}
|
||||
},
|
||||
axisTick: { show: false },
|
||||
axisLine: { show: false },
|
||||
axisLabel: { color: "#fff" },
|
||||
},
|
||||
series:series
|
||||
};
|
||||
option && myChart.setOption(option);
|
||||
window.addEventListener('resize',function(){
|
||||
myChart.resize();
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
||||
</style>
|
Reference in New Issue
Block a user