From b314ff21ef60af76b3a080f0a365a97ff0ceda3b Mon Sep 17 00:00:00 2001 From: vargburz Date: Fri, 27 May 2022 20:54:48 +0300 Subject: [PATCH] fix core --- src/index.ts | 6 +++--- src/models/options.ts | 10 +++++----- src/models/series.ts | 10 +++++----- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/index.ts b/src/index.ts index db69bba..e763f1b 100644 --- a/src/index.ts +++ b/src/index.ts @@ -2,8 +2,8 @@ import VueChartwerkPodMixin from './VueChartwerkPodMixin'; import { Grid } from './components/grid'; import { PodState } from './models/state'; -import { CoreSeries } from './models/series'; -import { CoreOptions } from './models/options'; +import { CoreSeries, CORE_SERIE_DEFAULTS } from './models/series'; +import { CoreOptions, CORE_DEFAULT_OPTIONS } from './models/options'; import styles from './css/style.css'; @@ -888,7 +888,7 @@ abstract class ChartwerkPod { export { ChartwerkPod, VueChartwerkPodMixin, - PodState, CoreSeries, CoreOptions, + PodState, CoreSeries, CoreOptions, CORE_SERIE_DEFAULTS, CORE_DEFAULT_OPTIONS, Margin, Serie, Options, TimeFormat, BrushOrientation, PanOrientation, AxesOptions, AxisOption, AxisFormat, yAxisOrientation, CrosshairOrientation, ScrollPanOrientation, ScrollPanDirection, KeyEvent, diff --git a/src/models/options.ts b/src/models/options.ts index ea2cf3d..b668691 100644 --- a/src/models/options.ts +++ b/src/models/options.ts @@ -52,7 +52,7 @@ const DEFAULT_CROSSHAIR_OPTIONS = { const DEFAULT_MARGIN: Margin = { top: 30, right: 20, bottom: 20, left: 30 }; -const DEFAULT_OPTIONS: Options = { +export const CORE_DEFAULT_OPTIONS: Options = { zoomEvents: { mouse: { zoom: { @@ -99,7 +99,7 @@ const DEFAULT_OPTIONS: Options = { export class CoreOptions { _options: O; - _coreDefaults: Options = DEFAULT_OPTIONS; + protected podDefaults?: Partial; constructor(options: O) { this.setOptions(options); @@ -110,12 +110,12 @@ export class CoreOptions { } protected setOptions(options: O): void { - this._options = lodashDefaultsDeep(lodashCloneDeep(options), this.defaults); + this._options = lodashDefaultsDeep(lodashCloneDeep(options), this.getDefaults()); } // this getter can be overrited in Pod - protected get defaults(): Options { - return this._coreDefaults; + protected getDefaults(): Partial { + return lodashDefaultsDeep(this.podDefaults, CORE_DEFAULT_OPTIONS); } get allOptions(): O { diff --git a/src/models/series.ts b/src/models/series.ts index 7028130..ac38bbe 100644 --- a/src/models/series.ts +++ b/src/models/series.ts @@ -13,7 +13,7 @@ import lodashIsNil from 'lodash/isNil'; import lodashIncludes from 'lodash/includes'; -const SERIE_DEFAULTS = { +export const CORE_SERIE_DEFAULTS = { alias: '', target: '', visible: true, @@ -27,7 +27,7 @@ const SERIE_DEFAULTS = { export class CoreSeries { _series: Array = []; - _coreDefaults: Serie = SERIE_DEFAULTS; + protected podDefaults?: Partial; constructor(series: T[]) { this.setSeries(series); @@ -51,7 +51,7 @@ export class CoreSeries { } protected fillDefaults(serie: T, idx: number): T { - let defaults = lodashCloneDeep(this.defaults); + let defaults = lodashCloneDeep(this.getDefaults()); defaults.color = palette[idx % palette.length]; defaults.idx = idx; lodashDefaultsDeep(serie, defaults); @@ -59,8 +59,8 @@ export class CoreSeries { } // this getter can be overrited in Pod - protected get defaults(): Serie { - return this._coreDefaults; + protected getDefaults(): Partial { + return lodashDefaultsDeep(this.podDefaults, CORE_SERIE_DEFAULTS); } private _isSerieEmpty(serie: T): boolean {