fix(type): more precise axis types
diff --git a/src/component/marker/MarkLineView.ts b/src/component/marker/MarkLineView.ts
index 212ce68..07335a1 100644
--- a/src/component/marker/MarkLineView.ts
+++ b/src/component/marker/MarkLineView.ts
@@ -41,7 +41,6 @@
logError,
merge,
map,
- defaults,
curry,
filter,
HashMap
diff --git a/src/coord/Axis.ts b/src/coord/Axis.ts
index a2f3e0a..7a334a0 100644
--- a/src/coord/Axis.ts
+++ b/src/coord/Axis.ts
@@ -28,7 +28,7 @@
import { DimensionName, ScaleDataValue, ScaleTick } from '../util/types';
import OrdinalScale from '../scale/Ordinal';
import Model from '../model/Model';
-import { AxisBaseOption, OptionAxisType } from './axisCommonTypes';
+import { AxisBaseOption, CategoryAxisBaseOption, OptionAxisType } from './axisCommonTypes';
import { AxisBaseModel } from './AxisBaseModel';
const NORMALIZED_EXTENT = [0, 1] as [number, number];
@@ -63,7 +63,7 @@
// Injected outside
model: AxisBaseModel;
- onBand: AxisBaseOption['boundaryGap'] = false;
+ onBand: CategoryAxisBaseOption['boundaryGap'] = false;
inverse: AxisBaseOption['inverse'] = false;
diff --git a/src/coord/AxisBaseModel.ts b/src/coord/AxisBaseModel.ts
index 18cd29a..9b482f0 100644
--- a/src/coord/AxisBaseModel.ts
+++ b/src/coord/AxisBaseModel.ts
@@ -20,16 +20,16 @@
/**
* Base Axis Model for xAxis, yAxis, angleAxis, radiusAxis. singleAxis
*/
-import { AxisBaseOption } from './axisCommonTypes';
+import { AxisBaseOptionCommon } from './axisCommonTypes';
import ComponentModel from '../model/Component';
import { AxisModelCommonMixin } from './axisModelCommonMixin';
import { AxisModelExtendedInCreator } from './axisModelCreator';
import Axis from './Axis';
-export interface AxisBaseModel<T extends AxisBaseOption = AxisBaseOption>
+export interface AxisBaseModel<T extends AxisBaseOptionCommon = AxisBaseOptionCommon>
extends ComponentModel<T>,
AxisModelCommonMixin<T>,
- AxisModelExtendedInCreator<T> {
+ AxisModelExtendedInCreator {
axis: Axis
}
\ No newline at end of file
diff --git a/src/coord/axisCommonTypes.ts b/src/coord/axisCommonTypes.ts
index 9d9bf11..3fe8999 100644
--- a/src/coord/axisCommonTypes.ts
+++ b/src/coord/axisCommonTypes.ts
@@ -20,16 +20,15 @@
import {
TextCommonOption, LineStyleOption, OrdinalRawValue, ZRColor,
AreaStyleOption, ComponentOption, ColorString,
- AnimationOptionMixin, Dictionary, ScaleDataValue
+ AnimationOptionMixin, Dictionary, ScaleDataValue, CommonAxisPointerOption
} from '../util/types';
export const AXIS_TYPES = {value: 1, category: 1, time: 1, log: 1} as const;
export type OptionAxisType = keyof typeof AXIS_TYPES;
-
-export interface AxisBaseOption extends ComponentOption,
- AnimationOptionMixin { // Support transition animation
+export interface AxisBaseOptionCommon extends ComponentOption,
+ AnimationOptionMixin {
type?: OptionAxisType;
show?: boolean;
// Inverse the axis.
@@ -55,21 +54,16 @@
show?: boolean;
};
- axisPointer?: any; // FIXME:TS axisPointerOption type?
+ axisLabel?: AxisLabelBaseOption;
+
+ axisPointer?: CommonAxisPointerOption;
axisLine?: AxisLineOption;
axisTick?: AxisTickOption;
- axisLabel?: AxisLabelOption;
minorTick?: MinorTickOption;
splitLine?: SplitLineOption;
minorSplitLine?: MinorSplitLineOption;
splitArea?: SplitAreaOption;
- // The gap at both ends of the axis.
- // For category axis: boolean.
- // For value axis: [GAP, GAP], where
- // `GAP` can be an absolute pixel number (like `35`), or percent (like `'30%'`)
- boundaryGap?: boolean | [number | string, number | string];
-
// Min value of the axis. can be:
// + ScaleDataValue
// + 'dataMin': use the min value in data.
@@ -85,43 +79,74 @@
// + `true`: the extent do not consider value 0.
scale?: boolean;
+}
- // --------------------------------------------
- // [Properties below only for 'category' axis]:
+interface NumericAxisBaseOptionCommon extends AxisBaseOptionCommon {
+ /*
+ * The gap at both ends of the axis.
+ * [GAP, GAP], where
+ * `GAP` can be an absolute pixel number (like `35`), or percent (like `'30%'`)
+ */
+ boundaryGap?: [number | string, number | string]
- // Set false to faster category collection.
- // Only usefull in the case like: category is
- // ['2012-01-01', '2012-01-02', ...], where the input
- // data has been ensured not duplicate and is large data.
- // null means "auto":
- // if axis.data provided, do not deduplication,
- // else do deduplication.
- deduplication?: boolean;
+ /**
+ * AxisTick and axisLabel and splitLine are caculated based on splitNumber.
+ */
+ splitNumber?: number;
+ /**
+ * Interval specifies the span of the ticks is mandatorily.
+ */
+ interval?: number;
+ /**
+ * Specify min interval when auto calculate tick interval.
+ */
+ minInterval?: number;
+ /**
+ * Specify max interval when auto calculate tick interval.
+ */
+ maxInterval?: number;
+}
+
+export interface CategoryAxisBaseOption extends AxisBaseOptionCommon {
+ type?: 'category';
+ boundaryGap?: boolean
+ axisLabel?: AxisLabelOption<'category'> & {
+ interval?: 'auto' | number | ((index: number, value: string) => boolean)
+ };
data?: (OrdinalRawValue | {
value: OrdinalRawValue;
textStyle?: TextCommonOption;
})[];
+ /*
+ * Set false to faster category collection.
+ * Only usefull in the case like: category is
+ * ['2012-01-01', '2012-01-02', ...], where the input
+ * data has been ensured not duplicate and is large data.
+ * null means "auto":
+ * if axis.data provided, do not deduplication,
+ * else do deduplication.
+ */
+ deduplication?: boolean;
-
- // ------------------------------------------------------
- // [Properties below only for 'value'/'log'/'time' axes]:
-
- // AxisTick and axisLabel and splitLine are caculated based on splitNumber.
- splitNumber?: number;
- // Interval specifies the span of the ticks is mandatorily.
- interval?: number;
- // Specify min interval when auto calculate tick interval.
- minInterval?: number;
- // Specify max interval when auto calculate tick interval.
- maxInterval?: number;
-
-
- // ---------------------------------------
- // [Properties below only for 'log' axis]:
-
+ axisTick?: AxisBaseOptionCommon['axisTick'] & {
+ // If tick is align with label when boundaryGap is true
+ alignWithLabel?: boolean,
+ interval?: 'auto' | number | ((index: number, value: string) => boolean)
+ }
+}
+export interface ValueAxisBaseOption extends NumericAxisBaseOptionCommon {
+ type?: 'value';
+ axisLabel?: AxisLabelOption<'value'>;
+}
+export interface LogAxisBaseOption extends NumericAxisBaseOptionCommon {
+ type?: 'log';
+ axisLabel?: AxisLabelOption<'log'>;
logBase?: number;
}
-
+export interface TimeAxisBaseOption extends NumericAxisBaseOptionCommon {
+ type?: 'time';
+ axisLabel?: AxisLabelOption<'time'>;
+}
interface AxisNameTextStyleOption extends TextCommonOption {
rich?: Dictionary<TextCommonOption>
}
@@ -147,15 +172,13 @@
// --------------------------------------------
// [Properties below only for 'category' axis]:
-
- // If tick is align with label when boundaryGap is true
- alignWithLabel?: boolean,
- interval?: 'auto' | number | ((index: number, value: string) => boolean)
}
-export type AxisLabelFormatterOption = string | ((value: OrdinalRawValue | number, index: number) => string);
+type AxisLabelValueFormatter = (value: number, index: number) => string;
+type AxisLabelCategoryFormatter = (value: string, index: number) => string;
-type TimeAxisLabelUnitFormatter = AxisLabelFormatterOption | string[];
+// export type AxisLabelFormatterOption = string | ((value: OrdinalRawValue | number, index: number) => string);
+type TimeAxisLabelUnitFormatter = AxisLabelValueFormatter | string[] | string;
export type TimeAxisLabelFormatterOption = string
| ((value: number, index: number, extra: {level: number}) => string)
@@ -171,7 +194,14 @@
inherit?: boolean
};
-interface AxisLabelOption extends Omit<TextCommonOption, 'color'> {
+type LabelFormatters = {
+ value: AxisLabelValueFormatter | string
+ log: AxisLabelValueFormatter | string
+ category: AxisLabelCategoryFormatter | string
+ time: TimeAxisLabelFormatterOption
+};
+
+interface AxisLabelBaseOption extends Omit<TextCommonOption, 'color'> {
show?: boolean,
// Whether axisLabel is inside the grid or outside the grid.
inside?: boolean,
@@ -181,18 +211,13 @@
// true | false | null/undefined (auto)
showMaxLabel?: boolean,
margin?: number,
- // value is supposed to be OptionDataPrimitive but for time axis, it is time stamp.
- formatter?: AxisLabelFormatterOption | TimeAxisLabelFormatterOption,
-
- // --------------------------------------------
- // [Properties below only for 'category' axis]:
-
- interval?: 'auto' | number | ((index: number, value: string) => boolean)
+ rich?: Dictionary<TextCommonOption>
// Color can be callback
color?: ColorString | ((value?: string | number, index?: number) => ColorString)
-
- rich?: Dictionary<TextCommonOption>
+}
+interface AxisLabelOption<TType extends OptionAxisType> extends AxisLabelBaseOption {
+ formatter?: LabelFormatters[TType]
}
interface MinorTickOption {
@@ -220,3 +245,7 @@
// colors will display in turn
areaStyle?: AreaStyleOption<ZRColor[]>
}
+
+
+export type AxisBaseOption = ValueAxisBaseOption | LogAxisBaseOption
+ | CategoryAxisBaseOption | TimeAxisBaseOption | AxisBaseOptionCommon;
diff --git a/src/coord/axisHelper.ts b/src/coord/axisHelper.ts
index d058db3..53a60b6 100644
--- a/src/coord/axisHelper.ts
+++ b/src/coord/axisHelper.ts
@@ -33,7 +33,13 @@
import { AxisBaseModel } from './AxisBaseModel';
import LogScale from '../scale/Log';
import Axis from './Axis';
-import { AxisBaseOption, TimeAxisLabelFormatterOption } from './axisCommonTypes';
+import {
+ AxisBaseOption,
+ CategoryAxisBaseOption,
+ LogAxisBaseOption,
+ TimeAxisLabelFormatterOption,
+ ValueAxisBaseOption
+} from './axisCommonTypes';
import type CartesianAxisModel from './cartesian/AxisModel';
import SeriesData from '../data/SeriesData';
import { getStackedDimension } from '../data/helper/dataStackHelper';
@@ -143,7 +149,8 @@
// Precondition of calling this method:
// The scale extent has been initailized using series data extent via
// `scale.setExtent` or `scale.unionExtentFromData`;
-export function niceScaleExtent(scale: Scale, model: AxisBaseModel) {
+export function niceScaleExtent(scale: Scale, inModel: AxisBaseModel) {
+ const model = inModel as AxisBaseModel<LogAxisBaseOption>;
const extentInfo = getScaleExtent(scale, model);
const extent = extentInfo.extent;
const splitNumber = model.get('splitNumber');
@@ -221,7 +228,8 @@
* return: {string} label string.
*/
export function makeLabelFormatter(axis: Axis): (tick: ScaleTick, idx?: number) => string {
- const labelFormatter = axis.getLabelModel().get('formatter');
+ const labelFormatter = (axis.getLabelModel() as Model<ValueAxisBaseOption['axisLabel']>)
+ .get('formatter');
const categoryTickStart = axis.type === 'category' ? axis.scale.getExtent()[0] : null;
if (axis.scale.type === 'time') {
@@ -263,7 +271,7 @@
} : null
);
};
- })(labelFormatter);
+ })(labelFormatter as (...args: any[]) => string);
}
else {
return function (tick: ScaleTick) {
@@ -347,7 +355,7 @@
* @return {number|String} Can be null|'auto'|number|function
*/
export function getOptionCategoryInterval(model: Model<AxisBaseOption['axisLabel']>) {
- const interval = model.get('interval');
+ const interval = (model as Model<CategoryAxisBaseOption['axisLabel']>).get('interval');
return interval == null ? 'auto' : interval;
}
diff --git a/src/coord/axisModelCreator.ts b/src/coord/axisModelCreator.ts
index 5d275ee..f7d8072 100644
--- a/src/coord/axisModelCreator.ts
+++ b/src/coord/axisModelCreator.ts
@@ -26,7 +26,7 @@
} from '../util/layout';
import OrdinalMeta from '../data/OrdinalMeta';
import { DimensionName, BoxLayoutOptionMixin, OrdinalRawValue } from '../util/types';
-import { AxisBaseOption, AXIS_TYPES } from './axisCommonTypes';
+import { AxisBaseOption, AXIS_TYPES, CategoryAxisBaseOption } from './axisCommonTypes';
import GlobalModel from '../model/Global';
import { each, merge } from 'zrender/src/core/util';
import { EChartsExtensionInstallRegisters } from '../extension';
@@ -34,8 +34,8 @@
type Constructor<T> = new (...args: any[]) => T;
-export interface AxisModelExtendedInCreator<Opt extends AxisBaseOption> {
- getCategories(rawData?: boolean): OrdinalRawValue[] | Opt['data']
+export interface AxisModelExtendedInCreator {
+ getCategories(rawData?: boolean): OrdinalRawValue[] | CategoryAxisBaseOption['data']
getOrdinalMeta(): OrdinalMeta
}
@@ -60,7 +60,7 @@
extraDefaultOption, true
);
- class AxisModel extends BaseAxisModelClass implements AxisModelExtendedInCreator<AxisOptionT> {
+ class AxisModel extends BaseAxisModelClass implements AxisModelExtendedInCreator {
static type = axisName + 'Axis.' + axisType;
type = axisName + 'Axis.' + axisType;
@@ -97,13 +97,13 @@
* Should not be called before all of 'getInitailData' finished.
* Because categories are collected during initializing data.
*/
- getCategories(rawData?: boolean): OrdinalRawValue[] | AxisBaseOption['data'] {
+ getCategories(rawData?: boolean): OrdinalRawValue[] | CategoryAxisBaseOption['data'] {
const option = this.option;
// FIXME
// warning if called before all of 'getInitailData' finished.
if (option.type === 'category') {
if (rawData) {
- return option.data as AxisBaseOption['data'];
+ return (option as CategoryAxisBaseOption).data;
}
return this.__ordinalMeta.categories;
}
@@ -125,5 +125,5 @@
function getAxisType(option: AxisBaseOption) {
// Default axis with data is category axis
- return option.type || (option.data ? 'category' : 'value');
+ return option.type || ((option as CategoryAxisBaseOption).data ? 'category' : 'value');
}
diff --git a/src/coord/cartesian/AxisModel.ts b/src/coord/cartesian/AxisModel.ts
index 076b1c1..726e0fa 100644
--- a/src/coord/cartesian/AxisModel.ts
+++ b/src/coord/cartesian/AxisModel.ts
@@ -31,21 +31,21 @@
export type CartesianAxisPosition = 'top' | 'bottom' | 'left' | 'right';
-export interface CartesianAxisOption extends AxisBaseOption {
+export type CartesianAxisOption = AxisBaseOption & {
gridIndex?: number;
gridId?: string;
position?: CartesianAxisPosition;
// Offset is for multiple axis on the same position.
offset?: number;
categorySortInfo?: OrdinalSortInfo;
-}
+};
-export interface XAXisOption extends CartesianAxisOption {
+export type XAXisOption = CartesianAxisOption & {
mainType?: 'xAxis'
-}
-export interface YAXisOption extends CartesianAxisOption {
+};
+export type YAXisOption = CartesianAxisOption & {
mainType?: 'yAxis'
-}
+};
export class CartesianAxisModel extends ComponentModel<CartesianAxisOption>
implements AxisBaseModel<CartesianAxisOption> {
@@ -60,7 +60,7 @@
}
export interface CartesianAxisModel extends AxisModelCommonMixin<CartesianAxisOption>,
- AxisModelExtendedInCreator<CartesianAxisOption> {}
+ AxisModelExtendedInCreator {}
zrUtil.mixin(CartesianAxisModel, AxisModelCommonMixin);
diff --git a/src/coord/cartesian/Grid.ts b/src/coord/cartesian/Grid.ts
index 6eef23e..aba0b73 100644
--- a/src/coord/cartesian/Grid.ts
+++ b/src/coord/cartesian/Grid.ts
@@ -47,6 +47,8 @@
import SeriesData from '../../data/SeriesData';
import OrdinalScale from '../../scale/Ordinal';
import { isCartesian2DSeries, findAxisModels } from './cartesianAxisHelper';
+import { CategoryAxisBaseOption } from '../axisCommonTypes';
+import { AxisBaseModel } from '../AxisBaseModel';
type Cartesian2DDimensionName = 'x' | 'y';
@@ -388,7 +390,7 @@
);
const isCategory = axis.type === 'category';
- axis.onBand = isCategory && axisModel.get('boundaryGap');
+ axis.onBand = isCategory && (axisModel as AxisBaseModel<CategoryAxisBaseOption>).get('boundaryGap');
axis.inverse = axisModel.get('inverse');
// Inject axis into axisModel
diff --git a/src/coord/parallel/AxisModel.ts b/src/coord/parallel/AxisModel.ts
index 31beb29..877dbae 100644
--- a/src/coord/parallel/AxisModel.ts
+++ b/src/coord/parallel/AxisModel.ts
@@ -40,7 +40,7 @@
width: number;
};
-export interface ParallelAxisOption extends AxisBaseOption {
+export type ParallelAxisOption = AxisBaseOption & {
/**
* 0, 1, 2, ...
*/
@@ -55,7 +55,7 @@
};
// Whether realtime update view when select.
realtime?: boolean;
-}
+};
class ParallelAxisModel extends ComponentModel<ParallelAxisOption> {
@@ -140,7 +140,7 @@
}
interface ParallelAxisModel extends AxisModelCommonMixin<ParallelAxisOption>,
- AxisModelExtendedInCreator<ParallelAxisOption> {}
+ AxisModelExtendedInCreator {}
zrUtil.mixin(ParallelAxisModel, AxisModelCommonMixin);
diff --git a/src/coord/parallel/Parallel.ts b/src/coord/parallel/Parallel.ts
index e22cf9a..f8c472d 100644
--- a/src/coord/parallel/Parallel.ts
+++ b/src/coord/parallel/Parallel.ts
@@ -38,6 +38,8 @@
import { CoordinateSystem, CoordinateSystemMaster } from '../CoordinateSystem';
import ParallelAxisModel, { ParallelActiveState } from './AxisModel';
import SeriesData from '../../data/SeriesData';
+import { AxisBaseModel } from '../AxisBaseModel';
+import { CategoryAxisBaseOption } from '../axisCommonTypes';
const each = zrUtil.each;
const mathMin = Math.min;
@@ -131,7 +133,8 @@
));
const isCategory = axis.type === 'category';
- axis.onBand = isCategory && axisModel.get('boundaryGap');
+ axis.onBand = isCategory
+ && (axisModel as AxisBaseModel<CategoryAxisBaseOption>).get('boundaryGap');
axis.inverse = axisModel.get('inverse');
// Injection
diff --git a/src/coord/polar/AxisModel.ts b/src/coord/polar/AxisModel.ts
index 2afbc3c..af2414a 100644
--- a/src/coord/polar/AxisModel.ts
+++ b/src/coord/polar/AxisModel.ts
@@ -27,7 +27,7 @@
import { AxisBaseModel } from '../AxisBaseModel';
import { SINGLE_REFERRING } from '../../util/model';
-export interface AngleAxisOption extends AxisBaseOption {
+export type AngleAxisOption = AxisBaseOption & {
mainType?: 'angleAxis';
/**
* Index of host polar component
@@ -41,12 +41,10 @@
startAngle?: number;
clockwise?: boolean;
- splitNumber?: number;
-
axisLabel?: AxisBaseOption['axisLabel']
-}
+};
-export interface RadiusAxisOption extends AxisBaseOption {
+export type RadiusAxisOption = AxisBaseOption & {
mainType?: 'radiusAxis';
/**
* Index of host polar component
@@ -56,7 +54,7 @@
* Id of host polar component
*/
polarId?: string;
-}
+};
type PolarAxisOption = AngleAxisOption | RadiusAxisOption;
@@ -72,7 +70,7 @@
}
interface PolarAxisModel<T extends PolarAxisOption = PolarAxisOption>
- extends AxisModelCommonMixin<T>, AxisModelExtendedInCreator<T> {}
+ extends AxisModelCommonMixin<T>, AxisModelExtendedInCreator {}
zrUtil.mixin(PolarAxisModel, AxisModelCommonMixin);
diff --git a/src/coord/polar/polarCreator.ts b/src/coord/polar/polarCreator.ts
index 69feeca..4df310c 100644
--- a/src/coord/polar/polarCreator.ts
+++ b/src/coord/polar/polarCreator.ts
@@ -38,6 +38,8 @@
import SeriesModel from '../../model/Series';
import { SeriesOption } from '../../util/types';
import { SINGLE_REFERRING } from '../../util/model';
+import { AxisBaseModel } from '../AxisBaseModel';
+import { CategoryAxisBaseOption } from '../axisCommonTypes';
/**
* Resize method bound to the polar
@@ -115,7 +117,8 @@
function setAxis(axis: RadiusAxis | AngleAxis, axisModel: PolarAxisModel) {
axis.type = axisModel.get('type');
axis.scale = createScaleByModel(axisModel);
- axis.onBand = axisModel.get('boundaryGap') && axis.type === 'category';
+ axis.onBand = (axisModel as AxisBaseModel<CategoryAxisBaseOption>).get('boundaryGap')
+ && axis.type === 'category';
axis.inverse = axisModel.get('inverse');
if (isAngleAxisModel(axisModel)) {
diff --git a/src/coord/radar/RadarModel.ts b/src/coord/radar/RadarModel.ts
index 1144ab0..cdcd3e8 100644
--- a/src/coord/radar/RadarModel.ts
+++ b/src/coord/radar/RadarModel.ts
@@ -28,7 +28,7 @@
LabelOption,
ColorString
} from '../../util/types';
-import { AxisBaseOption } from '../axisCommonTypes';
+import { AxisBaseOption, CategoryAxisBaseOption, ValueAxisBaseOption } from '../axisCommonTypes';
import { AxisBaseModel } from '../AxisBaseModel';
import Radar from './Radar';
import {CoordinateSystemHostModel} from '../../coord/CoordinateSystem';
@@ -79,15 +79,16 @@
scale?: boolean
splitNumber?: number
- boundaryGap?: AxisBaseOption['boundaryGap']
+ boundaryGap?: CategoryAxisBaseOption['boundaryGap']
+ | ValueAxisBaseOption['boundaryGap']
indicator?: RadarIndicatorOption[]
}
-export interface InnerIndicatorAxisOption extends AxisBaseOption {
+export type InnerIndicatorAxisOption = AxisBaseOption & {
// TODO Use type?
// axisType?: 'value' | 'log'
-}
+};
class RadarModel extends ComponentModel<RadarOption> implements CoordinateSystemHostModel {
static readonly type = 'radar';
diff --git a/src/coord/scaleRawExtentInfo.ts b/src/coord/scaleRawExtentInfo.ts
index 5a0abb6..45d2dc7 100644
--- a/src/coord/scaleRawExtentInfo.ts
+++ b/src/coord/scaleRawExtentInfo.ts
@@ -21,7 +21,7 @@
import Scale from '../scale/Scale';
import { AxisBaseModel } from './AxisBaseModel';
import { parsePercent } from 'zrender/src/contain/text';
-import { AxisBaseOption } from './axisCommonTypes';
+import { AxisBaseOption, CategoryAxisBaseOption } from './axisCommonTypes';
import { ScaleDataValue } from '../util/types';
@@ -129,7 +129,7 @@
this._axisDataLen = model.getCategories().length;
}
else {
- const boundaryGap = model.get('boundaryGap');
+ const boundaryGap = (model as AxisBaseModel<CategoryAxisBaseOption>).get('boundaryGap');
const boundaryGapArr = isArray(boundaryGap)
? boundaryGap : [boundaryGap || 0, boundaryGap || 0];
diff --git a/src/coord/single/AxisModel.ts b/src/coord/single/AxisModel.ts
index 7f76138..bcd8526 100644
--- a/src/coord/single/AxisModel.ts
+++ b/src/coord/single/AxisModel.ts
@@ -29,11 +29,11 @@
export type SingleAxisPosition = 'top' | 'bottom' | 'left' | 'right';
-export interface SingleAxisOption extends AxisBaseOption, BoxLayoutOptionMixin {
+export type SingleAxisOption = AxisBaseOption & BoxLayoutOptionMixin & {
mainType?: 'singleAxis'
position?: SingleAxisPosition
orient?: LayoutOrient
-}
+};
class SingleAxisModel extends ComponentModel<SingleAxisOption>
implements AxisBaseModel<SingleAxisOption> {
@@ -102,7 +102,7 @@
}
interface SingleAxisModel extends AxisModelCommonMixin<SingleAxisOption>,
- AxisModelExtendedInCreator<SingleAxisOption> {}
+ AxisModelExtendedInCreator {}
mixin(SingleAxisModel, AxisModelCommonMixin.prototype);
diff --git a/src/coord/single/Single.ts b/src/coord/single/Single.ts
index 5ad4031..4632190 100644
--- a/src/coord/single/Single.ts
+++ b/src/coord/single/Single.ts
@@ -32,6 +32,8 @@
import SingleAxisModel from './AxisModel';
import { ParsedModelFinder, ParsedModelFinderKnown } from '../../util/model';
import { ScaleDataValue } from '../../util/types';
+import { AxisBaseModel } from '../AxisBaseModel';
+import { CategoryAxisBaseOption } from '../axisCommonTypes';
export const singleDimensions = ['single'];
/**
@@ -80,7 +82,7 @@
);
const isCategory = axis.type === 'category';
- axis.onBand = isCategory && axisModel.get('boundaryGap');
+ axis.onBand = isCategory && (axisModel as AxisBaseModel<CategoryAxisBaseOption>).get('boundaryGap');
axis.inverse = axisModel.get('inverse');
axis.orient = axisModel.get('orient');
diff --git a/src/scale/Ordinal.ts b/src/scale/Ordinal.ts
index 7f23c2d..01139da 100644
--- a/src/scale/Ordinal.ts
+++ b/src/scale/Ordinal.ts
@@ -36,11 +36,11 @@
OrdinalScaleTick,
ScaleTick
} from '../util/types';
-import { AxisBaseOption } from '../coord/axisCommonTypes';
+import { CategoryAxisBaseOption } from '../coord/axisCommonTypes';
import { isArray, map, isObject } from 'zrender/src/core/util';
type OrdinalScaleSetting = {
- ordinalMeta?: OrdinalMeta | AxisBaseOption['data'];
+ ordinalMeta?: OrdinalMeta | CategoryAxisBaseOption['data'];
extent?: [number, number];
};