Browse Source

Merge pull request 'updateData: update segments and markers' (#44) from update-segments-and-markers-on-update-data into main

Reviewed-on: #44
core-0.6.23
rozetko 9 months ago
parent
commit
ff5973b106
  1. 2
      react/ChartwerkLinePod.tsx
  2. 11
      src/index.ts

2
react/ChartwerkLinePod.tsx

@ -47,6 +47,8 @@ export function ChartwerkLinePod(props: ChartwerkLinePodProps) {
setPod(newPod); setPod(newPod);
newPod.render(); newPod.render();
} else { } else {
pod.updateMarkers(props.markersConf);
pod.updateSegments(props.segments);
// TODO: actually it's wrong logic with updates // TODO: actually it's wrong logic with updates
// because it creates new pod anyway // because it creates new pod anyway
pod.updateData(props.series, props.options); pod.updateData(props.series, props.options);

11
src/index.ts

@ -5,6 +5,7 @@ import { Segments } from './components/segments';
import { LineSeries } from './models/line_series'; import { LineSeries } from './models/line_series';
import { MarkersConf } from './models/marker'; import { MarkersConf } from './models/marker';
import { SegmentSerie } from './models/segment';
import * as d3 from 'd3'; import * as d3 from 'd3';
import * as _ from 'lodash'; import * as _ from 'lodash';
@ -29,7 +30,7 @@ class LinePod extends ChartwerkPod<LineTimeSerie, LineOptions> {
_series: LineTimeSerie[] = [], _series: LineTimeSerie[] = [],
_options: LineOptions = {}, _options: LineOptions = {},
private _markersConf?: MarkersConf, private _markersConf?: MarkersConf,
private _segmentSeries = [], private _segmentSeries: SegmentSerie[] = [],
) { ) {
super(_el, _series, _options); super(_el, _series, _options);
this.series = new LineSeries(_series); this.series = new LineSeries(_series);
@ -393,6 +394,14 @@ class LinePod extends ChartwerkPod<LineTimeSerie, LineOptions> {
this.onMouseOver(); this.onMouseOver();
} }
updateMarkers(markersConf: MarkersConf): void {
this._markersConf = markersConf;
}
updateSegments(segments: SegmentSerie[]): void {
this._segmentSeries = segments;
}
// methods below rewrite s, (move more methods here) // methods below rewrite s, (move more methods here)
protected zoomOut(): void { protected zoomOut(): void {
if(d3.event.type === 'dblclick' && !this.isDoubleClickActive()) { if(d3.event.type === 'dblclick' && !this.isDoubleClickActive()) {

Loading…
Cancel
Save