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