Browse Source

Merge branch 'update-state-on-data-change' into 'main'

Update state on data change

See merge request chartwerk/core!8
merge-requests/9/merge
Alexey Velikiy 3 years ago
parent
commit
165ae10a3a
  1. 1
      dist/index.d.ts
  2. 2
      dist/index.js
  3. 2
      package.json
  4. 2
      src/components/grid.ts
  5. 11
      src/index.ts

1
dist/index.d.ts vendored

@ -40,6 +40,7 @@ declare abstract class ChartwerkPod<T extends TimeSerie, O extends Options> {
protected removeEventListeners(): void;
render(): void;
updateData(series?: T[], options?: O, shouldRerender?: boolean): void;
forceRerender(): void;
protected updateOptions(newOptions: O): void;
protected updateSeries(newSeries: T[]): void;
protected abstract renderMetrics(): void;

2
dist/index.js vendored

File diff suppressed because one or more lines are too long

2
package.json

@ -1,6 +1,6 @@
{
"name": "@chartwerk/core",
"version": "0.3.1",
"version": "0.3.2",
"description": "Chartwerk core",
"main": "dist/index.js",
"types": "dist/index.d.ts",

2
src/components/grid.ts

@ -78,7 +78,7 @@ export class Grid {
.call(
this._d3.axisLeft(this._svgElParams.yScale)
.ticks(this.gridOptions.y.ticksCount)
.tickSize(-this._svgElParams)
.tickSize(-this._svgElParams.width)
.tickFormat(() => '')
);
}

11
src/index.ts

@ -194,10 +194,19 @@ abstract class ChartwerkPod<T extends TimeSerie, O extends Options> {
this.updateSeries(series);
this.updateOptions(options);
if(shouldRerender) {
this.render();
this.forceRerender();
}
}
public forceRerender(): void {
// TODO: it is a hack. It is not nessesary to recreate svg.
// the only purpose for this action, to clear d3.zoom.transform (see https://gitlab.com/chartwerk/core/-/issues/10)
this.createSvg();
this.initPodState();
this.initComponents();
this.render();
}
protected updateOptions(newOptions: O): void {
if(newOptions === undefined) {
return;

Loading…
Cancel
Save