|
|
|
@ -90,6 +90,7 @@ export const CORE_DEFAULT_OPTIONS: Options = {
|
|
|
|
|
crosshair: DEFAULT_CROSSHAIR_OPTIONS, |
|
|
|
|
renderLegend: true, |
|
|
|
|
margin: DEFAULT_MARGIN, |
|
|
|
|
eventsCallbacks: {}, |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
export class CoreOptions<O extends Options> { |
|
|
|
@ -105,14 +106,6 @@ export class CoreOptions<O extends Options> {
|
|
|
|
|
|
|
|
|
|
protected setOptions(options: O): void { |
|
|
|
|
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
|
|
|
|
@ -167,86 +160,80 @@ export class CoreOptions<O extends Options> {
|
|
|
|
|
|
|
|
|
|
// event callbacks
|
|
|
|
|
callbackRenderStart(): void { |
|
|
|
|
if(has(this._options.events, 'renderStart')) { |
|
|
|
|
this._options.events.renderStart(); |
|
|
|
|
if(has(this._options.eventsCallbacks, 'renderStart')) { |
|
|
|
|
this._options.eventsCallbacks.renderStart(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
callbackRenderEnd(): void { |
|
|
|
|
if(has(this._options.events, 'renderEnd')) { |
|
|
|
|
this._options.events.renderEnd(); |
|
|
|
|
if(has(this._options.eventsCallbacks, 'renderEnd')) { |
|
|
|
|
this._options.eventsCallbacks.renderEnd(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
callbackComponentRenderEnd(part: RenderComponent): void { |
|
|
|
|
if(has(this._options.events, 'componentRenderEnd')) { |
|
|
|
|
this._options.events.componentRenderEnd(part); |
|
|
|
|
if(has(this._options.eventsCallbacks, 'componentRenderEnd')) { |
|
|
|
|
this._options.eventsCallbacks.componentRenderEnd(part); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
callbackLegendClick(idx: number): void { |
|
|
|
|
if(has(this._options.events, 'onLegendClick')) { |
|
|
|
|
this._options.events.onLegendClick(idx); |
|
|
|
|
if(has(this._options.eventsCallbacks, 'onLegendClick')) { |
|
|
|
|
this._options.eventsCallbacks.onLegendClick(idx); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
callbackLegendLabelClick(idx: number): void { |
|
|
|
|
if(has(this._options.events, 'onLegendLabelClick')) { |
|
|
|
|
this._options.events.onLegendLabelClick(idx); |
|
|
|
|
if(has(this._options.eventsCallbacks, 'onLegendLabelClick')) { |
|
|
|
|
this._options.eventsCallbacks.onLegendLabelClick(idx); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
callbackPanning(event: { ranges: AxisRange[], d3Event: any }): void { |
|
|
|
|
if(has(this._options.events, 'panning')) { |
|
|
|
|
this._options.events.panning(event); |
|
|
|
|
if(has(this._options.eventsCallbacks, 'panning')) { |
|
|
|
|
this._options.eventsCallbacks.panning(event); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
callbackPanningEnd(ranges: AxisRange[]): void { |
|
|
|
|
if(has(this._options.events, 'panningEnd')) { |
|
|
|
|
this._options.events.panningEnd(ranges); |
|
|
|
|
if(has(this._options.eventsCallbacks, 'panningEnd')) { |
|
|
|
|
this._options.eventsCallbacks.panningEnd(ranges); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
callbackZoomIn(ranges: AxisRange[]): void { |
|
|
|
|
if(has(this._options.events, 'zoomIn')) { |
|
|
|
|
this._options.events.zoomIn(ranges); |
|
|
|
|
if(has(this._options.eventsCallbacks, 'zoomIn')) { |
|
|
|
|
this._options.eventsCallbacks.zoomIn(ranges); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
callbackZoomOut(centers: { x: number, y: number }): void { |
|
|
|
|
if(has(this._options.events, 'zoomOut')) { |
|
|
|
|
this._options.events.zoomOut(centers); |
|
|
|
|
if(has(this._options.eventsCallbacks, 'zoomOut')) { |
|
|
|
|
this._options.eventsCallbacks.zoomOut(centers); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
callbackSharedCrosshairMove(event: { datapoints, eventX, eventY }): void { |
|
|
|
|
if(has(this._options.events, 'sharedCrosshairMove')) { |
|
|
|
|
this._options.events.sharedCrosshairMove(event); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
callbackMouseOver(): void { |
|
|
|
|
if(has(this._options.events, 'mouseOver')) { |
|
|
|
|
this._options.events.mouseOver(); |
|
|
|
|
if(has(this._options.eventsCallbacks, 'sharedCrosshairMove')) { |
|
|
|
|
this._options.eventsCallbacks.sharedCrosshairMove(event); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
callbackMouseMove(event): void { |
|
|
|
|
if(has(this._options.events, 'mouseMove')) { |
|
|
|
|
this._options.events.mouseMove(event); |
|
|
|
|
if(has(this._options.eventsCallbacks, 'mouseMove')) { |
|
|
|
|
this._options.eventsCallbacks.mouseMove(event); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
callbackMouseOut(): void { |
|
|
|
|
if(has(this._options.events, 'mouseOut')) { |
|
|
|
|
this._options.events.mouseOut(); |
|
|
|
|
if(has(this._options.eventsCallbacks, 'mouseOut')) { |
|
|
|
|
this._options.eventsCallbacks.mouseOut(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
callbackMouseClick(event): void { |
|
|
|
|
if(has(this._options.events, 'mouseClick')) { |
|
|
|
|
this._options.events.mouseClick(event); |
|
|
|
|
if(has(this._options.eventsCallbacks, 'mouseClick')) { |
|
|
|
|
this._options.eventsCallbacks.mouseClick(event); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|