From 6e6fa7dc8ec9bfd7950101c3b17b4805f3dbe14b Mon Sep 17 00:00:00 2001 From: vargburz Date: Wed, 21 Aug 2024 18:06:15 +0300 Subject: [PATCH] 0.7.6 && update vue with markers and conf --- package.json | 2 +- src/index.ts | 39 ++++++++++++++++++++++++++++++++++++--- 2 files changed, 37 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index ebaab58..b029f67 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@chartwerk/line-pod", - "version": "0.7.5", + "version": "0.7.6", "description": "Chartwerk line chart", "main": "dist/index.js", "files": [ diff --git a/src/index.ts b/src/index.ts index 13fe2ab..f6d187f 100644 --- a/src/index.ts +++ b/src/index.ts @@ -452,12 +452,45 @@ class LinePod extends ChartwerkPod { ); } } + + // override parent updateData method to provide markers and segments +protected updateLineData( + series?: LineTimeSerie[], + options?: LineOptions, + markersConf?: MarkersConf, + segments?: SegmentSerie[], + shouldRerender = true + ): void { + this.updateMarkers(markersConf); + this.updateSegments(segments); + this.updateData(series, options, shouldRerender); + } } // TODO: it should be moved to VUE folder // it is used with Vue.component, e.g.: Vue.component('chartwerk-line-pod', VueChartwerkLinePod) export const VueChartwerkLinePod = { // alternative to `template: '
'` + props: { + markersConf: { + type: Object, + required: false, + default: function() { return {}; } + }, + segments: { + type: Array, + required: false, + default: function() { return []; } + }, + }, + watch: { + markersConf() { + this.renderChart(); + }, + segments() { + this.renderChart(); + }, + }, render(createElement) { return createElement( 'div', @@ -471,10 +504,10 @@ export const VueChartwerkLinePod = { methods: { render() { if(this.pod === undefined) { - this.pod = new LinePod(document.getElementById(this.id), this.series, this.options); + this.pod = new LinePod(document.getElementById(this.id), this.series, this.options, this.markersConf, this.segments); this.pod.render(); } else { - this.pod.updateData(this.series, this.options); + this.pod.updateLineData(this.series, this.options, this.markersConf, this.segments); } }, renderSharedCrosshair(values) { @@ -486,4 +519,4 @@ export const VueChartwerkLinePod = { } }; -export { LineTimeSerie, LineOptions, TimeFormat, LinePod, AreaType }; +export { LineTimeSerie, LineOptions, TimeFormat, LinePod, AreaType, MarkersConf, SegmentSerie };