|
|
@ -90,7 +90,6 @@ export const CORE_DEFAULT_OPTIONS: Options = { |
|
|
|
crosshair: DEFAULT_CROSSHAIR_OPTIONS, |
|
|
|
crosshair: DEFAULT_CROSSHAIR_OPTIONS, |
|
|
|
renderLegend: true, |
|
|
|
renderLegend: true, |
|
|
|
margin: DEFAULT_MARGIN, |
|
|
|
margin: DEFAULT_MARGIN, |
|
|
|
eventsCallbacks: {}, |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
export class CoreOptions<O extends Options> { |
|
|
|
export class CoreOptions<O extends Options> { |
|
|
@ -106,6 +105,14 @@ export class CoreOptions<O extends Options> { |
|
|
|
|
|
|
|
|
|
|
|
protected setOptions(options: O): void { |
|
|
|
protected setOptions(options: O): void { |
|
|
|
this._options = lodashDefaultsDeep(lodashCloneDeep(options), this.getDefaults()); |
|
|
|
this._options = lodashDefaultsDeep(lodashCloneDeep(options), this.getDefaults()); |
|
|
|
|
|
|
|
if(this._options.eventsCallbacks !== undefined) { |
|
|
|
|
|
|
|
if(this._options.events !== undefined) { |
|
|
|
|
|
|
|
throw new Error('events and eventsCallbacks are mutually exclusive'); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
this._options.events = this._options.eventsCallbacks; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// also bakward compatibility for clients who use "eventsCallbacks" instead of "events"
|
|
|
|
|
|
|
|
this._options.eventsCallbacks = this._options.events; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// this getter can be overrited in Pod
|
|
|
|
// this getter can be overrited in Pod
|
|
|
@ -160,80 +167,80 @@ export class CoreOptions<O extends Options> { |
|
|
|
|
|
|
|
|
|
|
|
// event callbacks
|
|
|
|
// event callbacks
|
|
|
|
callbackRenderStart(): void { |
|
|
|
callbackRenderStart(): void { |
|
|
|
if(has(this._options.eventsCallbacks, 'renderStart')) { |
|
|
|
if(has(this._options.events, 'renderStart')) { |
|
|
|
this._options.eventsCallbacks.renderStart(); |
|
|
|
this._options.events.renderStart(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
callbackRenderEnd(): void { |
|
|
|
callbackRenderEnd(): void { |
|
|
|
if(has(this._options.eventsCallbacks, 'renderEnd')) { |
|
|
|
if(has(this._options.events, 'renderEnd')) { |
|
|
|
this._options.eventsCallbacks.renderEnd(); |
|
|
|
this._options.events.renderEnd(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
callbackComponentRenderEnd(part: RenderComponent): void { |
|
|
|
callbackComponentRenderEnd(part: RenderComponent): void { |
|
|
|
if(has(this._options.eventsCallbacks, 'componentRenderEnd')) { |
|
|
|
if(has(this._options.events, 'componentRenderEnd')) { |
|
|
|
this._options.eventsCallbacks.componentRenderEnd(part); |
|
|
|
this._options.events.componentRenderEnd(part); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
callbackLegendClick(idx: number): void { |
|
|
|
callbackLegendClick(idx: number): void { |
|
|
|
if(has(this._options.eventsCallbacks, 'onLegendClick')) { |
|
|
|
if(has(this._options.events, 'onLegendClick')) { |
|
|
|
this._options.eventsCallbacks.onLegendClick(idx); |
|
|
|
this._options.events.onLegendClick(idx); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
callbackLegendLabelClick(idx: number): void { |
|
|
|
callbackLegendLabelClick(idx: number): void { |
|
|
|
if(has(this._options.eventsCallbacks, 'onLegendLabelClick')) { |
|
|
|
if(has(this._options.events, 'onLegendLabelClick')) { |
|
|
|
this._options.eventsCallbacks.onLegendLabelClick(idx); |
|
|
|
this._options.events.onLegendLabelClick(idx); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
callbackPanning(event: { ranges: AxisRange[], d3Event: any }): void { |
|
|
|
callbackPanning(event: { ranges: AxisRange[], d3Event: any }): void { |
|
|
|
if(has(this._options.eventsCallbacks, 'panning')) { |
|
|
|
if(has(this._options.events, 'panning')) { |
|
|
|
this._options.eventsCallbacks.panning(event); |
|
|
|
this._options.events.panning(event); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
callbackPanningEnd(ranges: AxisRange[]): void { |
|
|
|
callbackPanningEnd(ranges: AxisRange[]): void { |
|
|
|
if(has(this._options.eventsCallbacks, 'panningEnd')) { |
|
|
|
if(has(this._options.events, 'panningEnd')) { |
|
|
|
this._options.eventsCallbacks.panningEnd(ranges); |
|
|
|
this._options.events.panningEnd(ranges); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
callbackZoomIn(ranges: AxisRange[]): void { |
|
|
|
callbackZoomIn(ranges: AxisRange[]): void { |
|
|
|
if(has(this._options.eventsCallbacks, 'zoomIn')) { |
|
|
|
if(has(this._options.events, 'zoomIn')) { |
|
|
|
this._options.eventsCallbacks.zoomIn(ranges); |
|
|
|
this._options.events.zoomIn(ranges); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
callbackZoomOut(centers: { x: number, y: number }): void { |
|
|
|
callbackZoomOut(centers: { x: number, y: number }): void { |
|
|
|
if(has(this._options.eventsCallbacks, 'zoomOut')) { |
|
|
|
if(has(this._options.events, 'zoomOut')) { |
|
|
|
this._options.eventsCallbacks.zoomOut(centers); |
|
|
|
this._options.events.zoomOut(centers); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
callbackSharedCrosshairMove(event: { datapoints, eventX, eventY }): void { |
|
|
|
callbackSharedCrosshairMove(event: { datapoints, eventX, eventY }): void { |
|
|
|
if(has(this._options.eventsCallbacks, 'sharedCrosshairMove')) { |
|
|
|
if(has(this._options.events, 'sharedCrosshairMove')) { |
|
|
|
this._options.eventsCallbacks.sharedCrosshairMove(event); |
|
|
|
this._options.events.sharedCrosshairMove(event); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
callbackMouseMove(event): void { |
|
|
|
callbackMouseMove(event): void { |
|
|
|
if(has(this._options.eventsCallbacks, 'mouseMove')) { |
|
|
|
if(has(this._options.events, 'mouseMove')) { |
|
|
|
this._options.eventsCallbacks.mouseMove(event); |
|
|
|
this._options.events.mouseMove(event); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
callbackMouseOut(): void { |
|
|
|
callbackMouseOut(): void { |
|
|
|
if(has(this._options.eventsCallbacks, 'mouseOut')) { |
|
|
|
if(has(this._options.events, 'mouseOut')) { |
|
|
|
this._options.eventsCallbacks.mouseOut(); |
|
|
|
this._options.events.mouseOut(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
callbackMouseClick(event): void { |
|
|
|
callbackMouseClick(event): void { |
|
|
|
if(has(this._options.eventsCallbacks, 'mouseClick')) { |
|
|
|
if(has(this._options.events, 'mouseClick')) { |
|
|
|
this._options.eventsCallbacks.mouseClick(event); |
|
|
|
this._options.events.mouseClick(event); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|