fix(图表): 修复柱条图条件样式配置不透明度不生效的问题及优化文案

This commit is contained in:
jianneng-fit2cloud
2025-01-02 16:43:27 +08:00
committed by jianneng-fit2cloud
parent 9bb4b88853
commit 5439cead12
2 changed files with 20 additions and 2 deletions

View File

@@ -148,6 +148,17 @@ const isRangeBar = computed(() => {
return props.chart.type === 'bar-range'
})
const isBarOrHorizontal = computed(() => {
return [
'bar',
'bar-group',
'waterfall',
'bar-horizontal',
'bidirectional-bar',
'progress-bar'
].includes(props.chart.type)
})
const initFields = () => {
let fields = []
if (isSymbolicMap.value) {
@@ -407,7 +418,9 @@ init()
<el-col :span="3">
<el-form-item
class="form-item"
:label="isSymbolicMap ? t('chart.color') : t('chart.textColor')"
:label="
isSymbolicMap || isBarOrHorizontal ? t('chart.color') : t('chart.textColor')
"
>
<el-color-picker
is-custom

View File

@@ -1169,12 +1169,17 @@ export const measureText = (chart, text, font, type) => {
* @param alpha
*/
export const hexToRgba = (hex, alpha = 1) => {
if (!hex.startsWith('#')) {
return hex
}
// 去掉 # 号
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)
const hexAlpha = hex.slice(6, 8)
const a = hexAlpha ? parseInt(hex.slice(6, 8), 16) / 255 : alpha
// 返回 RGBA 格式
return `rgba(${r}, ${g}, ${b}, ${alpha})`
return `rgba(${r}, ${g}, ${b}, ${a})`
}