From 1dd6deafe5009c6e2d721159a1e874eb13131e62 Mon Sep 17 00:00:00 2001 From: Martin Turoci Date: Thu, 5 Oct 2023 16:02:01 +0200 Subject: [PATCH 1/2] feat: Allow using "idx" as field name in plot data. --- ui/src/plot.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ui/src/plot.tsx b/ui/src/plot.tsx index 2811ac4ae7..4eacb820d9 100644 --- a/ui/src/plot.tsx +++ b/ui/src/plot.tsx @@ -591,7 +591,7 @@ const return mark }, refactorData = (ds: any[], marks: MarkExt[]): any[] => { - ds.forEach((d, idx) => d.idx = idx) + ds.forEach((d, idx) => d.wave_idx = idx) for (const m of marks) { if (m.x_scale === 'time') { for (const { x_field, x0_field } of marks) { @@ -1048,8 +1048,8 @@ tooltipContainer.className = 'g2-tooltip' const PlotTooltip = ({ items, originalItems, dateKeys }: { items: TooltipItem[], originalItems: any[], dateKeys: Set }) => <> {items.map(({ data, mappingData, color }: TooltipItem) => - Object.keys(originalItems[data.idx]).map((itemKey, idx) => { - let item = originalItems[data.idx][itemKey] + Object.keys(originalItems[data.wave_idx]).map((itemKey, idx) => { + let item = originalItems[data.wave_idx][itemKey] if (!(item instanceof Date) && dateKeys.has(itemKey)) item = new Date(item) return ( @@ -1132,7 +1132,7 @@ export const if (e.stateStatus && e.state === 'selected' && model.name && e.element.geometry.customOption.interactive) { const ret = Array.isArray(e.element?.data) ? e.element.data.map(({ idx }: any) => ({ idx, ...originalDataRef.current[idx] })) - : [{ idx: e.element.data.idx, ...originalDataRef.current[e.element.data.idx] }] + : [{ idx: e.element.data.wave_idx, ...originalDataRef.current[e.element.data.wave_idx] }] wave.emit(model.name, event, ret) } }) From 43354c59bd0cdb600cf8d5262cfe5e17ab9cde6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Tur=C3=B3ci?= <64769322+mturoci@users.noreply.github.com> Date: Mon, 9 Oct 2023 08:55:39 +0200 Subject: [PATCH 2/2] Update ui/src/plot.tsx Co-authored-by: Marek Mihok --- ui/src/plot.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/src/plot.tsx b/ui/src/plot.tsx index 4eacb820d9..819de34f29 100644 --- a/ui/src/plot.tsx +++ b/ui/src/plot.tsx @@ -1131,7 +1131,7 @@ export const const e = ev.gEvent.originalEvent if (e.stateStatus && e.state === 'selected' && model.name && e.element.geometry.customOption.interactive) { const ret = Array.isArray(e.element?.data) - ? e.element.data.map(({ idx }: any) => ({ idx, ...originalDataRef.current[idx] })) + ? e.element.data.map(({ wave_idx }: any) => ({ idx: wave_idx, ...originalDataRef.current[wave_idx] })) : [{ idx: e.element.data.wave_idx, ...originalDataRef.current[e.element.data.wave_idx] }] wave.emit(model.name, event, ret) }