Browse Source

fix core

pull/2/head
vargburz 3 years ago
parent
commit
b314ff21ef
  1. 6
      src/index.ts
  2. 10
      src/models/options.ts
  3. 10
      src/models/series.ts

6
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<T extends Serie, O extends Options> {
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,

10
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<O extends Options> {
_options: O;
_coreDefaults: Options = DEFAULT_OPTIONS;
protected podDefaults?: Partial<O>;
constructor(options: O) {
this.setOptions(options);
@ -110,12 +110,12 @@ export class CoreOptions<O extends Options> {
}
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<O> {
return lodashDefaultsDeep(this.podDefaults, CORE_DEFAULT_OPTIONS);
}
get allOptions(): O {

10
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<T extends Serie> {
_series: Array<T> = [];
_coreDefaults: Serie = SERIE_DEFAULTS;
protected podDefaults?: Partial<T>;
constructor(series: T[]) {
this.setSeries(series);
@ -51,7 +51,7 @@ export class CoreSeries<T extends Serie> {
}
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<T extends Serie> {
}
// this getter can be overrited in Pod
protected get defaults(): Serie {
return this._coreDefaults;
protected getDefaults(): Partial<T> {
return lodashDefaultsDeep(this.podDefaults, CORE_SERIE_DEFAULTS);
}
private _isSerieEmpty(serie: T): boolean {

Loading…
Cancel
Save