Skip to content

Commit 48c9558

Browse files
committed
Modification - VueUiXy - Use SlicerPreview component for all zoom cases
1 parent b14be96 commit 48c9558

File tree

2 files changed

+72
-105
lines changed

2 files changed

+72
-105
lines changed

src/atoms/SlicerPreview.vue

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ import { useResponsive } from '../useResponsive';
2424
import BaseIcon from './BaseIcon.vue';
2525
2626
const props = defineProps({
27+
immediate: {
28+
type: Boolean,
29+
default: true
30+
},
2731
background: {
2832
type: String,
2933
default: '#FFFFFF'
@@ -203,7 +207,12 @@ const start = computed({
203207
if (v === startValue.value) return;
204208
startValue.value = v;
205209
if (rangeStart.value) rangeStart.value.value = String(v);
206-
if (isRanging.value) emitFutureStart(v);
210+
211+
if (props.immediate) {
212+
emit('update:start', Number(v));
213+
} else if (isRanging.value) {
214+
emitFutureStart(v);
215+
}
207216
}
208217
});
209218
@@ -214,7 +223,10 @@ const end = computed({
214223
if (v === endValue.value) return;
215224
endValue.value = v;
216225
if (rangeEnd.value) rangeEnd.value.value = String(v);
217-
if (isRanging.value) emitFutureEnd(v);
226+
227+
if (props.immediate) {
228+
emit('update:end', Number(v));
229+
} else if (isRanging.value) emitFutureEnd(v);
218230
}
219231
});
220232
@@ -237,8 +249,10 @@ let _commitTimeout = null;
237249
238250
function commitImmediately() {
239251
clearTimeout(_commitTimeout);
240-
emit('update:start', Number(startValue.value));
241-
emit('update:end', Number(endValue.value));
252+
if (!props.immediate) {
253+
emit('update:start', Number(startValue.value));
254+
emit('update:end', Number(endValue.value));
255+
}
242256
isRanging.value = false;
243257
}
244258
@@ -1230,7 +1244,7 @@ defineExpose({
12301244
<g v-for="(dp, i) in allMinimapLines.filter(d => d.type === 'bar')">
12311245
<template v-for="(r, j) in dp.points">
12321246
<rect
1233-
v-if="dp && dp.hasSelection && dp.selectionSet && dp.isVisible && !isNaN(r.y)"
1247+
v-if="dp && dp.isVisible && !isNaN(r.y)"
12341248
:x="getBarX(r.x, i, j)"
12351249
:y="r.v >= 0 ? r.y : r.y0"
12361250
:width="getBarWidth(i, j)"

src/components/vue-ui-xy.vue

Lines changed: 53 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ import { useTimeLabelCollision } from '../useTimeLabelCollider.js';
6666
import img from '../img.js';
6767
import Title from '../atoms/Title.vue';
6868
import themes from "../themes.json";
69-
import Slicer from '../atoms/Slicer.vue';
7069
import Shape from '../atoms/Shape.vue';
7170
import BaseScanner from '../atoms/BaseScanner.vue';
7271
import SlicerPreview from '../atoms/SlicerPreview.vue'; // v3
@@ -4165,105 +4164,59 @@ defineExpose({
41654164
</template>
41664165
</template>
41674166
4168-
<template v-if="FINAL_CONFIG.chart.zoom.preview.enable">
4169-
<SlicerPreview
4170-
ref="chartSlicer"
4171-
v-if="FINAL_CONFIG.chart.zoom.show && maxX > 6 && isDataset && slicerReady"
4172-
:max="maxX"
4173-
:min="0"
4174-
:valueStart="slicer.start"
4175-
:valueEnd="slicer.end"
4176-
:start="slicer.start"
4177-
:end="slicer.end"
4178-
@update:start="onSlicerStart"
4179-
@update:end="onSlicerEnd"
4180-
:selectedSeries="selectedSeries"
4181-
:customFormat="FINAL_CONFIG.chart.zoom.customFormat"
4182-
:background="FINAL_CONFIG.chart.zoom.color"
4183-
:fontSize="FINAL_CONFIG.chart.zoom.fontSize" :useResetSlot="FINAL_CONFIG.chart.zoom.useResetSlot"
4184-
:labelLeft="timeLabels[0]? timeLabels[0].text : ''"
4185-
:labelRight="timeLabels.at(-1) ? timeLabels.at(-1).text : ''"
4186-
:textColor="FINAL_CONFIG.chart.color"
4187-
:usePreciseLabels="FINAL_CONFIG.chart.grid.labels.xAxisLabels.datetimeFormatter.enable && !FINAL_CONFIG.chart.zoom.useDefaultFormat"
4188-
:preciseLabels="preciseAllTimeLabels"
4189-
:inputColor="FINAL_CONFIG.chart.zoom.color" :selectColor="FINAL_CONFIG.chart.zoom.highlightColor"
4190-
:borderColor="FINAL_CONFIG.chart.backgroundColor" :minimap="minimap"
4191-
:smoothMinimap="FINAL_CONFIG.chart.zoom.minimap.smooth"
4192-
:minimapSelectedColor="FINAL_CONFIG.chart.zoom.minimap.selectedColor"
4193-
:minimapSelectionRadius="FINAL_CONFIG.chart.zoom.minimap.selectionRadius"
4194-
:minimapLineColor="FINAL_CONFIG.chart.zoom.minimap.lineColor"
4195-
:minimapSelectedColorOpacity="FINAL_CONFIG.chart.zoom.minimap.selectedColorOpacity"
4196-
:minimapSelectedIndex="selectedSerieIndex"
4197-
:minimapIndicatorColor="FINAL_CONFIG.chart.zoom.minimap.indicatorColor"
4198-
:verticalHandles="FINAL_CONFIG.chart.zoom.minimap.verticalHandles"
4199-
:refreshStartPoint="FINAL_CONFIG.chart.zoom.startIndex !== null ? FINAL_CONFIG.chart.zoom.startIndex : 0"
4200-
:refreshEndPoint="FINAL_CONFIG.chart.zoom.endIndex !== null ? FINAL_CONFIG.chart.zoom.endIndex + 1 : Math.max(...dataset.map(datapoint => lttb(datapoint.series).length))"
4201-
:enableRangeHandles="FINAL_CONFIG.chart.zoom.enableRangeHandles"
4202-
:enableSelectionDrag="FINAL_CONFIG.chart.zoom.enableSelectionDrag"
4203-
:minimapCompact="FINAL_CONFIG.chart.zoom.minimap.compact"
4204-
:allMinimaps="allMinimaps"
4205-
:minimapMerged="FINAL_CONFIG.chart.zoom.minimap.merged"
4206-
:minimapFrameColor="FINAL_CONFIG.chart.zoom.minimap.frameColor"
4207-
:cutNullValues="FINAL_CONFIG.line.cutNullValues"
4208-
:focusOnDrag="FINAL_CONFIG.chart.zoom.focusOnDrag"
4209-
:focusRangeRatio="FINAL_CONFIG.chart.zoom.focusRangeRatio"
4210-
@reset="refreshSlicer"
4211-
@trapMouse="selectMinimapIndex"
4212-
@futureStart="v => setPrecog('start', v)"
4213-
@futureEnd="v => setPrecog('end', v)"
4214-
:timeLabels="allTimeLabels"
4215-
:isPreview="isPrecog"
4216-
>
4217-
<template #reset-action="{ reset }">
4218-
<slot name="reset-action" v-bind="{ reset }" />
4219-
</template>
4220-
</SlicerPreview>
4221-
</template>
4222-
<template v-else>
4223-
<Slicer ref="chartSlicer"
4224-
v-if="FINAL_CONFIG.chart.zoom.show && maxX > 6 && isDataset"
4225-
:max="maxX"
4226-
:min="0"
4227-
:valueStart="slicer.start"
4228-
:valueEnd="slicer.end"
4229-
v-model:start="slicer.start"
4230-
v-model:end="slicer.end"
4231-
:background="FINAL_CONFIG.chart.zoom.color"
4232-
:fontSize="FINAL_CONFIG.chart.zoom.fontSize"
4233-
:useResetSlot="FINAL_CONFIG.chart.zoom.useResetSlot"
4234-
:labelLeft="slicerLabels.left"
4235-
:labelRight="slicerLabels.right"
4236-
:textColor="FINAL_CONFIG.chart.color"
4237-
:inputColor="FINAL_CONFIG.chart.zoom.color"
4238-
:selectColor="FINAL_CONFIG.chart.zoom.highlightColor"
4239-
:borderColor="FINAL_CONFIG.chart.backgroundColor"
4240-
:minimap="minimap"
4241-
:smoothMinimap="FINAL_CONFIG.chart.zoom.minimap.smooth"
4242-
:minimapSelectedColor="FINAL_CONFIG.chart.zoom.minimap.selectedColor"
4243-
:minimapSelectionRadius="FINAL_CONFIG.chart.zoom.minimap.selectionRadius"
4244-
:minimapLineColor="FINAL_CONFIG.chart.zoom.minimap.lineColor"
4245-
:minimapSelectedColorOpacity="FINAL_CONFIG.chart.zoom.minimap.selectedColorOpacity"
4246-
:minimapSelectedIndex="selectedSerieIndex"
4247-
:minimapIndicatorColor="FINAL_CONFIG.chart.zoom.minimap.indicatorColor"
4248-
:verticalHandles="FINAL_CONFIG.chart.zoom.minimap.verticalHandles"
4249-
:refreshStartPoint="FINAL_CONFIG.chart.zoom.startIndex !== null ? FINAL_CONFIG.chart.zoom.startIndex : 0"
4250-
:refreshEndPoint="FINAL_CONFIG.chart.zoom.endIndex !== null ? FINAL_CONFIG.chart.zoom.endIndex + 1 : Math.max(...dataset.map(datapoint => lttb(datapoint.series).length))"
4251-
:enableRangeHandles="FINAL_CONFIG.chart.zoom.enableRangeHandles"
4252-
:enableSelectionDrag="FINAL_CONFIG.chart.zoom.enableSelectionDrag"
4253-
:minimapCompact="FINAL_CONFIG.chart.zoom.minimap.compact"
4254-
:allMinimaps="allMinimaps"
4255-
:minimapMerged="FINAL_CONFIG.chart.zoom.minimap.merged"
4256-
:minimapFrameColor="FINAL_CONFIG.chart.zoom.minimap.frameColor"
4257-
:cutNullValues="FINAL_CONFIG.line.cutNullValues"
4258-
:focusOnDrag="FINAL_CONFIG.chart.zoom.focusOnDrag"
4259-
:focusRangeRatio="FINAL_CONFIG.chart.zoom.focusRangeRatio"
4260-
@reset="refreshSlicer"
4261-
@trapMouse="selectMinimapIndex">
4262-
<template #reset-action="{ reset }">
4263-
<slot name="reset-action" v-bind="{ reset }" />
4264-
</template>
4265-
</Slicer>
4266-
</template>
4167+
<SlicerPreview
4168+
ref="chartSlicer"
4169+
v-if="FINAL_CONFIG.chart.zoom.show && maxX > 6 && isDataset && slicerReady"
4170+
:immediate="!FINAL_CONFIG.chart.zoom.preview.enable"
4171+
:max="maxX"
4172+
:min="0"
4173+
:valueStart="slicer.start"
4174+
:valueEnd="slicer.end"
4175+
:start="slicer.start"
4176+
:end="slicer.end"
4177+
@update:start="onSlicerStart"
4178+
@update:end="onSlicerEnd"
4179+
:selectedSeries="selectedSeries"
4180+
:customFormat="FINAL_CONFIG.chart.zoom.customFormat"
4181+
:background="FINAL_CONFIG.chart.zoom.color"
4182+
:fontSize="FINAL_CONFIG.chart.zoom.fontSize" :useResetSlot="FINAL_CONFIG.chart.zoom.useResetSlot"
4183+
:labelLeft="timeLabels[0]? timeLabels[0].text : ''"
4184+
:labelRight="timeLabels.at(-1) ? timeLabels.at(-1).text : ''"
4185+
:textColor="FINAL_CONFIG.chart.color"
4186+
:usePreciseLabels="FINAL_CONFIG.chart.grid.labels.xAxisLabels.datetimeFormatter.enable && !FINAL_CONFIG.chart.zoom.useDefaultFormat"
4187+
:preciseLabels="preciseAllTimeLabels"
4188+
:inputColor="FINAL_CONFIG.chart.zoom.color" :selectColor="FINAL_CONFIG.chart.zoom.highlightColor"
4189+
:borderColor="FINAL_CONFIG.chart.backgroundColor" :minimap="minimap"
4190+
:smoothMinimap="FINAL_CONFIG.chart.zoom.minimap.smooth"
4191+
:minimapSelectedColor="FINAL_CONFIG.chart.zoom.minimap.selectedColor"
4192+
:minimapSelectionRadius="FINAL_CONFIG.chart.zoom.minimap.selectionRadius"
4193+
:minimapLineColor="FINAL_CONFIG.chart.zoom.minimap.lineColor"
4194+
:minimapSelectedColorOpacity="FINAL_CONFIG.chart.zoom.minimap.selectedColorOpacity"
4195+
:minimapSelectedIndex="selectedSerieIndex"
4196+
:minimapIndicatorColor="FINAL_CONFIG.chart.zoom.minimap.indicatorColor"
4197+
:verticalHandles="FINAL_CONFIG.chart.zoom.minimap.verticalHandles"
4198+
:refreshStartPoint="FINAL_CONFIG.chart.zoom.startIndex !== null ? FINAL_CONFIG.chart.zoom.startIndex : 0"
4199+
:refreshEndPoint="FINAL_CONFIG.chart.zoom.endIndex !== null ? FINAL_CONFIG.chart.zoom.endIndex + 1 : Math.max(...dataset.map(datapoint => lttb(datapoint.series).length))"
4200+
:enableRangeHandles="FINAL_CONFIG.chart.zoom.enableRangeHandles"
4201+
:enableSelectionDrag="FINAL_CONFIG.chart.zoom.enableSelectionDrag"
4202+
:minimapCompact="FINAL_CONFIG.chart.zoom.minimap.compact"
4203+
:allMinimaps="allMinimaps"
4204+
:minimapMerged="FINAL_CONFIG.chart.zoom.minimap.merged"
4205+
:minimapFrameColor="FINAL_CONFIG.chart.zoom.minimap.frameColor"
4206+
:cutNullValues="FINAL_CONFIG.line.cutNullValues"
4207+
:focusOnDrag="FINAL_CONFIG.chart.zoom.focusOnDrag"
4208+
:focusRangeRatio="FINAL_CONFIG.chart.zoom.focusRangeRatio"
4209+
@reset="refreshSlicer"
4210+
@trapMouse="selectMinimapIndex"
4211+
@futureStart="v => setPrecog('start', v)"
4212+
@futureEnd="v => setPrecog('end', v)"
4213+
:timeLabels="allTimeLabels"
4214+
:isPreview="isPrecog"
4215+
>
4216+
<template #reset-action="{ reset }">
4217+
<slot name="reset-action" v-bind="{ reset }" />
4218+
</template>
4219+
</SlicerPreview>
42674220
42684221
<div :id="`legend-bottom-${uniqueId}`" />
42694222

0 commit comments

Comments
 (0)