diff --git a/core/core-frontend/src/assets/svg/dv-ruler.svg b/core/core-frontend/src/assets/svg/dv-ruler.svg new file mode 100644 index 0000000000..46f262abb1 --- /dev/null +++ b/core/core-frontend/src/assets/svg/dv-ruler.svg @@ -0,0 +1 @@ + diff --git a/core/core-frontend/src/components/data-visualization/ComponentToolBar.vue b/core/core-frontend/src/components/data-visualization/ComponentToolBar.vue index cda9545518..3c2e1c1353 100644 --- a/core/core-frontend/src/components/data-visualization/ComponentToolBar.vue +++ b/core/core-frontend/src/components/data-visualization/ComponentToolBar.vue @@ -157,6 +157,7 @@ onUnmounted(() => { background-color: @side-area-background; border-top: 1px solid @side-outline-border-color; color: #fff; + z-index: 2; transition: 0.5s; .scale-area { display: flex; diff --git a/core/core-frontend/src/custom-component/common/DeRuler.vue b/core/core-frontend/src/custom-component/common/DeRuler.vue index e0a4116c4f..a12441b9ae 100644 --- a/core/core-frontend/src/custom-component/common/DeRuler.vue +++ b/core/core-frontend/src/custom-component/common/DeRuler.vue @@ -8,17 +8,60 @@ const props = defineProps({ tickLabelFormatter: { type: Function, default: value => value.toString() // 刻度标签格式化函数,默认直接转为字符串 + }, + size: { + type: Number, + default: 300 // 尺子方向 + }, + direction: { + type: String, + default: 'horizontal' // 尺子方向 } }) const labelInterval = 5 -const { canvasStyleData } = storeToRefs(dvMainStore) +const { canvasStyleData, curComponent } = storeToRefs(dvMainStore) + +const rulerSize = computed(() => + props.direction === 'horizontal' ? canvasStyleData.value.width : canvasStyleData.value.height +) + +const curComponentSize = computed(() => { + if (curComponent.value) { + return ( + ((props.direction === 'horizontal' + ? curComponent.value.style.width + : curComponent.value.style.height) * + canvasStyleData.value.scale) / + 100 + ) + } else { + return 0 + } +}) + +const curComponentShadow = computed(() => { + if (curComponent.value) { + return { + left: + (props.direction === 'horizontal' + ? curComponent.value.style.left + : curComponent.value.style.top) + 'px', + width: + (props.direction === 'horizontal' + ? curComponent.value.style.width + : curComponent.value.style.height) + 'px' + } + } else { + return {} + } +}) const ticks = computed(() => { const result = [] let currentValue = 0 - while (currentValue <= canvasStyleData.value.width) { + while (currentValue <= rulerSize.value) { const isLong = currentValue % (labelInterval * tickSize.value) === 0 const label = isLong ? props.tickLabelFormatter(currentValue) : '' result.push({ position: (currentValue * canvasStyleData.value.scale) / 100, label, isLong }) @@ -29,30 +72,50 @@ const ticks = computed(() => { const wStyle = computed(() => { return { - width: canvasStyleData.value.width * 1.5 + 'px' + width: rulerSize.value * 1.5 + 'px' } }) + +const radio = computed(() => rulerSize.value / canvasStyleData.value.width) const tickSize = computed( () => 10 * - Math.max(Math.floor(200000 / (canvasStyleData.value.width * canvasStyleData.value.scale)), 1) + Math.max( + Math.floor((200000 * radio.value) / (rulerSize.value * canvasStyleData.value.scale)), + 1 + ) ) -const scaleWidth = computed(() => (canvasStyleData.value.width * canvasStyleData.value.scale) / 100) +const scaleWidth = computed(() => (rulerSize.value * canvasStyleData.value.scale) / 100) const rulerScroll = e => { - wRuleRef.value.scrollTo(e.scrollLeft, 0) + const left = props.direction === 'vertical' ? e.scrollTop : e.scrollLeft + wRuleRef.value.scrollTo(left, 0) } +const outerStyle = computed(() => { + return { + width: props.direction === 'vertical' ? props.size - 30 + 'px' : '100%' + } +}) + defineExpose({ rulerScroll })