Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
alon@wen
echarts
提交
b7d730b9
E
echarts
项目概览
alon@wen
/
echarts
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
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,发现更多精彩内容 >>
提交
b7d730b9
编写于
9月 12, 2015
作者:
L
lang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Optimize polar, interval scale rounding error fix
上级
01d8ed56
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
73 addition
and
90 deletion
+73
-90
src/component/angleAxis.js
src/component/angleAxis.js
+16
-26
src/component/polar.js
src/component/polar.js
+1
-5
src/component/radiusAxis.js
src/component/radiusAxis.js
+22
-45
src/coord/Axis.js
src/coord/Axis.js
+5
-2
src/coord/polar/Polar.js
src/coord/polar/Polar.js
+25
-8
src/layout/barGrid.js
src/layout/barGrid.js
+2
-2
src/scale/Interval.js
src/scale/Interval.js
+2
-2
未找到文件。
src/component/angleAxis.js
浏览文件 @
b7d730b9
...
...
@@ -5,18 +5,9 @@ define(function(require) {
var
elementList
=
[
'
axisLine
'
,
'
axisLabel
'
,
'
axisTick
'
,
'
splitLine
'
,
'
splitArea
'
];
function
getPointOnAxisLine
(
cx
,
cy
,
r
,
radian
)
{
var
dx
=
r
*
Math
.
cos
(
radian
);
var
dy
=
r
*
Math
.
sin
(
radian
);
return
[
cx
+
dx
,
cy
+
dy
];
}
function
getAxisLineShape
(
cx
,
cy
,
r0
,
r
,
angle
)
{
var
radian
=
angle
/
180
*
Math
.
PI
;
var
start
=
getPointOnAxisLine
(
cx
,
cy
,
r0
,
radian
);
var
end
=
getPointOnAxisLine
(
cx
,
cy
,
r
,
radian
);
function
getAxisLineShape
(
polar
,
r0
,
r
,
angle
)
{
var
start
=
polar
.
coordToPoint
([
r0
,
angle
]);
var
end
=
polar
.
coordToPoint
([
r
,
angle
]);
return
{
x1
:
start
[
0
],
...
...
@@ -39,8 +30,6 @@ define(function(require) {
var
polarModel
=
ecModel
.
getComponent
(
'
polar
'
,
angleAxisModel
.
get
(
'
polarIndex
'
));
var
angleAxis
=
angleAxisModel
.
axis
;
var
polar
=
polarModel
.
coordinateSystem
;
var
cx
=
polar
.
cx
;
var
cy
=
polar
.
cy
;
var
radiusExtent
=
polar
.
getRadiusAxis
().
getExtent
();
var
ticksAngles
=
angleAxis
.
getTicksCoords
();
...
...
@@ -51,7 +40,7 @@ define(function(require) {
zrUtil
.
each
(
elementList
,
function
(
name
)
{
if
(
angleAxisModel
.
get
(
name
+
'
.show
'
))
{
this
[
'
_
'
+
name
](
angleAxisModel
,
ticksAngles
,
radiusExtent
,
cx
,
cy
,
api
);
this
[
'
_
'
+
name
](
angleAxisModel
,
polar
,
ticksAngles
,
radiusExtent
,
api
);
}
},
this
);
},
...
...
@@ -59,13 +48,13 @@ define(function(require) {
/**
* @private
*/
_axisLine
:
function
(
angleAxisModel
,
ticksAngles
,
radiusExtent
,
cx
,
cy
,
api
)
{
_axisLine
:
function
(
angleAxisModel
,
polar
,
ticksAngles
,
radiusExtent
,
api
)
{
var
lineStyleModel
=
angleAxisModel
.
getModel
(
'
axisLine.lineStyle
'
);
var
circle
=
new
api
.
Circle
({
shape
:
{
cx
:
cx
,
cy
:
cy
,
cx
:
polar
.
cx
,
cy
:
polar
.
cy
,
r
:
radiusExtent
[
1
]
},
style
:
lineStyleModel
.
getLineStyle
()
...
...
@@ -78,14 +67,14 @@ define(function(require) {
/**
* @private
*/
_axisTick
:
function
(
angleAxisModel
,
ticksAngles
,
radiusExtent
,
cx
,
cy
,
api
)
{
_axisTick
:
function
(
angleAxisModel
,
polar
,
ticksAngles
,
radiusExtent
,
api
)
{
var
tickModel
=
angleAxisModel
.
getModel
(
'
axisTick
'
);
var
tickLen
=
(
tickModel
.
get
(
'
inside
'
)
?
-
1
:
1
)
*
tickModel
.
get
(
'
length
'
);
var
lines
=
zrUtil
.
map
(
ticksAngles
,
function
(
tickAngle
)
{
return
new
api
.
Line
({
shape
:
getAxisLineShape
(
cx
,
cy
,
radiusExtent
[
1
],
radiusExtent
[
1
]
+
tickLen
,
tickAngle
)
shape
:
getAxisLineShape
(
polar
,
radiusExtent
[
1
],
radiusExtent
[
1
]
+
tickLen
,
tickAngle
)
});
});
this
.
group
.
add
(
api
.
mergePath
(
...
...
@@ -98,7 +87,7 @@ define(function(require) {
/**
* @private
*/
_axisLabel
:
function
(
angleAxisModel
,
ticksAngles
,
radiusExtent
,
cx
,
cy
,
api
)
{
_axisLabel
:
function
(
angleAxisModel
,
polar
,
ticksAngles
,
radiusExtent
,
api
)
{
var
axis
=
angleAxisModel
.
axis
;
var
labelModel
=
angleAxisModel
.
getModel
(
'
axisLabel
'
);
...
...
@@ -111,9 +100,10 @@ define(function(require) {
// Use length of ticksAngles because it may remove the last tick to avoid overlapping
for
(
var
i
=
0
;
i
<
ticksAngles
.
length
;
i
++
)
{
var
tickAngle
=
labelsAngles
[
i
]
*
Math
.
PI
/
180
;
var
r
=
radiusExtent
[
1
];
var
p
=
getPointOnAxisLine
(
cx
,
cy
,
r
+
labelMargin
,
tickAngle
);
var
p
=
polar
.
coordToPoint
([
r
+
labelMargin
,
labelsAngles
[
i
]]);
var
cx
=
polar
.
cx
;
var
cy
=
polar
.
cy
;
var
labelTextAlign
=
Math
.
abs
(
p
[
0
]
-
cx
)
/
r
<
0.3
?
'
center
'
:
(
p
[
0
]
>
cx
?
'
left
'
:
'
right
'
);
...
...
@@ -137,7 +127,7 @@ define(function(require) {
/**
* @private
*/
_splitLine
:
function
(
angleAxisModel
,
ticksAngles
,
radiusExtent
,
cx
,
cy
,
api
)
{
_splitLine
:
function
(
angleAxisModel
,
polar
,
ticksAngles
,
radiusExtent
,
api
)
{
var
splitLineModel
=
angleAxisModel
.
getModel
(
'
splitLine
'
);
var
lineStyleModel
=
splitLineModel
.
getModel
(
'
lineStyle
'
);
var
lineColors
=
lineStyleModel
.
get
(
'
color
'
);
...
...
@@ -152,7 +142,7 @@ define(function(require) {
var
colorIndex
=
(
lineCount
++
)
%
lineColors
.
length
;
splitLines
[
colorIndex
]
=
splitLines
[
colorIndex
]
||
[];
splitLines
[
colorIndex
].
push
(
new
api
.
Line
({
shape
:
getAxisLineShape
(
cx
,
cy
,
radiusExtent
[
0
],
radiusExtent
[
1
],
ticksAngles
[
i
])
shape
:
getAxisLineShape
(
polar
,
radiusExtent
[
0
],
radiusExtent
[
1
],
ticksAngles
[
i
])
}))
}
...
...
@@ -174,7 +164,7 @@ define(function(require) {
/**
* @private
*/
_splitArea
:
function
(
angleAxisModel
,
ticksAngles
,
radiusExtent
,
cx
,
cy
,
api
)
{
_splitArea
:
function
(
angleAxisModel
,
polar
,
ticksAngles
,
radiusExtent
,
api
)
{
}
});
...
...
src/component/polar.js
浏览文件 @
b7d730b9
...
...
@@ -7,10 +7,6 @@ define(function(require) {
// Polar view
require
(
'
../echarts
'
).
extendComponentView
({
type
:
'
polar
'
,
render
:
function
(
gridModel
,
ecModel
,
api
)
{
}
type
:
'
polar
'
});
});
\ No newline at end of file
src/component/radiusAxis.js
浏览文件 @
b7d730b9
...
...
@@ -6,33 +6,6 @@ define(function(require) {
var
elementList
=
[
'
splitLine
'
,
'
splitArea
'
,
'
axisLine
'
,
'
axisTick
'
,
'
axisLabel
'
];
function
getPointOnAxisLine
(
cx
,
cy
,
r
,
radian
)
{
var
dx
=
r
*
Math
.
cos
(
radian
);
var
dy
=
r
*
Math
.
sin
(
radian
);
return
[
cx
+
dx
,
cy
+
dy
];
}
function
getAxisLineShape
(
radiusAxisModel
,
cx
,
cy
)
{
var
radiusAxis
=
radiusAxisModel
.
axis
;
var
radius
=
radiusAxis
.
getExtent
();
var
axisAngle
=
radiusAxisModel
.
get
(
'
axisAngle
'
);
var
radian
=
axisAngle
/
180
*
Math
.
PI
;
var
start
=
getPointOnAxisLine
(
cx
,
cy
,
radius
[
0
],
radian
);
var
end
=
getPointOnAxisLine
(
cx
,
cy
,
radius
[
1
],
radian
);
return
{
x1
:
start
[
0
],
y1
:
start
[
1
],
x2
:
end
[
0
],
y2
:
end
[
1
]
};
}
require
(
'
../coord/polar/polarCreator
'
);
require
(
'
../echarts
'
).
extendComponentView
({
...
...
@@ -45,13 +18,12 @@ define(function(require) {
var
polarModel
=
ecModel
.
getComponent
(
'
polar
'
,
radiusAxisModel
.
get
(
'
polarIndex
'
));
var
radiusAxis
=
radiusAxisModel
.
axis
;
var
polar
=
polarModel
.
coordinateSystem
;
var
cx
=
polar
.
cx
;
var
cy
=
polar
.
cy
;
var
angleExtent
=
polar
.
getAngleAxis
().
getExtent
();
var
ticksCoords
=
radiusAxis
.
getTicksCoords
();
var
axisAngle
=
radiusAxisModel
.
get
(
'
axisAngle
'
);
var
radiusExtent
=
radiusAxis
.
getExtent
();
zrUtil
.
each
(
elementList
,
function
(
name
)
{
if
(
radiusAxisModel
.
get
(
name
+
'
.show
'
))
{
this
[
'
_
'
+
name
](
radiusAxisModel
,
ticksCoords
,
angleExtent
,
cx
,
cy
,
api
);
this
[
'
_
'
+
name
](
radiusAxisModel
,
polar
,
axisAngle
,
radiusExtent
,
ticksCoords
,
api
);
}
},
this
);
...
...
@@ -64,9 +36,16 @@ define(function(require) {
/**
* @private
*/
_axisLine
:
function
(
radiusAxisModel
,
ticksCoords
,
angleExtent
,
cx
,
cy
,
api
)
{
_axisLine
:
function
(
radiusAxisModel
,
polar
,
axisAngle
,
radiusExtent
,
ticksCoords
,
api
)
{
var
p1
=
polar
.
coordToPoint
([
radiusExtent
[
0
],
axisAngle
]);
var
p2
=
polar
.
coordToPoint
([
radiusExtent
[
1
],
axisAngle
]);
var
arc
=
new
api
.
Line
({
shape
:
getAxisLineShape
(
radiusAxisModel
,
cx
,
cy
),
shape
:
{
x1
:
p1
[
0
],
y1
:
p1
[
1
],
x2
:
p2
[
0
],
y2
:
p2
[
1
]
},
style
:
radiusAxisModel
.
getModel
(
'
axisLine.lineStyle
'
).
getLineStyle
()
});
...
...
@@ -76,12 +55,11 @@ define(function(require) {
/**
* @private
*/
_axisTick
:
function
(
radiusAxisModel
,
ticksCoords
,
angleExtent
,
cx
,
cy
,
api
)
{
_axisTick
:
function
(
radiusAxisModel
,
polar
,
axisAngle
,
radiusExtent
,
ticksCoords
,
api
)
{
var
tickModel
=
radiusAxisModel
.
getModel
(
'
axisTick
'
);
var
lineShape
=
getAxisLineShape
(
radiusAxisModel
,
cx
,
cy
);
var
start
=
[
lineShape
.
x1
,
lineShape
.
y1
];
var
end
=
[
lineShape
.
x2
,
lineShape
.
y2
];
var
start
=
polar
.
coordToPoint
([
radiusExtent
[
0
],
axisAngle
]);
var
end
=
polar
.
coordToPoint
([
radiusExtent
[
1
],
axisAngle
]);
var
len
=
vector
.
dist
(
end
,
start
);
var
direction
=
[
...
...
@@ -117,16 +95,15 @@ define(function(require) {
/**
* @private
*/
_axisLabel
:
function
(
radiusAxisModel
,
ticksCoords
,
angleExtent
,
cx
,
cy
,
api
)
{
_axisLabel
:
function
(
radiusAxisModel
,
polar
,
axisAngle
,
radiusExtent
,
ticksCoords
,
api
)
{
var
axis
=
radiusAxisModel
.
axis
;
var
labelModel
=
radiusAxisModel
.
getModel
(
'
axisLabel
'
);
var
textStyleModel
=
labelModel
.
getModel
(
'
textStyle
'
);
var
labels
=
radiusAxisModel
.
formatLabels
(
axis
.
scale
.
getTicksLabels
());
var
lineShape
=
getAxisLineShape
(
radiusAxisModel
,
cx
,
cy
);
var
start
=
[
lineShape
.
x1
,
lineShape
.
y1
];
var
end
=
[
lineShape
.
x2
,
lineShape
.
y2
];
var
start
=
polar
.
coordToPoint
([
radiusExtent
[
0
],
axisAngle
]);
var
end
=
polar
.
coordToPoint
([
radiusExtent
[
1
],
axisAngle
]);
var
len
=
vector
.
dist
(
end
,
start
);
var
direction
=
[
...
...
@@ -161,7 +138,7 @@ define(function(require) {
/**
* @private
*/
_splitLine
:
function
(
radiusAxisModel
,
ticksCoords
,
angleExtent
,
cx
,
cy
,
api
)
{
_splitLine
:
function
(
radiusAxisModel
,
polar
,
axisAngle
,
radiusExtent
,
ticksCoords
,
api
)
{
var
splitLineModel
=
radiusAxisModel
.
getModel
(
'
splitLine
'
);
var
lineStyleModel
=
splitLineModel
.
getModel
(
'
lineStyle
'
);
var
lineColors
=
lineStyleModel
.
get
(
'
color
'
);
...
...
@@ -177,8 +154,8 @@ define(function(require) {
splitLines
[
colorIndex
]
=
splitLines
[
colorIndex
]
||
[];
splitLines
[
colorIndex
].
push
(
new
api
.
Circle
({
shape
:
{
cx
:
cx
,
cy
:
cy
,
cx
:
polar
.
cx
,
cy
:
polar
.
cy
,
r
:
ticksCoords
[
i
]
},
silent
:
true
...
...
@@ -203,7 +180,7 @@ define(function(require) {
/**
* @private
*/
_splitArea
:
function
(
radiusAxisModel
,
ticksCoords
,
angleExtent
,
cx
,
cy
,
api
)
{
_splitArea
:
function
(
radiusAxisModel
,
polar
,
axisAngle
,
radiusExtent
,
ticksCoords
,
api
)
{
}
});
...
...
src/coord/Axis.js
浏览文件 @
b7d730b9
...
...
@@ -163,11 +163,13 @@ define(function (require) {
/**
* Get bands.
* If axis has ticks [1, 2, 3, 4]. Bands on the axis are
*
* If axis has labels [1, 2, 3, 4]. Bands on the axis are
* |---1---|---2---|---3---|---4---|.
*
* @return {Array}
*/
// FIXME Situation when labels is on ticks
getBands
:
function
()
{
var
extent
=
this
.
_extent
;
var
bands
=
[];
...
...
@@ -192,7 +194,8 @@ define(function (require) {
getBandWidth
:
function
()
{
var
axisExtent
=
this
.
_extent
;
var
extent
=
this
.
scale
.
getExtent
();
var
len
=
extent
[
1
]
-
extent
[
0
]
+
1
;
var
len
=
extent
[
1
]
-
extent
[
0
]
+
(
this
.
onBand
?
1
:
0
);
var
size
=
axisExtent
[
1
]
-
axisExtent
[
0
];
...
...
src/coord/polar/Polar.js
浏览文件 @
b7d730b9
...
...
@@ -60,6 +60,13 @@ define(function(require) {
&&
this
.
_angleAxis
.
contain
(
coord
[
1
]);
},
/**
* @return {module:echarts/coord/polar/AngleAxis|module:echarts/coord/polar/RadiusAxis}
*/
getAxis
:
function
(
axisType
)
{
return
this
[
'
_
'
+
axisType
+
'
Axis
'
];
},
/**
* @return {module:echarts/coord/polar/AngleAxis}
*/
...
...
@@ -94,13 +101,10 @@ define(function(require) {
* @return {Array.<number>}
*/
dataToPoint
:
function
(
data
)
{
var
radius
=
this
.
_radiusAxis
.
dataToRadius
(
data
[
0
]);
var
radian
=
this
.
_angleAxis
.
dataToAngle
(
data
[
1
])
/
180
*
Math
.
PI
;
var
x
=
Math
.
cos
(
radian
)
*
radius
+
this
.
cx
;
var
y
=
Math
.
sin
(
radian
)
*
radius
+
this
.
cy
;
return
[
x
,
y
];
return
this
.
coordToPoint
([
this
.
_radiusAxis
.
dataToRadius
(
data
[
0
]),
this
.
_angleAxis
.
dataToAngle
(
data
[
1
])
])
},
/**
...
...
@@ -110,7 +114,6 @@ define(function(require) {
*/
pointToData
:
function
(
point
)
{
var
coord
=
this
.
pointToCoord
(
point
);
return
[
this
.
_radiusAxis
.
radiusToData
(
coord
[
0
]),
this
.
_angleAxis
.
angleToData
(
coord
[
1
])
/
Math
.
PI
*
180
...
...
@@ -133,6 +136,20 @@ define(function(require) {
var
angle
=
Math
.
atan2
(
dy
,
dx
);
return
[
radius
,
angle
];
},
/**
* Convert a (radius, angle) coord to (x, y) point
* @param {Array.<number>} coord
* @return {Array.<number>}
*/
coordToPoint
:
function
(
coord
)
{
var
radius
=
coord
[
0
];
var
radian
=
coord
[
1
]
/
180
*
Math
.
PI
;
var
x
=
Math
.
cos
(
radian
)
*
radius
+
this
.
cx
;
var
y
=
Math
.
sin
(
radian
)
*
radius
+
this
.
cy
;
return
[
x
,
y
];
}
}
...
...
src/layout/barGrid.js
浏览文件 @
b7d730b9
...
...
@@ -19,7 +19,7 @@ define(function(require) {
if
(
categoryAxis
)
{
var
columnsOnAxis
=
columnsMap
[
cartesian
.
name
]
||
{
remainedWidth
:
categoryAxis
.
getBandWidth
(
true
),
remainedWidth
:
categoryAxis
.
getBandWidth
(),
autoWidthCount
:
0
,
categoryGap
:
'
20%
'
,
gap
:
'
30%
'
,
...
...
@@ -65,7 +65,7 @@ define(function(require) {
var
categoryGap
=
columnsOnAxis
.
categoryGap
;
var
barGapPercent
=
columnsOnAxis
.
gap
;
var
categoryAxis
=
columnsOnAxis
.
axis
;
var
bandWidth
=
categoryAxis
.
getBandWidth
(
true
);
var
bandWidth
=
categoryAxis
.
getBandWidth
();
if
(
typeof
categoryGap
===
'
string
'
)
{
categoryGap
=
(
parseFloat
(
categoryGap
)
/
100
)
*
bandWidth
;
}
...
...
src/scale/Interval.js
浏览文件 @
b7d730b9
...
...
@@ -224,10 +224,10 @@ define(function (require) {
var
interval
=
this
.
_interval
;
if
(
!
fixMin
)
{
extent
[
0
]
=
mathFloor
(
extent
[
0
]
/
interval
)
*
interval
;
extent
[
0
]
=
numberUtil
.
round
(
mathFloor
(
extent
[
0
]
/
interval
)
*
interval
)
;
}
if
(
!
fixMax
)
{
extent
[
1
]
=
mathCeil
(
extent
[
1
]
/
interval
)
*
interval
;
extent
[
1
]
=
numberUtil
.
round
(
mathCeil
(
extent
[
1
]
/
interval
)
*
interval
)
;
}
}
};
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录