Skip to content

Commit 3081892

Browse files
authored
Merge pull request #94 from graphieros/ft-zoom-minimap
Ft zoom minimap (VueUiQuickChart)
2 parents 92ae621 + f6ab5c8 commit 3081892

File tree

5 files changed

+57
-20
lines changed

5 files changed

+57
-20
lines changed

TestingArena/ArenaVueUiQuickChart.vue

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ const datasets = ref({
5454
longObject: [
5555
{
5656
name: 'Serie 1',
57-
values: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
57+
values: [12, 7, 4, 11, 13, 16, 19, 22, 15, 28, 16, 12]
5858
},
5959
{
6060
name: 'Serie 2',
@@ -89,7 +89,7 @@ const datasets = ref({
8989
})
9090
9191
92-
const selectedSerie = ref('shortObjectMixed');
92+
const selectedSerie = ref('longObject');
9393
9494
const model = ref([
9595
{ key: 'responsive', def: false, type: 'checkbox'},
@@ -162,13 +162,20 @@ const model = ref([
162162
{ key: 'xyShowGrid', def: true, type: 'checkbox'},
163163
{ key: 'xyShowScale', def: true, type: 'checkbox'},
164164
{ key: 'yAxisLabel', def: 'Lorem ipsum Y axis labellum'},
165+
165166
{ key: 'zoomXy', def: true, type: 'checkbox'},
166167
{ key: 'zoomColor', def: '#CCCCCC', type: 'color'},
167168
{ key: 'zoomHighlightColor', def: '#1A1A1A', type: 'color'},
168169
{ key: 'zoomFontSize', def: 14, type: 'number', min: 8, max: 48},
169-
{ key: 'zoomUseResetSlot', def: false, type: 'checkbox'}
170+
{ key: 'zoomUseResetSlot', def: false, type: 'checkbox'},
170171
171-
])
172+
{ key: 'zoomMinimap.show', def: true, type: 'checkbox'},
173+
{ key: 'zoomMinimap.smooth', def: true, type: 'checkbox'},
174+
{ key: 'zoomMinimap.selectedColor', def: '#1F77B4', type: 'color'},
175+
{ key: 'zoomMinimap.selectedColorOpacity', def: 0.2, type: 'range', min: 0, max: 0.5, step: 0.01},
176+
{ key: 'zoomMinimap.lineColor', def: '#1A1A1A', type: 'color'},
177+
{ key: 'zoomMinimap.selectionRadius', def: 2, type: 'range', min: 0, max: 24}
178+
]);
172179
173180
const themeOptions = ref([
174181
"",

src/atoms/Slicer.vue

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -200,21 +200,11 @@ const minimapLine = computed(() => {
200200
return props.smoothMinimap ? createSmoothPath(points) : createStraightPath(points);
201201
});
202202
203-
// const startPercent = computed(() => {
204-
// const range = props.max - props.min;
205-
// return ((startValue.value - props.min) / range) * 100;
206-
// });
207-
208-
// const endPercent = computed(() => {
209-
// const range = props.max - props.min;
210-
// return ((endValue.value - props.min) / range) * 100;
211-
// });
212-
213203
const range = computed(() => props.max - props.min);
214204
const leftLabelPosition = computed(() => {
215205
const leftPercent = ((startValue.value - props.min) / range.value) * 100;
216206
return {
217-
left: `calc(${leftPercent}%)`, // Adjust positioning as needed
207+
left: `calc(${leftPercent}%)`,
218208
color: props.textColor,
219209
fontSize: `${props.fontSize}px`,
220210
top: '-28px',
@@ -225,7 +215,7 @@ const leftLabelPosition = computed(() => {
225215
const rightLabelPosition = computed(() => {
226216
const rightPercent = ((endValue.value - props.min) / range.value) * 100;
227217
return {
228-
left: `calc(${rightPercent}%)`, // Adjust positioning as needed
218+
left: `calc(${rightPercent}%)`,
229219
color: props.textColor,
230220
fontSize: `${props.fontSize}px`,
231221
top: '28px',
@@ -238,7 +228,7 @@ const rightLabelPosition = computed(() => {
238228

239229
<template>
240230
<div data-html2canvas-ignore>
241-
<div class="vue-data-ui-slicer-labels">
231+
<div class="vue-data-ui-slicer-labels" style="position: relative; z-index: 1">
242232
<div v-if="valueStart > 0 || valueEnd < max" style="width: 100%; position: relative">
243233
<button v-if="!useResetSlot" data-cy-reset tabindex="0" role="button" class="vue-data-ui-refresh-button"
244234
@click="reset">
@@ -247,7 +237,7 @@ const rightLabelPosition = computed(() => {
247237
<slot v-else name="reset-action" :reset="reset" />
248238
</div>
249239
</div>
250-
<div class="double-range-slider" ref="minimapWrapper">
240+
<div class="double-range-slider" ref="minimapWrapper" style="z-index: 0">
251241
<template v-if="hasMinimap">
252242
<div class="minimap" style="width: 100%">
253243
<svg :xmlns="XMLNS" :viewBox="`0 0 ${svgMinimap.width < 0 ? 0 : svgMinimap.width} ${svgMinimap.height < 0 ? 0 : svgMinimap.height}`">
@@ -294,7 +284,6 @@ const rightLabelPosition = computed(() => {
294284
</div>
295285
</template>
296286

297-
298287
<style scoped lang="scss">
299288
.double-range-slider {
300289
position: relative !important;

src/components/vue-ui-quick-chart.vue

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,39 @@ function refreshSlicer() {
418418
slicerStep.value += 1;
419419
}
420420
421+
const minimap = computed(() => {
422+
if(!FINAL_CONFIG.value.zoomMinimap.show || chartType.value === detector.chartType.DONUT) return [];
423+
424+
let ds = [];
425+
426+
if (detector.isSimpleArrayOfNumbers(formattedDataset.value.dataset)) {
427+
ds = formattedDataset.value.dataset
428+
}
429+
430+
if (detector.isSimpleArrayOfObjects(formattedDataset.value.dataset)) {
431+
ds = formattedDataset.value.dataset.map((d, i) => {
432+
return {
433+
values: d.VALUE || d.DATA || d.SERIE || d.VALUES || d.NUM || 0,
434+
id: chartType.value === detector.chartType.LINE ? `line_${i}` : `bar_${i}`
435+
}
436+
}).filter(s => !segregated.value.includes(s.id))
437+
}
438+
439+
const maxIndex = detector.isSimpleArrayOfNumbers(ds) ? ds.length : Math.max(...ds.map(s => s.values.length));
440+
let sumAllSeries = []
441+
442+
if (detector.isSimpleArrayOfNumbers(ds)) {
443+
sumAllSeries = ds
444+
} else {
445+
for(let i = 0; i < maxIndex; i += 1) {
446+
sumAllSeries.push(ds.map(s => s.values[i] || 0).reduce((a, b) => (a || 0) + (b || 0), 0));
447+
}
448+
}
449+
450+
const min = Math.min(...sumAllSeries);
451+
return sumAllSeries.map(dp => dp + (min < 0 ? Math.abs(min) : 0)) // positivized
452+
});
453+
421454
const line = computed(() => {
422455
if(chartType.value !== detector.chartType.LINE) return null;
423456
@@ -1426,6 +1459,12 @@ defineExpose({
14261459
:min="0"
14271460
:valueStart="slicer.start"
14281461
:valueEnd="slicer.end"
1462+
:smoothMinimap="FINAL_CONFIG.zoomMinimap.smooth"
1463+
:minimapSelectedColor="FINAL_CONFIG.zoomMinimap.selectedColor"
1464+
:minimapSelectedColorOpacity="FINAL_CONFIG.zoomMinimap.selectedColorOpacity"
1465+
:minimapSelectionRadius="FINAL_CONFIG.zoomMinimap.selectionRadius"
1466+
:minimapLineColor="FINAL_CONFIG.zoomMinimap.lineColor"
1467+
:minimap="minimap"
14291468
v-model:start="slicer.start"
14301469
v-model:end="slicer.end"
14311470
@reset="refreshSlicer"

src/useConfig.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2385,7 +2385,8 @@ export function useConfig() {
23852385
zoomColor: COLOR_GREY_MID,
23862386
zoomHighlightColor: COLOR_GREY_DARK,
23872387
zoomFontSize: FONT._14,
2388-
zoomUseResetSlot: false
2388+
zoomUseResetSlot: false,
2389+
zoomMinimap: MINIMAP
23892390
}
23902391

23912392
const vue_ui_age_pyramid = {

types/vue-data-ui.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4393,6 +4393,7 @@ declare module 'vue-data-ui' {
43934393
zoomHighlightColor?: string;
43944394
zoomFontSize?: number;
43954395
zoomUseResetSlot?: boolean;
4396+
zoomMinimap?: ZoomMinimap;
43964397
userOptionsButtons?: {
43974398
tooltip?: boolean;
43984399
pdf?: boolean;

0 commit comments

Comments
 (0)