You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by sh...@apache.org on 2020/03/12 14:30:20 UTC

[incubator-echarts] branch typescript updated: ts: add types for radar coord. add deprecated log in compat preprocessor

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

shenyi 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 595c3d8  ts: add types for radar coord. add deprecated log in compat preprocessor
595c3d8 is described below

commit 595c3d8af4c9d7c6908c1e2d974e3ba66cb4cc69
Author: pissang <bm...@gmail.com>
AuthorDate: Thu Mar 12 22:29:41 2020 +0800

    ts: add types for radar coord. add deprecated log in compat preprocessor
---
 extension-src/bmap/BMapCoordSys.ts           |   1 +
 extension-src/bmap/BMapModel.ts              |   1 +
 extension-src/bmap/BMapView.ts               |   1 +
 extension-src/bmap/bmap.ts                   |   1 +
 extension-src/dataTool/gexf.ts               |   1 +
 extension-src/dataTool/index.ts              |   1 +
 extension-src/dataTool/prepareBoxplotData.ts |   1 +
 src/coord/axisCommonTypes.ts                 |   1 -
 src/coord/axisModelCommonMixin.ts            |   4 +-
 src/coord/radar/IndicatorAxis.ts             |  46 +--
 src/coord/radar/Radar.ts                     | 445 ++++++++++++++-------------
 src/coord/radar/RadarModel.ts                | 124 ++++++--
 src/preprocessor/helper/compatStyle.ts       |  45 +++
 src/scale/Interval.ts                        |   2 +-
 14 files changed, 393 insertions(+), 281 deletions(-)

diff --git a/extension-src/bmap/BMapCoordSys.ts b/extension-src/bmap/BMapCoordSys.ts
index 2bd8070..f133a39 100644
--- a/extension-src/bmap/BMapCoordSys.ts
+++ b/extension-src/bmap/BMapCoordSys.ts
@@ -17,6 +17,7 @@
 * under the License.
 */
 
