mirror of
https://github.com/dataease/dataease.git
synced 2025-02-24 19:42:56 +08:00
Merge pull request #13787 from dataease/pr@dev-v2@chart-area-extremum-fix
fix(图表): 修复面积图最值无法显示的问题
This commit is contained in:
commit
562178d7dd
@ -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 =
|
||||
|
@ -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})`
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user