Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
半栈学徒
incubator-echarts
提交
40166659
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,发现更多精彩内容 >>
提交
40166659
编写于
5月 23, 2017
作者:
P
pah100
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Some fix for polar bar.
上级
0c86be9f
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
97 addition
and
114 deletion
+97
-114
src/chart/bar/BarView.js
src/chart/bar/BarView.js
+93
-109
src/layout/barPolar.js
src/layout/barPolar.js
+4
-5
未找到文件。
src/chart/bar/BarView.js
浏览文件 @
40166659
...
...
@@ -20,8 +20,8 @@ define(function (require) {
var
coordinateSystemType
=
seriesModel
.
get
(
'
coordinateSystem
'
);
if
(
coordinateSystemType
===
'
cartesian2d
'
||
coordinateSystemType
===
'
polar
'
)
{
||
coordinateSystemType
===
'
polar
'
)
{
this
.
_render
(
seriesModel
,
ecModel
,
api
);
}
else
if
(
__DEV__
)
{
...
...
@@ -58,14 +58,17 @@ define(function (require) {
}
var
itemModel
=
data
.
getItemModel
(
dataIndex
);
var
layout
=
getLayout
(
coord
,
data
,
dataIndex
,
itemModel
);
var
el
=
createElement
(
coord
,
data
,
dataIndex
,
itemModel
,
layout
,
isHorizontalOrRadial
,
animationModel
);
var
layout
=
getLayout
[
coord
.
type
](
data
,
dataIndex
,
itemModel
);
var
el
=
elementCreator
[
coord
.
type
](
data
,
dataIndex
,
itemModel
,
layout
,
isHorizontalOrRadial
,
animationModel
);
data
.
setItemGraphicEl
(
dataIndex
,
el
);
group
.
add
(
el
);
updateStyle
(
el
,
data
,
dataIndex
,
itemModel
,
layout
,
seriesModel
,
isHorizontalOrRadial
,
coord
.
type
===
'
polar
'
);
updateStyle
(
el
,
data
,
dataIndex
,
itemModel
,
layout
,
seriesModel
,
isHorizontalOrRadial
,
coord
.
type
===
'
polar
'
);
})
.
update
(
function
(
newIndex
,
oldIndex
)
{
var
el
=
oldData
.
getItemGraphicEl
(
oldIndex
);
...
...
@@ -76,22 +79,25 @@ define(function (require) {
}
var
itemModel
=
data
.
getItemModel
(
newIndex
);
var
layout
=
getLayout
(
coord
,
data
,
newIndex
,
itemModel
);
var
layout
=
getLayout
[
coord
.
type
](
data
,
newIndex
,
itemModel
);
if
(
el
)
{
graphic
.
updateProps
(
el
,
{
shape
:
layout
},
animationModel
,
newIndex
);
}
else
{
el
=
createElement
(
coord
,
data
,
dataIndex
,
itemModel
,
layout
,
isHorizontalOrRadial
,
animationModel
,
true
);
el
=
elementCreator
[
coord
.
type
](
data
,
newIndex
,
itemModel
,
layout
,
isHorizontalOrRadial
,
animationModel
,
true
);
}
data
.
setItemGraphicEl
(
newIndex
,
el
);
// Add back
group
.
add
(
el
);
updateStyle
(
el
,
data
,
newIndex
,
itemModel
,
layout
,
seriesModel
,
isHorizontalOrRadial
,
coord
.
type
===
'
polar
'
);
updateStyle
(
el
,
data
,
newIndex
,
itemModel
,
layout
,
seriesModel
,
isHorizontalOrRadial
,
coord
.
type
===
'
polar
'
);
})
.
remove
(
function
(
dataIndex
)
{
var
el
=
oldData
.
getItemGraphicEl
(
dataIndex
);
...
...
@@ -113,7 +119,7 @@ define(function (require) {
if
(
ecModel
.
get
(
'
animation
'
))
{
if
(
data
)
{
data
.
eachItemGraphicEl
(
function
(
el
)
{
if
(
el
.
shape
.
startAngle
)
{
if
(
el
.
type
===
'
sector
'
)
{
removeSector
(
el
.
dataIndex
,
ecModel
,
el
);
}
else
{
...
...
@@ -128,66 +134,50 @@ define(function (require) {
}
});
// Create rect or sector based on coord
function
createElement
(
coord
,
data
,
dataIndex
,
itemModel
,
layout
,
isHorizontalOrRadial
,
animationModel
,
isUpdate
)
{
if
(
coord
.
type
===
'
cartesian2d
'
)
{
return
createRect
(
data
,
dataIndex
,
itemModel
,
layout
,
isHorizontalOrRadial
,
animationModel
,
isUpdate
);
}
else
if
(
coord
.
type
===
'
polar
'
)
{
return
createSector
(
data
,
dataIndex
,
itemModel
,
layout
,
isHorizontalOrRadial
,
animationModel
,
isUpdate
);
}
}
function
createRect
(
data
,
dataIndex
,
itemModel
,
layout
,
isHorizontal
,
animationModel
,
isUpdate
)
{
var
rect
=
new
graphic
.
Rect
({
shape
:
zrUtil
.
extend
({},
layout
)});
// Animation
if
(
animationModel
)
{
var
rectShape
=
rect
.
shape
;
var
animateProperty
=
isHorizontal
?
'
height
'
:
'
width
'
;
var
animateTarget
=
{};
rectShape
[
animateProperty
]
=
0
;
animateTarget
[
animateProperty
]
=
layout
[
animateProperty
];
graphic
[
isUpdate
?
'
updateProps
'
:
'
initProps
'
](
rect
,
{
shape
:
animateTarget
},
animationModel
,
dataIndex
);
}
var
elementCreator
=
{
cartesian2d
:
function
(
data
,
dataIndex
,
itemModel
,
layout
,
isHorizontal
,
animationModel
,
isUpdate
)
{
var
rect
=
new
graphic
.
Rect
({
shape
:
zrUtil
.
extend
({},
layout
)});
// Animation
if
(
animationModel
)
{
var
rectShape
=
rect
.
shape
;
var
animateProperty
=
isHorizontal
?
'
height
'
:
'
width
'
;
var
animateTarget
=
{};
rectShape
[
animateProperty
]
=
0
;
animateTarget
[
animateProperty
]
=
layout
[
animateProperty
];
graphic
[
isUpdate
?
'
updateProps
'
:
'
initProps
'
](
rect
,
{
shape
:
animateTarget
},
animationModel
,
dataIndex
);
}
return
rect
;
}
return
rect
;
},
function
createSector
(
data
,
dataIndex
,
itemModel
,
layout
,
isRadial
,
animationModel
,
isUpdate
)
{
var
sector
=
new
graphic
.
Sector
({
shape
:
zrUtil
.
extend
(
{
isRadial
:
isRadial
},
layout
)
});
polar
:
function
(
data
,
dataIndex
,
itemModel
,
layout
,
isRadial
,
animationModel
,
isUpdate
)
{
var
sector
=
new
graphic
.
Sector
({
shape
:
zrUtil
.
extend
({},
layout
)});
// Animation
if
(
animationModel
)
{
var
sectorShape
=
sector
.
shape
;
var
animateProperty
=
isRadial
?
'
r
'
:
'
endAngle
'
;
var
animateTarget
=
{};
sectorShape
[
animateProperty
]
=
isRadial
?
0
:
layout
.
startAngle
;
animateTarget
[
animateProperty
]
=
layout
[
animateProperty
];
graphic
[
isUpdate
?
'
updateProps
'
:
'
initProps
'
](
sector
,
{
shape
:
animateTarget
},
animationModel
,
dataIndex
);
}
// Animation
if
(
animationModel
)
{
var
sectorShape
=
sector
.
shape
;
var
animateProperty
=
isRadial
?
'
r
'
:
'
endAngle
'
;
var
animateTarget
=
{};
sectorShape
[
animateProperty
]
=
isRadial
?
0
:
layout
.
startAngle
;
animateTarget
[
animateProperty
]
=
layout
[
animateProperty
];
graphic
[
isUpdate
?
'
updateProps
'
:
'
initProps
'
](
sector
,
{
shape
:
animateTarget
},
animationModel
,
dataIndex
);
return
sector
;
}
return
sector
;
}
};
function
removeRect
(
dataIndex
,
animationModel
,
el
)
{
// Not show text when animating
...
...
@@ -204,52 +194,46 @@ define(function (require) {
function
removeSector
(
dataIndex
,
animationModel
,
el
)
{
// Not show text when animating
el
.
style
.
text
=
''
;
var
shape
=
{
r
:
el
.
shape
.
r0
};
graphic
.
updateProps
(
el
,
{
shape
},
animationModel
,
dataIndex
,
function
()
{
graphic
.
updateProps
(
el
,
{
shape
:
{
r
:
el
.
shape
.
r0
}
},
animationModel
,
dataIndex
,
function
()
{
el
.
parent
&&
el
.
parent
.
remove
(
el
);
});
}
function
getLayout
(
coord
,
data
,
dataIndex
,
itemModel
)
{
if
(
coord
.
type
===
'
cartesian2d
'
)
{
return
getRectItemLayout
(
data
,
dataIndex
,
itemModel
);
}
else
if
(
coord
.
type
===
'
polar
'
)
{
return
getSectorItemLayout
(
data
,
dataIndex
,
itemModel
);
}
}
function
getRectItemLayout
(
data
,
dataIndex
,
itemModel
)
{
var
layout
=
data
.
getItemLayout
(
dataIndex
);
var
fixedLineWidth
=
getLineWidth
(
itemModel
,
layout
);
// fix layout with lineWidth
var
signX
=
layout
.
width
>
0
?
1
:
-
1
;
var
signY
=
layout
.
height
>
0
?
1
:
-
1
;
return
{
x
:
layout
.
x
+
signX
*
fixedLineWidth
/
2
,
y
:
layout
.
y
+
signY
*
fixedLineWidth
/
2
,
width
:
layout
.
width
-
signX
*
fixedLineWidth
,
height
:
layout
.
height
-
signY
*
fixedLineWidth
};
}
var
getLayout
=
{
cartesian2d
:
function
(
data
,
dataIndex
,
itemModel
)
{
var
layout
=
data
.
getItemLayout
(
dataIndex
);
var
fixedLineWidth
=
getLineWidth
(
itemModel
,
layout
);
// fix layout with lineWidth
var
signX
=
layout
.
width
>
0
?
1
:
-
1
;
var
signY
=
layout
.
height
>
0
?
1
:
-
1
;
return
{
x
:
layout
.
x
+
signX
*
fixedLineWidth
/
2
,
y
:
layout
.
y
+
signY
*
fixedLineWidth
/
2
,
width
:
layout
.
width
-
signX
*
fixedLineWidth
,
height
:
layout
.
height
-
signY
*
fixedLineWidth
};
},
function
getSectorItemLayout
(
data
,
dataIndex
,
itemModel
)
{
var
layout
=
data
.
getItemLayout
(
dataIndex
);
return
{
cx
:
layout
.
cx
,
cy
:
layout
.
cy
,
r0
:
layout
.
r0
,
r
:
layout
.
r
,
startAngle
:
layout
.
startAngle
,
endAngle
:
layout
.
endAngle
};
}
polar
:
function
(
data
,
dataIndex
,
itemModel
)
{
var
layout
=
data
.
getItemLayout
(
dataIndex
);
return
{
cx
:
layout
.
cx
,
cy
:
layout
.
cy
,
r0
:
layout
.
r0
,
r
:
layout
.
r
,
startAngle
:
layout
.
startAngle
,
endAngle
:
layout
.
endAngle
};
}
};
function
updateStyle
(
el
,
data
,
dataIndex
,
itemModel
,
layout
,
seriesModel
,
isHorizontal
,
isPolar
function
updateStyle
(
el
,
data
,
dataIndex
,
itemModel
,
layout
,
seriesModel
,
isHorizontal
,
isPolar
)
{
var
color
=
data
.
getItemVisual
(
dataIndex
,
'
color
'
);
var
opacity
=
data
.
getItemVisual
(
dataIndex
,
'
opacity
'
);
...
...
src/layout/barPolar.js
浏览文件 @
40166659
...
...
@@ -61,7 +61,6 @@ define(function (require) {
var
cy
=
parsePercent
(
center
[
1
],
height
);
var
barMinHeight
=
seriesModel
.
get
(
'
barMinHeight
'
)
||
0
;
console
.
log
(
'
barMinHeight
'
,
barMinHeight
)
var
barMinAngle
=
seriesModel
.
get
(
'
barMinAngle
'
)
||
0
;
var
valueAxisStart
=
valueAxis
.
getExtent
()[
0
];
...
...
@@ -98,10 +97,10 @@ define(function (require) {
if
(
valueAxis
.
dim
===
'
radius
'
)
{
// value of barMinHeight
if
(
barMinHeight
)
{
//
if (barMinHeight) {
// var barMinValue = polar
//TODO
}
//
}
// radial sector
r0
=
lastCoordOrigin
;
...
...
@@ -121,10 +120,10 @@ define(function (require) {
r
=
r0
+
columnWidth
;
// clamp data if min or max is defined for valueAxis
if
(
valueMax
!=
undefined
)
{
if
(
valueMax
!=
null
)
{
value
=
Math
.
min
(
value
,
valueMax
);
}
if
(
valueMin
!=
undefined
)
{
if
(
valueMin
!=
null
)
{
value
=
Math
.
max
(
value
,
valueMin
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录