From 283f0995e8ffa7afae1643b59f2303a39ca9e885 Mon Sep 17 00:00:00 2001 From: glitch4347 Date: Mon, 18 Dec 2023 17:25:02 +0100 Subject: [PATCH] pod fix --- react/ChartwerkLinePod.tsx | 4 +++- src/components/segments.ts | 4 ++-- src/models/segment.ts | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/react/ChartwerkLinePod.tsx b/react/ChartwerkLinePod.tsx index f0db6e3..b0361f6 100644 --- a/react/ChartwerkLinePod.tsx +++ b/react/ChartwerkLinePod.tsx @@ -47,9 +47,11 @@ export function ChartwerkLinePod(props: ChartwerkLinePodProps) { setPod(newPod); newPod.render(); } else { + // TODO: actually it's wrong logic with updates + // because it creates new pod anyway pod.updateData(props.series, props.options); } - }, [chart, pod, props.id, props.options, props.markersConf, props.segments]); + }, [chart, props.id, props.options, props.markersConf, props.segments]); // TODO: it's a hack to render the LinePod right after the div appears in DOM setTimeout(() => { diff --git a/src/components/segments.ts b/src/components/segments.ts index 99251b4..c3de5c8 100644 --- a/src/components/segments.ts +++ b/src/components/segments.ts @@ -24,9 +24,9 @@ export class Segments { protected renderSerie(serie: SegmentSerie) { serie.data.forEach((d) => { // @ts-ignore - const startPositionX = pod.state.xScale(d[0]) as number; + const startPositionX = this._state.xScale(d[0]) as number; // @ts-ignore - const endPositionX = pod.state.xScale(d[1]) as number; + const endPositionX = this._state.xScale(d[1]) as number; const width = endPositionX - startPositionX // Math.max(endPositionX - startPositionX, MIMIMUM_SEGMENT_WIDTH); this._d3Holder.append('rect') diff --git a/src/models/segment.ts b/src/models/segment.ts index cf22624..39db4f8 100644 --- a/src/models/segment.ts +++ b/src/models/segment.ts @@ -1,4 +1,4 @@ export type SegmentSerie = { color: string; - data: [number, number, any][] // [from, to, payload] payload is any data for tooltip + data: [number, number, any?][] // [from, to, payload?] payload is any data for tooltip } \ No newline at end of file -- 2.34.1