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