Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
x649585723
incubator-echarts
提交
7b8d9695
I
incubator-echarts
项目概览
x649585723
/
incubator-echarts
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
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,发现更多精彩内容 >>
提交
7b8d9695
编写于
1月 12, 2018
作者:
S
sushuang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Handle dimension normalize and display name.
上级
1d6e9d89
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
63 addition
and
15 deletion
+63
-15
src/data/helper/completeDimensions.js
src/data/helper/completeDimensions.js
+12
-7
src/data/helper/dataProvider.js
src/data/helper/dataProvider.js
+2
-2
src/data/helper/sourceHelper.js
src/data/helper/sourceHelper.js
+47
-4
src/model/Series.js
src/model/Series.js
+2
-2
未找到文件。
src/data/helper/completeDimensions.js
浏览文件 @
7b8d9695
...
...
@@ -3,7 +3,7 @@
* Use `echarts/data/helper/createDimensions` instead.
*/
import
{
createHashMap
,
each
,
isString
,
defaults
,
clone
}
from
'
zrender/src/core/util
'
;
import
{
createHashMap
,
each
,
isString
,
defaults
,
extend
,
isObject
,
clone
}
from
'
zrender/src/core/util
'
;
import
{
normalizeToArray
}
from
'
../../util/model
'
;
import
{
guessOrdinal
}
from
'
./sourceHelper
'
;
import
Source
from
'
../Source
'
;
...
...
@@ -19,6 +19,7 @@ import {OTHER_DIMENSIONS} from './dimensionHelper';
*
* @param {Array.<string>} sysDims Necessary dimensions, like ['x', 'y'], which
* provides not only dim template, but also default order.
* properties: 'name', 'type', 'displayName'.
* `name` of each item provides default coord name.
* [{dimsDef: [string...]}, ...] can be specified to give names.
* @param {module:echarts/data/Source|Array|Object} source or data (for compatibal with pervious)
...
...
@@ -35,11 +36,12 @@ import {OTHER_DIMENSIONS} from './dimensionHelper';
* @param {number} [opt.encodeDefaulter] If not specified, auto find the next available data dim.
* @return {Array.<Object>} [{
* name: string mandatory,
* displayName: string, the origin name in dimsDef, see source helper.
* If displayName given, the tooltip will displayed vertically.
* coordDim: string mandatory,
* isSysCoord: boolean True if the coord is from sys dimension.
* coordDimIndex: number mandatory,
* type: string optional,
* tooltipName: string optional,
* otherDims: { never null/undefined
* tooltip: number optional,
* label: number optional,
...
...
@@ -69,18 +71,21 @@ function completeDimensions(sysDims, source, opt) {
// Apply user defined dims (`name` and `type`) and init result.
for
(
var
i
=
0
;
i
<
dimCount
;
i
++
)
{
var
dimDefItem
=
isString
(
dimsDef
[
i
])
?
{
name
:
dimsDef
[
i
]}
:
(
dimsDef
[
i
]
||
{});
var
dimDefItem
=
dimsDef
[
i
]
=
extend
(
{},
isObject
(
dimsDef
[
i
])
?
dimsDef
[
i
]
:
{
name
:
dimsDef
[
i
]}
);
var
userDimName
=
dimDefItem
.
name
;
var
resultItem
=
result
[
i
]
=
{
otherDims
:
{}};
// Name will be applied later for avoiding duplication.
if
(
userDimName
!=
null
&&
dataDimNameMap
.
get
(
userDimName
)
==
null
)
{
// Only if `series.dimensions` is defined in option
, tooltipName
// will be set, and dimension will be diplayed vertically in
// Only if `series.dimensions` is defined in option
//
displayName,
will be set, and dimension will be diplayed vertically in
// tooltip by default.
resultItem
.
name
=
resultItem
.
tooltip
Name
=
userDimName
;
resultItem
.
name
=
resultItem
.
display
Name
=
userDimName
;
dataDimNameMap
.
set
(
userDimName
,
i
);
}
dimDefItem
.
type
!=
null
&&
(
resultItem
.
type
=
dimDefItem
.
type
);
dimDefItem
.
displayName
!=
null
&&
(
resultItem
.
displayName
=
dimDefItem
.
displayName
);
}
// Set `coordDim` and `coordDimIndex` by `encodeDef` and normalize `encodeDef`.
...
...
@@ -134,7 +139,7 @@ function completeDimensions(sysDims, source, opt) {
var
resultItem
=
result
[
resultDimIdx
];
applyDim
(
defaults
(
resultItem
,
sysDimItem
),
coordDim
,
coordDimIndex
);
if
(
resultItem
.
name
==
null
&&
sysDimItemDimsDef
)
{
resultItem
.
name
=
resultItem
.
tooltip
Name
=
sysDimItemDimsDef
[
coordDimIndex
];
resultItem
.
name
=
resultItem
.
display
Name
=
sysDimItemDimsDef
[
coordDimIndex
];
}
resultItem
.
isSysCoord
=
true
;
// FIXME refactor, currently only used in case: {otherDims: {tooltip: false}}
...
...
src/data/helper/dataProvider.js
浏览文件 @
7b8d9695
...
...
@@ -107,7 +107,7 @@ var providerMethods = {
'
keyedColumns
'
:
{
pure
:
true
,
count
:
function
()
{
var
dimName
=
this
.
_source
.
dimensionsDefine
[
0
];
var
dimName
=
this
.
_source
.
dimensionsDefine
[
0
]
.
name
;
var
col
=
this
.
_data
[
dimName
];
return
col
?
col
.
length
:
0
;
},
...
...
@@ -115,7 +115,7 @@ var providerMethods = {
var
item
=
[];
var
dims
=
this
.
_source
.
dimensionsDefine
;
for
(
var
i
=
0
;
i
<
dims
.
length
;
i
++
)
{
var
col
=
this
.
_data
[
dims
[
i
]];
var
col
=
this
.
_data
[
dims
[
i
]
.
name
];
item
.
push
(
col
?
col
[
idx
]
:
null
);
}
},
...
...
src/data/helper/sourceHelper.js
浏览文件 @
7b8d9695
...
...
@@ -4,11 +4,13 @@ import {getCoordSysDefineBySeries} from '../../model/referHelper';
import
{
createHashMap
,
each
,
map
,
isArray
,
isString
,
isObject
,
isTypedArray
,
isArrayLike
,
extend
,
assert
}
from
'
zrender/src/core/util
'
;
import
{
getDataItemValue
}
from
'
../../util/model
'
;
...
...
@@ -178,7 +180,7 @@ export function prepareSource(seriesModel) {
// return {startIndex, dimensionsDefine, dimensionsCount}
function
completeBySourceData
(
data
,
sourceFormat
,
seriesLayoutBy
,
sourceHeader
,
dimensionsDefine
)
{
if
(
!
data
)
{
return
{
dimensionsDefine
:
dimensionsDefine
};
return
{
dimensionsDefine
:
normalizeDimensionsDefine
(
dimensionsDefine
)
};
}
var
dimensionsDetectCount
;
...
...
@@ -211,7 +213,7 @@ function completeBySourceData(data, sourceFormat, seriesLayoutBy, sourceHeader,
if
(
!
dimensionsDefine
&&
startIndex
===
1
)
{
dimensionsDefine
=
[];
arrayRowsTravelFirst
(
function
(
val
,
index
)
{
dimensionsDefine
[
index
]
=
val
+
''
;
dimensionsDefine
[
index
]
=
val
!=
null
?
val
:
''
;
},
seriesLayoutBy
,
data
);
}
...
...
@@ -259,13 +261,51 @@ function completeBySourceData(data, sourceFormat, seriesLayoutBy, sourceHeader,
return
{
startIndex
:
startIndex
,
dimensionsDefine
:
dimensionsDefine
,
dimensionsDefine
:
normalizeDimensionsDefine
(
dimensionsDefine
)
,
dimensionsDetectCount
:
dimensionsDetectCount
,
potentialNameDimIndex
:
potentialNameDimIndex
// TODO: potentialIdDimIdx
};
}
// Consider dimensions defined like ['A', 'price', 'B', 'price', 'C', 'price'],
// which is reasonable. But dimension name is duplicated.
// Returns undefined or an array contains only object without null/undefiend or string.
function
normalizeDimensionsDefine
(
dimensionsDefine
)
{
if
(
!
dimensionsDefine
)
{
// The meaning of null/undefined is different from empty array.
return
;
}
var
nameMap
=
createHashMap
();
return
map
(
dimensionsDefine
,
function
(
item
,
index
)
{
item
=
extend
({},
isObject
(
item
)
?
item
:
{
name
:
item
});
// User can set null in dimensions.
// We dont auto specify name, othewise a given name may
// cause it be refered unexpectedly.
if
(
item
.
name
==
null
)
{
return
item
;
}
// Also consider number form like 2012.
item
.
name
+=
''
;
// Use may also specify displayName.
if
(
item
.
displayName
==
null
)
{
item
.
displayName
=
item
.
name
;
}
var
exist
=
nameMap
.
get
(
item
.
name
);
if
(
!
exist
)
{
nameMap
.
set
(
item
.
name
,
{
count
:
1
});
}
else
{
item
.
name
+=
'
-
'
+
exist
.
count
++
;
}
return
item
;
});
}
function
arrayRowsTravelFirst
(
cb
,
seriesLayoutBy
,
data
,
maxLoop
)
{
maxLoop
==
null
&&
(
maxLoop
=
Infinity
);
if
(
seriesLayoutBy
===
SERIES_LAYOUT_BY_ROW
)
{
...
...
@@ -439,7 +479,10 @@ function doGuessOrdinal(
return
;
}
dimName
=
dimensionsDefine
[
dimIndex
];
isObject
(
dimName
)
&&
(
dimName
=
dimName
.
name
);
dimName
=
isObject
(
dimName
)
?
dimName
.
name
:
dimName
;
if
(
dimName
==
null
)
{
return
;
}
}
if
(
sourceFormat
===
SOURCE_FORMAT_ARRAY_ROWS
)
{
...
...
src/model/Series.js
浏览文件 @
7b8d9695
...
...
@@ -255,7 +255,7 @@ var SeriesModel = ComponentModel.extend({
// check: category-no-encode-has-axis-data in dataset.html
var
vertially
=
zrUtil
.
reduce
(
value
,
function
(
vertially
,
val
,
idx
)
{
var
dimItem
=
data
.
getDimensionInfo
(
idx
);
return
vertially
|=
dimItem
&&
dimItem
.
tooltip
!==
false
&&
dimItem
.
tooltip
Name
!=
null
;
return
vertially
|=
dimItem
&&
dimItem
.
tooltip
!==
false
&&
dimItem
.
display
Name
!=
null
;
},
0
);
var
result
=
[];
...
...
@@ -276,7 +276,7 @@ var SeriesModel = ComponentModel.extend({
var
dimType
=
dimInfo
.
type
;
var
dimHead
=
getTooltipMarker
({
color
:
color
,
type
:
'
subItem
'
});
var
valStr
=
(
vertially
?
dimHead
+
encodeHTML
(
dimInfo
.
tooltipName
||
dimInfo
.
name
)
+
'
:
'
?
dimHead
+
encodeHTML
(
dimInfo
.
displayName
||
'
-
'
)
+
'
:
'
:
''
)
+
encodeHTML
(
dimType
===
'
ordinal
'
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录