You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by su...@apache.org on 2020/10/29 03:58:44 UTC

[incubator-echarts] branch timeline-scale created (now af508e8)

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

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


      at af508e8  fix: [dataZoom] fix auto axis detection bug brought by 5.0 refactor.

This branch includes the following new commits:

     new bba8146  ts: fix incorrect locale params and fix type check of scales.
     new af508e8  fix: [dataZoom] fix auto axis detection bug brought by 5.0 refactor.

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



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


[incubator-echarts] 02/02: fix: [dataZoom] fix auto axis detection bug brought by 5.0 refactor.

Posted by su...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit af508e8a70f8b0ee4b23b6880f409cb9ed547ce2
Author: 100pah <su...@gmail.com>
AuthorDate: Thu Oct 29 11:56:32 2020 +0800

    fix: [dataZoom] fix auto axis detection bug brought by 5.0 refactor.
---
 src/component/dataZoom/DataZoomModel.ts | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/src/component/dataZoom/DataZoomModel.ts b/src/component/dataZoom/DataZoomModel.ts
index 877851f..08076e9 100644
--- a/src/component/dataZoom/DataZoomModel.ts
+++ b/src/component/dataZoom/DataZoomModel.ts
@@ -18,7 +18,6 @@
 */
 
 import { each, createHashMap, merge, HashMap, assert } from 'zrender/src/core/util';
