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/02/23 11:25:29 UTC
[incubator-echarts] branch typescript updated: ts: naming tweak.
add tooltip / axisPointer model
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 0fc8d2c ts: naming tweak. add tooltip / axisPointer model
0fc8d2c is described below
commit 0fc8d2c08b984af7e7bd8be9df308e0d8a9b0f76
Author: pissang <bm...@gmail.com>
AuthorDate: Sun Feb 23 19:24:48 2020 +0800
ts: naming tweak. add tooltip / axisPointer model
---
src/chart/pie/PieSeries.ts | 4 +-
src/component/axisPointer.ts | 2 -
src/component/axisPointer/AxisPointerModel.ts | 148 +++++++++++++++++++----
src/component/legend/LegendModel.ts | 2 +
src/component/title.ts | 13 +-
src/component/tooltip.ts | 2 -
src/component/tooltip/TooltipModel.ts | 165 ++++++++++++++++++++++----
src/component/visualMap/VisualMapModel.ts | 5 +-
src/coord/axisCommonTypes.ts | 6 +-
src/data/Graph.ts | 4 +-
src/data/List.ts | 62 +++++-----
src/data/Tree.ts | 4 +-
src/data/helper/dataProvider.ts | 36 +++---
src/model/mixin/dataFormat.ts | 4 +-
src/scale/Scale.ts | 4 +-
src/util/animation.ts | 6 +-
src/util/model.ts | 6 +-
src/util/types.ts | 33 +++---
src/visual/VisualMapping.ts | 4 +-
src/visual/visualSolution.ts | 8 +-
20 files changed, 374 insertions(+), 144 deletions(-)
diff --git a/src/chart/pie/PieSeries.ts b/src/chart/pie/PieSeries.ts
index 9679944..b384301 100644
--- a/src/chart/pie/PieSeries.ts
+++ b/src/chart/pie/PieSeries.ts
@@ -28,7 +28,7 @@ import LegendVisualProvider from '../../visual/LegendVisualProvider';
import SeriesModel from '../../model/Series';
import {
SeriesOption,
- DataParamsUserOutput,
+ CallbackDataParams,
CircleLayoutOptionMixin,
LabelLineOption,
ItemStyleOption,
@@ -155,7 +155,7 @@ class PieSeries extends SeriesModel<PieSeriesOption> {
/**
* @overwrite
*/
- getDataParams(dataIndex: number): DataParamsUserOutput {
+ getDataParams(dataIndex: number): CallbackDataParams {
var data = this.getData();
var params = super.getDataParams(dataIndex);
// FIXME toFixed?
diff --git a/src/component/axisPointer.ts b/src/component/axisPointer.ts
index 246068b..a846a31 100644
--- a/src/component/axisPointer.ts
+++ b/src/component/axisPointer.ts
@@ -16,9 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-
// @ts-nocheck
-
import * as echarts from '../echarts';
import * as zrUtil from 'zrender/src/core/util';
import * as axisPointerModelHelper from './axisPointer/modelHelper';
diff --git a/src/component/axisPointer/AxisPointerModel.ts b/src/component/axisPointer/AxisPointerModel.ts
index 3ce3b99..5afa5d6 100644
--- a/src/component/axisPointer/AxisPointerModel.ts
+++ b/src/component/axisPointer/AxisPointerModel.ts
@@ -17,19 +17,131 @@
* under the License.
*/
-import * as echarts from '../../echarts';
-
-var AxisPointerModel = echarts.extendComponentModel({
-
- type: 'axisPointer',
-
- coordSysAxesInfo: null,
-
- defaultOption: {
+import ComponentModel from '../../model/Component';
+import {
+ ComponentOption,
+ OptionDataValue,
+ LineStyleOption,
+ AreaStyleOption,
+ LabelOption,
+ ZREasing,
+ ColorString,
+ ShadowOptionMixin
+} from '../../util/types';
+
+interface AxisInfo {
+ axisIndex: number
+ axisName: string
+ axisId: string
+}
+
+interface AxisPointerLink {
+ xAxisIndex?: number[] | 'all'
+ yAxisIndex?: number[] | 'all'
+ xAxisId?: string[]
+ yAxisId?: string[]
+ xAxisName?: string[] | string
+ yAxisName?: string[] | string
+
+ radiusAxisIndex?: number[] | 'all'
+ angleAxisIndex?: number[] | 'all'
+ radiusAxisId?: string[]
+ angleAxisId?: string[]
+ radiusAxisName?: string[] | string
+ angleAxisName?: string[] | string
+
+ singleAxisIndex?: number[] | 'all'
+ singleAxisId?: string[]
+ singleAxisName?: string[] | string
+
+ mapper?(
+ sourceVal: OptionDataValue,
+ sourceAxisInfo: AxisInfo,
+ targetAxisInfo: AxisInfo
+ ): OptionDataValue
+}
+
+export interface AxisPointerOption extends ComponentOption {
+
+ show?: boolean | 'auto'
+
+ triggerOn?: 'click' | 'mousemove' | 'none' | 'mousemove|click'
+
+ type?: 'line' | 'shadow'
+
+ snap?: boolean
+
+ triggerTooltip?: boolean
+
+ /**
+ * current value. When using axisPointer.handle, value can be set to define the initail position of axisPointer.
+ */
+ value?: OptionDataValue
+
+ status?: 'show' | 'hide'
+
+ // [group0, group1, ...]
+ // Each group can be: {
+ // mapper: function () {},
+ // singleTooltip: 'multiple', // 'multiple' or 'single'
+ // xAxisId: ...,
+ // yAxisName: ...,
+ // angleAxisIndex: ...
+ // }
+ // mapper: can be ignored.
+ // input: {axisInfo, value}
+ // output: {axisInfo, value}
+ link?: AxisPointerLink[]
+
+ label?: LabelOption & {
+ precision?: 'auto' | string
+ margin?: number
+ }
+ animation?: boolean | 'auto'
+ animationDurationUpdate?: number
+ animationEasingUpdate?: ZREasing
+
+ /**
+ * Available when type is 'line'
+ */
+ lineStyle?: LineStyleOption
+ /**
+ * Available when type is 'shadow'
+ */
+ shadowStyle?: AreaStyleOption
+
+ handle?: {
+ show?: boolean
+ icon?: string
+ /**
+ * The size of the handle
+ */
+ size?: number | number[]
+ /**
+ * Distance from handle center to axis.
+ */
+ margin?: number
+
+ color?: ColorString
+
+ /**
+ * Throttle for mobile performance
+ */
+ throttle?: number
+ } & ShadowOptionMixin
+}
+
+
+class AxisPointerModel extends ComponentModel<AxisPointerOption> {
+
+ static type = 'axisPointer' as const
+ type = AxisPointerModel.type
+
+ // coordSysAxesInfo
+
+ static defaultOption: AxisPointerOption = {
// 'auto' means that show when triggered by tooltip or handle.
show: 'auto',
- // 'click' | 'mousemove' | 'none'
- triggerOn: null, // set default in AxisPonterView.js
zlevel: 0,
z: 50,
@@ -43,17 +155,6 @@ var AxisPointerModel = echarts.extendComponentModel({
value: null,
status: null, // Init value depends on whether handle is used.
- // [group0, group1, ...]
- // Each group can be: {
- // mapper: function () {},
- // singleTooltip: 'multiple', // 'multiple' or 'single'
- // xAxisId: ...,
- // yAxisName: ...,
- // angleAxisIndex: ...
- // }
- // mapper: can be ignored.
- // input: {axisInfo, value}
- // output: {axisInfo, value}
link: [],
// Do not set 'auto' here, otherwise global animation: false
@@ -109,7 +210,8 @@ var AxisPointerModel = echarts.extendComponentModel({
throttle: 40
}
}
+}
-});
+ComponentModel.registerClass(AxisPointerModel);
export default AxisPointerModel;
diff --git a/src/component/legend/LegendModel.ts b/src/component/legend/LegendModel.ts
index 067b4be..e574406 100644
--- a/src/component/legend/LegendModel.ts
+++ b/src/component/legend/LegendModel.ts
@@ -61,6 +61,8 @@ interface DataItem {
tooltip?: unknown
}
export interface LegendOption extends ComponentOption, BoxLayoutOptionMixin, BorderOptionMixin {
+ show?: boolean
+
orient?: 'horizontal' | 'vertical'
align?: 'auto' | 'left' | 'right'
diff --git a/src/component/title.ts b/src/component/title.ts
index 4ca14a9..99ae5a9 100644
--- a/src/component/title.ts
+++ b/src/component/title.ts
@@ -21,12 +21,23 @@ import * as zrUtil from 'zrender/src/core/util';
import * as graphic from '../util/graphic';
import {getLayoutRect} from '../util/layout';
import ComponentModel from '../model/Component';
-import { ComponentOption, BoxLayoutOptionMixin, ZRTextAlign, ZRTextVerticalAlign, ZRColor, BorderOptionMixin, LabelOption, ECElement } from '../util/types';
+import {
+ ComponentOption,
+ BoxLayoutOptionMixin,
+ ZRTextAlign,
+ ZRTextVerticalAlign,
+ ZRColor,
+ BorderOptionMixin,
+ LabelOption,
+ ECElement
+} from '../util/types';
import ComponentView from '../view/Component';
import GlobalModel from '../model/Global';
import ExtensionAPI from '../ExtensionAPI';
export interface TitleOption extends ComponentOption, BoxLayoutOptionMixin, BorderOptionMixin {
+ show?: boolean
+
type?: 'title'
text?: string
diff --git a/src/component/tooltip.ts b/src/component/tooltip.ts
index ef88016..31176e8 100644
--- a/src/component/tooltip.ts
+++ b/src/component/tooltip.ts
@@ -17,8 +17,6 @@
* under the License.
*/
-// @ts-nocheck
-
// FIXME Better way to pack data in graphic element
import * as echarts from '../echarts';
diff --git a/src/component/tooltip/TooltipModel.ts b/src/component/tooltip/TooltipModel.ts
index 0e18f79..b493bd7 100644
--- a/src/component/tooltip/TooltipModel.ts
+++ b/src/component/tooltip/TooltipModel.ts
@@ -17,17 +17,148 @@
* under the License.
*/
-// @ts-nocheck
-
-import * as echarts from '../../echarts';
-
-export default echarts.extendComponentModel({
+import ComponentModel from '../../model/Component';
+import {
+ ComponentOption,
+ CallbackDataParams,
+ ZRAlign,
+ ZRVerticalAlign,
+ ColorString,
+ LabelOption,
+ TooltipRenderMode,
+ LineStyleOption
+} from '../../util/types';
+import { RectLike } from 'zrender/src/core/BoundingRect';
+import {AxisPointerOption} from '../axisPointer/AxisPointerModel';
+
+/**
+ * Position relative to the hoverred element. Only available when trigger is item.
+ */
+type BuitlinPosition = 'inside' | 'top' | 'left' | 'right' | 'bottom'
+interface PositionCallback {
+ (
+ point: [number, number],
+ params: CallbackDataParams,
+ dom: HTMLElement | null,
+ /**
+ * Rect of hover elements. Will be null if not hovered
+ */
+ rect: RectLike | null,
+ size: {
+ /**
+ * Size of popup content
+ */
+ contentSize: [number, number]
+ /**
+ * Size of the chart view
+ */
+ viewSize: [number, number]
+ }
+ ): number[] | string[] | BuitlinPosition
+}
+interface TooltipOption extends ComponentOption {
+ show?: boolean
+
+ /**
+ * If show popup content
+ */
+ showContent?: boolean
+ /**
+ * Trigger only works on coordinate system.
+ */
+ trigger?: 'item' | 'axis' | 'none'
+ /**
+ * When to trigger
+ */
+ triggerOn?: 'mousemove' | 'click' | 'none' | 'mousemove|click'
+ /**
+ * Whether to not hide popup content automatically
+ */
+ alwaysShowContent?: boolean
+
+ displayMode?: 'single' | 'multipleByCoordSys';
+
+ /**
+ * 'auto': use html by default, and use non-html if `document` is not defined
+ * 'html': use html for tooltip
+ * 'richText': use canvas, svg, and etc. for tooltip
+ */
+ renderMode?: 'auto' | TooltipRenderMode // TODO richText renamed canvas?
+
+ /**
+ * Absolution pixel [x, y] array. Or relative percent string [x, y] array.
+ * If trigger is 'item'. position can be set to 'inside' / 'top' / 'left' / 'right' / 'bottom',
+ * which is relative to the hovered element.
+ *
+ * Support to be a callback
+ */
+ position?: number[] | string[] | BuitlinPosition | PositionCallback
+
+ confine?: boolean
+
+ /**
+ * Consider triggered from axisPointer handle, verticalAlign should be 'middle'
+ */
+ align?: ZRAlign
+
+ verticalAlign?: ZRVerticalAlign
+ /**
+ * Delay of show. milesecond.
+ */
+ showDelay?: number
+
+ /**
+ * Delay of hide. milesecond.
+ */
+ hideDelay?: number
+
+ transitionDuration?: number
+ /**
+ * Whether mouse is allowed to enter the floating layer of tooltip
+ * If you need to interact in the tooltip like with links or buttons, it can be set as true.
+ * @default false
+ */
+ enterable?: boolean
+
+ backgroundColor?: ColorString
+ borderColor?: ColorString
+ /**
+ * @default 4
+ */
+ borderRadius?: number
+ borderWidth?: number
+
+ /**
+ * Padding between tooltip content and tooltip border.
+ */
+ padding?: number | number[]
+
+ /**
+ * Available when renderMode is 'html'
+ */
+ extraCssText?: string
+
+ textStyle?: Pick<LabelOption,
+ 'color' | 'fontStyle' | 'fontWeight' | 'fontFamily' | 'fontSize' |
+ 'lineHeight' | 'width' | 'height' | 'textBorderColor' | 'textBorderWidth' |
+ 'textShadowColor' | 'textShadowBlur' | 'textShadowOffsetX' | 'textShadowOffsetY'>
+
+ axisPointer?: AxisPointerOption & {
+ axis?: 'auto' | 'x' | 'y' | 'angle' | 'radius'
+ crossStyle?: LineStyleOption & {
+ // TODO
+ textStyle?: LabelOption
+ }
+ }
+}
- type: 'tooltip',
+class TooltipModel extends ComponentModel<TooltipOption> {
+ static type = 'tooltip' as const
+ type = TooltipModel.type
- dependencies: ['axisPointer'],
+ static dependencies = ['axisPointer']
- defaultOption: {
+ static defaultOption: TooltipOption = {
zlevel: 0,
z: 60,
@@ -49,25 +180,12 @@ export default echarts.extendComponentModel({
displayMode: 'single', // 'single' | 'multipleByCoordSys'
renderMode: 'auto', // 'auto' | 'html' | 'richText'
- // 'auto': use html by default, and use non-html if `document` is not defined
- // 'html': use html for tooltip
- // 'richText': use canvas, svg, and etc. for tooltip
-
- // 位置 {Array} | {Function}
- // position: null
- // Consider triggered from axisPointer handle, verticalAlign should be 'middle'
- // align: null,
- // verticalAlign: null,
// 是否约束 content 在 viewRect 中。默认 false 是为了兼容以前版本。
confine: false,
- // 内容格式器:{string}(Template) ¦ {Function}
- // formatter: null
-
showDelay: 0,
- // 隐藏延迟,单位ms
hideDelay: 100,
// 动画变换时间,单位s
@@ -75,7 +193,6 @@ export default echarts.extendComponentModel({
enterable: false,
- // 提示背景颜色,默认为透明度为0.7的黑色
backgroundColor: 'rgba(50,50,50,0.7)',
// 提示边框颜色
@@ -127,4 +244,6 @@ export default echarts.extendComponentModel({
fontSize: 14
}
}
-});
\ No newline at end of file
+}
+
+ComponentModel.registerClass(TooltipModel);
\ No newline at end of file
diff --git a/src/component/visualMap/VisualMapModel.ts b/src/component/visualMap/VisualMapModel.ts
index 6776890..15de99c 100644
--- a/src/component/visualMap/VisualMapModel.ts
+++ b/src/component/visualMap/VisualMapModel.ts
@@ -31,7 +31,7 @@ import {
ColorString,
ZRColor,
BorderOptionMixin,
- OptionDataPrimitive,
+ OptionDataValue,
BuiltinVisualProperty
} from '../../util/types';
import ComponentModel from '../../model/Component';
@@ -49,13 +49,14 @@ const linearMap = numberUtil.linearMap;
type VisualOptionBase = {[key in BuiltinVisualProperty]?: any}
-type LabelFormatter = (min: OptionDataPrimitive, max?: OptionDataPrimitive) => string
+type LabelFormatter = (min: OptionDataValue, max?: OptionDataValue) => string
type VisualState = VisualMapModel['stateList'][number];
export interface VisualMapOption<T extends VisualOptionBase = VisualOptionBase> extends
ComponentOption,
BoxLayoutOptionMixin,
BorderOptionMixin {
+ show?: boolean
align?: string
diff --git a/src/coord/axisCommonTypes.ts b/src/coord/axisCommonTypes.ts
index 994a1f0..6d91988 100644
--- a/src/coord/axisCommonTypes.ts
+++ b/src/coord/axisCommonTypes.ts
@@ -19,7 +19,7 @@
import {
TextCommonOption, LineStyleOption, OrdinalRawValue, ZRColor,
- AreaStyleOption, ComponentOption, OptionDataPrimitive
+ AreaStyleOption, ComponentOption, OptionDataValue
} from '../util/types';
import { Dictionary } from 'zrender/src/core/types';
@@ -71,12 +71,12 @@ export interface AxisBaseOption extends ComponentOption {
// + a number
// + 'dataMin': use the min value in data.
// + null/undefined: auto decide min value (consider pretty look and boundaryGap).
- min?: OptionDataPrimitive | 'dataMin';
+ min?: OptionDataValue | 'dataMin';
// Max value of the axis. can be:
// + a number
// + 'dataMax': use the max value in data.
// + null/undefined: auto decide max value (consider pretty look and boundaryGap).
- max?: OptionDataPrimitive | 'dataMax';
+ max?: OptionDataValue | 'dataMax';
// Readonly prop, specifies start value of the range when using data zoom.
// Only for internal usage.
rangeStart?: number;
diff --git a/src/data/Graph.ts b/src/data/Graph.ts
index 20da5ab..b5eef6c 100644
--- a/src/data/Graph.ts
+++ b/src/data/Graph.ts
@@ -23,7 +23,7 @@ import { Dictionary } from 'zrender/src/core/types';
import List from './List';
import Model from '../model/Model';
import Element from 'zrender/src/Element';
-import { DimensionLoose, ParsedDataValue } from '../util/types';
+import { DimensionLoose, ParsedValue } from '../util/types';
// id may be function name of Object, add a prefix to avoid this problem.
function generateNodeKey(id: string): string {
@@ -420,7 +420,7 @@ function createGraphDataProxyMixin<Host extends GraphEdge | GraphNode>(
/**
* @param Default 'value'. can be 'a', 'b', 'c', 'd', 'e'.
*/
- getValue: function (this: Host, dimension: DimensionLoose): ParsedDataValue {
+ getValue: function (this: Host, dimension: DimensionLoose): ParsedValue {
var data = this[hostName][dataName];
return data.get(data.getDimension(dimension || 'value'), this.dataIndex);
},
diff --git a/src/data/List.ts b/src/data/List.ts
index 7f008a8..b3f1121 100644
--- a/src/data/List.ts
+++ b/src/data/List.ts
@@ -36,7 +36,7 @@ import {ArrayLike, Dictionary, FunctionPropertyNames} from 'zrender/src/core/typ
import Element from 'zrender/src/Element';
import {
DimensionIndex, DimensionName, ECElement, DimensionLoose, OptionDataItem,
- ParsedDataValue, ParsedDataNumeric, OrdinalNumber, DimensionUserOuput, ModelOption
+ ParsedValue, ParsedValueNumeric, OrdinalNumber, DimensionUserOuput, ModelOption
} from '../util/types';
import {parseDate} from '../util/number';
import {isDataItemOption} from '../util/model';
@@ -82,9 +82,9 @@ type DimValueGetter = (
dimName: DimensionName,
dataIndex: number,
dimIndex: DimensionIndex
-) => ParsedDataValue;
+) => ParsedValue;
-type DataValueChunk = ArrayLike<ParsedDataValue>;
+type DataValueChunk = ArrayLike<ParsedValue>;
type DataStorage = {[dimName: string]: DataValueChunk[]};
type NameRepeatCount = {[name: string]: number};
@@ -93,21 +93,21 @@ type ItrParamDims = DimensionLoose | Array<DimensionLoose>;
// If Ctx not specified, use List as Ctx
type CtxOrList<Ctx> = unknown extends Ctx ? List : Ctx;
type EachCb0<Ctx> = (this: CtxOrList<Ctx>, idx: number) => void;
-type EachCb1<Ctx> = (this: CtxOrList<Ctx>, x: ParsedDataValue, idx: number) => void;
-type EachCb2<Ctx> = (this: CtxOrList<Ctx>, x: ParsedDataValue, y: ParsedDataValue, idx: number) => void;
+type EachCb1<Ctx> = (this: CtxOrList<Ctx>, x: ParsedValue, idx: number) => void;
+type EachCb2<Ctx> = (this: CtxOrList<Ctx>, x: ParsedValue, y: ParsedValue, idx: number) => void;
type EachCb<Ctx> = (this: CtxOrList<Ctx>, ...args: any) => void;
type FilterCb0<Ctx> = (this: CtxOrList<Ctx>, idx: number) => boolean;
-type FilterCb1<Ctx> = (this: CtxOrList<Ctx>, x: ParsedDataValue, idx: number) => boolean;
-type FilterCb2<Ctx> = (this: CtxOrList<Ctx>, x: ParsedDataValue, y: ParsedDataValue, idx: number) => boolean;
+type FilterCb1<Ctx> = (this: CtxOrList<Ctx>, x: ParsedValue, idx: number) => boolean;
+type FilterCb2<Ctx> = (this: CtxOrList<Ctx>, x: ParsedValue, y: ParsedValue, idx: number) => boolean;
type FilterCb<Ctx> = (this: CtxOrList<Ctx>, ...args: any) => boolean;
type MapArrayCb0<Ctx> = (this: CtxOrList<Ctx>, idx: number) => any;
-type MapArrayCb1<Ctx> = (this: CtxOrList<Ctx>, x: ParsedDataValue, idx: number) => any;
-type MapArrayCb2<Ctx> = (this: CtxOrList<Ctx>, x: ParsedDataValue, y: ParsedDataValue, idx: number) => any;
+type MapArrayCb1<Ctx> = (this: CtxOrList<Ctx>, x: ParsedValue, idx: number) => any;
+type MapArrayCb2<Ctx> = (this: CtxOrList<Ctx>, x: ParsedValue, y: ParsedValue, idx: number) => any;
type MapArrayCb<Ctx> = (this: CtxOrList<Ctx>, ...args: any) => any;
-type MapCb1<Ctx> = (this: CtxOrList<Ctx>, x: ParsedDataValue, idx: number) => ParsedDataValue | ParsedDataValue[];
-type MapCb2<Ctx> = (this: CtxOrList<Ctx>, x: ParsedDataValue, y: ParsedDataValue, idx: number) =>
- ParsedDataValue | ParsedDataValue[];
-type MapCb<Ctx> = (this: CtxOrList<Ctx>, ...args: any) => ParsedDataValue | ParsedDataValue[];
+type MapCb1<Ctx> = (this: CtxOrList<Ctx>, x: ParsedValue, idx: number) => ParsedValue | ParsedValue[];
+type MapCb2<Ctx> = (this: CtxOrList<Ctx>, x: ParsedValue, y: ParsedValue, idx: number) =>
+ ParsedValue | ParsedValue[];
+type MapCb<Ctx> = (this: CtxOrList<Ctx>, ...args: any) => ParsedValue | ParsedValue[];
@@ -482,7 +482,7 @@ class List <HostModel extends Model = Model> {
var dim = dimensions[k];
var val = this._dimValueGetterArrayRows(
values[sourceIdx] || emptyDataItem, dim, sourceIdx, k
- ) as ParsedDataNumeric;
+ ) as ParsedValueNumeric;
storage[dim][chunkIndex][chunkOffset] = val;
var dimRawExtent = rawExtent[dim];
@@ -562,7 +562,7 @@ class List <HostModel extends Model = Model> {
var dim = dimensions[k];
var dimStorage = storage[dim][chunkIndex];
// PENDING NULL is empty or zero
- var val = this._dimValueGetter(dataItem, dim, idx, k) as ParsedDataNumeric;
+ var val = this._dimValueGetter(dataItem, dim, idx, k) as ParsedValueNumeric;
dimStorage[chunkOffset] = val;
var dimRawExtent = rawExtent[dim];
@@ -665,7 +665,7 @@ class List <HostModel extends Model = Model> {
* Get value. Return NaN if idx is out of range.
* @param dim Dim must be concrete name.
*/
- get(dim: DimensionName, idx: number): ParsedDataValue {
+ get(dim: DimensionName, idx: number): ParsedValue {
if (!(idx >= 0 && idx < this._count)) {
return NaN;
}
@@ -707,7 +707,7 @@ class List <HostModel extends Model = Model> {
/**
* @param dim concrete dim
*/
- getByRawIndex(dim: DimensionName, rawIdx: number): ParsedDataValue {
+ getByRawIndex(dim: DimensionName, rawIdx: number): ParsedValue {
if (!(rawIdx >= 0 && rawIdx < this._rawCount)) {
return NaN;
}
@@ -727,7 +727,7 @@ class List <HostModel extends Model = Model> {
* FIXME Use `get` on chrome maybe slow(in filterSelf and selectRange).
* Hack a much simpler _getFast
*/
- private _getFast(dim: DimensionName, rawIdx: number): ParsedDataValue {
+ private _getFast(dim: DimensionName, rawIdx: number): ParsedValue {
var chunkIndex = Math.floor(rawIdx / this._chunkSize);
var chunkOffset = rawIdx % this._chunkSize;
var chunkStore = this._storage[dim][chunkIndex];
@@ -738,9 +738,9 @@ class List <HostModel extends Model = Model> {
* Get value for multi dimensions.
* @param dimensions If ignored, using all dimensions.
*/
- getValues(idx: number): ParsedDataValue[];
- getValues(dimensions: DimensionName[], idx: number): ParsedDataValue[];
- getValues(dimensions: DimensionName[] | number, idx?: number): ParsedDataValue[] {
+ getValues(idx: number): ParsedValue[];
+ getValues(dimensions: DimensionName[], idx: number): ParsedValue[];
+ getValues(dimensions: DimensionName[] | number, idx?: number): ParsedValue[] {
var values = [];
if (!zrUtil.isArray(dimensions)) {
@@ -813,7 +813,7 @@ class List <HostModel extends Model = Model> {
for (var i = 0; i < currEnd; i++) {
// var value = stack ? this.get(dim, i, true) : this._getFast(dim, this.getRawIndex(i));
- var value = this._getFast(dim, this.getRawIndex(i)) as ParsedDataNumeric;
+ var value = this._getFast(dim, this.getRawIndex(i)) as ParsedValueNumeric;
value < min && (min = value);
value > max && (max = value);
}
@@ -875,7 +875,7 @@ class List <HostModel extends Model = Model> {
* Get median of data in one dimension
*/
getMedian(dim: DimensionLoose): number {
- var dimDataArray: ParsedDataValue[] = [];
+ var dimDataArray: ParsedValue[] = [];
// map all data of one dimension
this.each(dim, function (val) {
if (!isNaN(val as number)) {
@@ -1496,8 +1496,8 @@ class List <HostModel extends Model = Model> {
downSample(
dimension: DimensionName,
rate: number,
- sampleValue: (frameValues: ParsedDataValue[]) => ParsedDataNumeric,
- sampleIndex: (frameValues: ParsedDataValue[], value: ParsedDataNumeric) => number
+ sampleValue: (frameValues: ParsedValue[]) => ParsedValueNumeric,
+ sampleIndex: (frameValues: ParsedValue[], value: ParsedValueNumeric) => number
): List {
var list = cloneListForMapAndSample(this, [dimension]);
var targetStorage = list._storage;
@@ -1820,7 +1820,7 @@ class List <HostModel extends Model = Model> {
objectRows: function (
this: List, dataItem: Dictionary<any>, dimName: string, dataIndex: number, dimIndex: number
- ): ParsedDataValue {
+ ): ParsedValue {
return convertDataValue(dataItem[dimName], this._dimensionInfos[dimName]);
},
@@ -1828,7 +1828,7 @@ class List <HostModel extends Model = Model> {
original: function (
this: List, dataItem: any, dimName: string, dataIndex: number, dimIndex: number
- ): ParsedDataValue {
+ ): ParsedValue {
// Performance sensitive, do not use modelUtil.getDataItemValue.
// If dataItem is an plain object with no value field, the var `value`
// will be assigned with the object, but it will be tread correctly
@@ -1850,7 +1850,7 @@ class List <HostModel extends Model = Model> {
typedArray: function (
this: List, dataItem: any, dimName: string, dataIndex: number, dimIndex: number
- ): ParsedDataValue {
+ ): ParsedValue {
return dataItem[dimIndex];
}
@@ -1858,7 +1858,7 @@ class List <HostModel extends Model = Model> {
function getDimValueSimply(
this: List, dataItem: any, dimName: string, dataIndex: number, dimIndex: number
- ): ParsedDataValue {
+ ): ParsedValue {
return convertDataValue(dataItem[dimIndex], this._dimensionInfos[dimName]);
}
@@ -1867,7 +1867,7 @@ class List <HostModel extends Model = Model> {
* [Caution]: this is the key logic of user value parser.
* For backward compatibiliy, do not modify it until have to.
*/
- function convertDataValue(value: any, dimInfo: DataDimensionInfo): ParsedDataValue {
+ function convertDataValue(value: any, dimInfo: DataDimensionInfo): ParsedValue {
// Performance sensitive.
var dimType = dimInfo && dimInfo.type;
if (dimType === 'ordinal') {
@@ -2061,7 +2061,7 @@ class List <HostModel extends Model = Model> {
var Ctor = originalChunk.constructor;
// Only shallow clone is enough when Array.
return Ctor === Array
- ? (originalChunk as Array<ParsedDataValue>).slice()
+ ? (originalChunk as Array<ParsedValue>).slice()
: new (Ctor as DataTypedArrayConstructor)(originalChunk as DataTypedArray);
}
diff --git a/src/data/Tree.ts b/src/data/Tree.ts
index 96fdfdd..a8aa124 100644
--- a/src/data/Tree.ts
+++ b/src/data/Tree.ts
@@ -26,7 +26,7 @@ import Model from '../model/Model';
import linkList from './helper/linkList';
import List from './List';
import createDimensions from './helper/createDimensions';
-import { DimensionLoose, ParsedDataValue } from '../util/types';
+import { DimensionLoose, ParsedValue } from '../util/types';
import { Dictionary } from 'zrender/src/core/types';
type TreeTraverseOrder = 'preorder' | 'postorder';
@@ -187,7 +187,7 @@ class TreeNode {
return ancestors;
}
- getValue(dimension: DimensionLoose): ParsedDataValue {
+ getValue(dimension: DimensionLoose): ParsedValue {
var data = this.hostTree.data;
return data.get(data.getDimension(dimension || 'value'), this.dataIndex);
}
diff --git a/src/data/helper/dataProvider.ts b/src/data/helper/dataProvider.ts
index ab9753a..30e1b7e 100644
--- a/src/data/helper/dataProvider.ts
+++ b/src/data/helper/dataProvider.ts
@@ -35,7 +35,7 @@ import {
SERIES_LAYOUT_BY_COLUMN,
SERIES_LAYOUT_BY_ROW,
DimensionName, DimensionIndex, OptionSourceData,
- DimensionIndexLoose, OptionDataItem, OptionDataPrimitive
+ DimensionIndexLoose, OptionDataItem, OptionDataValue
} from '../../util/types';
import List from '../List';
@@ -144,8 +144,8 @@ export class DefaultDataProvider implements DataProvider {
count: function (this: DefaultDataProvider): number {
return Math.max(0, (this._data as OptionDataItem[][]).length - this._source.startIndex);
},
- getItem: function (this: DefaultDataProvider, idx: number): OptionDataPrimitive[] {
- return (this._data as OptionDataPrimitive[][])[idx + this._source.startIndex];
+ getItem: function (this: DefaultDataProvider, idx: number): OptionDataValue[] {
+ return (this._data as OptionDataValue[][])[idx + this._source.startIndex];
},
appendData: appendDataSimply
},
@@ -153,13 +153,13 @@ export class DefaultDataProvider implements DataProvider {
[SOURCE_FORMAT_ARRAY_ROWS + '_' + SERIES_LAYOUT_BY_ROW]: {
pure: true,
count: function (this: DefaultDataProvider): number {
- var row = (this._data as OptionDataPrimitive[][])[0];
+ var row = (this._data as OptionDataValue[][])[0];
return row ? Math.max(0, row.length - this._source.startIndex) : 0;
},
- getItem: function (this: DefaultDataProvider, idx: number): OptionDataPrimitive[] {
+ getItem: function (this: DefaultDataProvider, idx: number): OptionDataValue[] {
idx += this._source.startIndex;
var item = [];
- var data = this._data as OptionDataPrimitive[][];
+ var data = this._data as OptionDataValue[][];
for (var i = 0; i < data.length; i++) {
var row = data[i];
item.push(row ? row[idx] : null);
@@ -182,20 +182,20 @@ export class DefaultDataProvider implements DataProvider {
pure: true,
count: function (this: DefaultDataProvider): number {
var dimName = this._source.dimensionsDefine[0].name;
- var col = (this._data as Dictionary<OptionDataPrimitive[]>)[dimName];
+ var col = (this._data as Dictionary<OptionDataValue[]>)[dimName];
return col ? col.length : 0;
},
- getItem: function (this: DefaultDataProvider, idx: number): OptionDataPrimitive[] {
+ getItem: function (this: DefaultDataProvider, idx: number): OptionDataValue[] {
var item = [];
var dims = this._source.dimensionsDefine;
for (var i = 0; i < dims.length; i++) {
- var col = (this._data as Dictionary<OptionDataPrimitive[]>)[dims[i].name];
+ var col = (this._data as Dictionary<OptionDataValue[]>)[dims[i].name];
item.push(col ? col[idx] : null);
}
return item;
},
- appendData: function (this: DefaultDataProvider, newData: Dictionary<OptionDataPrimitive[]>) {
- var data = this._data as Dictionary<OptionDataPrimitive[]>;
+ appendData: function (this: DefaultDataProvider, newData: Dictionary<OptionDataValue[]>) {
+ var data = this._data as Dictionary<OptionDataValue[]>;
each(newData, function (newCol, key) {
var oldCol = data[key] || (data[key] = []);
for (var i = 0; i < (newCol || []).length; i++) {
@@ -272,15 +272,15 @@ type RawValueGetter = (
dimName: DimensionName
// If dimIndex not provided, return OptionDataItem.
// If dimIndex provided, return OptionDataPrimitive.
-) => OptionDataPrimitive | OptionDataItem;
+) => OptionDataValue | OptionDataItem;
var rawValueGetters: {[sourceFormat: string]: RawValueGetter} = {
[SOURCE_FORMAT_ARRAY_ROWS]: getRawValueSimply,
[SOURCE_FORMAT_OBJECT_ROWS]: function (
- dataItem: Dictionary<OptionDataPrimitive>, dataIndex: number, dimIndex: number, dimName: string
- ): OptionDataPrimitive | Dictionary<OptionDataPrimitive> {
+ dataItem: Dictionary<OptionDataValue>, dataIndex: number, dimIndex: number, dimName: string
+ ): OptionDataValue | Dictionary<OptionDataValue> {
return dimIndex != null ? dataItem[dimName] : dataItem;
},
@@ -288,7 +288,7 @@ var rawValueGetters: {[sourceFormat: string]: RawValueGetter} = {
[SOURCE_FORMAT_ORIGINAL]: function (
dataItem: OptionDataItem, dataIndex: number, dimIndex: number, dimName: string
- ): OptionDataPrimitive | OptionDataItem {
+ ): OptionDataValue | OptionDataItem {
// FIXME: In some case (markpoint in geo (geo-map.html)),
// dataItem is {coord: [...]}
var value = getDataItemValue(dataItem);
@@ -301,8 +301,8 @@ var rawValueGetters: {[sourceFormat: string]: RawValueGetter} = {
};
function getRawValueSimply(
- dataItem: ArrayLike<OptionDataPrimitive>, dataIndex: number, dimIndex: number, dimName: string
-): OptionDataPrimitive | ArrayLike<OptionDataPrimitive> {
+ dataItem: ArrayLike<OptionDataValue>, dataIndex: number, dimIndex: number, dimName: string
+): OptionDataValue | ArrayLike<OptionDataValue> {
return dimIndex != null ? dataItem[dimIndex] : dataItem;
}
@@ -370,6 +370,6 @@ export function retrieveRawAttr(data: List, dataIndex: number, attr: string): an
dataItem = null;
}
if (dataItem) {
- return (dataItem as Dictionary<OptionDataPrimitive>)[attr];
+ return (dataItem as Dictionary<OptionDataValue>)[attr];
}
}
diff --git a/src/model/mixin/dataFormat.ts b/src/model/mixin/dataFormat.ts
index e230fbe..696f350 100644
--- a/src/model/mixin/dataFormat.ts
+++ b/src/model/mixin/dataFormat.ts
@@ -20,7 +20,7 @@
import {retrieveRawValue} from '../../data/helper/dataProvider';
import {getTooltipMarker, formatTpl} from '../../util/format';
import { getTooltipRenderMode } from '../../util/model';
-import { DataHost, DisplayState, TooltipRenderMode, DataParamsUserOutput } from '../../util/types';
+import { DataHost, DisplayState, TooltipRenderMode, CallbackDataParams } from '../../util/types';
import GlobalModel from '../Global';
import Element from 'zrender/src/Element';
@@ -46,7 +46,7 @@ class DataFormatMixin {
dataIndex: number,
dataType?: string,
el?: Element // May be used in override.
- ): DataParamsUserOutput {
+ ): CallbackDataParams {
var data = this.getData(dataType);
var rawValue = this.getRawValue(dataIndex, dataType);
diff --git a/src/scale/Scale.ts b/src/scale/Scale.ts
index 339214d..9303428 100644
--- a/src/scale/Scale.ts
+++ b/src/scale/Scale.ts
@@ -21,7 +21,7 @@
import * as clazzUtil from '../util/clazz';
import { Dictionary } from 'zrender/src/core/types';
import List from '../data/List';
-import { DimensionName, ScaleDataValue, OptionDataPrimitive } from '../util/types';
+import { DimensionName, ScaleDataValue, OptionDataValue } from '../util/types';
abstract class Scale {
@@ -50,7 +50,7 @@ abstract class Scale {
* before extent set (like in dataZoom), it would be wrong.
* Nevertheless, parse does not depend on extent generally.
*/
- abstract parse(val: OptionDataPrimitive): number;
+ abstract parse(val: OptionDataValue): number;
/**
* Whether contain the given value.
diff --git a/src/util/animation.ts b/src/util/animation.ts
index f5dad67..d509531 100644
--- a/src/util/animation.ts
+++ b/src/util/animation.ts
@@ -21,7 +21,7 @@
import * as zrUtil from 'zrender/src/core/util';
import Element, { ElementProps } from 'zrender/src/Element';
-import { easingType } from 'zrender/src/animation/easing';
+import { ZREasing } from './types';
/**
* @param {number} [time=500] Time in ms
@@ -68,8 +68,8 @@ export function createWrap() {
el: Element,
target: ElementProps,
time?: number,
- delay?: number | easingType,
- easing?: easingType
+ delay?: number | ZREasing,
+ easing?: ZREasing
) {
if (zrUtil.isString(delay)) {
easing = delay;
diff --git a/src/util/model.ts b/src/util/model.ts
index 3a3b45d..e4e408b 100644
--- a/src/util/model.ts
+++ b/src/util/model.ts
@@ -40,7 +40,7 @@ import {
ComponentSubType,
DisplayStateHostOption,
OptionDataItem,
- OptionDataPrimitive,
+ OptionDataValue,
TooltipRenderMode
} from './types';
import { Dictionary } from 'zrender/src/core/types';
@@ -126,9 +126,9 @@ export var TEXT_STYLE_OPTIONS = [
*/
export function getDataItemValue(
dataItem: OptionDataItem
-): OptionDataPrimitive | OptionDataPrimitive[] {
+): OptionDataValue | OptionDataValue[] {
return (isObject(dataItem) && !isArray(dataItem) && !(dataItem instanceof Date))
- ? (dataItem as Dictionary<OptionDataPrimitive>).value : dataItem;
+ ? (dataItem as Dictionary<OptionDataValue>).value : dataItem;
}
/**
diff --git a/src/util/types.ts b/src/util/types.ts
index 26c249c..120615f 100644
--- a/src/util/types.ts
+++ b/src/util/types.ts
@@ -53,7 +53,7 @@ export type RendererType = 'canvas' | 'svg';
// Types from zrender
export type ColorString = string;
export type ZRColor = ColorString | LinearGradientObject | RadialGradientObject | PatternObject
-export type ZRLineType = 'solid' | 'dotted'
+export type ZRLineType = 'solid' | 'dotted' | 'dashed'
export type ZRAlign = 'left' | 'center' | 'right'
export type ZRVerticalAlign = 'top' | 'middle' | 'bottom'
@@ -227,16 +227,16 @@ export type TooltipRenderMode = 'html' | 'richText';
// Check `convertDataValue` for more details.
export type OrdinalRawValue = string | number;
export type OrdinalNumber = number; // The number mapped from each OrdinalRawValue.
-export type ParsedDataNumeric = number | OrdinalNumber;
-export type ParsedDataValue = ParsedDataNumeric | OrdinalRawValue;
+export type ParsedValueNumeric = number | OrdinalNumber;
+export type ParsedValue = ParsedValueNumeric | OrdinalRawValue;
// FIXME:TS better name?
// This is not `OptionDataPrimitive` because the "dataProvider parse"
// will not be performed. But "scale parse" will be performed.
-export type ScaleDataValue = ParsedDataValue | Date;
+export type ScaleDataValue = ParsedValue | Date;
-export type AxisValue = ParsedDataNumeric;
+export type AxisValue = ParsedValueNumeric;
-// Can only be string or index, because it is used in object key in some code.
+// Can only be string or index, because it is used in object key in s ome code.
// Making the type alias here just intending to show the meaning clearly in code.
export type DimensionIndex = number;
// If being a number-like string but not being defined a dimension name.
@@ -388,12 +388,12 @@ export type OptionSourceData =
| Dictionary<ArrayLike<OptionDataItem>>; // Only for `SOURCE_FORMAT_KEYED_COLUMNS`.
// See also `model.js#getDataItemValue`.
export type OptionDataItem =
- OptionDataPrimitive
- | Dictionary<OptionDataPrimitive>
- | ArrayLike<OptionDataPrimitive>
+ OptionDataValue
+ | Dictionary<OptionDataValue>
+ | ArrayLike<OptionDataValue>
// FIXME: In some case (markpoint in geo (geo-map.html)), dataItem is {coord: [...]}
- | {value: ArrayLike<OptionDataPrimitive>}; // Only for `SOURCE_FORMAT_KEYED_ORIGINAL`
-export type OptionDataPrimitive = string | number | Date;
+ | {value: ArrayLike<OptionDataValue>}; // Only for `SOURCE_FORMAT_KEYED_ORIGINAL`
+export type OptionDataValue = string | number | Date;
// export type ModelOption = Dictionary<any> | any[] | string | number | boolean | ((...args: any) => any);
export type ModelOption = any;
@@ -421,7 +421,7 @@ export type OptionEncodeValue = DimensionIndex[] | DimensionIndex | DimensionNam
export type EncodeDefaulter = (source: Source, dimCount: number) => OptionEncode;
// TODO: TYPE Different callback param for different series
-export interface DataParamsUserOutput {
+export interface CallbackDataParams {
// component main type
componentType: string;
// component sub type
@@ -577,8 +577,8 @@ export interface AnimationOptionMixin {
}
// TODO: TYPE value type?
-export type SymbolSizeCallback = (rawValue: any, params: DataParamsUserOutput) => number | number[]
-export type SymbolCallback = (rawValue: any, params: DataParamsUserOutput) => string
+export type SymbolSizeCallback = (rawValue: any, params: CallbackDataParams) => number | number[]
+export type SymbolCallback = (rawValue: any, params: CallbackDataParams) => string
/**
* Mixin of option set to control the element symbol.
* Include type of symbol, and size of symbol.
@@ -609,7 +609,7 @@ export interface ItemStyleOption extends ShadowOptionMixin, BorderOptionMixin {
* Used in the components or series like `line`, `axis`
* It includes stroke style.
*/
-export interface LineStyleOption<Clr = ZRColor> extends ShadowOptionMixin {
+export interface LineStyleOption<Clr = ZRColor> extends ShadowOptionMixin {
width?: number
color?: Clr
opacity?: number
@@ -711,7 +711,7 @@ export interface LabelOption extends TextCommonOption {
distance?: number
rotate?: number | boolean
offset?: number[]
- formatter?: string | ((params: DataParamsUserOutput) => string)
+ formatter?: string | ((params: CallbackDataParams) => string)
rich?: Dictionary<TextCommonOption>
}
@@ -725,7 +725,6 @@ export interface LabelLineOption {
}
export interface ComponentOption {
- show?: boolean
type?: string;
id?: string;
name?: string;
diff --git a/src/visual/VisualMapping.ts b/src/visual/VisualMapping.ts
index 291ff5b..995e3e7 100644
--- a/src/visual/VisualMapping.ts
+++ b/src/visual/VisualMapping.ts
@@ -28,7 +28,7 @@ import {
VisualOptionCategory,
VisualOptionLinear,
VisualOptionUnit,
- ParsedDataValue
+ ParsedValue
} from '../util/types';
const each = zrUtil.each;
@@ -37,7 +37,7 @@ const isObject = zrUtil.isObject;
const CATEGORY_DEFAULT_VISUAL_INDEX = -1;
// Type of raw value
-type RawValue = ParsedDataValue
+type RawValue = ParsedValue
// Type of mapping visual value
type VisualValue = AllPropTypes<VisualOptionUnit>
// Type of value after normalized. 0 - 1
diff --git a/src/visual/visualSolution.ts b/src/visual/visualSolution.ts
index 62cb939..2922dce 100644
--- a/src/visual/visualSolution.ts
+++ b/src/visual/visualSolution.ts
@@ -26,7 +26,7 @@ import VisualMapping, { VisualMappingOption } from './VisualMapping';
import { Dictionary } from 'zrender/src/core/types';
import {
BuiltinVisualProperty,
- ParsedDataValue,
+ ParsedValue,
DimensionLoose,
StageHandlerProgressExecutor
} from '../util/types';
@@ -136,7 +136,7 @@ export function applyVisual<VisualState extends string, Scope>(
stateList: VisualState[],
visualMappings: VisualMappingCollection<VisualState>,
data: List,
- getValueState: (this: Scope, valueOrIndex: ParsedDataValue | number) => VisualState,
+ getValueState: (this: Scope, valueOrIndex: ParsedValue | number) => VisualState,
scope?: Scope,
dimension?: DimensionLoose
) {
@@ -163,7 +163,7 @@ export function applyVisual<VisualState extends string, Scope>(
data.each([dimension], eachItem);
}
- function eachItem(valueOrIndex: ParsedDataValue | number, index?: number) {
+ function eachItem(valueOrIndex: ParsedValue | number, index?: number) {
dataIndex = dimension == null
? valueOrIndex as number // First argument is index
: index;
@@ -198,7 +198,7 @@ export function applyVisual<VisualState extends string, Scope>(
export function incrementalApplyVisual<VisualState extends string>(
stateList: VisualState[],
visualMappings: VisualMappingCollection<VisualState>,
- getValueState: (valueOrIndex: ParsedDataValue | number) => VisualState,
+ getValueState: (valueOrIndex: ParsedValue | number) => VisualState,
dim?: DimensionLoose
): StageHandlerProgressExecutor {
var visualTypesMap: WithKey<VisualState, BuiltinVisualProperty[]> = {};
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org