Browse Source

update appendData && use new core

merge-requests/13/head
vargburz 3 years ago
parent
commit
7b07cdfb47
  1. 4
      package.json
  2. 14
      src/index.ts

4
package.json

@ -1,6 +1,6 @@
{ {
"name": "@chartwerk/line-pod", "name": "@chartwerk/line-pod",
"version": "0.4.3", "version": "0.4.4",
"description": "Chartwerk line chart", "description": "Chartwerk line chart",
"main": "dist/index.js", "main": "dist/index.js",
"scripts": { "scripts": {
@ -15,7 +15,7 @@
"author": "CorpGlory", "author": "CorpGlory",
"license": "ISC", "license": "ISC",
"dependencies": { "dependencies": {
"@chartwerk/core": "^0.3.1" "@chartwerk/core": "^0.3.2"
}, },
"devDependencies": { "devDependencies": {
"@types/d3": "5.16.4", "@types/d3": "5.16.4",

14
src/index.ts

@ -65,8 +65,7 @@ export class LinePod extends ChartwerkPod<LineTimeSerie, LineOptions> {
.y(d => this.yScale(d[1])); .y(d => this.yScale(d[1]));
} }
public appendData(data: [number, number][]): void { public appendData(data: [number, number][], shouldRerender = true): void {
for(let idx = 0; idx < this.series.length; ++idx) { for(let idx = 0; idx < this.series.length; ++idx) {
if(this.series[idx].visible === false) { if(this.series[idx].visible === false) {
continue; continue;
@ -92,10 +91,13 @@ export class LinePod extends ChartwerkPod<LineTimeSerie, LineOptions> {
this._renderDots([data[idx]], idx); this._renderDots([data[idx]], idx);
} }
} }
if(shouldRerender) {
this.renderXAxis(); const rightBorder = _.last(data)[0];
this.renderYAxis(); this.state.xValueRange = [this.state.getMinValueX(), rightBorder];
this.renderGrid(); this.renderXAxis();
this.renderYAxis();
this.renderGrid();
}
} }
_renderDots(datapoints: number[][], serieIdx: number): void { _renderDots(datapoints: number[][], serieIdx: number): void {

Loading…
Cancel
Save