Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
x649585723
incubator-echarts
提交
dde51711
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,发现更多精彩内容 >>
提交
dde51711
编写于
2月 26, 2018
作者:
S
sushuang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
re support stacked by index (for 3d case)
上级
6ee37650
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
72 addition
and
19 deletion
+72
-19
src/data/helper/dataStackHelper.js
src/data/helper/dataStackHelper.js
+35
-10
src/helper.js
src/helper.js
+6
-1
src/processor/dataStack.js
src/processor/dataStack.js
+31
-8
未找到文件。
src/data/helper/dataStackHelper.js
浏览文件 @
dde51711
import
{
each
,
isString
}
from
'
zrender/src/core/util
'
;
/**
* Note that it is too complicated to support 3d stack by value
* (have to create two-dimension inverted index), so in 3d case
* we just support that stacked by index.
*
* @param {module:echarts/model/Series} seriesModel
* @param {Array.<string|Object>} dimensionInfoList The same as the input of <module:echarts/data/List>.
* The input dimensionInfoList will be modified.
* @param {Object} [opt]
* @param {boolean} [opt.stackedCoordDimension=''] Specify a coord dimension if needed.
* @param {boolean} [opt.byIndex=false]
* @return {Object} calculationInfo
* {
* stackedDimension: stackedDimInfo.name,
* stackedByDimension: stackedByDimension,
* stackedOverDimension: stackedOverDimension,
* stackResultDimension: stackResultDimension
* stackedDimension: string
* stackedByDimension: string
* isStackedByIndex: boolean
* stackedOverDimension: string
* stackResultDimension: string
* }
*/
export
function
enableDataStack
(
seriesModel
,
dimensionInfoList
)
{
export
function
enableDataStack
(
seriesModel
,
dimensionInfoList
,
opt
)
{
opt
=
opt
||
{};
var
byIndex
=
opt
.
byIndex
;
var
stackedCoordDimension
=
opt
.
stackedCoordDimension
;
// Compatibal: when `stack` is set as '', do not stack.
var
mayStack
=
!!
(
seriesModel
&&
seriesModel
.
get
(
'
stack
'
));
var
stackedByDimInfo
;
...
...
@@ -27,13 +39,14 @@ export function enableDataStack(seriesModel, dimensionInfoList) {
if
(
mayStack
&&
!
dimensionInfo
.
isExtraCoord
)
{
// Find the first ordinal dimension as the stackedByDimInfo.
if
(
!
stackedByDimInfo
&&
dimensionInfo
.
ordinalMeta
)
{
if
(
!
byIndex
&&
!
stackedByDimInfo
&&
dimensionInfo
.
ordinalMeta
)
{
stackedByDimInfo
=
dimensionInfo
;
}
// Find the first stackable dimension as the stackedDimInfo.
if
(
!
stackedDimInfo
&&
dimensionInfo
.
type
!==
'
ordinal
'
&&
dimensionInfo
.
type
!==
'
time
'
&&
(
!
stackedCoordDimension
||
stackedCoordDimension
===
dimensionInfo
.
coordDim
)
)
{
stackedDimInfo
=
dimensionInfo
;
}
...
...
@@ -43,13 +56,15 @@ export function enableDataStack(seriesModel, dimensionInfoList) {
// Add stack dimension, they can be both calculated by coordinate system in `unionExtent`.
// That put stack logic in List is for using conveniently in echarts extensions, but it
// might not be a good way.
if
(
stacked
ByDimInfo
&&
stackedDimInfo
)
{
if
(
stacked
DimInfo
&&
(
byIndex
||
stackedByDimInfo
)
)
{
// Use a weird name that not duplicated with other names.
stackResultDimension
=
'
__
\
0ecstackresult
'
;
stackedOverDimension
=
'
__
\
0ecstackedover
'
;
// Create inverted index to fast query index by value.
stackedByDimInfo
.
createInvertedIndices
=
true
;
if
(
stackedByDimInfo
)
{
stackedByDimInfo
.
createInvertedIndices
=
true
;
}
var
stackedDimCoordDim
=
stackedDimInfo
.
coordDim
;
var
stackedDimType
=
stackedDimInfo
.
type
;
...
...
@@ -83,14 +98,24 @@ export function enableDataStack(seriesModel, dimensionInfoList) {
return
{
stackedDimension
:
stackedDimInfo
&&
stackedDimInfo
.
name
,
stackedByDimension
:
stackedByDimInfo
&&
stackedByDimInfo
.
name
,
isStackedByIndex
:
byIndex
,
stackedOverDimension
:
stackedOverDimension
,
stackResultDimension
:
stackResultDimension
};
}
/**
* @param {module:echarts/data/List} data
* @param {string} stackedDim
* @param {string} [stackedByDim] If not input this parameter, check whether
* stacked by index.
*/
export
function
isDimensionStacked
(
data
,
stackedDim
,
stackedByDim
)
{
return
stackedDim
&&
stackedByDim
&&
stackedDim
===
data
.
getCalculationInfo
(
'
stackedDimension
'
)
&&
stackedByDim
===
data
.
getCalculationInfo
(
'
stackedByDimension
'
);
&&
(
stackedByDim
!=
null
?
stackedByDim
===
data
.
getCalculationInfo
(
'
stackedByDimension
'
)
:
data
.
getCalculationInfo
(
'
isStackedByIndex
'
)
);
}
src/helper.js
浏览文件 @
dde51711
...
...
@@ -5,7 +5,7 @@ import * as axisHelper from './coord/axisHelper';
import
axisModelCommonMixin
from
'
./coord/axisModelCommonMixin
'
;
import
Model
from
'
./model/Model
'
;
import
{
getLayoutRect
}
from
'
./util/layout
'
;
import
{
enableDataStack
,
isDimensionStacked
}
from
'
./data/helper/dataStackHelper
'
;
/**
* Create a muti dimension List structure from seriesModel.
...
...
@@ -31,6 +31,11 @@ export {default as completeDimensions} from './data/helper/completeDimensions';
export
{
default
as
createDimensions
}
from
'
./data/helper/createDimensions
'
;
export
var
dataStack
=
{
isDimensionStacked
:
isDimensionStacked
,
enableDataStack
:
enableDataStack
};
/**
* Create a symbol element with given symbol configuration: shape, x, y, width, height, color
* @see http://echarts.baidu.com/option.html#series-scatter.symbol
...
...
src/processor/dataStack.js
浏览文件 @
dde51711
...
...
@@ -14,19 +14,29 @@ export default function (ecModel) {
var
stackInfoList
=
stackInfoMap
.
get
(
stack
)
||
stackInfoMap
.
set
(
stack
,
[]);
var
data
=
seriesModel
.
getData
();
stackInfoList
.
length
&&
data
.
setCalculationInfo
(
'
stackedOnSeries
'
,
stackInfoList
[
stackInfoList
.
length
-
1
].
seriesModel
);
stackInfoList
.
push
({
var
stackInfo
=
{
// Used for calculate axis extent automatically.
stackResultDimension
:
data
.
getCalculationInfo
(
'
stackResultDimension
'
),
stackedOverDimension
:
data
.
getCalculationInfo
(
'
stackedOverDimension
'
),
stackedDimension
:
data
.
getCalculationInfo
(
'
stackedDimension
'
),
stackedByDimension
:
data
.
getCalculationInfo
(
'
stackedByDimension
'
),
isStackedByIndex
:
data
.
getCalculationInfo
(
'
isStackedByIndex
'
),
data
:
data
,
seriesModel
:
seriesModel
});
};
// If stacked on axis that do not support data stack.
if
(
!
stackInfo
.
stackedDimension
||
!
(
stackInfo
.
isStackedByIndex
||
stackInfo
.
stackedByDimension
)
)
{
return
;
}
stackInfoList
.
length
&&
data
.
setCalculationInfo
(
'
stackedOnSeries
'
,
stackInfoList
[
stackInfoList
.
length
-
1
].
seriesModel
);
stackInfoList
.
push
(
stackInfo
);
}
});
...
...
@@ -39,6 +49,7 @@ function calculateStack(stackInfoList) {
var
resultNaN
=
[
NaN
,
NaN
];
var
dims
=
[
targetStackInfo
.
stackResultDimension
,
targetStackInfo
.
stackedOverDimension
];
var
targetData
=
targetStackInfo
.
data
;
var
isStackedByIndex
=
targetStackInfo
.
isStackedByIndex
;
// Should not write on raw data, because stack series model list changes
// depending on legend selection.
...
...
@@ -51,14 +62,26 @@ function calculateStack(stackInfoList) {
return
resultNaN
;
}
var
byValue
=
targetData
.
get
(
targetStackInfo
.
stackedByDimension
,
dataIndex
);
var
byValue
;
var
stackedDataRawIndex
;
if
(
isStackedByIndex
)
{
stackedDataRawIndex
=
targetData
.
getRawIndex
(
dataIndex
);
}
else
{
byValue
=
targetData
.
get
(
targetStackInfo
.
stackedByDimension
,
dataIndex
);
}
var
stackedOver
=
0
;
for
(
var
j
=
idxInStack
-
1
;
j
>=
0
;
j
--
)
{
var
stackInfo
=
stackInfoList
[
j
];
// Has been optimized by inverted indices on `stackedByDimension`.
var
stackedDataRawIndex
=
stackInfo
.
data
.
rawIndexOf
(
stackInfo
.
stackedByDimension
,
byValue
);
if
(
!
isStackedByIndex
)
{
stackedDataRawIndex
=
stackInfo
.
data
.
rawIndexOf
(
stackInfo
.
stackedByDimension
,
byValue
);
}
if
(
stackedDataRawIndex
>=
0
)
{
var
val
=
stackInfo
.
data
.
getByRawIndex
(
stackInfo
.
stackResultDimension
,
stackedDataRawIndex
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录