+// @ts-nocheck
 /* global BMap */
 
 import {
diff --git a/extension-src/bmap/BMapModel.ts b/extension-src/bmap/BMapModel.ts
index ca5cb65..fc2764a 100644
--- a/extension-src/bmap/BMapModel.ts
+++ b/extension-src/bmap/BMapModel.ts
@@ -17,6 +17,7 @@
 * under the License.
 */
 
+// @ts-nocheck
 import * as echarts from 'echarts';
 
 function v2Equal(a, b) {
diff --git a/extension-src/bmap/BMapView.ts b/extension-src/bmap/BMapView.ts
index b69149e..1093a0c 100644
--- a/extension-src/bmap/BMapView.ts
+++ b/extension-src/bmap/BMapView.ts
@@ -17,6 +17,7 @@
 * under the License.
 */
 
+// @ts-nocheck
 import * as echarts from 'echarts';
 
 export default echarts.extendComponentView({
diff --git a/extension-src/bmap/bmap.ts b/extension-src/bmap/bmap.ts
index 1586408..d73b935 100644
--- a/extension-src/bmap/bmap.ts
+++ b/extension-src/bmap/bmap.ts
@@ -17,6 +17,7 @@
 * under the License.
 */
 
+// @ts-nocheck
 /**
  * BMap component extension
  */
diff --git a/extension-src/dataTool/gexf.ts b/extension-src/dataTool/gexf.ts
index 8883e1a..93fb990 100644
--- a/extension-src/dataTool/gexf.ts
+++ b/extension-src/dataTool/gexf.ts
@@ -17,6 +17,7 @@
 * under the License.
 */
 
+// @ts-nocheck
 /**
  * This is a parse of GEXF.
  *
diff --git a/extension-src/dataTool/index.ts b/extension-src/dataTool/index.ts
index 527a8d2..773aa74 100644
--- a/extension-src/dataTool/index.ts
+++ b/extension-src/dataTool/index.ts
@@ -17,6 +17,7 @@
 * under the License.
 */
 
+// @ts-nocheck
 import * as echarts from 'echarts';
 import * as gexf from './gexf';
 import prepareBoxplotData from './prepareBoxplotData';
diff --git a/extension-src/dataTool/prepareBoxplotData.ts b/extension-src/dataTool/prepareBoxplotData.ts
index 690a8de..06ed451 100644
--- a/extension-src/dataTool/prepareBoxplotData.ts
+++ b/extension-src/dataTool/prepareBoxplotData.ts
@@ -17,6 +17,7 @@
 * under the License.
 */
 
+// @ts-nocheck
 import * as numberUtil from '../../src/util/number';
 
 /**
diff --git a/src/coord/axisCommonTypes.ts b/src/coord/axisCommonTypes.ts
index fa0be78..1cdf2bf 100644
--- a/src/coord/axisCommonTypes.ts
+++ b/src/coord/axisCommonTypes.ts
@@ -22,7 +22,6 @@ import {
     AreaStyleOption, ComponentOption, OptionDataValue
 } from '../util/types';
 import { Dictionary } from 'zrender/src/core/types';
-import { AxisModelCommonMixin } from './axisModelCommonMixin';
 
 
 export var AXIS_TYPES = {value: 1, category: 1, time: 1, log: 1} as const;
diff --git a/src/coord/axisModelCommonMixin.ts b/src/coord/axisModelCommonMixin.ts
index 3657667..a68cec7 100644
--- a/src/coord/axisModelCommonMixin.ts
+++ b/src/coord/axisModelCommonMixin.ts
@@ -33,7 +33,7 @@ class AxisModelCommonMixin<Opt extends AxisBaseOption> {
     /**
      * @return min value or 'dataMin' or null/undefined (means auto) or NaN
      */
-    getMin(origin: boolean): number | 'dataMin' {
+    getMin(origin?: boolean): number | 'dataMin' {
         var option = this.option;
         var min = (!origin && option.rangeStart != null)
             ? option.rangeStart : option.min;
@@ -52,7 +52,7 @@ class AxisModelCommonMixin<Opt extends AxisBaseOption> {
     /**
      * @return max value or 'dataMax' or null/undefined (means auto) or NaN
      */
-    getMax(origin: boolean): number | 'dataMax' {
+    getMax(origin?: boolean): number | 'dataMax' {
         var option = this.option;
         var max = (!origin && option.rangeEnd != null)
             ? option.rangeEnd : option.max;
diff --git a/src/coord/radar/IndicatorAxis.ts b/src/coord/radar/IndicatorAxis.ts
index e1b3fc0..abfda20 100644
--- a/src/coord/radar/IndicatorAxis.ts
+++ b/src/coord/radar/IndicatorAxis.ts
@@ -17,37 +17,25 @@
 * under the License.
 */
 
-// @ts-nocheck
-
-import * as zrUtil from 'zrender/src/core/util';
 import Axis from '../Axis';
+import Scale from '../../scale/Scale';
+import { OptionAxisType } from '../axisCommonTypes';
+import { AxisBaseModel } from '../AxisBaseModel';
+import { InnerIndicatorAxisOption } from './RadarModel';
 
-function IndicatorAxis(dim, scale, radiusExtent) {
-    Axis.call(this, dim, scale, radiusExtent);
-
-    /**
-     * Axis type
-     *  - 'category'
-     *  - 'value'
-     *  - 'time'
-     *  - 'log'
-     * @type {string}
-     */
-    this.type = 'value';
-
-    this.angle = 0;
-
-    /**
-     * Indicator name
-     * @type {string}
-     */
-    this.name = '';
-    /**
-     * @type {module:echarts/model/Model}
-     */
-    this.model;
-}
+class IndicatorAxis extends Axis {
+
+    type: OptionAxisType = 'value'
+
+    angle = 0
 
-zrUtil.inherits(IndicatorAxis, Axis);
+    name = ''
+
+    model: AxisBaseModel<InnerIndicatorAxisOption>
+
+    constructor(dim: string, scale: Scale, radiusExtent?: [number, number]) {
+        super(dim, scale, radiusExtent);
+    }
+}
 
 export default IndicatorAxis;
\ No newline at end of file
diff --git a/src/coord/radar/Radar.ts b/src/coord/radar/Radar.ts
index 624dfd6..de374b6 100644
--- a/src/coord/radar/Radar.ts
+++ b/src/coord/radar/Radar.ts
@@ -17,8 +17,6 @@
 * under the License.
 */
 
-// @ts-nocheck
-
 // TODO clockwise
 
 import * as zrUtil from 'zrender/src/core/util';
@@ -29,243 +27,256 @@ import {
     getScaleExtent,
     niceScaleExtent
 } from '../axisHelper';
-import CoordinateSystem from '../../CoordinateSystem';
-import LogScale from '../../scale/Log';
+import CoordinateSystemManager from '../../CoordinateSystem';
+import { CoordinateSystemMaster, CoordinateSystem } from '../CoordinateSystem';
+import RadarModel from './RadarModel';
+import GlobalModel from '../../model/Global';
+import ExtensionAPI from '../../ExtensionAPI';
+import { ScaleDataValue } from '../../util/types';
+import { ParsedModelFinder } from '../../util/model';
+
 
-function Radar(radarModel, ecModel, api) {
+class Radar implements CoordinateSystem, CoordinateSystemMaster {
 
-    this._model = radarModel;
+    readonly type: 'radar'
     /**
+     *
      * Radar dimensions
-     * @type {Array.<string>}
      */
-    this.dimensions = [];
-
-    this._indicatorAxes = zrUtil.map(radarModel.getIndicatorModels(), function (indicatorModel, idx) {
-        var dim = 'indicator_' + idx;
-        var indicatorAxis = new IndicatorAxis(dim,
-            (indicatorModel.get('axisType') === 'log') ? new LogScale() : new IntervalScale());
-        indicatorAxis.name = indicatorModel.get('name');
-        // Inject model and axis
-        indicatorAxis.model = indicatorModel;
-        indicatorModel.axis = indicatorAxis;
-        this.dimensions.push(dim);
-        return indicatorAxis;
-    }, this);
-
-    this.resize(radarModel, api);
+    readonly dimensions: string[] = []
 
-    /**
-     * @type {number}
-     * @readOnly
-     */
-    this.cx;
-    /**
-     * @type {number}
-     * @readOnly
-     */
-    this.cy;
-    /**
-     * @type {number}
-     * @readOnly
-     */
-    this.r;
-    /**
-     * @type {number}
-     * @readOnly
-     */
-    this.r0;
-    /**
-     * @type {number}
-     * @readOnly
-     */
-    this.startAngle;
-}
+    cx: number
 
-Radar.prototype.getIndicatorAxes = function () {
-    return this._indicatorAxes;
-};
-
-Radar.prototype.dataToPoint = function (value, indicatorIndex) {
-    var indicatorAxis = this._indicatorAxes[indicatorIndex];
-
-    return this.coordToPoint(indicatorAxis.dataToCoord(value), indicatorIndex);
-};
-
-Radar.prototype.coordToPoint = function (coord, indicatorIndex) {
-    var indicatorAxis = this._indicatorAxes[indicatorIndex];
-    var angle = indicatorAxis.angle;
-    var x = this.cx + coord * Math.cos(angle);
-    var y = this.cy - coord * Math.sin(angle);
-    return [x, y];
-};
-
-Radar.prototype.pointToData = function (pt) {
-    var dx = pt[0] - this.cx;
-    var dy = pt[1] - this.cy;
-    var radius = Math.sqrt(dx * dx + dy * dy);
-    dx /= radius;
-    dy /= radius;
-
-    var radian = Math.atan2(-dy, dx);
-
-    // Find the closest angle
-    // FIXME index can calculated directly
-    var minRadianDiff = Infinity;
-    var closestAxis;
-    var closestAxisIdx = -1;
-    for (var i = 0; i < this._indicatorAxes.length; i++) {
-        var indicatorAxis = this._indicatorAxes[i];
-        var diff = Math.abs(radian - indicatorAxis.angle);
-        if (diff < minRadianDiff) {
-            closestAxis = indicatorAxis;
-            closestAxisIdx = i;
-            minRadianDiff = diff;
-        }
+    cy: number
+
+    r: number
+
+    r0: number
+
+    startAngle: number
+
+    private _model: RadarModel;
+
+    private _indicatorAxes: IndicatorAxis[];
+
+    constructor(radarModel: RadarModel, ecModel: GlobalModel, api: ExtensionAPI) {
+        this._indicatorAxes = zrUtil.map(radarModel.getIndicatorModels(), function (indicatorModel, idx) {
+            var dim = 'indicator_' + idx;
+            var indicatorAxis = new IndicatorAxis(dim,
+                new IntervalScale()
+                // (indicatorModel.get('axisType') === 'log') ? new LogScale() : new IntervalScale()
+            );
+            indicatorAxis.name = indicatorModel.get('name');
+            // Inject model and axis
+            indicatorAxis.model = indicatorModel;
+            indicatorModel.axis = indicatorAxis;
+            this.dimensions.push(dim);
+            return indicatorAxis;
+        }, this);
+
+        this.resize(radarModel, api);
     }
 
-    return [closestAxisIdx, +(closestAxis && closestAxis.coordToData(radius))];
-};
+    getIndicatorAxes() {
+        return this._indicatorAxes;
+    }
 
-Radar.prototype.resize = function (radarModel, api) {
-    var center = radarModel.get('center');
-    var viewWidth = api.getWidth();
-    var viewHeight = api.getHeight();
-    var viewSize = Math.min(viewWidth, viewHeight) / 2;
-    this.cx = numberUtil.parsePercent(center[0], viewWidth);
-    this.cy = numberUtil.parsePercent(center[1], viewHeight);
+    dataToPoint(value: ScaleDataValue, indicatorIndex: number) {
+        var indicatorAxis = this._indicatorAxes[indicatorIndex];
 
-    this.startAngle = radarModel.get('startAngle') * Math.PI / 180;
+        return this.coordToPoint(indicatorAxis.dataToCoord(value), indicatorIndex);
+    }
 
-    // radius may be single value like `20`, `'80%'`, or array like `[10, '80%']`
-    var radius = radarModel.get('radius');
-    if (typeof radius === 'string' || typeof radius === 'number') {
-        radius = [0, radius];
+    // TODO: API should be coordToPoint([coord, indicatorIndex])
+    coordToPoint(coord: number, indicatorIndex: number) {
+        var indicatorAxis = this._indicatorAxes[indicatorIndex];
+        var angle = indicatorAxis.angle;
+        var x = this.cx + coord * Math.cos(angle);
+        var y = this.cy - coord * Math.sin(angle);
+        return [x, y];
     }
-    this.r0 = numberUtil.parsePercent(radius[0], viewSize);
-    this.r = numberUtil.parsePercent(radius[1], viewSize);
-
-    zrUtil.each(this._indicatorAxes, function (indicatorAxis, idx) {
-        indicatorAxis.setExtent(this.r0, this.r);
-        var angle = (this.startAngle + idx * Math.PI * 2 / this._indicatorAxes.length);
-        // Normalize to [-PI, PI]
-        angle = Math.atan2(Math.sin(angle), Math.cos(angle));
-        indicatorAxis.angle = angle;
-    }, this);
-};
-
-Radar.prototype.update = function (ecModel, api) {
-    var indicatorAxes = this._indicatorAxes;
-    var radarModel = this._model;
-    zrUtil.each(indicatorAxes, function (indicatorAxis) {
-        indicatorAxis.scale.setExtent(Infinity, -Infinity);
-    });
-    ecModel.eachSeriesByType('radar', function (radarSeries, idx) {
-        if (radarSeries.get('coordinateSystem') !== 'radar'
-            || ecModel.getComponent('radar', radarSeries.get('radarIndex')) !== radarModel
-        ) {
-            return;
-        }
-        var data = radarSeries.getData();
-        zrUtil.each(indicatorAxes, function (indicatorAxis) {
-            indicatorAxis.scale.unionExtentFromData(data, data.mapDimension(indicatorAxis.dim));
-        });
-    }, this);
 
-    var splitNumber = radarModel.get('splitNumber');
+    pointToData(pt: number[]) {
+        var dx = pt[0] - this.cx;
+        var dy = pt[1] - this.cy;
+        var radius = Math.sqrt(dx * dx + dy * dy);
+        dx /= radius;
+        dy /= radius;
 
-    function increaseInterval(interval) {
-        var exp10 = Math.pow(10, Math.floor(Math.log(interval) / Math.LN10));
-        // Increase interval
-        var f = interval / exp10;
-        if (f === 2) {
-            f = 5;
-        }
-        else { // f is 2 or 5
-            f *= 2;
+        var radian = Math.atan2(-dy, dx);
+
+        // Find the closest angle
+        // FIXME index can calculated directly
+        var minRadianDiff = Infinity;
+        var closestAxis;
+        var closestAxisIdx = -1;
+        for (var i = 0; i < this._indicatorAxes.length; i++) {
+            var indicatorAxis = this._indicatorAxes[i];
+            var diff = Math.abs(radian - indicatorAxis.angle);
+            if (diff < minRadianDiff) {
+                closestAxis = indicatorAxis;
+                closestAxisIdx = i;
+                minRadianDiff = diff;
+            }
         }
-        return f * exp10;
+
+        return [closestAxisIdx, +(closestAxis && closestAxis.coordToData(radius))];
     }
-    // Force all the axis fixing the maxSplitNumber.
-    zrUtil.each(indicatorAxes, function (indicatorAxis, idx) {
-        var rawExtent = getScaleExtent(indicatorAxis.scale, indicatorAxis.model);
-        niceScaleExtent(indicatorAxis.scale, indicatorAxis.model);
-
-        var axisModel = indicatorAxis.model;
-        var scale = indicatorAxis.scale;
-        var fixedMin = axisModel.getMin();
-        var fixedMax = axisModel.getMax();
-        var interval = scale.getInterval();
-
-        if (fixedMin != null && fixedMax != null) {
-            // User set min, max, divide to get new interval
-            scale.setExtent(+fixedMin, +fixedMax);
-            scale.setInterval(
-                (fixedMax - fixedMin) / splitNumber
-            );
+
+    resize(radarModel: RadarModel, api: ExtensionAPI) {
+        var center = radarModel.get('center');
+        var viewWidth = api.getWidth();
+        var viewHeight = api.getHeight();
+        var viewSize = Math.min(viewWidth, viewHeight) / 2;
+        this.cx = numberUtil.parsePercent(center[0], viewWidth);
+        this.cy = numberUtil.parsePercent(center[1], viewHeight);
+
+        this.startAngle = radarModel.get('startAngle') * Math.PI / 180;
+
+        // radius may be single value like `20`, `'80%'`, or array like `[10, '80%']`
+        var radius = radarModel.get('radius');
+        if (typeof radius === 'string' || typeof radius === 'number') {
+            radius = [0, radius];
         }
-        else if (fixedMin != null) {
-            var max;
-            // User set min, expand extent on the other side
-            do {
-                max = fixedMin + interval * splitNumber;
-                scale.setExtent(+fixedMin, max);
-                // Interval must been set after extent
-                // FIXME
-                scale.setInterval(interval);
+        this.r0 = numberUtil.parsePercent(radius[0], viewSize);
+        this.r = numberUtil.parsePercent(radius[1], viewSize);
+
+        zrUtil.each(this._indicatorAxes, function (indicatorAxis, idx) {
+            indicatorAxis.setExtent(this.r0, this.r);
+            var angle = (this.startAngle + idx * Math.PI * 2 / this._indicatorAxes.length);
+            // Normalize to [-PI, PI]
+            angle = Math.atan2(Math.sin(angle), Math.cos(angle));
+            indicatorAxis.angle = angle;
+        }, this);
+    }
 
-                interval = increaseInterval(interval);
-            } while (max < rawExtent[1] && isFinite(max) && isFinite(rawExtent[1]));
+    update(ecModel: GlobalModel, api: ExtensionAPI) {
+        var indicatorAxes = this._indicatorAxes;
+        var radarModel = this._model;
+        zrUtil.each(indicatorAxes, function (indicatorAxis) {
+            indicatorAxis.scale.setExtent(Infinity, -Infinity);
+        });
+        ecModel.eachSeriesByType('radar', function (radarSeries, idx) {
+            if (radarSeries.get('coordinateSystem') !== 'radar'
+                // @ts-ignore
+                || ecModel.getComponent('radar', radarSeries.get('radarIndex')) !== radarModel
+            ) {
+                return;
+            }
+            var data = radarSeries.getData();
+            zrUtil.each(indicatorAxes, function (indicatorAxis) {
+                indicatorAxis.scale.unionExtentFromData(data, data.mapDimension(indicatorAxis.dim));
+            });
+        }, this);
+
+        var splitNumber = radarModel.get('splitNumber');
+
+        function increaseInterval(interval: number) {
+            var exp10 = Math.pow(10, Math.floor(Math.log(interval) / Math.LN10));
+            // Increase interval
+            var f = interval / exp10;
+            if (f === 2) {
+                f = 5;
+            }
+            else { // f is 2 or 5
+                f *= 2;
+            }
+            return f * exp10;
         }
-        else if (fixedMax != null) {
-            var min;
-            // User set min, expand extent on the other side
-            do {
-                min = fixedMax - interval * splitNumber;
-                scale.setExtent(min, +fixedMax);
+        // Force all the axis fixing the maxSplitNumber.
+        zrUtil.each(indicatorAxes, function (indicatorAxis, idx) {
+            var rawExtent = getScaleExtent(indicatorAxis.scale, indicatorAxis.model);
+            niceScaleExtent(indicatorAxis.scale, indicatorAxis.model);
+
+            var axisModel = indicatorAxis.model;
+            var scale = indicatorAxis.scale as IntervalScale;
+            var fixedMin = axisModel.getMin() as number;
+            var fixedMax = axisModel.getMax() as number;
+            var interval = scale.getInterval();
+
+            if (fixedMin != null && fixedMax != null) {
+                // User set min, max, divide to get new interval
+                scale.setExtent(+fixedMin, +fixedMax);
+                scale.setInterval(
+                    (fixedMax - fixedMin) / splitNumber
+                );
+            }
+            else if (fixedMin != null) {
+                var max;
+                // User set min, expand extent on the other side
+                do {
+                    max = fixedMin + interval * splitNumber;
+                    scale.setExtent(+fixedMin, max);
+                    // Interval must been set after extent
+                    // FIXME
+                    scale.setInterval(interval);
+
+                    interval = increaseInterval(interval);
+                } while (max < rawExtent[1] && isFinite(max) && isFinite(rawExtent[1]));
+            }
+            else if (fixedMax != null) {
+                var min;
+                // User set min, expand extent on the other side
+                do {
+                    min = fixedMax - interval * splitNumber;
+                    scale.setExtent(min, +fixedMax);
+                    scale.setInterval(interval);
+                    interval = increaseInterval(interval);
+                } while (min > rawExtent[0] && isFinite(min) && isFinite(rawExtent[0]));
+            }
+            else {
+                var nicedSplitNumber = scale.getTicks().length - 1;
+                if (nicedSplitNumber > splitNumber) {
+                    interval = increaseInterval(interval);
+                }
+                // PENDING
+                var center = Math.ceil((rawExtent[0] + rawExtent[1]) / 2 / interval) * interval;
+                var halfSplitNumber = Math.round(splitNumber / 2);
+                scale.setExtent(
+                    numberUtil.round(center - halfSplitNumber * interval),
+                    numberUtil.round(center + (splitNumber - halfSplitNumber) * interval)
+                );
                 scale.setInterval(interval);
-                interval = increaseInterval(interval);
-            } while (min > rawExtent[0] && isFinite(min) && isFinite(rawExtent[0]));
-        }
-        else {
-            var nicedSplitNumber = scale.getTicks().length - 1;
-            if (nicedSplitNumber > splitNumber) {
-                interval = increaseInterval(interval);
             }
-            // PENDING
-            var center = Math.ceil((rawExtent[0] + rawExtent[1]) / 2 / interval) * interval;
-            var halfSplitNumber = Math.round(splitNumber / 2);
-            scale.setExtent(
-                numberUtil.round(center - halfSplitNumber * interval),
-                numberUtil.round(center + (splitNumber - halfSplitNumber) * interval)
-            );
-            scale.setInterval(interval);
-        }
-    });
-};
-
-/**
- * Radar dimensions is based on the data
- * @type {Array}
- */
-Radar.dimensions = [];
-
-Radar.create = function (ecModel, api) {
-    var radarList = [];
-    ecModel.eachComponent('radar', function (radarModel) {
-        var radar = new Radar(radarModel, ecModel, api);
-        radarList.push(radar);
-        radarModel.coordinateSystem = radar;
-    });
-    ecModel.eachSeriesByType('radar', function (radarSeries) {
-        if (radarSeries.get('coordinateSystem') === 'radar') {
-            // Inject coordinate system
-            radarSeries.coordinateSystem = radarList[radarSeries.get('radarIndex') || 0];
-        }
-    });
-    return radarList;
-};
+        });
+    }
+
+    convertToPixel(ecModel: GlobalModel, finder: ParsedModelFinder, value: ScaleDataValue[]): never {
+        console.warn('Not implemented.');
+        return null as never;
+    }
+    convertFromPixel(ecModel: GlobalModel, finder: ParsedModelFinder, pixel: number[]): never {
+        console.warn('Not implemented.');
+        return null as never;
+    }
+    containPoint(point: number[]): boolean {
+        console.warn('Not implemented.');
+        return false;
+    }
+    /**
+     * Radar dimensions is based on the data
+     */
+    static dimensions: string[] = []
+
+    static create(ecModel: GlobalModel, api: ExtensionAPI) {
+        var radarList: Radar[] = [];
+        ecModel.eachComponent('radar', function (radarModel: RadarModel) {
+            var radar = new Radar(radarModel, ecModel, api);
+            radarList.push(radar);
+            radarModel.coordinateSystem = radar;
+        });
+        ecModel.eachSeriesByType('radar', function (radarSeries) {
+            if (radarSeries.get('coordinateSystem') === 'radar') {
+                // Inject coordinate system
+                // @ts-ignore
+                radarSeries.coordinateSystem = radarList[radarSeries.get('radarIndex') || 0];
+            }
+        });
+        return radarList;
+    }
+}
+
 
-CoordinateSystem.register('radar', Radar);
+CoordinateSystemManager.register('radar', Radar);
 
 export default Radar;
\ No newline at end of file
diff --git a/src/coord/radar/RadarModel.ts b/src/coord/radar/RadarModel.ts
index de7b215..0d63735 100644
--- a/src/coord/radar/RadarModel.ts
+++ b/src/coord/radar/RadarModel.ts
@@ -17,38 +17,95 @@
 * under the License.
 */
 
-// @ts-nocheck
-
-import * as echarts from '../../echarts';
 import * as zrUtil from 'zrender/src/core/util';
 import axisDefault from '../axisDefault';
 import Model from '../../model/Model';
 import {AxisModelCommonMixin} from '../axisModelCommonMixin';
+import ComponentModel from '../../model/Component';
+import {
+    ComponentOption,
+    CircleLayoutOptionMixin,
+    LabelOption,
+    ColorString
+} from '../../util/types';
+import { AxisBaseOption } from '../axisCommonTypes';
+import { AxisBaseModel } from '../AxisBaseModel';
+import Radar from './Radar';
+import {CoordinateSystemHostModel} from '../../coord/CoordinateSystem';
 
 var valueAxisDefault = axisDefault.value;
 
-function defaultsShow(opt, show) {
+function defaultsShow(opt: object, show: boolean) {
     return zrUtil.defaults({
         show: show
     }, opt);
 }
 
-var RadarModel = echarts.extendComponentModel({
+export interface RadarIndicatorOption {
+    text?: string
+    min?: number
+    max?: number
+    color?: ColorString
+
+    axisType?: 'value' | 'log'
+}
+
+export interface RadarOption extends ComponentOption, CircleLayoutOptionMixin {
+    startAngle?: number
+
+    shape?: 'polygon' | 'circle'
+
+    // TODO. axisType seems to have issue.
+    // axisType?: 'value' | 'log'
+
+    axisLine?: AxisBaseOption['axisLine']
+    axisTick?: AxisBaseOption['axisTick']
+    axisLabel?: AxisBaseOption['axisLabel']
+    splitLine?: AxisBaseOption['splitLine']
+    splitArea?: AxisBaseOption['splitArea']
+
+    // TODO Use axisName?
+    axisName?: {
+        show?: boolean
+        formatter?: string | ((name?: string, indicatorOpt?: InnerIndicatorAxisOption) => string)
+    } & LabelOption
+    axisNameGap?: number
+
+    triggerEvent?: boolean
+
+    scale?: boolean
+    splitNumber?: number
+
+    boundaryGap?: AxisBaseOption['boundaryGap']
+
+    indicator?: RadarIndicatorOption[]
+}
+
+export interface InnerIndicatorAxisOption extends AxisBaseOption {
+    // TODO Use type?
+    // axisType?: 'value' | 'log'
+}
+
+class RadarModel extends ComponentModel<RadarOption> implements CoordinateSystemHostModel {
+    static readonly type = 'radar'
+    readonly type = RadarModel.type
+
+    coordinateSystem: Radar
 
-    type: 'radar',
+    private _indicatorModels: AxisBaseModel<InnerIndicatorAxisOption>[]
 
-    optionUpdated: function () {
+    optionUpdated() {
         var boundaryGap = this.get('boundaryGap');
         var splitNumber = this.get('splitNumber');
         var scale = this.get('scale');
         var axisLine = this.get('axisLine');
         var axisTick = this.get('axisTick');
-        var axisType = this.get('axisType');
+        // var axisType = this.get('axisType');
         var axisLabel = this.get('axisLabel');
-        var nameTextStyle = this.get('name');
-        var showName = this.get('name.show');
-        var nameFormatter = this.get('name.formatter');
-        var nameGap = this.get('nameGap');
+        var nameTextStyle = this.get('axisName');
+        var showName = this.get(['axisName', 'show']);
+        var nameFormatter = this.get(['axisName', 'formatter']);
+        var nameGap = this.get('axisNameGap');
         var triggerEvent = this.get('triggerEvent');
 
         var indicatorModels = zrUtil.map(this.get('indicator') || [], function (indicatorOpt) {
@@ -61,16 +118,18 @@ var RadarModel = echarts.extendComponentModel({
             }
             var iNameTextStyle = nameTextStyle;
             if (indicatorOpt.color != null) {
-                iNameTextStyle = zrUtil.defaults({color: indicatorOpt.color}, nameTextStyle);
+                iNameTextStyle = zrUtil.defaults({
+                    color: indicatorOpt.color
+                }, nameTextStyle);
             }
             // Use same configuration
-            indicatorOpt = zrUtil.merge(zrUtil.clone(indicatorOpt), {
+            const innerIndicatorOpt: InnerIndicatorAxisOption = zrUtil.merge(zrUtil.clone(indicatorOpt), {
                 boundaryGap: boundaryGap,
                 splitNumber: splitNumber,
                 scale: scale,
                 axisLine: axisLine,
                 axisTick: axisTick,
-                axisType: axisType,
+                // axisType: axisType,
                 axisLabel: axisLabel,
                 // Compatible with 2 and use text
                 name: indicatorOpt.text,
@@ -81,21 +140,21 @@ var RadarModel = echarts.extendComponentModel({
                 triggerEvent: triggerEvent
             }, false);
             if (!showName) {
-                indicatorOpt.name = '';
+                innerIndicatorOpt.name = '';
             }
             if (typeof nameFormatter === 'string') {
-                var indName = indicatorOpt.name;
-                indicatorOpt.name = nameFormatter.replace('{value}', indName != null ? indName : '');
+                var indName = innerIndicatorOpt.name;
+                innerIndicatorOpt.name = nameFormatter.replace('{value}', indName != null ? indName : '');
             }
             else if (typeof nameFormatter === 'function') {
-                indicatorOpt.name = nameFormatter(
-                    indicatorOpt.name, indicatorOpt
+                innerIndicatorOpt.name = nameFormatter(
+                    innerIndicatorOpt.name, innerIndicatorOpt
                 );
             }
             var model = zrUtil.extend(
-                new Model(indicatorOpt, null, this.ecModel),
+                new Model(innerIndicatorOpt, null, this.ecModel),
                 AxisModelCommonMixin.prototype
-            );
+            ) as AxisBaseModel<InnerIndicatorAxisOption>;
 
             // For triggerEvent.
             model.mainType = 'radar';
@@ -104,12 +163,14 @@ var RadarModel = echarts.extendComponentModel({
             return model;
         }, this);
 
-        this.getIndicatorModels = function () {
-            return indicatorModels;
-        };
-    },
+        this._indicatorModels = indicatorModels;
+    }
+
+    getIndicatorModels() {
+        return this._indicatorModels;
+    }
 
-    defaultOption: {
+    static defaultOption: RadarOption = {
 
         zlevel: 0,
 
@@ -121,7 +182,7 @@ var RadarModel = echarts.extendComponentModel({
 
         startAngle: 90,
 
-        name: {
+        axisName: {
             show: true
             // formatter: null
             // textStyle: {}
@@ -131,7 +192,7 @@ var RadarModel = echarts.extendComponentModel({
 
         splitNumber: 5,
 
-        nameGap: 15,
+        axisNameGap: 15,
 
         scale: false,
 
@@ -148,13 +209,14 @@ var RadarModel = echarts.extendComponentModel({
         ),
         axisLabel: defaultsShow(valueAxisDefault.axisLabel, false),
         axisTick: defaultsShow(valueAxisDefault.axisTick, false),
-        axisType: 'interval',
+        // axisType: 'value',
         splitLine: defaultsShow(valueAxisDefault.splitLine, true),
         splitArea: defaultsShow(valueAxisDefault.splitArea, true),
 
         // {text, min, max}
         indicator: []
     }
-});
+}
+
 
 export default RadarModel;
diff --git a/src/preprocessor/helper/compatStyle.ts b/src/preprocessor/helper/compatStyle.ts
index 11ae7a9..2721a4a 100644
--- a/src/preprocessor/helper/compatStyle.ts
+++ b/src/preprocessor/helper/compatStyle.ts
@@ -20,6 +20,7 @@
 import * as zrUtil from 'zrender/src/core/util';
 import * as modelUtil from '../../util/model';
 import { Dictionary } from 'zrender/src/core/types';
+import { __DEV__ } from '../../config';
 
 var each = zrUtil.each;
 var isObject = zrUtil.isObject;
@@ -29,6 +30,17 @@ var POSSIBLE_STYLES = [
     'chordStyle', 'label', 'labelLine'
 ];
 
+let storedLogs: Dictionary<boolean> = {};
+function deprecateLog(str: string) {
+    if (storedLogs[str]) {  // Not display duplicate message.
+        return;
+    }
+    if (typeof console !== 'undefined' && console.warn) {
+        storedLogs[str] = true;
+        console.warn('DEPRECATED: ' + str);
+    }
+}
+
 function compatEC2ItemStyle(opt: Dictionary<any>) {
     var itemStyleOpt = opt && opt.itemStyle;
     if (!itemStyleOpt) {
@@ -39,6 +51,9 @@ function compatEC2ItemStyle(opt: Dictionary<any>) {
         var normalItemStyleOpt = itemStyleOpt.normal;
         var emphasisItemStyleOpt = itemStyleOpt.emphasis;
         if (normalItemStyleOpt && normalItemStyleOpt[styleName]) {
+            if (__DEV__) {
+                deprecateLog(`itemStyle.normal.${styleName} has been changed to ${styleName}`);
+            }
             opt[styleName] = opt[styleName] || {};
             if (!opt[styleName].normal) {
                 opt[styleName].normal = normalItemStyleOpt[styleName];
@@ -49,6 +64,9 @@ function compatEC2ItemStyle(opt: Dictionary<any>) {
             normalItemStyleOpt[styleName] = null;
         }
         if (emphasisItemStyleOpt && emphasisItemStyleOpt[styleName]) {
+            if (__DEV__) {
+                deprecateLog(`itemStyle.emphasis.${styleName} has been changed to emphasis.${styleName}`);
+            }
             opt[styleName] = opt[styleName] || {};
             if (!opt[styleName].emphasis) {
                 opt[styleName].emphasis = emphasisItemStyleOpt[styleName];
@@ -67,6 +85,10 @@ function convertNormalEmphasis(opt: Dictionary<any>, optType: string, useExtend?
         var emphasisOpt = opt[optType].emphasis;
 
         if (normalOpt) {
+            if (__DEV__) {
+                // eslint-disable-next-line max-len
+                deprecateLog(`'normal' hierarchy in ${optType} has been removed since 4.0. All style properties are configured in ${optType} directly now.`);
+            }
             // Timeline controlStyle has other properties besides normal and emphasis
             if (useExtend) {
                 opt[optType].normal = opt[optType].emphasis = null;
@@ -77,6 +99,7 @@ function convertNormalEmphasis(opt: Dictionary<any>, optType: string, useExtend?
             }
         }
         if (emphasisOpt) {
+            deprecateLog(`${optType}.emphasis has been changed to emphasis.${optType} since 4.0`);
             opt.emphasis = opt.emphasis || {};
             opt.emphasis[optType] = emphasisOpt;
         }
@@ -100,6 +123,10 @@ function compatTextStyle(opt: any, propName: string) {
     var labelOptSingle = isObject(opt) && opt[propName];
     var textStyle = isObject(labelOptSingle) && labelOptSingle.textStyle;
     if (textStyle) {
+        if (__DEV__) {
+            // eslint-disable-next-line max-len
+            deprecateLog(`textStyle hierarchy in ${propName} has been removed since 4.0. All textStyle properties are configured in ${propName} directly now.`);
+        }
         for (var i = 0, len = modelUtil.TEXT_STYLE_OPTIONS.length; i < len; i++) {
             var textPropName = modelUtil.TEXT_STYLE_OPTIONS[i];
             if (textStyle.hasOwnProperty(textPropName)) {
@@ -264,6 +291,21 @@ export default function (option: any, isTheme?: boolean) {
     // radar.name.textStyle
     each(toArr(option.radar), function (radarOpt) {
         compatTextStyle(radarOpt, 'name');
+        // Use axisName instead of name because component has name property
+        if (radarOpt.name && !radarOpt.axisName) {
+            radarOpt.axisName = radarOpt.name;
+            delete radarOpt.name;
+            if (__DEV__) {
+                deprecateLog('name property in radar component has been changed to axisName');
+            }
+        }
+        if (radarOpt.nameGap != null && radarOpt.axisNameGap == null) {
+            radarOpt.axisNameGap = radarOpt.nameGap;
+            delete radarOpt.nameGap;
+            if (__DEV__) {
+                deprecateLog('nameGap property in radar component has been changed to axisNameGap');
+            }
+        }
     });
 
     each(toArr(option.geo), function (geoOpt) {
@@ -299,4 +341,7 @@ export default function (option: any, isTheme?: boolean) {
 
     compatTextStyle(toObj(option.axisPointer), 'label');
     compatTextStyle(toObj(option.tooltip).axisPointer, 'label');
+
+    // Clean logs
+    storedLogs = {};
 }
\ No newline at end of file
diff --git a/src/scale/Interval.ts b/src/scale/Interval.ts
index 6e9f688..8ccac18 100644
--- a/src/scale/Interval.ts
+++ b/src/scale/Interval.ts
@@ -87,7 +87,7 @@ class IntervalScale extends Scale {
     /**
      * @param expandToNicedExtent Whether expand the ticks to niced extent.
      */
-    getTicks(expandToNicedExtent: boolean): number[] {
+    getTicks(expandToNicedExtent?: boolean): number[] {
         var interval = this._interval;
         var extent = this._extent;
         var niceTickExtent = this._niceExtent;


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