refactor(数据大屏): 大屏辅助网格与刻度尺保持缩放一致
This commit is contained in:
parent
ca0eac3f62
commit
654a1a093d
@ -7,7 +7,12 @@
|
|||||||
:height="smallGridH"
|
:height="smallGridH"
|
||||||
patternUnits="userSpaceOnUse"
|
patternUnits="userSpaceOnUse"
|
||||||
>
|
>
|
||||||
<path :d="smallGridPathD" fill="none" stroke="rgba(207, 207, 207, 0.3)" stroke-width="1" />
|
<path
|
||||||
|
:d="smallGridPathD"
|
||||||
|
fill="none"
|
||||||
|
stroke="rgba(207, 207, 207, 0.3)"
|
||||||
|
stroke-width="0.8"
|
||||||
|
/>
|
||||||
</pattern>
|
</pattern>
|
||||||
<pattern
|
<pattern
|
||||||
id="middleGrid"
|
id="middleGrid"
|
||||||
@ -16,16 +21,11 @@
|
|||||||
patternUnits="userSpaceOnUse"
|
patternUnits="userSpaceOnUse"
|
||||||
>
|
>
|
||||||
<rect :width="middleGridW" :height="middleGridH" fill="url(#smallGrid)" />
|
<rect :width="middleGridW" :height="middleGridH" fill="url(#smallGrid)" />
|
||||||
<path
|
<path :d="middleGridPathD" fill="none" stroke="rgba(207, 207, 207, 0.3)" stroke-width="1" />
|
||||||
:d="middleGridPathD"
|
|
||||||
fill="none"
|
|
||||||
stroke="rgba(207, 207, 207, 0.3)"
|
|
||||||
stroke-width="1.5"
|
|
||||||
/>
|
|
||||||
</pattern>
|
</pattern>
|
||||||
<pattern id="grid" :width="gridW" :height="gridH" patternUnits="userSpaceOnUse">
|
<pattern id="grid" :width="gridW" :height="gridH" patternUnits="userSpaceOnUse">
|
||||||
<rect :width="gridW" :height="gridH" fill="url(#middleGrid)" />
|
<rect :width="gridW" :height="gridH" fill="url(#middleGrid)" />
|
||||||
<path :d="pathD" fill="none" stroke="rgba(207, 207, 207, 0.7)" stroke-width="2.5" />
|
<path :d="pathD" fill="none" stroke="rgba(207, 207, 207, 0.3)" stroke-width="1.2" />
|
||||||
</pattern>
|
</pattern>
|
||||||
</defs>
|
</defs>
|
||||||
<rect width="100%" height="100%" fill="url(#grid)" />
|
<rect width="100%" height="100%" fill="url(#grid)" />
|
||||||
|
|||||||
@ -0,0 +1,71 @@
|
|||||||
|
<template>
|
||||||
|
<svg class="grid" width="100%" height="100%" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<defs>
|
||||||
|
<pattern id="grid" :width="gridW" :height="gridH" patternUnits="userSpaceOnUse">
|
||||||
|
<rect :width="gridW" :height="gridH" fill="url(#middleGrid)" />
|
||||||
|
<path :d="pathD" fill="none" stroke="rgba(207, 207, 207, 0.2)" stroke-width="0.5" />
|
||||||
|
</pattern>
|
||||||
|
<pattern
|
||||||
|
id="middleGrid"
|
||||||
|
:width="middleGridW"
|
||||||
|
:height="middleGridH"
|
||||||
|
patternUnits="userSpaceOnUse"
|
||||||
|
>
|
||||||
|
<rect :width="middleGridW" :height="middleGridH" fill="url(#smallGrid)" />
|
||||||
|
<path
|
||||||
|
:d="middleGridPathD"
|
||||||
|
fill="none"
|
||||||
|
stroke="rgba(207, 207, 207, 0.2)"
|
||||||
|
stroke-width="0.3"
|
||||||
|
/>
|
||||||
|
</pattern>
|
||||||
|
</defs>
|
||||||
|
<rect width="100%" height="100%" fill="url(#grid)" />
|
||||||
|
</svg>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { computed } from 'vue'
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
matrixStyle: {
|
||||||
|
type: Object
|
||||||
|
},
|
||||||
|
themes: {
|
||||||
|
type: String,
|
||||||
|
default: 'dark'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const pathD = computed(() => {
|
||||||
|
return 'M ' + gridW.value + ' 0 L 0 0 0 ' + gridH.value
|
||||||
|
})
|
||||||
|
|
||||||
|
const gridW = computed(() => {
|
||||||
|
return props.matrixStyle.width * 5
|
||||||
|
})
|
||||||
|
|
||||||
|
const gridH = computed(() => {
|
||||||
|
return props.matrixStyle.height * 5
|
||||||
|
})
|
||||||
|
|
||||||
|
const middleGridPathD = computed(() => {
|
||||||
|
return 'M ' + middleGridW.value + ' 0 L 0 0 0 ' + middleGridH.value
|
||||||
|
})
|
||||||
|
|
||||||
|
const middleGridW = computed(() => {
|
||||||
|
return props.matrixStyle.width
|
||||||
|
})
|
||||||
|
|
||||||
|
const middleGridH = computed(() => {
|
||||||
|
return props.matrixStyle.height
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="less" scoped>
|
||||||
|
.grid {
|
||||||
|
position: absolute;
|
||||||
|
top: -1px;
|
||||||
|
left: -1px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@ -46,6 +46,7 @@ import { activeWatermarkCheckUser } from '@/components/watermark/watermark'
|
|||||||
import PopArea from '@/custom-component/pop-area/Component.vue'
|
import PopArea from '@/custom-component/pop-area/Component.vue'
|
||||||
import DatasetParamsComponent from '@/components/visualization/DatasetParamsComponent.vue'
|
import DatasetParamsComponent from '@/components/visualization/DatasetParamsComponent.vue'
|
||||||
import DeGrid from '@/components/data-visualization/DeGrid.vue'
|
import DeGrid from '@/components/data-visualization/DeGrid.vue'
|
||||||
|
import DeGridScreen from '@/components/data-visualization/DeGridScreen.vue'
|
||||||
|
|
||||||
const snapshotStore = snapshotStoreWithOut()
|
const snapshotStore = snapshotStoreWithOut()
|
||||||
const dvMainStore = dvMainStoreWithOut()
|
const dvMainStore = dvMainStoreWithOut()
|
||||||
@ -1422,7 +1423,19 @@ const contextMenuShow = computed(() => {
|
|||||||
const markLineShow = computed(() => isMainCanvas(canvasId.value))
|
const markLineShow = computed(() => isMainCanvas(canvasId.value))
|
||||||
|
|
||||||
const showGrid = computed(() => {
|
const showGrid = computed(() => {
|
||||||
return Boolean(canvasStyleData.value.dashboard.showGrid) && isMainCanvas(canvasId.value)
|
return (
|
||||||
|
Boolean(canvasStyleData.value.dashboard.showGrid) &&
|
||||||
|
isMainCanvas(canvasId.value) &&
|
||||||
|
isDashboard()
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
const showGridScreen = computed(() => {
|
||||||
|
return (
|
||||||
|
Boolean(canvasStyleData.value.dashboard.showGrid) &&
|
||||||
|
isMainCanvas(canvasId.value) &&
|
||||||
|
!isDashboard()
|
||||||
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
// 批量设置
|
// 批量设置
|
||||||
@ -1557,6 +1570,11 @@ defineExpose({
|
|||||||
></PopArea>
|
></PopArea>
|
||||||
<!-- 网格线 -->
|
<!-- 网格线 -->
|
||||||
<de-grid v-if="showGrid" :matrix-style="matrixStyle" :themes="themes"></de-grid>
|
<de-grid v-if="showGrid" :matrix-style="matrixStyle" :themes="themes"></de-grid>
|
||||||
|
<de-grid-screen
|
||||||
|
v-if="showGridScreen"
|
||||||
|
:matrix-style="matrixStyle"
|
||||||
|
:themes="themes"
|
||||||
|
></de-grid-screen>
|
||||||
<drag-shadow
|
<drag-shadow
|
||||||
v-if="infoBox && infoBox.moveItem && editMode !== 'preview'"
|
v-if="infoBox && infoBox.moveItem && editMode !== 'preview'"
|
||||||
:base-height="baseHeight"
|
:base-height="baseHeight"
|
||||||
|
|||||||
@ -1,37 +0,0 @@
|
|||||||
<template>
|
|
||||||
<svg class="grid" width="100%" height="100%" xmlns="http://www.w3.org/2000/svg">
|
|
||||||
<defs>
|
|
||||||
<pattern
|
|
||||||
id="smallGrid"
|
|
||||||
width="7.236328125"
|
|
||||||
height="7.236328125"
|
|
||||||
patternUnits="userSpaceOnUse"
|
|
||||||
>
|
|
||||||
<path
|
|
||||||
d="M 7.236328125 0 L 0 0 0 7.236328125"
|
|
||||||
fill="none"
|
|
||||||
stroke="rgba(207, 207, 207, 0.3)"
|
|
||||||
stroke-width="1"
|
|
||||||
></path>
|
|
||||||
</pattern>
|
|
||||||
<pattern id="grid" width="36.181640625" height="36.181640625" patternUnits="userSpaceOnUse">
|
|
||||||
<rect width="36.181640625" height="36.181640625" fill="url(#smallGrid)"></rect>
|
|
||||||
<path
|
|
||||||
d="M 36.181640625 0 L 0 0 0 36.181640625"
|
|
||||||
fill="none"
|
|
||||||
stroke="rgba(186, 186, 186, 0.5)"
|
|
||||||
stroke-width="1"
|
|
||||||
></path>
|
|
||||||
</pattern>
|
|
||||||
</defs>
|
|
||||||
<rect width="100%" height="100%" fill="url(#grid)"></rect>
|
|
||||||
</svg>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<style lang="less" scoped>
|
|
||||||
.grid {
|
|
||||||
position: absolute;
|
|
||||||
top: 0;
|
|
||||||
left: 0;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@ -1,5 +1,5 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed, ref } from 'vue'
|
import { computed, ref, watch } from 'vue'
|
||||||
import { dvMainStoreWithOut } from '@/store/modules/data-visualization/dvMain'
|
import { dvMainStoreWithOut } from '@/store/modules/data-visualization/dvMain'
|
||||||
import { storeToRefs } from 'pinia'
|
import { storeToRefs } from 'pinia'
|
||||||
const dvMainStore = dvMainStoreWithOut()
|
const dvMainStore = dvMainStoreWithOut()
|
||||||
@ -20,6 +20,7 @@ const props = defineProps({
|
|||||||
})
|
})
|
||||||
|
|
||||||
const labelInterval = 5
|
const labelInterval = 5
|
||||||
|
const emits = defineEmits(['update:tickSize'])
|
||||||
|
|
||||||
const { canvasStyleData, curComponent, componentData } = storeToRefs(dvMainStore)
|
const { canvasStyleData, curComponent, componentData } = storeToRefs(dvMainStore)
|
||||||
|
|
||||||
@ -105,6 +106,16 @@ const outerStyle = computed(() => {
|
|||||||
|
|
||||||
const curShadowShow = computed(() => curComponent.value && curComponent.value.category !== 'hidden')
|
const curShadowShow = computed(() => curComponent.value && curComponent.value.category !== 'hidden')
|
||||||
|
|
||||||
|
const tickSizeScale = computed(() => (tickSize.value * canvasStyleData.value.scale) / 100)
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => tickSizeScale.value,
|
||||||
|
() => {
|
||||||
|
emits('update:tickSize', tickSizeScale.value)
|
||||||
|
},
|
||||||
|
{ immediate: true }
|
||||||
|
)
|
||||||
|
|
||||||
defineExpose({
|
defineExpose({
|
||||||
rulerScroll
|
rulerScroll
|
||||||
})
|
})
|
||||||
|
|||||||
@ -102,7 +102,9 @@ const state = reactive({
|
|||||||
canvasInitStatus: false,
|
canvasInitStatus: false,
|
||||||
sourcePid: null,
|
sourcePid: null,
|
||||||
resourceId: null,
|
resourceId: null,
|
||||||
opt: null
|
opt: null,
|
||||||
|
baseWidth: 10,
|
||||||
|
baseHeight: 10
|
||||||
})
|
})
|
||||||
|
|
||||||
// 启用拖动
|
// 启用拖动
|
||||||
@ -484,8 +486,13 @@ eventBus.on('handleNew', handleNew)
|
|||||||
<Icon name="dv-ruler"><dvRuler class="svg-icon" /></Icon>
|
<Icon name="dv-ruler"><dvRuler class="svg-icon" /></Icon>
|
||||||
</el-icon>
|
</el-icon>
|
||||||
</div>
|
</div>
|
||||||
<de-ruler ref="deWRulerRef"></de-ruler>
|
<de-ruler ref="deWRulerRef" @update:tickSize="val => (state.baseWidth = val)"></de-ruler>
|
||||||
<de-ruler direction="vertical" :size="mainHeight" ref="deHRulerRef"></de-ruler>
|
<de-ruler
|
||||||
|
direction="vertical"
|
||||||
|
@update:tickSize="val => (state.baseHeight = val)"
|
||||||
|
:size="mainHeight"
|
||||||
|
ref="deHRulerRef"
|
||||||
|
></de-ruler>
|
||||||
<el-scrollbar
|
<el-scrollbar
|
||||||
ref="canvasOut"
|
ref="canvasOut"
|
||||||
@scroll="scrollCanvas"
|
@scroll="scrollCanvas"
|
||||||
@ -516,6 +523,8 @@ eventBus.on('handleNew', handleNew)
|
|||||||
:canvas-style-data="canvasStyleData"
|
:canvas-style-data="canvasStyleData"
|
||||||
:canvas-view-info="canvasViewInfo"
|
:canvas-view-info="canvasViewInfo"
|
||||||
:canvas-id="state.canvasId"
|
:canvas-id="state.canvasId"
|
||||||
|
:base-height="state.baseHeight"
|
||||||
|
:base-width="state.baseWidth"
|
||||||
>
|
>
|
||||||
<template v-slot:canvasDragTips>
|
<template v-slot:canvasDragTips>
|
||||||
<div class="canvas-drag-tip">按住空格可拖动画布</div>
|
<div class="canvas-drag-tip">按住空格可拖动画布</div>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user