|
|
@ -53,11 +53,11 @@ const options = { |
|
|
|
}, |
|
|
|
dataset: { |
|
|
|
source: [ |
|
|
|
['product', '2024-01-01', '2024-01-02', '2024-01-03', '2024-01-04', '2024-01-05', '2024-01-06', '2024-01-07'], |
|
|
|
['供温', 59.2, 78.9, 87.8, 79.5, 52.4, 90.7, 55], |
|
|
|
['回温', 42.0, 60.1, 62.8, 55.9, 30.2, 79.2, 20], |
|
|
|
['供温均温', 52, 77, 75, 70.1, 53.4, 50, 40], |
|
|
|
['回温均温', 40, 52, 61, 49, 20.4, 61.8, 10] |
|
|
|
// ['product', '2024-01-01', '2024-01-02', '2024-01-03', '2024-01-04', '2024-01-05', '2024-01-06', '2024-01-07'], |
|
|
|
// ['供温', 59.2, 78.9, 87.8, 79.5, 52.4, 90.7, 55], |
|
|
|
// ['回温', 42.0, 60.1, 62.8, 55.9, 30.2, 79.2, 20], |
|
|
|
// ['供温均温', 52, 77, 75, 70.1, 53.4, 50, 40], |
|
|
|
// ['回温均温', 40, 52, 61, 49, 20.4, 61.8, 10] |
|
|
|
] |
|
|
|
}, |
|
|
|
xAxis: { |
|
|
@ -70,7 +70,7 @@ const options = { |
|
|
|
yAxis: [ |
|
|
|
{ |
|
|
|
type: 'value', |
|
|
|
name: '温度(℃)', |
|
|
|
name: '', |
|
|
|
scale: true, //自适应 |
|
|
|
nameTextStyle: { |
|
|
|
color: '#000', |
|
|
@ -102,32 +102,40 @@ const options = { |
|
|
|
type: 'line', |
|
|
|
smooth: true, |
|
|
|
seriesLayoutBy: 'row', |
|
|
|
emphasis: { |
|
|
|
focus: 'series' |
|
|
|
tooltip: { |
|
|
|
valueFormatter: function (value: any) { |
|
|
|
return value + ' ℃'; |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
{ |
|
|
|
type: 'line', |
|
|
|
smooth: true, |
|
|
|
seriesLayoutBy: 'row', |
|
|
|
emphasis: { |
|
|
|
focus: 'series' |
|
|
|
tooltip: { |
|
|
|
valueFormatter: function (value: any) { |
|
|
|
return value + ' ℃'; |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
{ |
|
|
|
type: 'line', |
|
|
|
smooth: true, |
|
|
|
seriesLayoutBy: 'row', |
|
|
|
emphasis: { |
|
|
|
focus: 'series' |
|
|
|
tooltip: { |
|
|
|
valueFormatter: function (value: any) { |
|
|
|
return value + ' ℃'; |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
{ |
|
|
|
type: 'line', |
|
|
|
smooth: true, |
|
|
|
seriesLayoutBy: 'row', |
|
|
|
emphasis: { |
|
|
|
focus: 'series' |
|
|
|
tooltip: { |
|
|
|
valueFormatter: function (value: any) { |
|
|
|
return value + ' ℃'; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
] |
|
|
@ -135,24 +143,33 @@ const options = { |
|
|
|
|
|
|
|
onMounted(() => { |
|
|
|
// 图表初始化 |
|
|
|
const chart = echarts.init(document.getElementById(props.id) as HTMLDivElement); |
|
|
|
chart.setOption(options); |
|
|
|
// const chart = echarts.init(document.getElementById(props.id) as HTMLDivElement); |
|
|
|
// chart.setOption(options); |
|
|
|
getFirstLine(); |
|
|
|
|
|
|
|
// 大小自适应 |
|
|
|
window.addEventListener('resize', () => { |
|
|
|
chart.resize(); |
|
|
|
}); |
|
|
|
// window.addEventListener('resize', () => { |
|
|
|
// chart.resize(); |
|
|
|
// }); |
|
|
|
}); |
|
|
|
function getFirstLine() { |
|
|
|
//获取图表数据 |
|
|
|
const params = {}; |
|
|
|
getFirstLineApi().then((res: any) => { |
|
|
|
const chart = echarts.init(document.getElementById(props.id) as HTMLDivElement); |
|
|
|
if (res.code === 200 && Object.keys(res.data).length != 0) { |
|
|
|
options.dataset.source = res.data.source; |
|
|
|
options.yAxis[0].name = `单位(${res.data.unit})`; |
|
|
|
const chart = echarts.init(document.getElementById(props.id) as HTMLDivElement); |
|
|
|
options.dataset.source = res.data; |
|
|
|
options.yAxis[0].name = '单位(℃)'; |
|
|
|
chart.setOption(options); |
|
|
|
} else { |
|
|
|
chart.showLoading({ |
|
|
|
text: '暂无数据', |
|
|
|
color: '#fff', |
|
|
|
textColor: '#303133', |
|
|
|
maskColor: '#fff', |
|
|
|
fontSize: 16, |
|
|
|
zlevel: 0 |
|
|
|
}); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|