Skip to content

Commit f6ab5c8

Browse files
committed
Improvement - VueUiQuickChart - Add optional minimap to zoom inputs
1 parent d241799 commit f6ab5c8

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

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"

0 commit comments

Comments
 (0)