Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
x649585723
incubator-echarts
提交
91965d6e
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,发现更多精彩内容 >>
提交
91965d6e
编写于
11月 20, 2013
作者:
K
kener
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
pie polar radius支持百分比
上级
65fa9e58
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
40 addition
and
60 deletion
+40
-60
doc/example/pie1.html
doc/example/pie1.html
+1
-1
doc/example/pie2.html
doc/example/pie2.html
+2
-2
src/chart/pie.js
src/chart/pie.js
+12
-24
src/component/base.js
src/component/base.js
+16
-0
src/component/polar.js
src/component/polar.js
+6
-30
src/config.js
src/config.js
+3
-3
未找到文件。
doc/example/pie1.html
浏览文件 @
91965d6e
...
...
@@ -96,7 +96,7 @@ option = {
{
name:'访问来源',
type:'pie',
radius :
[0, 110]
,
radius :
'55%'
,
center: ['50%', 225],
data:[
{value:335, name:'直接访问'},
...
...
doc/example/pie2.html
浏览文件 @
91965d6e
...
...
@@ -91,8 +91,8 @@ option = {
{
name:'访问来源',
type:'pie',
radius : [
80, 120
],
itemStyle :
{
radius : [
'50%', '70%'
],
itemStyle :
{
normal : {
label : {
show : false
...
...
src/chart/pie.js
浏览文件 @
91965d6e
...
...
@@ -42,6 +42,7 @@ define(function(require) {
self
.
selectedMap
=
{};
_selected
=
{};
var
center
;
var
radius
;
var
pieCase
;
// 饼图箱子
_selectedMode
=
false
;
...
...
@@ -49,20 +50,20 @@ define(function(require) {
if
(
series
[
i
].
type
==
ecConfig
.
CHART_TYPE_PIE
)
{
series
[
i
]
=
self
.
reformOption
(
series
[
i
]);
center
=
self
.
parseCenter
(
series
[
i
].
center
);
radius
=
self
.
parseRadius
(
series
[
i
].
radius
);
_selectedMode
=
_selectedMode
||
series
[
i
].
selectedMode
;
_selected
[
i
]
=
[];
if
(
self
.
deepQuery
([
series
[
i
],
option
],
'
calculable
'
))
{
pieCase
=
{
shape
:
series
[
i
].
radius
[
0
]
<=
10
?
'
circle
'
:
'
ring
'
,
shape
:
radius
[
0
]
<=
10
?
'
circle
'
:
'
ring
'
,
zlevel
:
_zlevelBase
,
hoverable
:
false
,
style
:
{
x
:
center
[
0
],
// 圆心横坐标
y
:
center
[
1
],
// 圆心纵坐标
r0
:
series
[
i
].
radius
[
0
]
<=
10
// 圆环内
半径
?
0
:
series
[
i
].
radius
[
0
]
-
10
,
r
:
series
[
i
].
radius
[
1
]
+
10
,
// 圆环外半径
// 圆环内外
半径
r0
:
radius
[
0
]
<=
10
?
0
:
radius
[
0
]
-
10
,
r
:
radius
[
1
]
+
10
,
brushType
:
'
stroke
'
,
strokeColor
:
series
[
i
].
calculableHolderColor
||
ecConfig
.
calculableHolderColor
...
...
@@ -118,6 +119,7 @@ define(function(require) {
var
totalAngle
=
360
-
(
minAngle
*
totalSelected
);
var
defaultColor
;
var
roseType
=
serie
.
roseType
;
var
radius
;
var
r0
;
// 扇形内半径
var
r1
;
// 扇形外半径
...
...
@@ -147,8 +149,9 @@ define(function(require) {
}
percent
=
(
percent
*
100
).
toFixed
(
2
);
r0
=
+
serie
.
radius
[
0
];
r1
=
+
serie
.
radius
[
1
];
radius
=
self
.
parseRadius
(
serie
.
radius
);
r0
=
+
radius
[
0
];
r1
=
+
radius
[
1
];
if
(
roseType
==
'
radius
'
)
{
r1
=
data
[
i
].
value
/
maxValue
*
(
r1
-
r0
)
*
0.8
...
...
@@ -412,11 +415,11 @@ define(function(require) {
var
centerX
=
center
[
0
];
// 圆心横坐标
var
centerY
=
center
[
1
];
// 圆心纵坐标
var
midAngle
=
((
endAngle
+
startAngle
)
/
2
)
%
360
;
// 角度中值
var
radius
;
// 标签位置半径
var
radius
=
self
.
parseRadius
(
serie
.
radius
);
// 标签位置半径
var
textAlign
;
if
(
labelControl
.
position
==
'
outer
'
)
{
// 外部显示,默认
radius
=
serie
.
radius
[
1
]
radius
=
radius
[
1
]
-
(
-
itemStyle
[
status
].
labelLine
.
length
)
-
(
-
textStyle
.
fontSize
);
textAlign
=
(
midAngle
>=
150
&&
midAngle
<=
210
)
...
...
@@ -475,11 +478,6 @@ define(function(require) {
else
{
// 内部显示由sector自带,不返回即可
return
;
/*
radius = (serie.radius[0] + serie.radius[1]) / 2;
textAlign = 'center';
defaultColor = '#fff';
*/
}
}
else
{
...
...
@@ -632,16 +630,6 @@ define(function(require) {
}
);
// 传数组实现环形图,[内半径,外半径],传单个则默认为外半径为
if
(
typeof
opt
.
radius
==
'
undefined
'
)
{
opt
.
radius
=
[
0
,
Math
.
round
(
Math
.
min
(
zr
.
getWidth
(),
zr
.
getHeight
())
/
2
-
50
)
];
}
else
if
(
!
(
opt
.
radius
instanceof
Array
))
{
opt
.
radius
=
[
0
,
opt
.
radius
];
}
// 通用字体设置
opt
.
itemStyle
.
normal
.
label
.
textStyle
=
_merge
(
opt
.
itemStyle
.
normal
.
label
.
textStyle
||
{},
...
...
src/component/base.js
浏览文件 @
91965d6e
...
...
@@ -295,6 +295,21 @@ define(function(require) {
];
}
/**
* 获取自适应半径
*/
function
parseRadius
(
radius
)
{
// 传数组实现环形图,[内半径,外半径],传单个则默认为外半径为
if
(
!
(
radius
instanceof
Array
))
{
radius
=
[
0
,
radius
];
}
var
zrSize
=
Math
.
min
(
self
.
zr
.
getWidth
(),
self
.
zr
.
getHeight
())
/
2
;
return
[
parsePercent
(
radius
[
0
],
zrSize
),
parsePercent
(
radius
[
1
],
zrSize
),
];
}
function
_trim
(
str
)
{
return
str
.
replace
(
/^
\s\s
*/
,
''
).
replace
(
/
\s\s
*$/
,
''
);
}
...
...
@@ -342,6 +357,7 @@ define(function(require) {
self
.
addLabel
=
addLabel
;
self
.
parsePercent
=
parsePercent
;
self
.
parseCenter
=
parseCenter
;
self
.
parseRadius
=
parseRadius
;
self
.
clear
=
clear
;
self
.
dispose
=
dispose
;
self
.
resize
=
resize
;
...
...
src/component/polar.js
浏览文件 @
91965d6e
...
...
@@ -67,16 +67,13 @@ define(
var
length
=
indicator
.
length
;
var
startAngle
=
item
.
startAngle
;
var
dStep
=
2
*
Math
.
PI
/
length
;
var
radius
=
item
.
radius
;
var
radius
=
self
.
parsePercent
(
item
.
radius
,
Math
.
min
(
zr
.
getWidth
(),
zr
.
getHeight
())
/
2
);
var
__ecIndicator
=
item
.
__ecIndicator
=
[];
var
vector
;
if
(
typeof
radius
!=
'
number
'
)
{
radius
=
Math
.
floor
(
Math
.
min
(
_width
,
_height
)
/
2
-
50
);
}
for
(
var
i
=
0
;
i
<
length
;
i
++
)
{
vector
=
ecCoordinates
.
polar2cartesian
(
radius
,
startAngle
*
Math
.
PI
/
180
+
dStep
*
i
...
...
@@ -760,27 +757,6 @@ define(
}
}
function
reformOption
(
opt
)
{
// 常用方法快捷方式
var
_merge
=
zrUtil
.
merge
;
opt
=
_merge
(
opt
||
{},
ecConfig
.
polar
,
{
'
overwrite
'
:
false
,
'
recursive
'
:
true
}
);
if
(
!
opt
.
radius
)
{
opt
.
radius
=
Math
.
floor
(
Math
.
min
(
_width
,
_height
)
/
2
-
50
);
}
return
opt
;
}
/**
* 获取每个指标上某个value对应的坐标
* @param {number} polarIndex
...
...
@@ -850,6 +826,7 @@ define(
var
len
;
var
angle
;
var
finalAngle
;
var
zrSize
=
Math
.
min
(
zr
.
getWidth
(),
zr
.
getHeight
())
/
2
;
for
(
var
i
=
0
;
i
<
polar
.
length
;
i
++
)
{
item
=
polar
[
i
];
center
=
getCenter
(
i
);
...
...
@@ -859,7 +836,7 @@ define(
valueIndex
:
0
};
}
radius
=
self
.
deepQuery
([
item
,
option
],
'
radius
'
);
radius
=
self
.
parsePercent
(
item
.
radius
,
zrSize
);
startAngle
=
item
.
startAngle
;
indicator
=
item
.
indicator
;
len
=
indicator
.
length
;
...
...
@@ -917,7 +894,6 @@ define(
}
self
.
refresh
=
refresh
;
self
.
reformOption
=
reformOption
;
self
.
getVector
=
getVector
;
self
.
getDropBox
=
_addDropBox
;
...
...
src/config.js
浏览文件 @
91965d6e
...
...
@@ -332,7 +332,7 @@ define(function() {
polar
:
{
center
:
[
'
50%
'
,
'
50%
'
],
// 默认全局居中
// radius: 'min(width, height) / 2 - 50
',
radius
:
'
75%
'
,
startAngle
:
90
,
splitNumber
:
5
,
name
:
{
...
...
@@ -545,7 +545,7 @@ define(function() {
// 饼图默认参数
pie
:
{
center
:
[
'
50%
'
,
'
50%
'
],
// 默认全局居中
// radius: [0, min(width, height) / 2 - 50
],
radius
:
[
0
,
'
75%
'
],
startAngle
:
90
,
minAngle
:
0
,
// 最小角度改为0
selectedOffset
:
10
,
// 选中是扇区偏移量
...
...
@@ -680,7 +680,6 @@ define(function() {
chord
:
{
radius
:
[
'
65%
'
,
'
75%
'
],
// Source data matrix
center
:
[
'
50%
'
,
'
50%
'
],
padding
:
2
,
sort
:
'
none
'
,
// can be 'none', 'ascending', 'descending'
...
...
@@ -719,6 +718,7 @@ define(function() {
}
}
},
// Source data matrix
/**
* target
* -1--2--3--4--5-
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录