diff --git a/extensions/dataease-extensions-view/view-racebar/view-racebar-frontend/src/components/selector/GraphicSetting.vue b/extensions/dataease-extensions-view/view-racebar/view-racebar-frontend/src/components/selector/GraphicSetting.vue index a1e4f0e4fe..a2d762f470 100644 --- a/extensions/dataease-extensions-view/view-racebar/view-racebar-frontend/src/components/selector/GraphicSetting.vue +++ b/extensions/dataease-extensions-view/view-racebar/view-racebar-frontend/src/components/selector/GraphicSetting.vue @@ -1,7 +1,7 @@ diff --git a/extensions/dataease-extensions-view/view-racebar/view-racebar-frontend/src/utils/map.js b/extensions/dataease-extensions-view/view-racebar/view-racebar-frontend/src/utils/map.js index caa4c17e11..1d49e69424 100644 --- a/extensions/dataease-extensions-view/view-racebar/view-racebar-frontend/src/utils/map.js +++ b/extensions/dataease-extensions-view/view-racebar/view-racebar-frontend/src/utils/map.js @@ -87,6 +87,7 @@ export const DEFAULT_SLIDER = { export const DEFAULT_Graphic = { show: true, fontSize: '60', + marginModel: 'absolute', color: '#000000', alpha: 25, bottom: 90, @@ -842,7 +843,7 @@ const hexToRgba = (hex, opacity) => { } export const getMarginUnit = marginForm => { - if (!marginForm.marginModel || marginForm.marginModel === 'auto') return null + if (!marginForm || !marginForm.marginModel || marginForm.marginModel === 'auto') return null if (marginForm.marginModel === 'absolute') return 'px' if (marginForm.marginModel === 'relative') return '%' return null diff --git a/extensions/dataease-extensions-view/view-racebar/view-racebar-frontend/src/views/antv/racebar/index.vue b/extensions/dataease-extensions-view/view-racebar/view-racebar-frontend/src/views/antv/racebar/index.vue index 6bb96cde53..3d64523083 100644 --- a/extensions/dataease-extensions-view/view-racebar/view-racebar-frontend/src/views/antv/racebar/index.vue +++ b/extensions/dataease-extensions-view/view-racebar/view-racebar-frontend/src/views/antv/racebar/index.vue @@ -46,7 +46,7 @@ import { componentStyle, seniorCfg, DEFAULT_SLIDER, - DEFAULT_Graphic, + DEFAULT_Graphic, getMarginUnit, } from '../../../utils/map'; import ChartTitleUpdate from '../../../components/views/ChartTitleUpdate'; import {mapState} from 'vuex' @@ -554,17 +554,20 @@ export default { chart_option.graphic.elements[0].style.text = extX; chart_option.graphic.elements[0].style.fill = hexColorToRGBA(DEFAULT_Graphic.color, DEFAULT_Graphic.alpha); chart_option.graphic.elements[0].style.font = 'bolder ' + DEFAULT_Graphic.fontSize + 'px monospace'; - chart_option.graphic.elements[0].right = DEFAULT_Graphic.right; - chart_option.graphic.elements[0].bottom = DEFAULT_Graphic.bottom; + chart_option.graphic.elements[0].right = DEFAULT_Graphic.right + 'px'; + chart_option.graphic.elements[0].bottom = DEFAULT_Graphic.bottom + 'px'; if (customAttr.graphic) { chart_option.graphic.elements[0].style.fill = hexColorToRGBA(customAttr.graphic.color, customAttr.graphic.alpha); chart_option.graphic.elements[0].style.font = 'bolder ' + customAttr.graphic.fontSize + 'px monospace'; + + const unit = _.defaultTo(getMarginUnit(customAttr.graphic), ''); + if (customAttr.graphic.right !== undefined) { - chart_option.graphic.elements[0].right = customAttr.graphic.right; + chart_option.graphic.elements[0].right = customAttr.graphic.right + unit; } if (customAttr.graphic.bottom !== undefined) { - chart_option.graphic.elements[0].bottom = customAttr.graphic.bottom; + chart_option.graphic.elements[0].bottom = customAttr.graphic.bottom + unit; } } } else {