|
|
|
@ -49,141 +49,164 @@ const props = defineProps({
|
|
|
|
|
const chartRef = ref();
|
|
|
|
|
let chart = null;
|
|
|
|
|
const colorList = ['#9E87FF', '#73DDFF', '#fe9a8b', '#F56948', '#9E87FF'];
|
|
|
|
|
const defaultOption= {
|
|
|
|
|
title: {
|
|
|
|
|
text: props.data.options.title || '',
|
|
|
|
|
textStyle: {
|
|
|
|
|
fontSize: 12,
|
|
|
|
|
fontWeight: 400,
|
|
|
|
|
color: '#fff'
|
|
|
|
|
},
|
|
|
|
|
left: '0',
|
|
|
|
|
top: '5%'
|
|
|
|
|
},
|
|
|
|
|
legend: {
|
|
|
|
|
icon: 'circle',
|
|
|
|
|
top: '5%',
|
|
|
|
|
right: '5%',
|
|
|
|
|
itemWidth: 6,
|
|
|
|
|
itemGap: 20,
|
|
|
|
|
textStyle: {
|
|
|
|
|
color: '#fff'
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
tooltip: {
|
|
|
|
|
trigger: 'axis',
|
|
|
|
|
axisPointer: {
|
|
|
|
|
label: {
|
|
|
|
|
show: true,
|
|
|
|
|
backgroundColor: '#fff',
|
|
|
|
|
color: '#000',
|
|
|
|
|
borderColor: 'rgba(0,0,0,0)',
|
|
|
|
|
shadowColor: 'rgba(0,0,0,0)',
|
|
|
|
|
shadowOffsetY: 0
|
|
|
|
|
},
|
|
|
|
|
lineStyle: {
|
|
|
|
|
width: 0
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
backgroundColor: '#fff',
|
|
|
|
|
textStyle: {
|
|
|
|
|
color: '#000'
|
|
|
|
|
},
|
|
|
|
|
padding: [10, 10],
|
|
|
|
|
extraCssText: 'box-shadow: 1px 0 2px 0 rgba(163,163,163,0.5)'
|
|
|
|
|
},
|
|
|
|
|
grid: {
|
|
|
|
|
top: props.data?.options?.gridTop+'%' || '20%',
|
|
|
|
|
left: props.data?.options?.gridLeft+'%' || '20%',
|
|
|
|
|
bottom: props.data?.options?.gridBottom+'%' || '20%',
|
|
|
|
|
right: props.data?.options?.gridRight+'%' || '20%'
|
|
|
|
|
},
|
|
|
|
|
xAxis: [
|
|
|
|
|
{
|
|
|
|
|
name:props.data?.options?.xName || '',
|
|
|
|
|
type: 'category',
|
|
|
|
|
axisLine: {
|
|
|
|
|
lineStyle: {
|
|
|
|
|
color: '#DCE2E8'
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
axisTick: {
|
|
|
|
|
show: true
|
|
|
|
|
},
|
|
|
|
|
axisLabel: {
|
|
|
|
|
interval: 0,
|
|
|
|
|
textStyle: {
|
|
|
|
|
color: '#fff'
|
|
|
|
|
},
|
|
|
|
|
fontSize: 12,
|
|
|
|
|
margin: 3
|
|
|
|
|
},
|
|
|
|
|
axisPointer: {
|
|
|
|
|
label: {
|
|
|
|
|
padding: [0, 0, 0, 0],
|
|
|
|
|
margin: 0,
|
|
|
|
|
fontSize: 12
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
boundaryGap: true
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
yAxis: [
|
|
|
|
|
{
|
|
|
|
|
name:props.data?.options?.yName || '',
|
|
|
|
|
type: 'value',
|
|
|
|
|
axisTick: {
|
|
|
|
|
show: false
|
|
|
|
|
},
|
|
|
|
|
axisLine: {
|
|
|
|
|
show: true,
|
|
|
|
|
lineStyle: {
|
|
|
|
|
color: '#fff'
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
axisLabel: {
|
|
|
|
|
textStyle: {
|
|
|
|
|
color: '#fff'
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
splitLine: {
|
|
|
|
|
show: false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
series: [
|
|
|
|
|
{
|
|
|
|
|
type: 'line',
|
|
|
|
|
symbolSize: 1,
|
|
|
|
|
symbol: 'circle',
|
|
|
|
|
smooth: false,
|
|
|
|
|
yAxisIndex: 0,
|
|
|
|
|
showSymbol: false,
|
|
|
|
|
lineStyle: {
|
|
|
|
|
width: 1,
|
|
|
|
|
color: new echarts.graphic.LinearGradient(0, 1, 0, 0, [
|
|
|
|
|
{
|
|
|
|
|
offset: 0,
|
|
|
|
|
color: '#9effff'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
offset: 1,
|
|
|
|
|
color: '#9E87FF'
|
|
|
|
|
}
|
|
|
|
|
]),
|
|
|
|
|
shadowColor: 'rgba(158,135,255, 0.3)',
|
|
|
|
|
shadowBlur: 10,
|
|
|
|
|
shadowOffsetY: 20
|
|
|
|
|
},
|
|
|
|
|
itemStyle: {
|
|
|
|
|
normal: {
|
|
|
|
|
color: colorList[0],
|
|
|
|
|
borderColor: colorList[0]
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
const getOption = () => {
|
|
|
|
|
const chartOption = {
|
|
|
|
|
title: {
|
|
|
|
|
text: props.data.options.title || '设备运行数量',
|
|
|
|
|
textStyle: {
|
|
|
|
|
fontSize: 12,
|
|
|
|
|
fontWeight: 400,
|
|
|
|
|
color: '#fff'
|
|
|
|
|
},
|
|
|
|
|
left: '0',
|
|
|
|
|
top: '5%'
|
|
|
|
|
},
|
|
|
|
|
legend: {
|
|
|
|
|
icon: 'circle',
|
|
|
|
|
top: '5%',
|
|
|
|
|
right: '5%',
|
|
|
|
|
itemWidth: 6,
|
|
|
|
|
itemGap: 20,
|
|
|
|
|
textStyle: {
|
|
|
|
|
color: '#fff'
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
tooltip: {
|
|
|
|
|
trigger: 'axis',
|
|
|
|
|
axisPointer: {
|
|
|
|
|
label: {
|
|
|
|
|
show: true,
|
|
|
|
|
backgroundColor: '#fff',
|
|
|
|
|
color: '#000',
|
|
|
|
|
borderColor: 'rgba(0,0,0,0)',
|
|
|
|
|
shadowColor: 'rgba(0,0,0,0)',
|
|
|
|
|
shadowOffsetY: 0
|
|
|
|
|
},
|
|
|
|
|
lineStyle: {
|
|
|
|
|
width: 0
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
backgroundColor: '#fff',
|
|
|
|
|
textStyle: {
|
|
|
|
|
color: '#000'
|
|
|
|
|
},
|
|
|
|
|
padding: [10, 10],
|
|
|
|
|
extraCssText: 'box-shadow: 1px 0 2px 0 rgba(163,163,163,0.5)'
|
|
|
|
|
text: props.data.options.title || '',
|
|
|
|
|
},
|
|
|
|
|
grid: {
|
|
|
|
|
top: '30%',
|
|
|
|
|
bottom: '10%'
|
|
|
|
|
top: props.data?.options?.gridTop+'%' || '20%',
|
|
|
|
|
left: props.data?.options?.gridLeft+'%' || '20%',
|
|
|
|
|
bottom: props.data?.options?.gridBottom+'%' || '20%',
|
|
|
|
|
right: props.data?.options?.gridRight+'%' || '20%'
|
|
|
|
|
},
|
|
|
|
|
xAxis: [
|
|
|
|
|
{
|
|
|
|
|
type: 'category',
|
|
|
|
|
axisLine: {
|
|
|
|
|
lineStyle: {
|
|
|
|
|
color: '#DCE2E8'
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
axisTick: {
|
|
|
|
|
show: true
|
|
|
|
|
},
|
|
|
|
|
axisLabel: {
|
|
|
|
|
interval: 0,
|
|
|
|
|
textStyle: {
|
|
|
|
|
color: '#fff'
|
|
|
|
|
},
|
|
|
|
|
// 默认x轴字体大小
|
|
|
|
|
fontSize: 12,
|
|
|
|
|
// margin:文字到x轴的距离
|
|
|
|
|
margin: 3
|
|
|
|
|
},
|
|
|
|
|
axisPointer: {
|
|
|
|
|
label: {
|
|
|
|
|
padding: [0, 0, 0, 0],
|
|
|
|
|
margin: 0,
|
|
|
|
|
// 移入时的字体大小
|
|
|
|
|
fontSize: 12
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
boundaryGap: true
|
|
|
|
|
name:props.data?.options?.xName || '',
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
yAxis: [
|
|
|
|
|
{
|
|
|
|
|
type: 'value',
|
|
|
|
|
axisTick: {
|
|
|
|
|
show: false
|
|
|
|
|
},
|
|
|
|
|
axisLine: {
|
|
|
|
|
show: true,
|
|
|
|
|
lineStyle: {
|
|
|
|
|
color: '#fff'
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
axisLabel: {
|
|
|
|
|
textStyle: {
|
|
|
|
|
color: '#fff'
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
splitLine: {
|
|
|
|
|
show: false
|
|
|
|
|
}
|
|
|
|
|
name:props.data?.options?.yName || '',
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
series: [
|
|
|
|
|
{
|
|
|
|
|
type: 'line',
|
|
|
|
|
symbolSize: 1,
|
|
|
|
|
symbol: 'circle',
|
|
|
|
|
smooth: false,
|
|
|
|
|
yAxisIndex: 0,
|
|
|
|
|
showSymbol: false,
|
|
|
|
|
lineStyle: {
|
|
|
|
|
width: 1,
|
|
|
|
|
color: new echarts.graphic.LinearGradient(0, 1, 0, 0, [
|
|
|
|
|
{
|
|
|
|
|
offset: 0,
|
|
|
|
|
color: '#9effff'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
offset: 1,
|
|
|
|
|
color: '#9E87FF'
|
|
|
|
|
}
|
|
|
|
|
]),
|
|
|
|
|
shadowColor: 'rgba(158,135,255, 0.3)',
|
|
|
|
|
shadowBlur: 10,
|
|
|
|
|
shadowOffsetY: 20
|
|
|
|
|
},
|
|
|
|
|
itemStyle: {
|
|
|
|
|
normal: {
|
|
|
|
|
color: colorList[0],
|
|
|
|
|
borderColor: colorList[0]
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
};
|
|
|
|
|
console.log(chartOption);
|
|
|
|
|
let xData = [props.inputData?.x1 || []];
|
|
|
|
|
let yData = [props.inputData?.y1 || []];
|
|
|
|
|
let length = Math.min(...xData.map(e => e.length), ...yData.map(e => e.length));
|
|
|
|
@ -209,12 +232,12 @@ onMounted(() => {
|
|
|
|
|
chart = echarts.init(chartRef.value, 'macarons', {
|
|
|
|
|
renderer: 'svg'
|
|
|
|
|
});
|
|
|
|
|
chart.setOption(getOption(), true);
|
|
|
|
|
chart.setOption(defaultOption, true);
|
|
|
|
|
});
|
|
|
|
|
watch(() => [JSON.parse(JSON.stringify(props.inputData)), JSON.parse(JSON.stringify(props.data.options))], (obj1, obj2) => {
|
|
|
|
|
if (JSON.stringify(obj1) !== JSON.stringify(obj2)) {
|
|
|
|
|
|
|
|
|
|
chart && chart.setOption(getOption(), true);
|
|
|
|
|
chart && chart.setOption(getOption(), false);
|
|
|
|
|
}
|
|
|
|
|
}, { deep: true, immediate: true });
|
|
|
|
|
watch(() => JSON.parse(JSON.stringify(props.dimensions)), (obj1, obj2) => {
|
|
|
|
|