feat:悬浮标签修改
This commit is contained in:
@@ -1107,7 +1107,26 @@ function updateChart(config: {
|
|||||||
if (!params || params.length === 0) return ''
|
if (!params || params.length === 0) return ''
|
||||||
const param = params[0]
|
const param = params[0]
|
||||||
if (config.dataType === 'hourly') {
|
if (config.dataType === 'hourly') {
|
||||||
return `${param.name}Hour: 0`
|
// 将小时数转换为AM/PM格式
|
||||||
|
const hour = parseInt(param.name)
|
||||||
|
let displayHour = hour
|
||||||
|
let period = 'AM'
|
||||||
|
|
||||||
|
if (hour === 0) {
|
||||||
|
displayHour = 12
|
||||||
|
period = 'AM'
|
||||||
|
} else if (hour < 12) {
|
||||||
|
displayHour = hour
|
||||||
|
period = 'AM'
|
||||||
|
} else if (hour === 12) {
|
||||||
|
displayHour = 12
|
||||||
|
period = 'PM'
|
||||||
|
} else {
|
||||||
|
displayHour = hour - 12
|
||||||
|
period = 'PM'
|
||||||
|
}
|
||||||
|
|
||||||
|
return `${displayHour} ${period}:0`
|
||||||
} else if (config.dataType === 'realtime-enhanced') {
|
} else if (config.dataType === 'realtime-enhanced') {
|
||||||
const minutesAgo = defaultData.length - 1 - param.dataIndex
|
const minutesAgo = defaultData.length - 1 - param.dataIndex
|
||||||
return `${minutesAgo}Min ago: 0`
|
return `${minutesAgo}Min ago: 0`
|
||||||
@@ -1227,7 +1246,26 @@ function updateChart(config: {
|
|||||||
const formatValue = config.formatValue || ((val: number) => val.toString())
|
const formatValue = config.formatValue || ((val: number) => val.toString())
|
||||||
const value = typeof param.value === 'object' ? param.value.value : param.value
|
const value = typeof param.value === 'object' ? param.value.value : param.value
|
||||||
if (config.dataType === 'hourly') {
|
if (config.dataType === 'hourly') {
|
||||||
return `${param.name}Hour: ${formatValue(value)}`
|
// 将小时数转换为AM/PM格式
|
||||||
|
const hour = parseInt(param.name)
|
||||||
|
let displayHour = hour
|
||||||
|
let period = 'AM'
|
||||||
|
|
||||||
|
if (hour === 0) {
|
||||||
|
displayHour = 12
|
||||||
|
period = 'AM'
|
||||||
|
} else if (hour < 12) {
|
||||||
|
displayHour = hour
|
||||||
|
period = 'AM'
|
||||||
|
} else if (hour === 12) {
|
||||||
|
displayHour = 12
|
||||||
|
period = 'PM'
|
||||||
|
} else {
|
||||||
|
displayHour = hour - 12
|
||||||
|
period = 'PM'
|
||||||
|
}
|
||||||
|
|
||||||
|
return `${displayHour} ${period}:${formatValue(value)}`
|
||||||
} else if (config.dataType === 'realtime-enhanced') {
|
} else if (config.dataType === 'realtime-enhanced') {
|
||||||
// 对于增强实时数据,计算实际的分钟数
|
// 对于增强实时数据,计算实际的分钟数
|
||||||
const minutesAgo = processedData.length - 1 - param.dataIndex
|
const minutesAgo = processedData.length - 1 - param.dataIndex
|
||||||
|
|||||||
Reference in New Issue
Block a user