Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
半栈学徒
incubator-echarts
提交
9d9ffce7
I
incubator-echarts
项目概览
半栈学徒
/
incubator-echarts
与 Fork 源项目一致
从无法访问的项目Fork
通知
5
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
I
incubator-echarts
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
9d9ffce7
编写于
7月 26, 2020
作者:
1
100pah
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
ts: add types to some @ts-nocheck and remove some 'any'.
上级
39bd739c
变更
31
展开全部
隐藏空白更改
内联
并排
Showing
31 changed file
with
484 addition
and
298 deletion
+484
-298
src/chart/bar/BarView.ts
src/chart/bar/BarView.ts
+1
-1
src/chart/custom.ts
src/chart/custom.ts
+3
-2
src/chart/funnel/FunnelSeries.ts
src/chart/funnel/FunnelSeries.ts
+1
-1
src/chart/graph/GraphSeries.ts
src/chart/graph/GraphSeries.ts
+8
-12
src/chart/helper/createGraphFromNodeEdge.ts
src/chart/helper/createGraphFromNodeEdge.ts
+17
-4
src/chart/helper/createListFromArray.ts
src/chart/helper/createListFromArray.ts
+4
-2
src/chart/helper/whiskerBoxCommon.ts
src/chart/helper/whiskerBoxCommon.ts
+4
-3
src/chart/map/MapSeries.ts
src/chart/map/MapSeries.ts
+1
-1
src/chart/pie/PieSeries.ts
src/chart/pie/PieSeries.ts
+1
-1
src/chart/sankey/SankeySeries.ts
src/chart/sankey/SankeySeries.ts
+7
-12
src/chart/sunburst/SunburstSeries.ts
src/chart/sunburst/SunburstSeries.ts
+1
-1
src/component/toolbox/feature/DataView.ts
src/component/toolbox/feature/DataView.ts
+1
-1
src/component/toolbox/feature/MagicType.ts
src/component/toolbox/feature/MagicType.ts
+9
-8
src/coord/calendar/Calendar.ts
src/coord/calendar/Calendar.ts
+1
-1
src/data/DataDimensionInfo.ts
src/data/DataDimensionInfo.ts
+1
-1
src/data/Graph.ts
src/data/Graph.ts
+1
-1
src/data/List.ts
src/data/List.ts
+17
-6
src/data/Source.ts
src/data/Source.ts
+5
-3
src/data/helper/completeDimensions.ts
src/data/helper/completeDimensions.ts
+65
-35
src/data/helper/createDimensions.ts
src/data/helper/createDimensions.ts
+18
-4
src/data/helper/dimensionHelper.ts
src/data/helper/dimensionHelper.ts
+11
-12
src/data/helper/linkList.ts
src/data/helper/linkList.ts
+68
-51
src/data/helper/sourceHelper.ts
src/data/helper/sourceHelper.ts
+155
-91
src/label/LabelManager.ts
src/label/LabelManager.ts
+4
-3
src/model/Series.ts
src/model/Series.ts
+9
-11
src/model/mixin/dataFormat.ts
src/model/mixin/dataFormat.ts
+5
-4
src/stream/task.ts
src/stream/task.ts
+3
-2
src/util/graphic.ts
src/util/graphic.ts
+3
-2
src/util/model.ts
src/util/model.ts
+1
-1
src/util/states.ts
src/util/states.ts
+4
-4
src/util/types.ts
src/util/types.ts
+55
-17
未找到文件。
src/chart/bar/BarView.ts
浏览文件 @
9d9ffce7
...
...
@@ -787,7 +787,7 @@ function updateStyle(
// In case width or height are too small.
function
getLineWidth
(
itemModel
:
Model
<
Bar
Series
Option
>
,
itemModel
:
Model
<
Bar
DataItem
Option
>
,
rawLayout
:
RectLayout
)
{
const
lineWidth
=
itemModel
.
get
(
BAR_BORDER_WIDTH_QUERY
)
||
0
;
...
...
src/chart/custom.ts
浏览文件 @
9d9ffce7
...
...
@@ -50,7 +50,8 @@ import {
DisplayState
,
ECElement
,
DisplayStateNonNormal
,
BlurScope
BlurScope
,
SeriesDataType
}
from
'
../util/types
'
;
import
Element
,
{
ElementProps
,
ElementTextConfig
}
from
'
zrender/src/Element
'
;
import
prepareCartesian2d
from
'
../coord/cartesian/prepareCustom
'
;
...
...
@@ -411,7 +412,7 @@ class CustomSeriesModel extends SeriesModel<CustomSeriesOption> {
return
createListFromArray
(
this
.
getSource
(),
this
);
}
getDataParams
(
dataIndex
:
number
,
dataType
?:
string
,
el
?:
Element
):
CallbackDataParams
&
{
getDataParams
(
dataIndex
:
number
,
dataType
?:
SeriesDataType
,
el
?:
Element
):
CallbackDataParams
&
{
info
:
CustomExtraElementInfo
}
{
const
params
=
super
.
getDataParams
(
dataIndex
,
dataType
)
as
ReturnType
<
CustomSeriesModel
[
'
getDataParams
'
]
>
;
...
...
src/chart/funnel/FunnelSeries.ts
浏览文件 @
9d9ffce7
...
...
@@ -99,7 +99,7 @@ class FunnelSeriesModel extends SeriesModel<FunnelSeriesOption> {
this
.
_defaultLabelLine
(
option
);
}
getInitialData
(
option
:
FunnelSeriesOption
,
ecModel
:
GlobalModel
):
List
{
getInitialData
(
this
:
FunnelSeriesModel
,
option
:
FunnelSeriesOption
,
ecModel
:
GlobalModel
):
List
{
return
createListSimply
(
this
,
{
coordDimensions
:
[
'
value
'
],
encodeDefaulter
:
zrUtil
.
curry
(
makeSeriesEncodeForNameBased
,
this
)
...
...
src/chart/graph/GraphSeries.ts
浏览文件 @
9d9ffce7
...
...
@@ -41,7 +41,9 @@ import {
LabelFormatterCallback
,
Dictionary
,
LineLabelOption
,
StatesOptionMixin
StatesOptionMixin
,
GraphEdgeItemObject
,
OptionDataValueNumeric
}
from
'
../../util/types
'
;
import
SeriesModel
from
'
../../model/Series
'
;
import
Graph
from
'
../../data/Graph
'
;
...
...
@@ -107,16 +109,10 @@ export interface GraphEdgeStateOption {
lineStyle
?:
GraphEdgeLineStyleOption
label
?:
LineLabelOption
}
export
interface
GraphEdgeItemOption
extends
GraphEdgeStateOption
,
StatesOptionMixin
<
GraphEdgeStateOption
,
ExtraEdgeStateOption
>
{
/**
* Name or index of source node.
*/
source
?:
string
|
number
/**
* Name or index of target node.
*/
target
?:
string
|
number
export
interface
GraphEdgeItemOption
extends
GraphEdgeStateOption
,
StatesOptionMixin
<
GraphEdgeStateOption
,
ExtraEdgeStateOption
>
,
GraphEdgeItemObject
<
OptionDataValueNumeric
>
{
value
?:
number
...
...
@@ -272,7 +268,7 @@ class GraphSeriesModel extends SeriesModel<GraphSeriesOption> {
defaultEmphasis
(
option
,
'
edgeLabel
'
,
[
'
show
'
]);
}
getInitialData
(
option
:
GraphSeriesOption
,
ecModel
:
GlobalModel
)
{
getInitialData
(
option
:
GraphSeriesOption
,
ecModel
:
GlobalModel
)
:
List
{
const
edges
=
option
.
edges
||
option
.
links
||
[];
const
nodes
=
option
.
data
||
option
.
nodes
||
[];
const
self
=
this
;
...
...
src/chart/helper/createGraphFromNodeEdge.ts
浏览文件 @
9d9ffce7
...
...
@@ -17,7 +17,6 @@
* under the License.
*/
// @ts-nocheck
import
*
as
zrUtil
from
'
zrender/src/core/util
'
;
import
List
from
'
../../data/List
'
;
...
...
@@ -26,8 +25,19 @@ import linkList from '../../data/helper/linkList';
import
createDimensions
from
'
../../data/helper/createDimensions
'
;
import
CoordinateSystem
from
'
../../CoordinateSystem
'
;
import
createListFromArray
from
'
./createListFromArray
'
;
import
{
OptionSourceDataOriginal
,
GraphEdgeItemObject
,
OptionDataValue
,
OptionDataItemObject
}
from
'
../../util/types
'
;
import
SeriesModel
from
'
../../model/Series
'
;
export
default
function
(
nodes
,
edges
,
seriesModel
,
directed
,
beforeLink
)
{
export
default
function
(
nodes
:
OptionSourceDataOriginal
<
OptionDataValue
,
OptionDataItemObject
<
OptionDataValue
>>
,
edges
:
OptionSourceDataOriginal
<
OptionDataValue
,
GraphEdgeItemObject
<
OptionDataValue
>>
,
seriesModel
:
SeriesModel
,
directed
:
boolean
,
beforeLink
:
(
nodeData
:
List
,
edgeData
:
List
)
=>
void
):
Graph
{
// ??? TODO
// support dataset?
const
graph
=
new
Graph
(
directed
);
...
...
@@ -48,7 +58,10 @@ export default function (nodes, edges, seriesModel, directed, beforeLink) {
// addEdge may fail when source or target not exists
if
(
graph
.
addEdge
(
source
,
target
,
linkCount
))
{
validEdges
.
push
(
link
);
linkNameList
.
push
(
zrUtil
.
retrieve
(
link
.
id
,
source
+
'
>
'
+
target
));
linkNameList
.
push
(
zrUtil
.
retrieve
(
link
.
id
!=
null
?
link
.
id
+
''
:
null
,
source
+
'
>
'
+
target
));
linkCount
++
;
}
}
...
...
@@ -60,7 +73,7 @@ export default function (nodes, edges, seriesModel, directed, beforeLink) {
}
else
{
const
coordSysCtor
=
CoordinateSystem
.
get
(
coordSys
);
const
coordDimensions
=
(
coordSysCtor
&&
coordSysCtor
.
type
!==
'
view
'
)
const
coordDimensions
=
coordSysCtor
?
(
coordSysCtor
.
dimensions
||
[])
:
[];
// FIXME: Some geo do not need `value` dimenson, whereas `calendar` needs
// `value` dimension, but graph need `value` dimension. It's better to
...
...
src/chart/helper/createListFromArray.ts
浏览文件 @
9d9ffce7
...
...
@@ -27,10 +27,12 @@ import {getCoordSysInfoBySeries} from '../../model/referHelper';
import
Source
from
'
../../data/Source
'
;
import
{
enableDataStack
}
from
'
../../data/helper/dataStackHelper
'
;
import
{
makeSeriesEncodeForAxisCoordSys
}
from
'
../../data/helper/sourceHelper
'
;
import
{
SOURCE_FORMAT_ORIGINAL
,
DimensionDefinitionLoose
,
DimensionDefinition
}
from
'
../../util/types
'
;
import
{
SOURCE_FORMAT_ORIGINAL
,
DimensionDefinitionLoose
,
DimensionDefinition
,
OptionSourceData
}
from
'
../../util/types
'
;
import
SeriesModel
from
'
../../model/Series
'
;
function
createListFromArray
(
source
:
Source
|
any
[]
,
seriesModel
:
SeriesModel
,
opt
?:
{
function
createListFromArray
(
source
:
Source
|
OptionSourceData
,
seriesModel
:
SeriesModel
,
opt
?:
{
generateCoord
?:
string
useEncodeDefaulter
?:
boolean
}):
List
{
...
...
src/chart/helper/whiskerBoxCommon.ts
浏览文件 @
9d9ffce7
...
...
@@ -28,6 +28,7 @@ import type CartesianAxisModel from '../../coord/cartesian/AxisModel';
import
type
DataDimensionInfo
from
'
../../data/DataDimensionInfo
'
;
import
type
List
from
'
../../data/List
'
;
import
type
Axis2D
from
'
../../coord/cartesian/Axis2D
'
;
import
{
CoordDimensionDefinition
}
from
'
../../data/helper/createDimensions
'
;
interface
CommonOption
extends
SeriesOption
,
SeriesOnCartesianOptionMixin
{
layout
?:
LayoutOrient
...
...
@@ -50,7 +51,7 @@ class WhiskerBoxCommonMixin<Opts extends CommonOption> {
*/
_baseAxisDim
:
string
;
defaultValueDimensions
:
Partial
<
DataDimensionInfo
>
[
];
defaultValueDimensions
:
CoordDimensionDefinition
[
'
dimsDef
'
];
/**
* @override
...
...
@@ -117,7 +118,7 @@ class WhiskerBoxCommonMixin<Opts extends CommonOption> {
}
const
defaultValueDimensions
=
this
.
defaultValueDimensions
;
const
coordDimensions
=
[{
const
coordDimensions
:
CoordDimensionDefinition
[]
=
[{
name
:
baseAxisDim
,
type
:
getDimensionTypeByAxis
(
baseAxisType
),
ordinalMeta
:
ordinalMeta
,
...
...
@@ -138,7 +139,7 @@ class WhiskerBoxCommonMixin<Opts extends CommonOption> {
coordDimensions
:
coordDimensions
,
dimensionsCount
:
defaultValueDimensions
.
length
+
1
,
encodeDefaulter
:
zrUtil
.
curry
(
makeSeriesEncodeForAxisCoordSys
,
coordDimensions
,
this
makeSeriesEncodeForAxisCoordSys
,
coordDimensions
,
this
as
any
)
}
);
...
...
src/chart/map/MapSeries.ts
浏览文件 @
9d9ffce7
...
...
@@ -110,7 +110,7 @@ class MapSeries extends SeriesModel<MapSeriesOption> {
seriesGroup
:
MapSeries
[]
=
[];
getInitialData
(
option
:
MapSeriesOption
):
List
{
getInitialData
(
this
:
MapSeries
,
option
:
MapSeriesOption
):
List
{
const
data
=
createListSimply
(
this
,
{
coordDimensions
:
[
'
value
'
],
encodeDefaulter
:
zrUtil
.
curry
(
makeSeriesEncodeForNameBased
,
this
)
...
...
src/chart/pie/PieSeries.ts
浏览文件 @
9d9ffce7
...
...
@@ -135,7 +135,7 @@ class PieSeriesModel extends SeriesModel<PieSeriesOption> {
/**
* @overwrite
*/
getInitialData
():
List
{
getInitialData
(
this
:
PieSeriesModel
):
List
{
return
createListSimply
(
this
,
{
coordDimensions
:
[
'
value
'
],
encodeDefaulter
:
zrUtil
.
curry
(
makeSeriesEncodeForNameBased
,
this
)
...
...
src/chart/sankey/SankeySeries.ts
浏览文件 @
9d9ffce7
...
...
@@ -32,7 +32,9 @@ import {
LayoutOrient
,
ColorString
,
StatesOptionMixin
,
OptionDataItemObject
OptionDataItemObject
,
GraphEdgeItemObject
,
OptionDataValueNumeric
}
from
'
../../util/types
'
;
import
GlobalModel
from
'
../../model/Global
'
;
import
List
from
'
../../data/List
'
;
...
...
@@ -77,17 +79,10 @@ export interface SankeyNodeItemOption extends SankeyNodeStateOption,
focusNodeAdjacency
?:
FocusNodeAdjacency
}
export
interface
SankeyEdgeItemOption
extends
SankeyEdgeStateOption
,
StatesOptionMixin
<
SankeyEdgeStateOption
,
ExtraStateOption
>
{
/**
* Name or index of source node.
*/
source
?:
string
|
number
/**
* Name or index of target node.
*/
target
?:
string
|
number
export
interface
SankeyEdgeItemOption
extends
SankeyEdgeStateOption
,
StatesOptionMixin
<
SankeyEdgeStateOption
,
ExtraStateOption
>
,
GraphEdgeItemObject
<
OptionDataValueNumeric
>
{
focusNodeAdjacency
?:
FocusNodeAdjacency
}
...
...
src/chart/sunburst/SunburstSeries.ts
浏览文件 @
9d9ffce7
...
...
@@ -128,7 +128,7 @@ class SunburstSeriesModel extends SeriesModel<SunburstSeriesOption> {
getInitialData
(
option
:
SunburstSeriesOption
,
ecModel
:
GlobalModel
)
{
// Create a virtual root.
const
root
=
{
name
:
option
.
name
,
children
:
option
.
data
};
const
root
=
{
name
:
option
.
name
,
children
:
option
.
data
}
as
SunburstSeriesNodeItemOption
;
completeTreeValue
(
root
);
...
...
src/component/toolbox/feature/DataView.ts
浏览文件 @
9d9ffce7
...
...
@@ -485,7 +485,7 @@ echarts.registerAction({
const
originalData
=
seriesModel
.
get
(
'
data
'
);
newSeriesOptList
.
push
({
name
:
seriesOpt
.
name
,
data
:
tryMergeDataOption
(
seriesOpt
.
data
,
originalData
)
data
:
tryMergeDataOption
(
seriesOpt
.
data
as
DataList
,
originalData
as
DataList
)
});
}
});
...
...
src/component/toolbox/feature/MagicType.ts
浏览文件 @
9d9ffce7
...
...
@@ -100,7 +100,7 @@ class MagicType extends ToolboxFeature<ToolboxMagicTypeFeatureOption> {
const
newOption
:
ECUnitOption
=
{
series
:
[]
};
const
generateNewSeriesTypes
=
function
(
seriesModel
:
SeriesModel
)
{
const
generateNewSeriesTypes
=
function
(
seriesModel
:
SeriesModel
<
MegicTypeSeriesOption
>
)
{
const
seriesType
=
seriesModel
.
subType
;
const
seriesId
=
seriesModel
.
id
;
const
newSeriesOpt
=
seriesOptGenreator
[
type
](
...
...
@@ -170,17 +170,18 @@ class MagicType extends ToolboxFeature<ToolboxMagicTypeFeatureOption> {
}
}
type
MegicTypeSeriesOption
=
SeriesOption
&
{
// TODO: TYPE More specified series option
stack
?:
boolean
|
string
data
?:
unknown
[]
markPoint
?:
unknown
markLine
?:
unknown
};
type
SeriesOptGenreator
=
(
seriesType
:
string
,
seriesId
:
string
,
seriesModel
:
SeriesModel
<
SeriesOption
&
{
// TODO: TYPE More specified series option
stack
?:
boolean
|
string
data
?:
any
[]
markPoint
?:
any
markLine
?:
any
}
>
,
seriesModel
:
SeriesModel
<
MegicTypeSeriesOption
>
,
model
:
ToolboxFeatureModel
<
ToolboxMagicTypeFeatureOption
>
)
=>
SeriesOption
;
...
...
src/coord/calendar/Calendar.ts
浏览文件 @
9d9ffce7
...
...
@@ -98,7 +98,7 @@ class Calendar implements CoordinateSystem, CoordinateSystemMaster {
static
readonly
dimensions
=
[
'
time
'
,
'
value
'
];
static
getDimensionsInfo
()
{
return
[{
name
:
'
time
'
,
type
:
'
time
'
name
:
'
time
'
,
type
:
'
time
'
as
const
},
'
value
'
];
}
...
...
src/data/DataDimensionInfo.ts
浏览文件 @
9d9ffce7
...
...
@@ -126,7 +126,7 @@ class DataDimensionInfo {
/**
* @param opt All of the fields will be shallow copied.
*/
constructor
(
opt
:
object
|
DataDimensionInfo
)
{
constructor
(
opt
?
:
object
|
DataDimensionInfo
)
{
if
(
opt
!=
null
)
{
zrUtil
.
extend
(
this
,
opt
);
}
...
...
src/data/Graph.ts
浏览文件 @
9d9ffce7
...
...
@@ -68,7 +68,7 @@ class Graph {
/**
* Add a new node
*/
addNode
(
id
:
string
,
dataIndex
?:
number
):
GraphNode
{
addNode
(
id
:
string
|
number
,
dataIndex
?:
number
):
GraphNode
{
id
=
id
==
null
?
(
''
+
dataIndex
)
:
(
''
+
id
);
const
nodesMap
=
this
.
_nodesMap
;
...
...
src/data/List.ts
浏览文件 @
9d9ffce7
...
...
@@ -35,7 +35,7 @@ import {ArrayLike, Dictionary, FunctionPropertyNames} from 'zrender/src/core/typ
import
Element
from
'
zrender/src/Element
'
;
import
{
DimensionIndex
,
DimensionName
,
DimensionLoose
,
OptionDataItem
,
ParsedValue
,
ParsedValueNumeric
,
OrdinalNumber
,
DimensionUserOuput
,
ModelOption
ParsedValue
,
ParsedValueNumeric
,
OrdinalNumber
,
DimensionUserOuput
,
ModelOption
,
SeriesDataType
}
from
'
../util/types
'
;
import
{
parseDate
}
from
'
../util/number
'
;
import
{
isDataItemOption
}
from
'
../util/model
'
;
...
...
@@ -180,16 +180,22 @@ class List<
readonly
hostModel
:
HostModel
;
readonly
dataType
:
string
;
/**
* @readonly
*/
dataType
:
SeriesDataType
;
/**
* @readonly
* Host graph if List is used to store graph nodes / edges.
*/
readonly
graph
?:
Graph
;
graph
?:
Graph
;
/**
* @readonly
* Host tree if List is used to store tree ndoes.
*/
readonly
tree
?:
Tree
;
tree
?:
Tree
;
// Indices stores the indices of data subset after filtered.
// This data subset will be used in chart.
...
...
@@ -267,9 +273,9 @@ class List<
// Methods that create a new list based on this list should be listed here.
// Notice that those method should `RETURN` the new list.
TRANSFERABLE_METHODS
=
[
'
cloneShallow
'
,
'
downSample
'
,
'
map
'
];
TRANSFERABLE_METHODS
=
[
'
cloneShallow
'
,
'
downSample
'
,
'
map
'
]
as
const
;
// Methods that change indices of this list should be listed here.
CHANGABLE_METHODS
=
[
'
filterSelf
'
,
'
selectRange
'
];
CHANGABLE_METHODS
=
[
'
filterSelf
'
,
'
selectRange
'
]
as
const
;
/**
...
...
@@ -2190,4 +2196,9 @@ class List<
}
interface
List
{
getLinkedData
(
dataType
?:
SeriesDataType
):
List
;
getLinkedDataAll
():
{
data
:
List
,
type
?:
SeriesDataType
}[];
}
export
default
List
;
src/data/Source.ts
浏览文件 @
9d9ffce7
...
...
@@ -25,7 +25,8 @@ import {
SERIES_LAYOUT_BY_COLUMN
,
SOURCE_FORMAT_UNKNOWN
,
SOURCE_FORMAT_KEYED_COLUMNS
,
SOURCE_FORMAT_TYPED_ARRAY
SOURCE_FORMAT_TYPED_ARRAY
,
DimensionName
}
from
'
../util/types
'
;
/**
...
...
@@ -97,7 +98,7 @@ class Source {
* can be null/undefined.
* Might be specified outside.
*/
encodeDefine
:
HashMap
<
OptionEncodeValue
>
;
encodeDefine
:
HashMap
<
OptionEncodeValue
,
DimensionName
>
;
/**
* Not null/undefined, uint.
...
...
@@ -128,7 +129,8 @@ class Source {
this
.
sourceFormat
=
fields
.
sourceFormat
||
SOURCE_FORMAT_UNKNOWN
;
this
.
seriesLayoutBy
=
fields
.
seriesLayoutBy
||
SERIES_LAYOUT_BY_COLUMN
;
this
.
dimensionsDefine
=
fields
.
dimensionsDefine
;
this
.
encodeDefine
=
fields
.
encodeDefine
&&
createHashMap
(
fields
.
encodeDefine
);
this
.
encodeDefine
=
fields
.
encodeDefine
&&
createHashMap
<
OptionEncodeValue
,
DimensionName
>
(
fields
.
encodeDefine
);
this
.
startIndex
=
fields
.
startIndex
||
0
;
this
.
dimensionsDetectCount
=
fields
.
dimensionsDetectCount
;
}
...
...
src/data/helper/completeDimensions.ts
浏览文件 @
9d9ffce7
...
...
@@ -17,18 +17,22 @@
* under the License.
*/
// @ts-nocheck
/**
* @deprecated
* Use `echarts/data/helper/createDimensions` instead.
*/
import
{
createHashMap
,
each
,
isString
,
defaults
,
extend
,
isObject
,
clone
}
from
'
zrender/src/core/util
'
;
import
{
createHashMap
,
each
,
isString
,
defaults
,
extend
,
isObject
,
clone
,
HashMap
}
from
'
zrender/src/core/util
'
;
import
{
normalizeToArray
}
from
'
../../util/model
'
;
import
{
guessOrdinal
,
BE_ORDINAL
}
from
'
./sourceHelper
'
;
import
Source
from
'
../Source
'
;
import
{
VISUAL_DIMENSIONS
}
from
'
../../util/types
'
;
import
{
VISUAL_DIMENSIONS
,
DimensionDefinitionLoose
,
OptionSourceData
,
EncodeDefaulter
,
OptionEncodeValue
,
OptionEncode
,
DimensionName
,
DimensionIndex
,
DataVisualDimensions
}
from
'
../../util/types
'
;
import
DataDimensionInfo
from
'
../DataDimensionInfo
'
;
import
List
from
'
../List
'
;
import
{
CoordDimensionDefinition
,
CoordDimensionDefinitionLoose
}
from
'
./createDimensions
'
;
/**
* @see {module:echarts/test/ut/spec/data/completeDimensions}
...
...
@@ -69,25 +73,37 @@ import DataDimensionInfo from '../DataDimensionInfo';
* @param {number} [opt.dimCount] If not specified, guess by the first data item.
* @return {Array.<module:data/DataDimensionInfo>}
*/
function
completeDimensions
(
sysDims
,
source
,
opt
)
{
function
completeDimensions
(
sysDims
:
CoordDimensionDefinitionLoose
[],
source
:
Source
|
List
|
OptionSourceData
,
opt
:
{
dimsDef
?:
DimensionDefinitionLoose
[];
encodeDef
?:
HashMap
<
OptionEncodeValue
,
DimensionName
>
|
OptionEncode
;
dimCount
?:
number
;
encodeDefaulter
?:
EncodeDefaulter
;
generateCoord
?:
string
;
generateCoordCount
?:
number
;
}
):
DataDimensionInfo
[]
{
if
(
!
(
source
instanceof
Source
))
{
source
=
Source
.
seriesDataToSource
(
source
);
source
=
Source
.
seriesDataToSource
(
source
as
OptionSourceData
);
}
opt
=
opt
||
{};
sysDims
=
(
sysDims
||
[]).
slice
();
const
dimsDef
=
(
opt
.
dimsDef
||
[]).
slice
();
const
dataDimNameMap
=
createHashMap
();
const
coordDimNameMap
=
createHashMap
();
const
dataDimNameMap
=
createHashMap
<
DimensionIndex
,
DimensionName
>
();
const
coordDimNameMap
=
createHashMap
<
true
,
DimensionName
>
();
// let valueCandidate;
const
result
=
[];
const
result
:
DataDimensionInfo
[]
=
[];
const
dimCount
=
getDimCount
(
source
,
sysDims
,
dimsDef
,
opt
.
dimCount
);
// Apply user defined dims (`name` and `type`) and init result.
for
(
let
i
=
0
;
i
<
dimCount
;
i
++
)
{
const
dimDefItemRaw
=
dimsDef
[
i
];
const
dimDefItem
=
dimsDef
[
i
]
=
extend
(
{},
isObject
(
dim
sDef
[
i
])
?
dimsDef
[
i
]
:
{
name
:
dimsDef
[
i
]
}
{},
isObject
(
dim
DefItemRaw
)
?
dimDefItemRaw
:
{
name
:
dimDefItemRaw
}
);
const
userDimName
=
dimDefItem
.
name
;
const
resultItem
=
result
[
i
]
=
new
DataDimensionInfo
();
...
...
@@ -107,24 +123,26 @@ function completeDimensions(sysDims, source, opt) {
if
(
!
encodeDef
&&
opt
.
encodeDefaulter
)
{
encodeDef
=
opt
.
encodeDefaulter
(
source
,
dimCount
);
}
encodeDef
=
createHashMap
(
encodeDef
);
const
encodeDefMap
=
createHashMap
<
DimensionIndex
[]
|
false
,
DimensionName
>
(
encodeDef
as
any
);
// Set `coordDim` and `coordDimIndex` by `encodeDef
` and normalize `encodeDef
`.
encodeDef
.
each
(
function
(
dataDims
,
coordDim
)
{
dataDims
=
normalizeToArray
(
dataDims
).
slice
();
// Set `coordDim` and `coordDimIndex` by `encodeDef
Map` and normalize `encodeDefMap
`.
encodeDef
Map
.
each
(
function
(
dataDimsRaw
,
coordDim
)
{
const
dataDims
=
normalizeToArray
(
dataDimsRaw
as
[]
).
slice
();
// Note: It is allowed that `dataDims.length` is `0`, e.g., options is
// `{encode: {x: -1, y: 1}}`. Should not filter anything in
// this case.
if
(
dataDims
.
length
===
1
&&
!
isString
(
dataDims
[
0
])
&&
dataDims
[
0
]
<
0
)
{
encodeDef
.
set
(
coordDim
,
false
);
encodeDef
Map
.
set
(
coordDim
,
false
);
return
;
}
const
validDataDims
=
encodeDef
.
set
(
coordDim
,
[])
;
each
(
dataDims
,
function
(
resultDimIdx
,
idx
)
{
const
validDataDims
=
encodeDef
Map
.
set
(
coordDim
,
[])
as
DimensionIndex
[]
;
each
(
dataDims
,
function
(
resultDimIdx
OrName
,
idx
)
{
// The input resultDimIdx can be dim name or index.
isString
(
resultDimIdx
)
&&
(
resultDimIdx
=
dataDimNameMap
.
get
(
resultDimIdx
));
const
resultDimIdx
=
isString
(
resultDimIdxOrName
)
?
dataDimNameMap
.
get
(
resultDimIdxOrName
)
:
resultDimIdxOrName
;
if
(
resultDimIdx
!=
null
&&
resultDimIdx
<
dimCount
)
{
validDataDims
[
idx
]
=
resultDimIdx
;
applyDim
(
result
[
resultDimIdx
],
coordDim
,
idx
);
...
...
@@ -134,15 +152,17 @@ function completeDimensions(sysDims, source, opt) {
// Apply templetes and default order from `sysDims`.
let
availDimIdx
=
0
;
each
(
sysDims
,
function
(
sysDimItem
,
sysDimIndex
)
{
let
coordDim
;
let
sysDimItemDimsDef
;
let
sysDimItemOtherDims
;
if
(
isString
(
sysDimItem
))
{
coordDim
=
sysDimItem
;
sysDimItem
=
{};
each
(
sysDims
,
function
(
sysDimItemRaw
)
{
let
coordDim
:
DimensionName
;
let
sysDimItemDimsDef
:
CoordDimensionDefinition
[
'
dimsDef
'
];
let
sysDimItemOtherDims
:
CoordDimensionDefinition
[
'
otherDims
'
];
let
sysDimItem
:
CoordDimensionDefinition
;
if
(
isString
(
sysDimItemRaw
))
{
coordDim
=
sysDimItemRaw
;
sysDimItem
=
{}
as
CoordDimensionDefinition
;
}
else
{
sysDimItem
=
sysDimItemRaw
;
coordDim
=
sysDimItem
.
name
;
const
ordinalMeta
=
sysDimItem
.
ordinalMeta
;
sysDimItem
.
ordinalMeta
=
null
;
...
...
@@ -155,7 +175,7 @@ function completeDimensions(sysDims, source, opt) {
sysDimItem
.
dimsDef
=
sysDimItem
.
otherDims
=
null
;
}
let
dataDims
=
encodeDef
.
get
(
coordDim
);
let
dataDims
=
encodeDef
Map
.
get
(
coordDim
);
// negative resultDimIdx means no need to mapping.
if
(
dataDims
===
false
)
{
...
...
@@ -189,9 +209,9 @@ function completeDimensions(sysDims, source, opt) {
});
});
function
applyDim
(
resultItem
,
coordDim
,
coordDim
Index
)
{
if
(
VISUAL_DIMENSIONS
.
get
(
coordDim
)
!=
null
)
{
resultItem
.
otherDims
[
coordDim
]
=
coordDimIndex
;
function
applyDim
(
resultItem
:
DataDimensionInfo
,
coordDim
:
DimensionName
,
coordDimIndex
:
Dimension
Index
)
{
if
(
VISUAL_DIMENSIONS
.
get
(
coordDim
as
keyof
DataVisualDimensions
)
!=
null
)
{
resultItem
.
otherDims
[
coordDim
as
keyof
DataVisualDimensions
]
=
coordDimIndex
;
}
else
{
resultItem
.
coordDim
=
coordDim
;
...
...
@@ -224,13 +244,12 @@ function completeDimensions(sysDims, source, opt) {
}
resultItem
.
name
==
null
&&
(
resultItem
.
name
=
genName
(
resultItem
.
coordDim
,
dataDimNameMap
resultItem
.
coordDim
,
dataDimNameMap
,
false
));
if
(
resultItem
.
type
==
null
&&
(
guessOrdinal
(
source
,
resultDimIdx
,
resultItem
.
name
)
===
BE_ORDINAL
.
Must
guessOrdinal
(
source
,
resultDimIdx
)
===
BE_ORDINAL
.
Must
// Consider the case:
// {
// dataset: {source: [
...
...
@@ -267,7 +286,12 @@ function completeDimensions(sysDims, source, opt) {
// (2) sometimes user need to calcualte bubble size or use visualMap
// on other dimensions besides coordSys needed.
// So, dims that is not used by system, should be shared in storage?
function
getDimCount
(
source
,
sysDims
,
dimsDef
,
optDimCount
)
{
function
getDimCount
(
source
:
Source
,
sysDims
:
CoordDimensionDefinitionLoose
[],
dimsDef
:
DimensionDefinitionLoose
[],
optDimCount
:
number
):
number
{
// Note that the result dimCount should not small than columns count
// of data, otherwise `dataDimNameMap` checking will be incorrect.
let
dimCount
=
Math
.
max
(
...
...
@@ -277,13 +301,19 @@ function getDimCount(source, sysDims, dimsDef, optDimCount) {
optDimCount
||
0
);
each
(
sysDims
,
function
(
sysDimItem
)
{
const
sysDimItemDimsDef
=
sysDimItem
.
dimsDef
;
sysDimItemDimsDef
&&
(
dimCount
=
Math
.
max
(
dimCount
,
sysDimItemDimsDef
.
length
));
let
sysDimItemDimsDef
;
if
(
isObject
(
sysDimItem
)
&&
(
sysDimItemDimsDef
=
sysDimItem
.
dimsDef
))
{
dimCount
=
Math
.
max
(
dimCount
,
sysDimItemDimsDef
.
length
);
}
});
return
dimCount
;
}
function
genName
(
name
,
map
,
fromZero
)
{
function
genName
(
name
:
DimensionName
,
map
:
HashMap
<
unknown
,
DimensionName
>
,
fromZero
:
boolean
):
DimensionName
{
if
(
fromZero
||
map
.
get
(
name
)
!=
null
)
{
let
i
=
0
;
while
(
map
.
get
(
name
+
i
)
!=
null
)
{
...
...
src/data/helper/createDimensions.ts
浏览文件 @
9d9ffce7
...
...
@@ -22,16 +22,30 @@
* `completeDimensions` is to be deprecated.
*/
import
completeDimensions
from
'
./completeDimensions
'
;
import
{
DimensionDefinitionLoose
,
OptionEncode
,
OptionEncodeValue
,
EncodeDefaulter
}
from
'
../../util/types
'
;
import
{
DimensionDefinitionLoose
,
OptionEncode
,
OptionEncodeValue
,
EncodeDefaulter
,
OptionSourceData
,
DimensionName
,
DimensionDefinition
,
DataVisualDimensions
,
DimensionIndex
}
from
'
../../util/types
'
;
import
Source
from
'
../Source
'
;
import
List
from
'
../List
'
;
import
DataDimensionInfo
from
'
../DataDimensionInfo
'
;
import
{
HashMap
}
from
'
zrender/src/core/util
'
;
import
OrdinalMeta
from
'
../OrdinalMeta
'
;
export
interface
CoordDimensionDefinition
extends
DimensionDefinition
{
dimsDef
?:
(
DimensionName
|
{
name
:
DimensionName
,
defaultTooltip
?:
boolean
})[];
otherDims
?:
DataVisualDimensions
;
ordinalMeta
?:
OrdinalMeta
;
coordDim
?:
DimensionName
;
coordDimIndex
?:
DimensionIndex
;
}
export
type
CoordDimensionDefinitionLoose
=
CoordDimensionDefinition
[
'
name
'
]
|
CoordDimensionDefinition
;
export
type
CreateDimensionsParams
=
{
coordDimensions
?:
DimensionDefinitionLoose
[],
coordDimensions
?:
Coord
DimensionDefinitionLoose
[],
dimensionsDefine
?:
DimensionDefinitionLoose
[],
encodeDefine
?:
HashMap
<
OptionEncodeValue
>
|
OptionEncode
,
encodeDefine
?:
HashMap
<
OptionEncodeValue
,
DimensionName
>
|
OptionEncode
,
dimensionsCount
?:
number
,
encodeDefaulter
?:
EncodeDefaulter
,
generateCoord
?:
string
,
...
...
@@ -46,7 +60,7 @@ export type CreateDimensionsParams = {
*/
export
default
function
(
// TODO: TYPE completeDimensions type
source
:
Source
|
List
|
any
[]
,
source
:
Source
|
List
|
OptionSourceData
,
opt
?:
CreateDimensionsParams
):
DataDimensionInfo
[]
{
opt
=
opt
||
{};
...
...
src/data/helper/dimensionHelper.ts
浏览文件 @
9d9ffce7
...
...
@@ -17,13 +17,12 @@
* under the License.
*/
// @ts-nocheck
import
{
each
,
createHashMap
,
assert
}
from
'
zrender/src/core/util
'
;
import
{
__DEV__
}
from
'
../../config
'
;
import
List
from
'
../List
'
;
import
List
,
{
ListDimensionType
}
from
'
../List
'
;
import
{
DimensionName
,
VISUAL_DIMENSIONS
,
DimensionType
,
DimensionUserOuput
DimensionName
,
VISUAL_DIMENSIONS
,
DimensionType
,
DimensionUserOuput
,
DimensionUserOuputEncode
,
DimensionIndex
}
from
'
../../util/types
'
;
export
type
DimensionSummaryEncode
=
{
...
...
@@ -45,9 +44,9 @@ export type DimensionSummary = {
export
function
summarizeDimensions
(
data
:
List
):
DimensionSummary
{
const
summary
:
DimensionSummary
=
{}
as
DimensionSummary
;
const
encode
=
summary
.
encode
=
{}
as
DimensionSummaryEncode
;
const
notExtraCoordDimMap
=
createHashMap
();
let
defaultedLabel
=
[];
let
defaultedTooltip
=
[];
const
notExtraCoordDimMap
=
createHashMap
<
1
,
DimensionName
>
();
let
defaultedLabel
=
[]
as
DimensionName
[]
;
let
defaultedTooltip
=
[]
as
DimensionName
[]
;
// See the comment of `List.js#userOutput`.
const
userOutput
=
summary
.
userOutput
=
{
...
...
@@ -61,7 +60,7 @@ export function summarizeDimensions(data: List): DimensionSummary {
const
coordDim
=
dimItem
.
coordDim
;
if
(
coordDim
)
{
if
(
__DEV__
)
{
assert
(
VISUAL_DIMENSIONS
.
get
(
coordDim
)
==
null
);
assert
(
VISUAL_DIMENSIONS
.
get
(
coordDim
as
any
)
==
null
);
}
const
coordDimIndex
=
dimItem
.
coordDimIndex
;
...
...
@@ -97,8 +96,8 @@ export function summarizeDimensions(data: List): DimensionSummary {
});
});
let
dataDimsOnCoord
=
[];
const
encodeFirstDimNotExtra
=
{};
let
dataDimsOnCoord
=
[]
as
DimensionName
[]
;
const
encodeFirstDimNotExtra
=
{}
as
{[
coordDim
:
string
]:
DimensionName
}
;
notExtraCoordDimMap
.
each
(
function
(
v
,
coordDim
)
{
const
dimArr
=
encode
[
coordDim
];
...
...
@@ -136,8 +135,8 @@ export function summarizeDimensions(data: List): DimensionSummary {
}
function
getOrCreateEncodeArr
(
encode
:
DimensionSummaryEncode
,
dim
:
DimensionName
):
DimensionName
[]
{
encode
:
DimensionSummaryEncode
|
DimensionUserOuputEncode
,
dim
:
DimensionName
):
(
DimensionIndex
|
DimensionName
)
[]
{
if
(
!
encode
.
hasOwnProperty
(
dim
))
{
encode
[
dim
]
=
[];
}
...
...
@@ -145,7 +144,7 @@ function getOrCreateEncodeArr(
}
// FIXME:TS should be type `AxisType`
export
function
getDimensionTypeByAxis
(
axisType
:
string
)
{
export
function
getDimensionTypeByAxis
(
axisType
:
string
)
:
ListDimensionType
{
return
axisType
===
'
category
'
?
'
ordinal
'
:
axisType
===
'
time
'
...
...
src/data/helper/linkList.ts
浏览文件 @
9d9ffce7
...
...
@@ -17,18 +17,28 @@
* under the License.
*/
// @ts-nocheck
/**
* Link lists and struct (graph or tree)
*/
import
*
as
zrUtil
from
'
zrender/src/core/util
'
;
import
{
curry
,
each
,
assert
,
extend
,
map
,
keys
}
from
'
zrender/src/core/util
'
;
import
List
from
'
../List
'
;
import
{
makeInner
}
from
'
../../util/model
'
;
import
{
SeriesDataType
}
from
'
../../util/types
'
;
const
each
=
zrUtil
.
each
;
// That is: { dataType: data },
// like: { node: nodeList, edge: edgeList }.
// Should contain mainData.
type
Datas
=
{
[
key
in
SeriesDataType
]?:
List
};
type
StructReferDataAttr
=
'
data
'
|
'
edgeData
'
;
type
StructAttr
=
'
tree
'
|
'
graph
'
;
const
inner
=
makeInner
<
{
datas
:
Datas
;
mainData
:
List
;
},
List
>
();
const
DATAS
=
'
\
0__link_datas
'
;
const
MAIN_DATA
=
'
\
0__link_mainData
'
;
// Caution:
// In most case, either list or its shallow clones (see list.cloneShallow)
...
...
@@ -37,75 +47,79 @@ const MAIN_DATA = '\0__link_mainData';
// But in some rare case, we have to keep old list (like do animation in chart). So
// please take care that both the old list and the new list share the same tree/graph.
/**
* @param {Object} opt
* @param {module:echarts/data/List} opt.mainData
* @param {Object} [opt.struct] For example, instance of Graph or Tree.
* @param {string} [opt.structAttr] designation: list[structAttr] = struct;
* @param {Object} [opt.datas] {dataType: data},
* like: {node: nodeList, edge: edgeList}.
* Should contain mainData.
* @param {Object} [opt.datasAttr] {dataType: attr},
* designation: struct[datasAttr[dataType]] = list;
*/
function
linkList
(
opt
)
{
type
LinkListOpt
=
{
mainData
:
List
;
// For example, instance of Graph or Tree.
struct
:
{
update
:
()
=>
void
;
}
&
{
[
key
in
StructReferDataAttr
]?:
List
};
// Will designate: `mainData[structAttr] = struct;`
structAttr
:
StructAttr
;
datas
?:
Datas
;
// { dataType: attr },
// Will designate: `struct[datasAttr[dataType]] = list;`
datasAttr
?:
{
[
key
in
SeriesDataType
]?:
StructReferDataAttr
};
};
function
linkList
(
opt
:
LinkListOpt
):
void
{
const
mainData
=
opt
.
mainData
;
let
datas
=
opt
.
datas
;
if
(
!
datas
)
{
datas
=
{
main
:
mainData
};
opt
.
datasAttr
=
{
main
:
'
data
'
};
datas
=
{
main
:
mainData
};
opt
.
datasAttr
=
{
main
:
'
data
'
};
}
opt
.
datas
=
opt
.
mainData
=
null
;
linkAll
(
mainData
,
datas
,
opt
);
// Porxy data original methods.
each
(
datas
,
function
(
data
)
{
each
(
datas
,
function
(
data
:
List
)
{
each
(
mainData
.
TRANSFERABLE_METHODS
,
function
(
methodName
)
{
data
.
wrapMethod
(
methodName
,
zrUtil
.
curry
(
transferInjection
,
opt
));
data
.
wrapMethod
(
methodName
,
curry
(
transferInjection
,
opt
));
});
});
// Beyond transfer, additional features should be added to `cloneShallow`.
mainData
.
wrapMethod
(
'
cloneShallow
'
,
zrUtil
.
curry
(
cloneShallowInjection
,
opt
));
mainData
.
wrapMethod
(
'
cloneShallow
'
,
curry
(
cloneShallowInjection
,
opt
));
// Only mainData trigger change, because struct.update may trigger
// another changable methods, which may bring about dead lock.
each
(
mainData
.
CHANGABLE_METHODS
,
function
(
methodName
)
{
mainData
.
wrapMethod
(
methodName
,
zrUtil
.
curry
(
changeInjection
,
opt
));
mainData
.
wrapMethod
(
methodName
,
curry
(
changeInjection
,
opt
));
});
// Make sure datas contains mainData.
zrUtil
.
assert
(
datas
[
mainData
.
dataType
]
===
mainData
);
assert
(
datas
[
mainData
.
dataType
]
===
mainData
);
}
function
transferInjection
(
opt
,
res
)
{
function
transferInjection
(
this
:
List
,
opt
:
LinkListOpt
,
res
:
List
):
unknown
{
if
(
isMainData
(
this
))
{
// Transfer datas to new main data.
const
datas
=
zrUtil
.
extend
({},
this
[
DATAS
]
);
const
datas
=
extend
({},
inner
(
this
).
datas
);
datas
[
this
.
dataType
]
=
res
;
linkAll
(
res
,
datas
,
opt
);
}
else
{
// Modify the reference in main data to point newData.
linkSingle
(
res
,
this
.
dataType
,
this
[
MAIN_DATA
]
,
opt
);
linkSingle
(
res
,
this
.
dataType
,
inner
(
this
).
mainData
,
opt
);
}
return
res
;
}
function
changeInjection
(
opt
,
res
)
{
opt
.
struct
&&
opt
.
struct
.
update
(
this
);
function
changeInjection
(
opt
:
LinkListOpt
,
res
:
unknown
):
unknown
{
opt
.
struct
&&
opt
.
struct
.
update
();
return
res
;
}
function
cloneShallowInjection
(
opt
,
res
)
{
function
cloneShallowInjection
(
opt
:
LinkListOpt
,
res
:
List
):
List
{
// cloneShallow, which brings about some fragilities, may be inappropriate
// to be exposed as an API. So for implementation simplicity we can make
// the restriction that cloneShallow of not-mainData should not be invoked
// outside, but only be invoked here.
each
(
res
[
DATAS
],
function
(
data
,
dataType
)
{
each
(
inner
(
res
).
datas
,
function
(
data
:
List
,
dataType
)
{
data
!==
res
&&
linkSingle
(
data
.
cloneShallow
(),
dataType
,
res
,
opt
);
});
return
res
;
...
...
@@ -115,49 +129,52 @@ function cloneShallowInjection(opt, res) {
* Supplement method to List.
*
* @public
* @param {string} [dataType] If not specified, return mainData.
* @return {module:echarts/data/List}
* @param [dataType] If not specified, return mainData.
*/
function
getLinkedData
(
dataType
)
{
const
mainData
=
this
[
MAIN_DATA
]
;
function
getLinkedData
(
this
:
List
,
dataType
?:
SeriesDataType
):
List
{
const
mainData
=
inner
(
this
).
mainData
;
return
(
dataType
==
null
||
mainData
==
null
)
?
mainData
:
mainData
[
DATAS
]
[
dataType
];
:
inner
(
mainData
).
datas
[
dataType
];
}
/**
* Get list of all linked data
*/
function
getLinkedDataAll
()
{
const
mainData
=
this
[
MAIN_DATA
];
function
getLinkedDataAll
(
this
:
List
):
{
data
:
List
,
type
?:
SeriesDataType
}[]
{
const
mainData
=
inner
(
this
).
mainData
;
return
(
mainData
==
null
)
?
[{
data
:
mainData
}]
:
zrUtil
.
map
(
zrUtil
.
keys
(
mainData
[
DATAS
]
),
function
(
type
)
{
:
map
(
keys
(
inner
(
mainData
).
datas
),
function
(
type
)
{
return
{
type
,
data
:
mainData
[
DATAS
]
[
type
]
data
:
inner
(
mainData
).
datas
[
type
]
};
});
}
function
isMainData
(
data
)
{
return
data
[
MAIN_DATA
]
===
data
;
function
isMainData
(
data
:
List
):
boolean
{
return
inner
(
data
).
mainData
===
data
;
}
function
linkAll
(
mainData
,
datas
,
opt
)
{
mainData
[
DATAS
]
=
{};
each
(
datas
,
function
(
data
,
dataType
)
{
function
linkAll
(
mainData
:
List
,
datas
:
Datas
,
opt
:
LinkListOpt
):
void
{
inner
(
mainData
).
datas
=
{};
each
(
datas
,
function
(
data
:
List
,
dataType
)
{
linkSingle
(
data
,
dataType
,
mainData
,
opt
);
});
}
function
linkSingle
(
data
,
dataType
,
mainData
,
opt
)
{
mainData
[
DATAS
][
dataType
]
=
data
;
data
[
MAIN_DATA
]
=
mainData
;
function
linkSingle
(
data
:
List
,
dataType
:
SeriesDataType
,
mainData
:
List
,
opt
:
LinkListOpt
):
void
{
inner
(
mainData
).
datas
[
dataType
]
=
data
;
inner
(
data
).
mainData
=
mainData
;
data
.
dataType
=
dataType
;
if
(
opt
.
struct
)
{
data
[
opt
.
structAttr
]
=
opt
.
struct
;
data
[
opt
.
structAttr
]
=
opt
.
struct
as
any
;
opt
.
struct
[
opt
.
datasAttr
[
dataType
]]
=
data
;
}
...
...
@@ -166,4 +183,4 @@ function linkSingle(data, dataType, mainData, opt) {
data
.
getLinkedDataAll
=
getLinkedDataAll
;
}
export
default
linkList
;
\ No newline at end of file
export
default
linkList
;
src/data/helper/sourceHelper.ts
浏览文件 @
9d9ffce7
此差异已折叠。
点击以展开。
src/label/LabelManager.ts
浏览文件 @
9d9ffce7
...
...
@@ -36,7 +36,8 @@ import {
LabelLayoutOptionCallbackParams
,
LabelLineOption
,
Dictionary
,
ECElement
ECElement
,
SeriesDataType
}
from
'
../util/types
'
;
import
{
parsePercent
}
from
'
../util/number
'
;
import
ChartView
from
'
../view/Chart
'
;
...
...
@@ -57,7 +58,7 @@ interface LabelDesc {
seriesModel
:
SeriesModel
dataIndex
:
number
dataType
:
string
dataType
:
SeriesDataType
layoutOption
:
LabelLayoutOptionCallback
|
LabelLayoutOption
computedLayoutOption
:
LabelLayoutOption
...
...
@@ -188,7 +189,7 @@ class LabelManager {
*/
private
_addLabel
(
dataIndex
:
number
,
dataType
:
string
,
dataType
:
SeriesDataType
,
seriesModel
:
SeriesModel
,
label
:
ZRText
,
layoutOption
:
LabelDesc
[
'
layoutOption
'
]
...
...
src/model/Series.ts
浏览文件 @
9d9ffce7
...
...
@@ -30,7 +30,7 @@ import * as modelUtil from '../util/model';
import
{
DataHost
,
DimensionName
,
StageHandlerProgressParams
,
SeriesOption
,
TooltipRenderMode
,
ZRColor
,
BoxLayoutOptionMixin
,
ScaleDataValue
,
Dictionary
,
ColorString
,
OptionDataItemObject
ScaleDataValue
,
Dictionary
,
ColorString
,
OptionDataItemObject
,
SeriesDataType
}
from
'
../util/types
'
;
import
ComponentModel
,
{
ComponentModelConstructor
}
from
'
./Component
'
;
import
{
ColorPaletteMixin
}
from
'
./mixin/colorPalette
'
;
...
...
@@ -327,11 +327,11 @@ class SeriesModel<Opt extends SeriesOption = SeriesOption> extends ComponentMode
* data in the stream procedure. So we fetch data from upstream
* each time `task.perform` called.
*/
getData
(
dataType
?:
string
):
List
<
this
>
{
getData
(
dataType
?:
SeriesDataType
):
List
<
this
>
{
const
task
=
getCurrentTask
(
this
);
if
(
task
)
{
const
data
=
task
.
context
.
data
;
return
dataType
==
null
?
data
:
data
.
getLinkedData
(
dataType
)
;
return
(
dataType
==
null
?
data
:
data
.
getLinkedData
(
dataType
))
as
List
<
this
>
;
}
else
{
// When series is not alive (that may happen when click toolbox
...
...
@@ -344,12 +344,10 @@ class SeriesModel<Opt extends SeriesOption = SeriesOption> extends ComponentMode
getAllData
():
({
data
:
List
,
type
?:
string
type
?:
SeriesDataType
})[]
{
const
mainData
=
this
.
getData
();
// @ts-ignore
return
(
mainData
&&
mainData
.
getLinkedDataAll
)
// @ts-ignore
?
mainData
.
getLinkedDataAll
()
:
[{
data
:
mainData
}];
}
...
...
@@ -419,7 +417,7 @@ class SeriesModel<Opt extends SeriesOption = SeriesOption> extends ComponentMode
formatTooltip
(
dataIndex
:
number
,
multipleSeries
?:
boolean
,
dataType
?:
string
,
dataType
?:
SeriesDataType
,
renderMode
?:
TooltipRenderMode
):
{
html
:
string
,
...
...
@@ -613,11 +611,11 @@ class SeriesModel<Opt extends SeriesOption = SeriesOption> extends ComponentMode
}
// PENGING If selectedMode is null ?
select
(
innerDataIndices
:
number
[],
dataType
?:
string
):
void
{
select
(
innerDataIndices
:
number
[],
dataType
?:
SeriesDataType
):
void
{
this
.
_innerSelect
(
this
.
getData
(
dataType
),
innerDataIndices
);
}
unselect
(
innerDataIndices
:
number
[],
dataType
?:
string
):
void
{
unselect
(
innerDataIndices
:
number
[],
dataType
?:
SeriesDataType
):
void
{
const
selectedMap
=
this
.
option
.
selectedMap
;
if
(
!
selectedMap
)
{
return
;
...
...
@@ -631,7 +629,7 @@ class SeriesModel<Opt extends SeriesOption = SeriesOption> extends ComponentMode
}
}
toggleSelect
(
innerDataIndices
:
number
[],
dataType
?:
string
):
void
{
toggleSelect
(
innerDataIndices
:
number
[],
dataType
?:
SeriesDataType
):
void
{
const
tmpArr
:
number
[]
=
[];
for
(
let
i
=
0
;
i
<
innerDataIndices
.
length
;
i
++
)
{
tmpArr
[
0
]
=
innerDataIndices
[
i
];
...
...
@@ -654,7 +652,7 @@ class SeriesModel<Opt extends SeriesOption = SeriesOption> extends ComponentMode
return
dataIndices
;
}
isSelected
(
dataIndex
:
number
,
dataType
?:
string
):
boolean
{
isSelected
(
dataIndex
:
number
,
dataType
?:
SeriesDataType
):
boolean
{
const
selectedMap
=
this
.
option
.
selectedMap
;
if
(
!
selectedMap
)
{
return
false
;
...
...
src/model/mixin/dataFormat.ts
浏览文件 @
9d9ffce7
...
...
@@ -27,7 +27,8 @@ import {
CallbackDataParams
,
ColorString
,
ZRColor
,
OptionDataValue
OptionDataValue
,
SeriesDataType
}
from
'
../../util/types
'
;
import
GlobalModel
from
'
../Global
'
;
...
...
@@ -51,7 +52,7 @@ class DataFormatMixin {
*/
getDataParams
(
dataIndex
:
number
,
dataType
?:
string
dataType
?:
SeriesDataType
):
CallbackDataParams
{
const
data
=
this
.
getData
(
dataType
);
...
...
@@ -102,7 +103,7 @@ class DataFormatMixin {
getFormattedLabel
(
dataIndex
:
number
,
status
?:
DisplayState
,
dataType
?:
string
,
dataType
?:
SeriesDataType
,
labelDimIndex
?:
number
,
formatter
?:
string
|
((
params
:
object
)
=>
string
),
extendParams
?:
Partial
<
CallbackDataParams
>
...
...
@@ -154,7 +155,7 @@ class DataFormatMixin {
*/
getRawValue
(
idx
:
number
,
dataType
?:
string
dataType
?:
SeriesDataType
):
unknown
{
return
retrieveRawValue
(
this
.
getData
(
dataType
),
idx
);
}
...
...
src/stream/task.ts
浏览文件 @
9d9ffce7
...
...
@@ -22,10 +22,11 @@ import { __DEV__ } from '../config';
import
SeriesModel
from
'
../model/Series
'
;
import
{
Pipeline
}
from
'
./Scheduler
'
;
import
{
Payload
}
from
'
../util/types
'
;
import
List
from
'
../data/List
'
;
export
interface
TaskContext
{
outputData
?:
any
;
data
?:
any
;
outputData
?:
List
;
data
?:
List
;
payload
?:
Payload
;
model
?:
SeriesModel
;
};
...
...
src/util/graphic.ts
浏览文件 @
9d9ffce7
...
...
@@ -58,7 +58,8 @@ import {
ParsedValue
,
BlurScope
,
InnerFocus
,
PayloadAnimationPart
PayloadAnimationPart
,
SeriesDataType
}
from
'
./types
'
;
import
{
makeInner
}
from
'
./model
'
;
import
{
...
...
@@ -897,7 +898,7 @@ export interface ECData {
dataModel
?:
DataModel
;
eventData
?:
ECEventData
;
seriesIndex
?:
number
;
dataType
?:
string
;
dataType
?:
SeriesDataType
;
focus
?:
InnerFocus
blurScope
?:
BlurScope
...
...
src/util/model.ts
浏览文件 @
9d9ffce7
...
...
@@ -29,7 +29,7 @@ import {
indexOf
}
from
'
zrender/src/core/util
'
;
import
env
from
'
zrender/src/core/env
'
;
import
GlobalModel
,
{
QueryConditionKindB
}
from
'
../model/Global
'
;
import
GlobalModel
from
'
../model/Global
'
;
import
ComponentModel
,
{
ComponentModelConstructor
}
from
'
../model/Component
'
;
import
List
from
'
../data/List
'
;
import
{
...
...
src/util/states.ts
浏览文件 @
9d9ffce7
...
...
@@ -5,7 +5,7 @@ import { PatternObject } from 'zrender/src/graphic/Pattern';
import
{
GradientObject
}
from
'
zrender/src/graphic/Gradient
'
;
import
Element
,
{
ElementEvent
}
from
'
zrender/src/Element
'
;
import
Model
from
'
../model/Model
'
;
import
{
DisplayState
,
ECElement
,
ColorString
,
BlurScope
,
InnerFocus
,
Payload
,
ZRColor
}
from
'
./types
'
;
import
{
DisplayState
,
ECElement
,
ColorString
,
BlurScope
,
InnerFocus
,
Payload
,
ZRColor
,
SeriesDataType
}
from
'
./types
'
;
import
{
extend
,
indexOf
,
isArrayLike
,
isObject
,
keys
,
isArray
,
each
}
from
'
zrender/src/core/util
'
;
import
{
getECData
}
from
'
./graphic
'
;
import
*
as
colorTool
from
'
zrender/src/tool/color
'
;
...
...
@@ -188,7 +188,7 @@ function getFromStateStyle(
function
createEmphasisDefaultState
(
el
:
Displayable
,
stateName
:
'
emphasis
'
,
targetStates
?
:
string
[],
targetStates
:
string
[],
state
:
Displayable
[
'
states
'
][
number
]
)
{
const
hasSelect
=
targetStates
&&
indexOf
(
targetStates
,
'
select
'
)
>=
0
;
...
...
@@ -436,7 +436,7 @@ export function toggleSeriesBlurState(
else
if
(
isObject
(
focus
))
{
const
dataTypes
=
keys
(
focus
);
for
(
let
d
=
0
;
d
<
dataTypes
.
length
;
d
++
)
{
leaveBlurOfIndices
(
seriesModel
.
getData
(
dataTypes
[
d
]),
focus
[
dataTypes
[
d
]]);
leaveBlurOfIndices
(
seriesModel
.
getData
(
dataTypes
[
d
]
as
SeriesDataType
),
focus
[
dataTypes
[
d
]]);
}
}
...
...
@@ -530,7 +530,7 @@ export function updateSeriesElementSelection(seriesModel: SeriesModel) {
export
function
getAllSelectedIndices
(
ecModel
:
GlobalModel
)
{
const
ret
:
{
seriesIndex
:
number
dataType
?:
string
dataType
?:
SeriesDataType
dataIndex
:
number
[]
}[]
=
[];
ecModel
.
eachSeries
(
function
(
seriesModel
)
{
...
...
src/util/types.ts
浏览文件 @
9d9ffce7
...
...
@@ -126,7 +126,7 @@ export interface ECElement extends Element {
}
export
interface
DataHost
{
getData
(
dataType
?:
string
):
List
;
getData
(
dataType
?:
SeriesDataType
):
List
;
}
export
interface
DataModel
extends
DataHost
,
DataFormatMixin
{}
...
...
@@ -161,7 +161,7 @@ export interface SelectChangedPayload extends Payload {
fromActionPayload
:
Payload
selected
:
{
seriesIndex
:
number
dataType
?:
string
dataType
?:
SeriesDataType
dataIndex
:
number
[]
}[]
}
...
...
@@ -302,7 +302,7 @@ export type DimensionName = string;
export
type
DimensionLoose
=
DimensionName
|
DimensionIndexLoose
;
export
type
DimensionType
=
ListDimensionType
;
export
const
VISUAL_DIMENSIONS
=
createHashMap
([
export
const
VISUAL_DIMENSIONS
=
createHashMap
<
number
,
keyof
DataVisualDimensions
>
([
'
tooltip
'
,
'
label
'
,
'
itemName
'
,
'
itemId
'
,
'
seriesName
'
]);
// The key is VISUAL_DIMENSIONS
...
...
@@ -318,11 +318,11 @@ export interface DataVisualDimensions {
}
export
type
DimensionDefinition
=
{
type
?:
string
,
name
:
string
,
type
?:
ListDimensionType
,
name
:
DimensionName
,
displayName
?:
string
};
export
type
DimensionDefinitionLoose
=
DimensionDefinition
[
'
typ
e
'
]
|
DimensionDefinition
;
export
type
DimensionDefinitionLoose
=
DimensionDefinition
[
'
nam
e
'
]
|
DimensionDefinition
;
export
const
SOURCE_FORMAT_ORIGINAL
=
'
original
'
as
const
;
export
const
SOURCE_FORMAT_ARRAY_ROWS
=
'
arrayRows
'
as
const
;
...
...
@@ -343,7 +343,10 @@ export const SERIES_LAYOUT_BY_COLUMN = 'column' as const;
export
const
SERIES_LAYOUT_BY_ROW
=
'
row
'
as
const
;
export
type
SeriesLayoutBy
=
typeof
SERIES_LAYOUT_BY_COLUMN
|
typeof
SERIES_LAYOUT_BY_ROW
;
// null/undefined/'auto': auto detect header, see "src/data/helper/sourceHelper".
export
type
OptionSourceHeader
=
boolean
|
'
auto
'
;
export
type
SeriesDataType
=
'
main
'
|
'
node
'
|
'
edge
'
;
// --------------------------------------------
...
...
@@ -445,22 +448,56 @@ export type ECOption = ECUnitOption | {
};
// series.data or dataset.source
export
type
OptionSourceData
=
ArrayLike
<
OptionDataItem
>
|
Dictionary
<
ArrayLike
<
OptionDataItem
>>
;
// Only for `SOURCE_FORMAT_KEYED_COLUMNS`.
export
type
OptionSourceData
<
VAL
extends
OptionDataValue
=
OptionDataValue
,
ORIITEM
extends
OptionDataItemOriginal
<
VAL
>
=
OptionDataItemOriginal
<
VAL
>
>
=
OptionSourceDataOriginal
<
VAL
,
ORIITEM
>
|
OptionSourceDataObjectRows
<
VAL
>
|
OptionSourceDataArrayRows
<
VAL
>
|
OptionSourceDataKeyedColumns
<
VAL
>
|
OptionSourceDataTypedArray
;
export
type
OptionDataItemOriginal
<
VAL
extends
OptionDataValue
=
OptionDataValue
>
=
VAL
|
VAL
[]
|
OptionDataItemObject
<
VAL
>
;
export
type
OptionSourceDataOriginal
<
VAL
extends
OptionDataValue
=
OptionDataValue
,
ORIITEM
extends
OptionDataItemOriginal
<
VAL
>
=
OptionDataItemOriginal
<
VAL
>
>
=
ArrayLike
<
ORIITEM
>
;
export
type
OptionSourceDataObjectRows
<
VAL
extends
OptionDataValue
=
OptionDataValue
>
=
ArrayLike
<
Dictionary
<
VAL
>>
;
export
type
OptionSourceDataArrayRows
<
VAL
extends
OptionDataValue
=
OptionDataValue
>
=
ArrayLike
<
ArrayLike
<
VAL
>>
;
export
type
OptionSourceDataKeyedColumns
<
VAL
extends
OptionDataValue
=
OptionDataValue
>
=
Dictionary
<
ArrayLike
<
VAL
>>
;
export
type
OptionSourceDataTypedArray
=
ArrayLike
<
number
>
;
// See also `model.js#getDataItemValue`.
export
type
OptionDataItem
=
OptionDataValue
|
Dictionary
<
OptionDataValue
>
|
ArrayLike
<
OptionDataValue
>
|
OptionDataValue
[]
// FIXME: In some case (markpoint in geo (geo-map.html)), dataItem is {coord: [...]}
|
OptionDataItemObject
<
OptionDataValue
>
;
// Only for `SOURCE_FORMAT_KEYED_ORIGINAL`
export
type
OptionDataItemObject
<
T
>
=
{
name
?:
string
value
?:
T
[]
|
T
id
?:
string
|
number
;
name
?:
string
;
value
?:
T
[]
|
T
;
selected
?:
boolean
;
};
export
interface
GraphEdgeItemObject
<
VAL
extends
OptionDataValue
>
extends
OptionDataItemObject
<
VAL
>
{
/**
* Name or index of source node.
*/
source
?:
string
|
number
/**
* Name or index of target node.
*/
target
?:
string
|
number
}
export
type
OptionDataValue
=
string
|
number
|
Date
;
export
type
OptionDataValueNumeric
=
number
|
'
-
'
;
...
...
@@ -490,7 +527,7 @@ export interface OptionEncodeVisualDimensions {
export
interface
OptionEncode
extends
OptionEncodeVisualDimensions
{
[
coordDim
:
string
]:
OptionEncodeValue
}
export
type
OptionEncodeValue
=
Dimension
Index
[]
|
DimensionIndex
|
DimensionName
[]
|
DimensionName
;
export
type
OptionEncodeValue
=
Dimension
Loose
|
DimensionLoose
[]
;
export
type
EncodeDefaulter
=
(
source
:
Source
,
dimCount
:
number
)
=>
OptionEncode
;
// TODO: TYPE Different callback param for different series
...
...
@@ -509,7 +546,7 @@ export interface CallbackDataParams {
name
:
string
;
dataIndex
:
number
;
data
:
any
;
dataType
?:
string
;
dataType
?:
SeriesDataType
;
value
:
any
;
color
?:
ZRColor
;
borderColor
?:
string
;
...
...
@@ -869,7 +906,7 @@ export interface LabelLineOption {
export
interface
LabelLayoutOptionCallbackParams
{
dataIndex
:
number
,
dataType
:
string
,
dataType
:
SeriesDataType
,
seriesIndex
:
number
,
text
:
string
align
:
ZRTextAlign
...
...
@@ -1234,7 +1271,7 @@ export interface SeriesOption<StateOption=any, ExtraStateOpts extends {
cursor
?:
string
// Needs to be override
data
?:
any
data
?:
unknown
legendHoverLink
?:
boolean
...
...
@@ -1327,6 +1364,7 @@ export interface SeriesSamplingOptionMixin {
export
interface
SeriesEncodeOptionMixin
{
datasetIndex
?:
number
;
seriesLayoutBy
?:
SeriesLayoutBy
;
dimensions
?:
DimensionName
[];
sourceHeader
?:
OptionSourceHeader
;
dimensions
?:
DimensionDefinitionLoose
[];
encode
?:
OptionEncode
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录