From 878e86d8498547eb46a617e9341f42653fc28f7e Mon Sep 17 00:00:00 2001 From: rozetko Date: Mon, 29 Jan 2024 17:18:40 +0300 Subject: [PATCH] updateData: update segments and markers --- react/ChartwerkLinePod.tsx | 2 ++ src/index.ts | 11 ++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/react/ChartwerkLinePod.tsx b/react/ChartwerkLinePod.tsx index b0361f6..0c418b1 100644 --- a/react/ChartwerkLinePod.tsx +++ b/react/ChartwerkLinePod.tsx @@ -47,6 +47,8 @@ export function ChartwerkLinePod(props: ChartwerkLinePodProps) { setPod(newPod); newPod.render(); } else { + pod.updateMarkers(props.markersConf); + pod.updateSegments(props.segments); // TODO: actually it's wrong logic with updates // because it creates new pod anyway pod.updateData(props.series, props.options); diff --git a/src/index.ts b/src/index.ts index 2bd04b5..925b516 100644 --- a/src/index.ts +++ b/src/index.ts @@ -5,6 +5,7 @@ import { Segments } from './components/segments'; import { LineSeries } from './models/line_series'; import { MarkersConf } from './models/marker'; +import { SegmentSerie } from './models/segment'; import * as d3 from 'd3'; import * as _ from 'lodash'; @@ -29,7 +30,7 @@ class LinePod extends ChartwerkPod { _series: LineTimeSerie[] = [], _options: LineOptions = {}, private _markersConf?: MarkersConf, - private _segmentSeries = [], + private _segmentSeries: SegmentSerie[] = [], ) { super(_el, _series, _options); this.series = new LineSeries(_series); @@ -393,6 +394,14 @@ class LinePod extends ChartwerkPod { this.onMouseOver(); } + updateMarkers(markersConf: MarkersConf): void { + this._markersConf = markersConf; + } + + updateSegments(segments: SegmentSerie[]): void { + this._segmentSeries = segments; + } + // methods below rewrite s, (move more methods here) protected zoomOut(): void { if(d3.event.type === 'dblclick' && !this.isDoubleClickActive()) { -- 2.34.1