forked from github/dataease
fix(数据大屏): 修复流向地图配置好线条颜色后,修改大屏主题颜色,流线颜色未适配的问题
This commit is contained in:
parent
b2c6531e52
commit
0cbdb08c88
@ -5,7 +5,7 @@ import { storeToRefs } from 'pinia'
|
|||||||
import { nextTick, onMounted, ref } from 'vue'
|
import { nextTick, onMounted, ref } from 'vue'
|
||||||
import { ElFormItem } from 'element-plus-secondary'
|
import { ElFormItem } from 'element-plus-secondary'
|
||||||
|
|
||||||
import { merge } from 'lodash-es'
|
import { merge, cloneDeep } from 'lodash-es'
|
||||||
import { useEmitt } from '@/hooks/web/useEmitt'
|
import { useEmitt } from '@/hooks/web/useEmitt'
|
||||||
import ComponentColorSelector from '@/components/dashboard/subject-setting/dashboard-style/ComponentColorSelector.vue'
|
import ComponentColorSelector from '@/components/dashboard/subject-setting/dashboard-style/ComponentColorSelector.vue'
|
||||||
import OverallSetting from '@/components/dashboard/subject-setting/dashboard-style/OverallSetting.vue'
|
import OverallSetting from '@/components/dashboard/subject-setting/dashboard-style/OverallSetting.vue'
|
||||||
@ -38,7 +38,19 @@ const themeAttrChange = (custom, property, value) => {
|
|||||||
try {
|
try {
|
||||||
const viewInfo = canvasViewInfo.value[viewId]
|
const viewInfo = canvasViewInfo.value[viewId]
|
||||||
if (custom === 'customAttr') {
|
if (custom === 'customAttr') {
|
||||||
|
if (viewInfo.type === 'flow-map') {
|
||||||
|
const { customAttr } = viewInfo
|
||||||
|
const tmpValue = cloneDeep(value)
|
||||||
|
const miscObj = cloneDeep(customAttr.misc)
|
||||||
|
for (const key in miscObj) {
|
||||||
|
if (miscObj.hasOwnProperty(key) && tmpValue.misc?.[key] !== undefined) {
|
||||||
|
tmpValue.misc[key] = miscObj[key]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
merge(viewInfo['customAttr'], tmpValue)
|
||||||
|
} else {
|
||||||
merge(viewInfo['customAttr'], value)
|
merge(viewInfo['customAttr'], value)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
Object.keys(value).forEach(function (key) {
|
Object.keys(value).forEach(function (key) {
|
||||||
if (viewInfo[custom][property][key] !== undefined) {
|
if (viewInfo[custom][property][key] !== undefined) {
|
||||||
|
@ -55,6 +55,16 @@ watch(
|
|||||||
)
|
)
|
||||||
const emit = defineEmits(['onBasicStyleChange', 'onMiscChange'])
|
const emit = defineEmits(['onBasicStyleChange', 'onMiscChange'])
|
||||||
const changeBasicStyle = (prop?: string, requestData = false) => {
|
const changeBasicStyle = (prop?: string, requestData = false) => {
|
||||||
|
const mapLineColorStyle = prop?.split('@')
|
||||||
|
if (mapLineColorStyle.length === 2) {
|
||||||
|
if (mapLineColorStyle[1].toLowerCase() === 'SourceColor'.toLowerCase()) {
|
||||||
|
state.basicStyleForm.colors[0] = state.miscForm.mapLineSourceColor
|
||||||
|
}
|
||||||
|
if (mapLineColorStyle[1].toLowerCase() === 'TargetColor'.toLowerCase()) {
|
||||||
|
state.basicStyleForm.colors[1] = state.miscForm.mapLineTargetColor
|
||||||
|
}
|
||||||
|
changeMisc(state.basicStyleForm.colors[0] + state.basicStyleForm.colors[1])
|
||||||
|
}
|
||||||
emit('onBasicStyleChange', { data: state.basicStyleForm, requestData }, prop)
|
emit('onBasicStyleChange', { data: state.basicStyleForm, requestData }, prop)
|
||||||
}
|
}
|
||||||
const onAlphaChange = v => {
|
const onAlphaChange = v => {
|
||||||
@ -82,6 +92,10 @@ const init = () => {
|
|||||||
configCompat(basicStyle)
|
configCompat(basicStyle)
|
||||||
state.basicStyleForm = defaultsDeep(basicStyle, cloneDeep(DEFAULT_BASIC_STYLE)) as ChartBasicStyle
|
state.basicStyleForm = defaultsDeep(basicStyle, cloneDeep(DEFAULT_BASIC_STYLE)) as ChartBasicStyle
|
||||||
state.miscForm = defaultsDeep(miscStyle, cloneDeep(DEFAULT_MISC)) as ChartMiscAttr
|
state.miscForm = defaultsDeep(miscStyle, cloneDeep(DEFAULT_MISC)) as ChartMiscAttr
|
||||||
|
if (props.chart.type === 'flow-map') {
|
||||||
|
state.miscForm.mapLineSourceColor = state.basicStyleForm.colors[0]
|
||||||
|
state.miscForm.mapLineTargetColor = state.basicStyleForm.colors[1]
|
||||||
|
}
|
||||||
if (!state.customColor) {
|
if (!state.customColor) {
|
||||||
state.customColor = state.basicStyleForm.colors[0]
|
state.customColor = state.basicStyleForm.colors[0]
|
||||||
state.colorIndex = 0
|
state.colorIndex = 0
|
||||||
@ -467,7 +481,7 @@ onMounted(() => {
|
|||||||
:effect="themes"
|
:effect="themes"
|
||||||
:trigger-width="108"
|
:trigger-width="108"
|
||||||
:predefine="predefineColors"
|
:predefine="predefineColors"
|
||||||
@change="changeMisc('mapLineSourceColor')"
|
@change="changeBasicStyle('mapLine@SourceColor')"
|
||||||
/>
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
@ -485,7 +499,7 @@ onMounted(() => {
|
|||||||
:effect="themes"
|
:effect="themes"
|
||||||
:trigger-width="108"
|
:trigger-width="108"
|
||||||
:predefine="predefineColors"
|
:predefine="predefineColors"
|
||||||
@change="changeMisc('mapLineTargetColor')"
|
@change="changeBasicStyle('mapLine@TargetColor')"
|
||||||
/>
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
@ -507,7 +521,7 @@ onMounted(() => {
|
|||||||
:effect="themes"
|
:effect="themes"
|
||||||
:trigger-width="108"
|
:trigger-width="108"
|
||||||
:predefine="predefineColors"
|
:predefine="predefineColors"
|
||||||
@change="changeMisc('mapLineSourceColor')"
|
@change="changeBasicStyle('mapLine@SourceColor')"
|
||||||
/>
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
|
@ -6,7 +6,7 @@ import {
|
|||||||
L7Wrapper
|
L7Wrapper
|
||||||
} from '@/views/chart/components/js/panel/types/impl/l7'
|
} from '@/views/chart/components/js/panel/types/impl/l7'
|
||||||
import { MAP_EDITOR_PROPERTY_INNER } from '@/views/chart/components/js/panel/charts/map/common'
|
import { MAP_EDITOR_PROPERTY_INNER } from '@/views/chart/components/js/panel/charts/map/common'
|
||||||
import { flow, parseJson } from '@/views/chart/components/js/util'
|
import { flow, hexColorToRGBA, parseJson } from '@/views/chart/components/js/util'
|
||||||
import { deepCopy } from '@/utils/utils'
|
import { deepCopy } from '@/utils/utils'
|
||||||
import { GaodeMap } from '@antv/l7-maps'
|
import { GaodeMap } from '@antv/l7-maps'
|
||||||
import { Scene } from '@antv/l7-scene'
|
import { Scene } from '@antv/l7-scene'
|
||||||
@ -49,22 +49,21 @@ export class FlowMap extends L7ChartView<Scene, L7Config> {
|
|||||||
const { chart, container } = drawOption
|
const { chart, container } = drawOption
|
||||||
const xAxis = deepCopy(chart.xAxis)
|
const xAxis = deepCopy(chart.xAxis)
|
||||||
const xAxisExt = deepCopy(chart.xAxisExt)
|
const xAxisExt = deepCopy(chart.xAxisExt)
|
||||||
let basicStyle
|
const { basicStyle, misc } = deepCopy(parseJson(chart.customAttr))
|
||||||
let miscStyle
|
|
||||||
if (chart.customAttr) {
|
|
||||||
basicStyle = parseJson(chart.customAttr).basicStyle
|
|
||||||
miscStyle = parseJson(chart.customAttr).misc
|
|
||||||
}
|
|
||||||
const flowLineStyle = {
|
const flowLineStyle = {
|
||||||
type: miscStyle.mapLineType,
|
type: misc.mapLineType,
|
||||||
size: miscStyle.mapLineType === 'line' ? miscStyle.mapLineWidth / 2 : miscStyle.mapLineWidth,
|
size: misc.mapLineType === 'line' ? misc.mapLineWidth / 2 : misc.mapLineWidth,
|
||||||
animate: miscStyle.mapLineAnimate,
|
animate: misc.mapLineAnimate,
|
||||||
animateDuration: miscStyle.mapLineAnimateDuration,
|
animateDuration: misc.mapLineAnimateDuration,
|
||||||
gradient: miscStyle.mapLineGradient,
|
gradient: misc.mapLineGradient,
|
||||||
sourceColor: miscStyle.mapLineSourceColor,
|
sourceColor: misc.mapLineSourceColor,
|
||||||
targetColor: miscStyle.mapLineTargetColor,
|
targetColor: misc.mapLineTargetColor,
|
||||||
alpha: basicStyle.alpha
|
alpha: basicStyle.alpha
|
||||||
}
|
}
|
||||||
|
const colorsWithAlpha = basicStyle.colors.map(color => hexColorToRGBA(color, basicStyle.alpha))
|
||||||
|
flowLineStyle.sourceColor = colorsWithAlpha[0]
|
||||||
|
flowLineStyle.targetColor = colorsWithAlpha[1]
|
||||||
|
|
||||||
const mapStyle = `amap://styles/${basicStyle.mapStyle ? basicStyle.mapStyle : 'normal'}`
|
const mapStyle = `amap://styles/${basicStyle.mapStyle ? basicStyle.mapStyle : 'normal'}`
|
||||||
const key = await this.getMapKey()
|
const key = await this.getMapKey()
|
||||||
// 底层
|
// 底层
|
||||||
@ -74,7 +73,7 @@ export class FlowMap extends L7ChartView<Scene, L7Config> {
|
|||||||
map: new GaodeMap({
|
map: new GaodeMap({
|
||||||
token: key ?? undefined,
|
token: key ?? undefined,
|
||||||
style: mapStyle,
|
style: mapStyle,
|
||||||
pitch: miscStyle.mapPitch,
|
pitch: misc.mapPitch,
|
||||||
zoom: 2.5
|
zoom: 2.5
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user