This is an automated email from the ASF dual-hosted git repository.

sushuang pushed a commit to branch typescript
in repository https://gitbox.apache.org/repos/asf/incubator-echarts.git


The following commit(s) were added to refs/heads/typescript by this push:
     new b479abe  strick axis type
b479abe is described below

commit b479abe409a3b4a95e4425323998cda2ecf9a734
Author: 100pah <sushuang0...@gmail.com>
AuthorDate: Sat Feb 22 05:55:21 2020 +0800

    strick axis type
---
 src/coord/axisCommonTypes.ts     |  3 +++
 src/coord/axisModelCreator.ts    | 12 +++++++++---
 src/coord/cartesian/Axis2D.ts    | 12 ++++++------
 src/coord/cartesian/AxisModel.ts |  9 ++++-----
 4 files changed, 22 insertions(+), 14 deletions(-)

diff --git a/src/coord/axisCommonTypes.ts b/src/coord/axisCommonTypes.ts
index 218d681..994a1f0 100644
--- a/src/coord/axisCommonTypes.ts
+++ b/src/coord/axisCommonTypes.ts
@@ -24,7 +24,10 @@ import {
 import { Dictionary } from 'zrender/src/core/types';
 
 
+export type OptionAxisType = 'category' | 'value' | 'time' | 'log';
+
 export interface AxisBaseOption extends ComponentOption {
+    type?: OptionAxisType;
     show?: boolean;
     // Inverse the axis.
     inverse?: boolean;
diff --git a/src/coord/axisModelCreator.ts b/src/coord/axisModelCreator.ts
index 3d18cd2..1d3ec6f 100644
--- a/src/coord/axisModelCreator.ts
+++ b/src/coord/axisModelCreator.ts
@@ -23,11 +23,12 @@ import * as zrUtil from 'zrender/src/core/util';
 import axisDefault from './axisDefault';
 import ComponentModel from '../model/Component';
 import {
-    getLayoutMode,
     getLayoutParams,
     mergeLayoutParam
 } from '../util/layout';
 import OrdinalMeta from '../data/OrdinalMeta';
+import { DimensionName, ComponentOption } from '../util/types';
+import { OptionAxisType } from './axisCommonTypes';
 
 
 // FIXME axisType is fixed ?
@@ -35,12 +36,17 @@ var AXIS_TYPES = ['value', 'category', 'time', 'log'];
 
 /**
  * Generate sub axis model class
- * @param {string} axisName 'x' 'y' 'radius' 'angle' 'parallel'
+ * @param axisName 'x' 'y' 'radius' 'angle' 'parallel'
  * @param {module:echarts/model/Component} BaseAxisModelClass
  * @param {Function} axisTypeDefaulter
  * @param {Object} [extraDefaultOption]
  */
-export default function (axisName, BaseAxisModelClass, axisTypeDefaulter, 
extraDefaultOption) {
+export default function (
+    axisName: DimensionName,
+    BaseAxisModelClass,
+    axisTypeDefaulter: (axisDim: DimensionName, option: ComponentOption) => 
OptionAxisType,
+    extraDefaultOption?: ComponentOption
+) {
 
     zrUtil.each(AXIS_TYPES, function (axisType) {
 
diff --git a/src/coord/cartesian/Axis2D.ts b/src/coord/cartesian/Axis2D.ts
index 5ad1fcc..8abf3bb 100644
--- a/src/coord/cartesian/Axis2D.ts
+++ b/src/coord/cartesian/Axis2D.ts
@@ -20,8 +20,9 @@
 import Axis from '../Axis';
 import { DimensionName } from '../../util/types';
 import Scale from '../../scale/Scale';
-import AxisModel, { Axis2DPosition } from './AxisModel';
+import AxisModel, { CartesianAxisPosition } from './AxisModel';
 import Grid from './Grid';
+import { OptionAxisType } from '../axisCommonTypes';
 
 
 class Axis2D extends Axis {
@@ -32,9 +33,8 @@ class Axis2D extends Axis {
      *  - 'value'
      *  - 'time'
      *  - 'log'
-     *  ...
      */
-    readonly type: string;
+    readonly type: OptionAxisType;
 
     /**
      * Axis position
@@ -43,7 +43,7 @@ class Axis2D extends Axis {
      *  - 'left'
      *  - 'right'
      */
-    readonly position: Axis2DPosition;
+    readonly position: CartesianAxisPosition;
 
     /**
      * Index of axis, can be used as key
@@ -66,8 +66,8 @@ class Axis2D extends Axis {
         dim: DimensionName,
         scale: Scale,
         coordExtent: [number, number],
-        axisType?: string,
-        position?: Axis2DPosition
+        axisType?: OptionAxisType,
+        position?: CartesianAxisPosition
     ) {
         super(dim, scale, coordExtent);
         this.type = axisType || 'value';
diff --git a/src/coord/cartesian/AxisModel.ts b/src/coord/cartesian/AxisModel.ts
index d86a712..d038337 100644
--- a/src/coord/cartesian/AxisModel.ts
+++ b/src/coord/cartesian/AxisModel.ts
@@ -27,12 +27,13 @@ import { AxisBaseOption } from '../axisCommonTypes';
 import GridModel from './GridModel';
 
 
-export type Axis2DPosition = 'top' | 'bottom' | 'left' | 'right';
+export type CartesianAxisPosition = 'top' | 'bottom' | 'left' | 'right';
 
 interface CartesianAxisOption extends AxisBaseOption {
     gridIndex?: number;
     gridId?: string;
-    position?: Axis2DPosition;
+    position?: CartesianAxisPosition;
+    // Offset is for multiple axis on the same position.
     offset?: number;
 }
 
@@ -76,11 +77,9 @@ function getAxisType(axisDim: DimensionName, option: 
CartesianAxisOption) {
 interface AxisModel extends AxisModelCommonMixin<CartesianAxisOption> {}
 zrUtil.mixin(AxisModel, AxisModelCommonMixin);
 
-var extraOption = {
+var extraOption: CartesianAxisOption = {
     // gridIndex: 0,
     // gridId: '',
-
-    // Offset is for multiple axis on the same position
     offset: 0
 };
 


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@echarts.apache.org
For additional commands, e-mail: commits-h...@echarts.apache.org

Reply via email to