|
|
|
@ -32,14 +32,8 @@ import includes from 'lodash/includes';
|
|
|
|
|
import first from 'lodash/first'; |
|
|
|
|
import last from 'lodash/last'; |
|
|
|
|
import mergeWith from 'lodash/mergeWith'; |
|
|
|
|
import min from 'lodash/min'; |
|
|
|
|
import minBy from 'lodash/minBy'; |
|
|
|
|
import max from 'lodash/max'; |
|
|
|
|
import maxBy from 'lodash/maxBy'; |
|
|
|
|
import add from 'lodash/add'; |
|
|
|
|
import replace from 'lodash/replace'; |
|
|
|
|
import reverse from 'lodash/reverse'; |
|
|
|
|
import sortBy from 'lodash/sortBy'; |
|
|
|
|
import cloneDeep from 'lodash/cloneDeep'; |
|
|
|
|
import debounce from 'lodash/debounce'; |
|
|
|
|
import has from 'lodash/has'; |
|
|
|
@ -142,11 +136,6 @@ abstract class ChartwerkPod<T extends TimeSerie, O extends Options> {
|
|
|
|
|
// components
|
|
|
|
|
protected grid: Grid; |
|
|
|
|
|
|
|
|
|
// TODO: test variables instead of functions with cache
|
|
|
|
|
private _xScale: d3.ScaleLinear<number, number> | null = null; |
|
|
|
|
private _yScale: d3.ScaleLinear<number, number> | null = null; |
|
|
|
|
private _y1Scale: d3.ScaleLinear<number, number> | null = null; |
|
|
|
|
|
|
|
|
|
constructor( |
|
|
|
|
// maybe it's not the best idea
|
|
|
|
|
_d3: typeof d3, |
|
|
|
@ -180,7 +169,6 @@ abstract class ChartwerkPod<T extends TimeSerie, O extends Options> {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public render(): void { |
|
|
|
|
console.log('render'); |
|
|
|
|
this.renderAxes(); |
|
|
|
|
this.renderGrid(); |
|
|
|
|
|
|
|
|
@ -608,8 +596,7 @@ abstract class ChartwerkPod<T extends TimeSerie, O extends Options> {
|
|
|
|
|
|
|
|
|
|
this.onPanningRescale(event); |
|
|
|
|
|
|
|
|
|
const shouldClearState = false; |
|
|
|
|
this.clearScaleCache(shouldClearState); |
|
|
|
|
// TODO: check clear state for necessity
|
|
|
|
|
this.renderYAxis(); |
|
|
|
|
this.renderXAxis(); |
|
|
|
|
|
|
|
|
@ -839,6 +826,7 @@ abstract class ChartwerkPod<T extends TimeSerie, O extends Options> {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// TODO: move to State
|
|
|
|
|
get absXScale(): d3.ScaleLinear<number, number> { |
|
|
|
|
const domain = [0, Math.abs(this.state.maxValueX - this.state.minValueX)]; |
|
|
|
|
return this.d3.scaleLinear() |
|
|
|
@ -853,6 +841,7 @@ abstract class ChartwerkPod<T extends TimeSerie, O extends Options> {
|
|
|
|
|
.range([0, this.height]); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// TODO: these getters can be removed, but it will break all Pods.
|
|
|
|
|
get xScale(): d3.ScaleLinear<number, number> { |
|
|
|
|
return this.state.xScale; |
|
|
|
|
} |
|
|
|
@ -1008,16 +997,8 @@ abstract class ChartwerkPod<T extends TimeSerie, O extends Options> {
|
|
|
|
|
return confidenceMetric; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
protected clearScaleCache(shouldClearState = true): void { |
|
|
|
|
this._xScale = null; |
|
|
|
|
this._yScale = null; |
|
|
|
|
this._y1Scale = null; |
|
|
|
|
if(shouldClearState) { |
|
|
|
|
this.state.xValueRange = undefined; |
|
|
|
|
this.state.yValueRange = undefined; |
|
|
|
|
this.state.y1ValueRange = undefined; |
|
|
|
|
this.state.transform = { x: 0, y: 0, k: 1 }; |
|
|
|
|
} |
|
|
|
|
protected clearState(): void { |
|
|
|
|
this.state.clearState(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
protected getSerieColor(idx: number): string { |
|
|
|
|