-import env from 'zrender/src/core/env';
 import AxisProxy from './AxisProxy';
 import ComponentModel from '../../model/Component';
 import {
@@ -240,10 +239,9 @@ class DataZoomModel<Opts extends DataZoomOption = DataZoomOption> extends Compon
     private _doInit(inputRawOption: Opts): void {
         const thisOption = this.option;
 
-        // Disable realtime view update if canvas is not supported.
-        if (!env.canvasSupported) {
-            thisOption.realtime = false;
-        }
+        // if (!env.canvasSupported) {
+        //     thisOption.realtime = false;
+        // }
 
         this._setDefaultThrottle(inputRawOption);
 
@@ -354,7 +352,7 @@ class DataZoomModel<Opts extends DataZoomOption = DataZoomOption> extends Compon
         if (needAuto) {
             // If no parallel axis, find the first category axis as default. (Also consider polar).
             each(DATA_ZOOM_AXIS_DIMENSIONS, function (axisDim) {
-                if (needAuto) {
+                if (!needAuto) {
                     return;
                 }
                 const axisModels = ecModel.findComponents({
@@ -365,6 +363,7 @@ class DataZoomModel<Opts extends DataZoomOption = DataZoomOption> extends Compon
                     const axisInfo = new DataZoomAxisInfo();
                     axisInfo.add(axisModels[0].componentIndex);
                     targetAxisIndexMap.set(axisDim, axisInfo);
+                    needAuto = false;
                 }
             }, this);
         }


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


[incubator-echarts] 01/02: ts: fix incorrect locale params and fix type check of scales.

Posted by su...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit bba8146981c2b2a2661470eb95e62836da147a9b
Author: 100pah <su...@gmail.com>
AuthorDate: Thu Oct 29 02:53:21 2020 +0800

    ts: fix incorrect locale params and fix type check of scales.
---
 src/component/timeline/SliderTimelineView.ts |  2 +-
 src/scale/Interval.ts                        |  4 ++--
 src/scale/Ordinal.ts                         | 25 +++++++++++++++----------
 src/scale/Scale.ts                           | 10 +++++-----
 src/scale/Time.ts                            | 17 ++++++++++-------
 src/util/types.ts                            |  1 +
 6 files changed, 34 insertions(+), 25 deletions(-)

diff --git a/src/component/timeline/SliderTimelineView.ts b/src/component/timeline/SliderTimelineView.ts
index d934d6f..f8a5bc8 100644
--- a/src/component/timeline/SliderTimelineView.ts
+++ b/src/component/timeline/SliderTimelineView.ts
@@ -738,7 +738,7 @@ function createScaleByModel(model: SliderTimelineModel, axisType?: string): Scal
                 });
             case 'time':
                 return new TimeScale({
-                    lang: model.ecModel.getLocaleModel(),
+                    locale: model.ecModel.getLocaleModel(),
                     useUTC: model.ecModel.get('useUTC')
                 });
             default:
diff --git a/src/scale/Interval.ts b/src/scale/Interval.ts
index a70613e..ffc9799 100644
--- a/src/scale/Interval.ts
+++ b/src/scale/Interval.ts
@@ -22,11 +22,11 @@ import * as numberUtil from '../util/number';
 import * as formatUtil from '../util/format';
 import Scale from './Scale';
 import * as helper from './helper';
-import {ScaleTick} from '../util/types';
+import {ScaleTick, Dictionary} from '../util/types';
 
 const roundNumber = numberUtil.round;
 
-class IntervalScale extends Scale {
+class IntervalScale<SETTING extends Dictionary<unknown> = Dictionary<unknown>> extends Scale<SETTING> {
 
     static type = 'interval';
     type = 'interval';
diff --git a/src/scale/Ordinal.ts b/src/scale/Ordinal.ts
index 502bb10..98fbf0f 100644
--- a/src/scale/Ordinal.ts
+++ b/src/scale/Ordinal.ts
@@ -37,10 +37,14 @@ import {
     ScaleTick
 } from '../util/types';
 import { AxisBaseOption } from '../coord/axisCommonTypes';
-import { isArray } from 'zrender/src/core/util';
+import { isArray, map, isObject } from 'zrender/src/core/util';
 
+type OrdinalScaleSetting = {
+    ordinalMeta?: OrdinalMeta | AxisBaseOption['data'];
+    extent?: [number, number];
+};
 
-class OrdinalScale extends Scale {
+class OrdinalScale extends Scale<OrdinalScaleSetting> {
 
     static type = 'ordinal';
     readonly type = 'ordinal';
@@ -48,20 +52,21 @@ class OrdinalScale extends Scale {
     private _ordinalMeta: OrdinalMeta;
     private _categorySortInfo: OrdinalSortInfo[];
 
-
-    constructor(setting?: {
-        ordinalMeta?: OrdinalMeta | AxisBaseOption['data'],
-        extent?: [number, number]
-    }) {
+    constructor(setting?: OrdinalScaleSetting) {
         super(setting);
 
         let ordinalMeta = this.getSetting('ordinalMeta');
         // Caution: Should not use instanceof, consider ec-extensions using
         // import approach to get OrdinalMeta class.
-        if (!ordinalMeta || isArray(ordinalMeta)) {
-            ordinalMeta = new OrdinalMeta({categories: ordinalMeta});
+        if (!ordinalMeta) {
+            ordinalMeta = new OrdinalMeta({});
+        }
+        if (isArray(ordinalMeta)) {
+            ordinalMeta = new OrdinalMeta({
+                categories: map(ordinalMeta, item => (isObject(item) ? item.value : item))
+            });
         }
-        this._ordinalMeta = ordinalMeta;
+        this._ordinalMeta = ordinalMeta as OrdinalMeta;
         this._categorySortInfo = [];
         this._extent = this.getSetting('extent') || [0, ordinalMeta.categories.length - 1];
     }
diff --git a/src/scale/Scale.ts b/src/scale/Scale.ts
index 458fd4a..815ae54 100644
--- a/src/scale/Scale.ts
+++ b/src/scale/Scale.ts
@@ -31,11 +31,11 @@ import {
 import { ScaleRawExtentInfo } from '../coord/scaleRawExtentInfo';
 
 
-abstract class Scale {
+abstract class Scale<SETTING extends Dictionary<unknown> = Dictionary<unknown>> {
 
     type: string;
 
-    private _setting: Dictionary<any>;
+    private _setting: SETTING;
 
     protected _extent: [number, number];
 
@@ -44,12 +44,12 @@ abstract class Scale {
     // Inject
     readonly rawExtentInfo: ScaleRawExtentInfo;
 
-    constructor(setting?: Dictionary<any>) {
-        this._setting = setting || {};
+    constructor(setting?: SETTING) {
+        this._setting = setting || {} as SETTING;
         this._extent = [Infinity, -Infinity];
     }
 
-    getSetting(name: string): any {
+    getSetting<KEY extends keyof SETTING>(name: KEY): SETTING[KEY] {
         return this._setting[name];
     }
 
diff --git a/src/scale/Time.ts b/src/scale/Time.ts
index 70eb9a9..a5157b4 100644
--- a/src/scale/Time.ts
+++ b/src/scale/Time.ts
@@ -99,14 +99,12 @@ const bisect = function (
     return lo;
 };
 
-interface TimeScale {
-    constructor(settings?: {
-        locale: Model<LocaleOption>,
-        useUTC: boolean
-    }): void
-}
+type TimeScaleSetting = {
+    locale: Model<LocaleOption>;
+    useUTC: boolean;
+};
 
-class TimeScale extends IntervalScale {
+class TimeScale extends IntervalScale<TimeScaleSetting> {
 
     static type = 'time';
     readonly type = 'time';
@@ -115,6 +113,10 @@ class TimeScale extends IntervalScale {
 
     _minLevelUnit: TimeUnit;
 
+    constructor(settings?: TimeScaleSetting) {
+        super(settings);
+    }
+
     /**
      * Get label is mainly for other components like dataZoom, tooltip.
      */
@@ -125,6 +127,7 @@ class TimeScale extends IntervalScale {
             fullLeveledFormatter[
                 getDefaultFormatPrecisionOfInterval(getPrimaryTimeUnit(this._minLevelUnit))
             ] || fullLeveledFormatter.second,
+            this.getSetting('locale'),
             useUTC
         );
     }
diff --git a/src/util/types.ts b/src/util/types.ts
index c2411d8..2d7f6aa 100644
--- a/src/util/types.ts
+++ b/src/util/types.ts
@@ -477,6 +477,7 @@ export type ECUnitOption = {
     backgroundColor?: ZRColor
     darkMode?: boolean | 'auto'
     textStyle?: Pick<LabelOption, 'color' | 'fontStyle' | 'fontWeight' | 'fontSize' | 'fontFamily'>
+    useUTC?: boolean
 
     [key: string]: ComponentOption | ComponentOption[] | Dictionary<unknown> | unknown
 


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