Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
x649585723
incubator-echarts
提交
2fcdde6e
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,发现更多精彩内容 >>
提交
2fcdde6e
编写于
11月 11, 2015
作者:
L
lang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Improve polar to support startAngle and clockwise
上级
75b33832
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
69 addition
and
42 deletion
+69
-42
src/chart/line/LineView.js
src/chart/line/LineView.js
+10
-7
src/component/axis/AngleAxisView.js
src/component/axis/AngleAxisView.js
+2
-2
src/component/axis/RadiusAxisView.js
src/component/axis/RadiusAxisView.js
+16
-6
src/component/tooltip.js
src/component/tooltip.js
+3
-2
src/coord/Axis.js
src/coord/Axis.js
+10
-9
src/coord/cartesian/AxisModel.js
src/coord/cartesian/AxisModel.js
+0
-1
src/coord/polar/AngleAxis.js
src/coord/polar/AngleAxis.js
+1
-1
src/coord/polar/AxisModel.js
src/coord/polar/AxisModel.js
+3
-3
src/coord/polar/Polar.js
src/coord/polar/Polar.js
+14
-9
src/coord/polar/polarCreator.js
src/coord/polar/polarCreator.js
+10
-2
未找到文件。
src/chart/line/LineView.js
浏览文件 @
2fcdde6e
...
@@ -173,7 +173,8 @@ define(function(require) {
...
@@ -173,7 +173,8 @@ define(function(require) {
group
.
add
(
polygon
);
group
.
add
(
polygon
);
}
}
polyline
.
setStyle
(
zrUtil
.
extend
(
polyline
.
setStyle
(
zrUtil
.
defaults
(
// Use color in lineStyle first
lineStyleModel
.
getLineStyle
(),
lineStyleModel
.
getLineStyle
(),
{
{
stroke
:
data
.
getVisual
(
'
color
'
),
stroke
:
data
.
getVisual
(
'
color
'
),
...
@@ -408,12 +409,13 @@ define(function(require) {
...
@@ -408,12 +409,13 @@ define(function(require) {
},
},
_createPolarClipShape
:
function
(
polar
,
animation
)
{
_createPolarClipShape
:
function
(
polar
,
animation
)
{
//
var angleAxis = polar.getAngleAxis();
var
angleAxis
=
polar
.
getAngleAxis
();
var
radiusAxis
=
polar
.
getRadiusAxis
();
var
radiusAxis
=
polar
.
getRadiusAxis
();
var
radiusExtent
=
radiusAxis
.
getExtent
();
var
radiusExtent
=
radiusAxis
.
getExtent
();
var
angleExtent
=
angleAxis
.
getExtent
();
var
PI2
=
Math
.
PI
*
2
;
var
RADIAN
=
Math
.
PI
/
180
;
var
clipPath
=
new
graphic
.
Sector
({
var
clipPath
=
new
graphic
.
Sector
({
shape
:
{
shape
:
{
...
@@ -421,16 +423,17 @@ define(function(require) {
...
@@ -421,16 +423,17 @@ define(function(require) {
cy
:
polar
.
cy
,
cy
:
polar
.
cy
,
r0
:
radiusExtent
[
0
],
r0
:
radiusExtent
[
0
],
r
:
radiusExtent
[
1
],
r
:
radiusExtent
[
1
],
startAngle
:
0
,
startAngle
:
-
angleExtent
[
0
]
*
RADIAN
,
endAngle
:
PI2
endAngle
:
-
angleExtent
[
1
]
*
RADIAN
,
clockwise
:
angleAxis
.
inverse
}
}
});
});
if
(
animation
)
{
if
(
animation
)
{
clipPath
.
shape
.
endAngle
=
0
;
clipPath
.
shape
.
endAngle
=
-
angleExtent
[
0
]
*
RADIAN
;
clipPath
.
animateTo
({
clipPath
.
animateTo
({
shape
:
{
shape
:
{
endAngle
:
PI2
endAngle
:
-
angleExtent
[
1
]
*
RADIAN
}
}
},
1500
,
animation
);
},
1500
,
animation
);
}
}
...
...
src/component/axis/AngleAxisView.js
浏览文件 @
2fcdde6e
...
@@ -119,7 +119,7 @@ define(function (require) {
...
@@ -119,7 +119,7 @@ define(function (require) {
textFont
:
textStyleModel
.
getFont
()
textFont
:
textStyleModel
.
getFont
()
},
},
silent
:
true
silent
:
true
}))
}))
;
}
}
},
},
...
@@ -141,7 +141,7 @@ define(function (require) {
...
@@ -141,7 +141,7 @@ define(function (require) {
splitLines
[
colorIndex
]
=
splitLines
[
colorIndex
]
||
[];
splitLines
[
colorIndex
]
=
splitLines
[
colorIndex
]
||
[];
splitLines
[
colorIndex
].
push
(
new
graphic
.
Line
({
splitLines
[
colorIndex
].
push
(
new
graphic
.
Line
({
shape
:
getAxisLineShape
(
polar
,
radiusExtent
[
0
],
radiusExtent
[
1
],
ticksAngles
[
i
])
shape
:
getAxisLineShape
(
polar
,
radiusExtent
[
0
],
radiusExtent
[
1
],
ticksAngles
[
i
])
}))
}))
;
}
}
// Simple optimization
// Simple optimization
...
...
src/component/axis/RadiusAxisView.js
浏览文件 @
2fcdde6e
...
@@ -16,10 +16,11 @@ define(function (require) {
...
@@ -16,10 +16,11 @@ define(function (require) {
this
.
group
.
removeAll
();
this
.
group
.
removeAll
();
var
polarModel
=
ecModel
.
getComponent
(
'
polar
'
,
radiusAxisModel
.
get
(
'
polarIndex
'
));
var
polarModel
=
ecModel
.
getComponent
(
'
polar
'
,
radiusAxisModel
.
get
(
'
polarIndex
'
));
var
angleAxis
=
polarModel
.
coordinateSystem
.
getAngleAxis
();
var
radiusAxis
=
radiusAxisModel
.
axis
;
var
radiusAxis
=
radiusAxisModel
.
axis
;
var
polar
=
polarModel
.
coordinateSystem
;
var
polar
=
polarModel
.
coordinateSystem
;
var
ticksCoords
=
radiusAxis
.
getTicksCoords
();
var
ticksCoords
=
radiusAxis
.
getTicksCoords
();
var
axisAngle
=
radiusAxisModel
.
get
(
'
axisAngle
'
)
;
var
axisAngle
=
angleAxis
.
getExtent
()[
0
]
;
var
radiusExtent
=
radiusAxis
.
getExtent
();
var
radiusExtent
=
radiusAxis
.
getExtent
();
zrUtil
.
each
(
elementList
,
function
(
name
)
{
zrUtil
.
each
(
elementList
,
function
(
name
)
{
if
(
radiusAxisModel
.
get
(
name
+
'
.show
'
))
{
if
(
radiusAxisModel
.
get
(
name
+
'
.show
'
))
{
...
@@ -95,6 +96,7 @@ define(function (require) {
...
@@ -95,6 +96,7 @@ define(function (require) {
var
axis
=
radiusAxisModel
.
axis
;
var
axis
=
radiusAxisModel
.
axis
;
var
labelModel
=
radiusAxisModel
.
getModel
(
'
axisLabel
'
);
var
labelModel
=
radiusAxisModel
.
getModel
(
'
axisLabel
'
);
var
textStyleModel
=
labelModel
.
getModel
(
'
textStyle
'
);
var
textStyleModel
=
labelModel
.
getModel
(
'
textStyle
'
);
var
tickModel
=
radiusAxisModel
.
getModel
(
'
axisTick
'
);
var
labels
=
radiusAxisModel
.
formatLabels
(
axis
.
scale
.
getTicksLabels
());
var
labels
=
radiusAxisModel
.
formatLabels
(
axis
.
scale
.
getTicksLabels
());
...
@@ -102,34 +104,42 @@ define(function (require) {
...
@@ -102,34 +104,42 @@ define(function (require) {
var
end
=
polar
.
coordToPoint
([
radiusExtent
[
1
],
axisAngle
]);
var
end
=
polar
.
coordToPoint
([
radiusExtent
[
1
],
axisAngle
]);
var
len
=
vector
.
dist
(
end
,
start
);
var
len
=
vector
.
dist
(
end
,
start
);
var
dir
ection
=
[
var
dir
=
[
end
[
1
]
-
start
[
1
],
end
[
1
]
-
start
[
1
],
start
[
0
]
-
end
[
0
]
start
[
0
]
-
end
[
0
]
];
];
vector
.
normalize
(
dir
ection
,
direction
);
vector
.
normalize
(
dir
,
dir
);
var
p
=
[];
var
p
=
[];
var
tickLen
=
tickModel
.
get
(
'
length
'
);
var
labelMargin
=
labelModel
.
get
(
'
margin
'
);
var
labelMargin
=
labelModel
.
get
(
'
margin
'
);
var
labelsPositions
=
axis
.
getLabelsCoords
();
var
labelsPositions
=
axis
.
getLabelsCoords
();
var
labelRotate
=
labelModel
.
get
(
'
rotate
'
);
var
labelRotate
=
labelModel
.
get
(
'
rotate
'
);
var
labelTextAlign
=
'
center
'
;
var
labelTextAlign
=
'
center
'
;
if
(
labelRotate
)
{
if
(
labelRotate
)
{
labelTextAlign
=
labelRotate
>
0
?
'
left
'
:
'
right
'
labelTextAlign
=
labelRotate
>
0
?
'
left
'
:
'
right
'
;
}
// Point to top
if
(
dir
[
0
]
>
-
0.3
&&
dir
[
0
]
<=
0
)
{
labelTextAlign
=
'
right
'
;
}
else
if
(
dir
[
0
]
<
0.3
&&
dir
[
0
]
>=
0
)
{
labelTextAlign
=
'
left
'
;
}
}
// FIXME Text align and text baseline when axis angle is 90 degree
// FIXME Text align and text baseline when axis angle is 90 degree
for
(
var
i
=
0
;
i
<
labelsPositions
.
length
;
i
++
)
{
for
(
var
i
=
0
;
i
<
labelsPositions
.
length
;
i
++
)
{
// Get point on axis
// Get point on axis
vector
.
lerp
(
p
,
start
,
end
,
labelsPositions
[
i
]
/
len
);
vector
.
lerp
(
p
,
start
,
end
,
labelsPositions
[
i
]
/
len
);
vector
.
scaleAndAdd
(
p
,
p
,
dir
ection
,
labelMargi
n
);
vector
.
scaleAndAdd
(
p
,
p
,
dir
,
labelMargin
+
tickLe
n
);
this
.
group
.
add
(
new
graphic
.
Text
({
this
.
group
.
add
(
new
graphic
.
Text
({
style
:
{
style
:
{
x
:
p
[
0
],
x
:
p
[
0
],
y
:
p
[
1
],
y
:
p
[
1
],
text
:
labels
[
i
],
text
:
labels
[
i
],
textAlign
:
labelTextAlign
,
textAlign
:
labelTextAlign
,
textBaseline
:
'
bottom
'
,
textBaseline
:
dir
[
1
]
>
0.4
?
'
bottom
'
:
(
dir
[
1
]
<
-
0.4
?
'
top
'
:
'
middle
'
)
,
textFont
:
textStyleModel
.
getFont
()
textFont
:
textStyleModel
.
getFont
()
},
},
rotation
:
labelRotate
*
Math
.
PI
/
180
,
rotation
:
labelRotate
*
Math
.
PI
/
180
,
...
...
src/component/tooltip.js
浏览文件 @
2fcdde6e
...
@@ -491,8 +491,9 @@ define(function (require) {
...
@@ -491,8 +491,9 @@ define(function (require) {
targetShape
=
makeSectorShape
(
targetShape
=
makeSectorShape
(
polar
.
cx
,
polar
.
cy
,
polar
.
cx
,
polar
.
cy
,
otherExtent
[
0
],
otherExtent
[
1
],
otherExtent
[
0
],
otherExtent
[
1
],
(
mouseCoord
[
1
]
-
bandWidth
/
2
)
*
radian
,
// In ECharts y is negative if angle is positive
(
mouseCoord
[
1
]
+
bandWidth
/
2
)
*
radian
(
-
mouseCoord
[
1
]
-
bandWidth
/
2
)
*
radian
,
(
-
mouseCoord
[
1
]
+
bandWidth
/
2
)
*
radian
);
);
}
}
else
{
else
{
...
...
src/coord/Axis.js
浏览文件 @
2fcdde6e
...
@@ -104,13 +104,14 @@ define(function (require) {
...
@@ -104,13 +104,14 @@ define(function (require) {
/**
/**
* Set coord extent
* Set coord extent
* @param {number}
min
* @param {number}
start
* @param {number}
max
* @param {number}
end
*/
*/
setExtent
:
function
(
min
,
max
)
{
setExtent
:
function
(
start
,
end
)
{
var
extent
=
this
.
_extent
;
var
extent
=
this
.
_extent
;
extent
[
0
]
=
min
;
var
inverse
=
this
.
inverse
;
extent
[
1
]
=
max
;
extent
[
0
]
=
inverse
?
end
:
start
;
extent
[
1
]
=
inverse
?
start
:
end
;
},
},
/**
/**
...
@@ -197,17 +198,17 @@ define(function (require) {
...
@@ -197,17 +198,17 @@ define(function (require) {
*/
*/
// FIXME Situation when labels is on ticks
// FIXME Situation when labels is on ticks
getBands
:
function
()
{
getBands
:
function
()
{
var
extent
=
this
.
_extent
;
var
extent
=
this
.
getExtent
()
;
var
bands
=
[];
var
bands
=
[];
var
len
=
this
.
scale
.
count
();
var
len
=
this
.
scale
.
count
();
var
start
=
extent
[
0
];
var
start
=
extent
[
0
];
var
end
=
extent
[
1
];
var
end
=
extent
[
1
];
var
s
ize
=
end
-
start
;
var
s
pan
=
end
-
start
;
for
(
var
i
=
0
;
i
<
len
;
i
++
)
{
for
(
var
i
=
0
;
i
<
len
;
i
++
)
{
bands
.
push
([
bands
.
push
([
s
ize
*
i
/
len
+
start
,
s
pan
*
i
/
len
+
start
,
s
ize
*
(
i
+
1
)
/
len
+
start
s
pan
*
(
i
+
1
)
/
len
+
start
]);
]);
}
}
return
bands
;
return
bands
;
...
...
src/coord/cartesian/AxisModel.js
浏览文件 @
2fcdde6e
...
@@ -34,7 +34,6 @@ define(function(require) {
...
@@ -34,7 +34,6 @@ define(function(require) {
zrUtil
.
merge
(
AxisModel
.
prototype
,
require
(
'
../axisModelCommonMixin
'
));
zrUtil
.
merge
(
AxisModel
.
prototype
,
require
(
'
../axisModelCommonMixin
'
));
// x axis
// x axis
AxisModel
.
extend
({
AxisModel
.
extend
({
...
...
src/coord/polar/AngleAxis.js
浏览文件 @
2fcdde6e
...
@@ -19,7 +19,7 @@ define(function(require) {
...
@@ -19,7 +19,7 @@ define(function(require) {
* @type {string}
* @type {string}
*/
*/
this
.
type
=
'
category
'
;
this
.
type
=
'
category
'
;
}
;
}
AngleAxis
.
prototype
=
{
AngleAxis
.
prototype
=
{
...
...
src/coord/polar/AxisModel.js
浏览文件 @
2fcdde6e
...
@@ -47,8 +47,6 @@ define(function(require) {
...
@@ -47,8 +47,6 @@ define(function(require) {
polarIndex
:
0
,
polarIndex
:
0
,
axisAngle
:
0
,
splitNumber
:
5
splitNumber
:
5
}
}
});
});
...
@@ -75,7 +73,9 @@ define(function(require) {
...
@@ -75,7 +73,9 @@ define(function(require) {
polarIndex
:
0
,
polarIndex
:
0
,
clockWise
:
true
,
startAngle
:
90
,
clockwise
:
true
,
splitNumber
:
12
,
splitNumber
:
12
,
...
...
src/coord/polar/Polar.js
浏览文件 @
2fcdde6e
...
@@ -159,7 +159,7 @@ define(function(require) {
...
@@ -159,7 +159,7 @@ define(function(require) {
return
this
.
coordToPoint
([
return
this
.
coordToPoint
([
this
.
_radiusAxis
.
dataToRadius
(
data
[
0
],
clamp
),
this
.
_radiusAxis
.
dataToRadius
(
data
[
0
],
clamp
),
this
.
_angleAxis
.
dataToAngle
(
data
[
1
],
clamp
)
this
.
_angleAxis
.
dataToAngle
(
data
[
1
],
clamp
)
])
])
;
},
},
/**
/**
...
@@ -184,20 +184,24 @@ define(function(require) {
...
@@ -184,20 +184,24 @@ define(function(require) {
pointToCoord
:
function
(
point
)
{
pointToCoord
:
function
(
point
)
{
var
dx
=
point
[
0
]
-
this
.
cx
;
var
dx
=
point
[
0
]
-
this
.
cx
;
var
dy
=
point
[
1
]
-
this
.
cy
;
var
dy
=
point
[
1
]
-
this
.
cy
;
var
angleAxis
=
this
.
getAngleAxis
();
var
extent
=
angleAxis
.
getExtent
();
var
minAngle
=
Math
.
min
(
extent
[
0
],
extent
[
1
]);
var
maxAngle
=
Math
.
max
(
extent
[
0
],
extent
[
1
]);
var
radius
=
Math
.
sqrt
(
dx
*
dx
+
dy
*
dy
);
var
radius
=
Math
.
sqrt
(
dx
*
dx
+
dy
*
dy
);
dx
/=
radius
;
dx
/=
radius
;
dy
/=
radius
;
dy
/=
radius
;
var
radian
=
Math
.
atan2
(
dy
,
dx
)
;
var
radian
=
Math
.
atan2
(
-
dy
,
dx
)
/
Math
.
PI
*
180
;
//
Threshold to 0 - 360
//
move to angleExtent
// FIXME Angle Extent ?
var
dir
=
radian
<
minAngle
?
1
:
-
1
;
if
(
radian
<
0
)
{
while
(
radian
<
minAngle
||
radian
>
maxAngle
)
{
radian
+=
Math
.
PI
*
2
;
radian
+=
dir
*
360
;
}
}
return
[
radius
,
radian
/
Math
.
PI
*
180
];
return
[
radius
,
radian
];
},
},
/**
/**
...
@@ -209,11 +213,12 @@ define(function(require) {
...
@@ -209,11 +213,12 @@ define(function(require) {
var
radius
=
coord
[
0
];
var
radius
=
coord
[
0
];
var
radian
=
coord
[
1
]
/
180
*
Math
.
PI
;
var
radian
=
coord
[
1
]
/
180
*
Math
.
PI
;
var
x
=
Math
.
cos
(
radian
)
*
radius
+
this
.
cx
;
var
x
=
Math
.
cos
(
radian
)
*
radius
+
this
.
cx
;
var
y
=
Math
.
sin
(
radian
)
*
radius
+
this
.
cy
;
// Inverse the y
var
y
=
-
Math
.
sin
(
radian
)
*
radius
+
this
.
cy
;
return
[
x
,
y
];
return
[
x
,
y
];
}
}
}
}
;
return
Polar
;
return
Polar
;
});
});
\ No newline at end of file
src/coord/polar/polarCreator.js
浏览文件 @
2fcdde6e
...
@@ -46,6 +46,12 @@ define(function (require) {
...
@@ -46,6 +46,12 @@ define(function (require) {
axis
.
onBand
=
axisModel
.
get
(
'
boundaryGap
'
)
&&
axis
.
type
===
'
category
'
;
axis
.
onBand
=
axisModel
.
get
(
'
boundaryGap
'
)
&&
axis
.
type
===
'
category
'
;
axis
.
inverse
=
axisModel
.
get
(
'
inverse
'
);
axis
.
inverse
=
axisModel
.
get
(
'
inverse
'
);
if
(
axisModel
.
type
===
'
angleAxis
'
)
{
var
startAngle
=
axisModel
.
get
(
'
startAngle
'
);
axis
.
setExtent
(
startAngle
,
startAngle
+
360
);
axis
.
inverse
=
axisModel
.
get
(
'
clockwise
'
);
}
// Inject axis instance
// Inject axis instance
axisModel
.
axis
=
axis
;
axisModel
.
axis
=
axis
;
axis
.
model
=
axisModel
;
axis
.
model
=
axisModel
;
...
@@ -118,8 +124,10 @@ define(function (require) {
...
@@ -118,8 +124,10 @@ define(function (require) {
zrUtil
.
each
(
polarList
,
function
(
polar
)
{
zrUtil
.
each
(
polarList
,
function
(
polar
)
{
var
angleAxis
=
polar
.
getAngleAxis
();
var
angleAxis
=
polar
.
getAngleAxis
();
if
(
angleAxis
.
type
===
'
category
'
&&
!
angleAxis
.
onBand
)
{
if
(
angleAxis
.
type
===
'
category
'
&&
!
angleAxis
.
onBand
)
{
var
angle
=
360
-
360
/
(
angleAxis
.
scale
.
count
()
+
1
);
var
extent
=
angleAxis
.
getExtent
();
angleAxis
.
setExtent
(
0
,
angle
);
var
diff
=
360
/
(
angleAxis
.
scale
.
count
()
+
1
);
angleAxis
.
inverse
?
(
extent
[
1
]
+=
diff
)
:
(
extent
[
1
]
-=
diff
);
angleAxis
.
setExtent
(
extent
[
0
],
extent
[
1
]);
}
}
});
});
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录