Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
安冬的码畜日常
echarts
提交
9269cf35
E
echarts
项目概览
安冬的码畜日常
/
echarts
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
E
echarts
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
9269cf35
编写于
12月 21, 2019
作者:
N
newraina
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: add missing splitArea support for singleAxis #11690
上级
ea2bcb37
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
106 addition
and
4 deletion
+106
-4
src/component/axis/SingleAxisView.js
src/component/axis/SingleAxisView.js
+106
-4
未找到文件。
src/component/axis/SingleAxisView.js
浏览文件 @
9269cf35
...
...
@@ -28,7 +28,7 @@ var axisBuilderAttrs = [
'
axisLine
'
,
'
axisTickLabel
'
,
'
axisName
'
];
var
selfBuilderAttr
=
'
splitLine
'
;
var
selfBuilderAttr
s
=
[
'
splitArea
'
,
'
splitLine
'
]
;
var
SingleAxisView
=
AxisView
.
extend
({
...
...
@@ -42,17 +42,26 @@ var SingleAxisView = AxisView.extend({
group
.
removeAll
();
var
oldAxisGroup
=
this
.
_axisGroup
;
this
.
_axisGroup
=
new
graphic
.
Group
();
var
layout
=
singleAxisHelper
.
layout
(
axisModel
);
var
axisBuilder
=
new
AxisBuilder
(
axisModel
,
layout
);
zrUtil
.
each
(
axisBuilderAttrs
,
axisBuilder
.
add
,
axisBuilder
);
group
.
add
(
this
.
_axisGroup
);
group
.
add
(
axisBuilder
.
getGroup
());
if
(
axisModel
.
get
(
selfBuilderAttr
+
'
.show
'
))
{
this
[
'
_
'
+
selfBuilderAttr
](
axisModel
);
}
var
gridModel
=
axisModel
.
getCoordSysModel
();
zrUtil
.
each
(
selfBuilderAttrs
,
function
(
name
)
{
if
(
axisModel
.
get
(
name
+
'
.show
'
))
{
this
[
'
_
'
+
name
](
axisModel
,
gridModel
);
}
},
this
);
graphic
.
groupTransition
(
oldAxisGroup
,
this
.
_axisGroup
,
axisModel
);
SingleAxisView
.
superCall
(
this
,
'
render
'
,
axisModel
,
ecModel
,
api
,
payload
);
},
...
...
@@ -125,6 +134,99 @@ var SingleAxisView = AxisView.extend({
silent
:
true
}));
}
},
/**
* @param {module:echarts/coord/cartesian/AxisModel} axisModel
* @param {module:echarts/coord/cartesian/GridModel} gridModel
* @private
*/
_splitArea
:
function
(
axisModel
,
gridModel
)
{
var
axis
=
axisModel
.
axis
;
if
(
axis
.
scale
.
isBlank
())
{
return
;
}
var
splitAreaModel
=
axisModel
.
getModel
(
'
splitArea
'
);
var
areaStyleModel
=
splitAreaModel
.
getModel
(
'
areaStyle
'
);
var
areaColors
=
areaStyleModel
.
get
(
'
color
'
);
var
gridRect
=
gridModel
.
coordinateSystem
.
getRect
();
var
ticksCoords
=
axis
.
getTicksCoords
({
tickModel
:
splitAreaModel
,
clamp
:
true
});
if
(
!
ticksCoords
.
length
)
{
return
;
}
// For Making appropriate splitArea animation, the color and anid
// should be corresponding to previous one if possible.
var
areaColorsLen
=
areaColors
.
length
;
var
lastSplitAreaColors
=
this
.
_splitAreaColors
;
var
newSplitAreaColors
=
zrUtil
.
createHashMap
();
var
colorIndex
=
0
;
if
(
lastSplitAreaColors
)
{
for
(
var
i
=
0
;
i
<
ticksCoords
.
length
;
i
++
)
{
var
cIndex
=
lastSplitAreaColors
.
get
(
ticksCoords
[
i
].
tickValue
);
if
(
cIndex
!=
null
)
{
colorIndex
=
(
cIndex
+
(
areaColorsLen
-
1
)
*
i
)
%
areaColorsLen
;
break
;
}
}
}
var
prev
=
axis
.
toGlobalCoord
(
ticksCoords
[
0
].
coord
);
var
areaStyle
=
areaStyleModel
.
getAreaStyle
();
areaColors
=
zrUtil
.
isArray
(
areaColors
)
?
areaColors
:
[
areaColors
];
for
(
var
i
=
1
;
i
<
ticksCoords
.
length
;
i
++
)
{
var
tickCoord
=
axis
.
toGlobalCoord
(
ticksCoords
[
i
].
coord
);
var
x
;
var
y
;
var
width
;
var
height
;
if
(
axis
.
isHorizontal
())
{
x
=
prev
;
y
=
gridRect
.
y
;
width
=
tickCoord
-
x
;
height
=
gridRect
.
height
;
prev
=
x
+
width
;
}
else
{
x
=
gridRect
.
x
;
y
=
prev
;
width
=
gridRect
.
width
;
height
=
tickCoord
-
y
;
prev
=
y
+
height
;
}
var
tickValue
=
ticksCoords
[
i
-
1
].
tickValue
;
tickValue
!=
null
&&
newSplitAreaColors
.
set
(
tickValue
,
colorIndex
);
this
.
_axisGroup
.
add
(
new
graphic
.
Rect
({
anid
:
tickValue
!=
null
?
'
area_
'
+
tickValue
:
null
,
shape
:
{
x
:
x
,
y
:
y
,
width
:
width
,
height
:
height
},
style
:
zrUtil
.
defaults
({
fill
:
areaColors
[
colorIndex
]
},
areaStyle
),
silent
:
true
}));
colorIndex
=
(
colorIndex
+
1
)
%
areaColorsLen
;
}
this
.
_splitAreaColors
=
newSplitAreaColors
;
}
});
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录