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",
"version": "0.4.3",
"version": "0.4.4",
"description": "Chartwerk line chart",
"main": "dist/index.js",
"scripts": {
@ -15,7 +15,7 @@
"author": "CorpGlory",
"license": "ISC",
"dependencies": {
"@chartwerk/core": "^0.3.1"
"@chartwerk/core": "^0.3.2"
},
"devDependencies": {
"@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]));
}
public appendData(data: [number, number][]): void {
public appendData(data: [number, number][], shouldRerender = true): void {
for(let idx = 0; idx < this.series.length; ++idx) {
if(this.series[idx].visible === false) {
continue;
@ -92,10 +91,13 @@ export class LinePod extends ChartwerkPod<LineTimeSerie, LineOptions> {
this._renderDots([data[idx]], idx);
}
}
this.renderXAxis();
this.renderYAxis();
this.renderGrid();
if(shouldRerender) {
const rightBorder = _.last(data)[0];
this.state.xValueRange = [this.state.getMinValueX(), rightBorder];
this.renderXAxis();
this.renderYAxis();
this.renderGrid();
}
}
_renderDots(datapoints: number[][], serieIdx: number): void {

Loading…
Cancel
Save