Merge pull request #13787 from dataease/pr@dev-v2@chart-area-extremum-fix

fix(图表): 修复面积图最值无法显示的问题
This commit is contained in:
jianneng-fit2cloud 2024-12-03 18:34:54 +08:00 committed by GitHub
commit 562178d7dd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 21 additions and 2 deletions

View File

@ -1,5 +1,5 @@
import { valueFormatter } from '@/views/chart/components/js/formatter'
import { parseJson } from '@/views/chart/components/js/util'
import { hexToRgba, parseJson } from '@/views/chart/components/js/util'
import { isEmpty } from 'lodash-es'
export const clearExtremum = chart => {
@ -326,7 +326,10 @@ export const createExtremumPoint = (chart, ev) => {
pointElement.style.fontSize = fontSize + 'px'
pointElement.style.lineHeight = fontSize + 'px'
// 渐变颜色时需要获取最后一个rgba的值作为背景
const { r, b, g, a } = getRgbaColorLastRgba(point.color)
const color = point.color.startsWith('#')
? hexToRgba(point.color, basicStyle.alpha / 100)
: getRgbaColorLastRgba(point.color)
const { r, b, g, a } = color
pointElement.style.backgroundColor = 'rgba(' + r + ',' + g + ',' + b + ',' + a + ')'
pointElement.style.color = isColorLight(point.color) ? '#000' : '#fff'
pointElement.children[0]['style'].borderTopColor =

View File

@ -1142,3 +1142,19 @@ export const measureText = (chart, text, font, type) => {
}
return 0
}
/**
* 获取十六进制颜色值
* @param hex
* @param alpha
*/
export const hexToRgba = (hex, alpha = 1) => {
// 去掉 #
hex = hex.replace('#', '')
// 转换为 RGB 分量
const r = parseInt(hex.slice(0, 2), 16)
const g = parseInt(hex.slice(2, 4), 16)
const b = parseInt(hex.slice(4, 6), 16)
// 返回 RGBA 格式
return `rgba(${r}, ${g}, ${b}, ${alpha})`
}