Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
x649585723
incubator-echarts
提交
fdecbddc
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,体验更适合开发者的 AI 搜索 >>
提交
fdecbddc
编写于
6月 24, 2014
作者:
E
erik
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
little optimize
上级
f92127bc
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
112 addition
and
113 deletion
+112
-113
src/util/accMath.js
src/util/accMath.js
+22
-28
src/util/ecAnimation.js
src/util/ecAnimation.js
+73
-47
src/util/ecData.js
src/util/ecData.js
+6
-30
src/util/ecQuery.js
src/util/ecQuery.js
+7
-6
src/util/kwargs.js
src/util/kwargs.js
+4
-2
未找到文件。
src/util/accMath.js
浏览文件 @
fdecbddc
...
...
@@ -2,18 +2,18 @@
* 高精度数学运算
*/
define
(
function
()
{
//除法函数,用来得到精确的除法结果
//说明:javascript的除法结果会有误差,在两个浮点数相除的时候会比较明显。这个函数返回较为精确的除法结果。
//调用:accDiv(arg1,arg2)
//返回值:arg1除以arg2的精确结果
//
除法函数,用来得到精确的除法结果
//
说明:javascript的除法结果会有误差,在两个浮点数相除的时候会比较明显。这个函数返回较为精确的除法结果。
//
调用:accDiv(arg1,arg2)
//
返回值:arg1除以arg2的精确结果
function
accDiv
(
arg1
,
arg2
)
{
return
accMul
(
arg1
,
1
/
arg2
);
return
accMul
(
arg1
,
1
/
arg2
);
}
//乘法函数,用来得到精确的乘法结果
//说明:javascript的乘法结果会有误差,在两个浮点数相乘的时候会比较明显。这个函数返回较为精确的乘法结果。
//调用:accMul(arg1,arg2)
//返回值:arg1乘以arg2的精确结果
//
乘法函数,用来得到精确的乘法结果
//
说明:javascript的乘法结果会有误差,在两个浮点数相乘的时候会比较明显。这个函数返回较为精确的乘法结果。
//
调用:accMul(arg1,arg2)
//
返回值:arg1乘以arg2的精确结果
function
accMul
(
arg1
,
arg2
)
{
var
m
=
0
;
var
s1
=
arg1
.
toString
();
...
...
@@ -28,34 +28,28 @@ define(function() {
}
catch
(
e
){}
return
Number
(
s1
.
replace
(
'
.
'
,
''
))
*
Number
(
s2
.
replace
(
'
.
'
,
''
))
/
Math
.
pow
(
10
,
m
);
return
(
s1
.
replace
(
'
.
'
,
''
)
-
0
)
*
(
s2
.
replace
(
'
.
'
,
''
)
-
0
)
/
Math
.
pow
(
10
,
m
);
}
//加法函数,用来得到精确的加法结果
//说明:javascript的加法结果会有误差,在两个浮点数相加的时候会比较明显。这个函数返回较为精确的加法结果。
//调用:accAdd(arg1,arg2)
//返回值:arg1加上arg2的精确结果
function
accAdd
(
arg1
,
arg2
)
{
var
r1
;
var
r2
;
var
m
;
//
加法函数,用来得到精确的加法结果
//
说明:javascript的加法结果会有误差,在两个浮点数相加的时候会比较明显。这个函数返回较为精确的加法结果。
//
调用:accAdd(arg1,arg2)
//
返回值:arg1加上arg2的精确结果
function
accAdd
(
arg1
,
arg2
)
{
var
r1
=
0
;
var
r2
=
0
;
try
{
r1
=
arg1
.
toString
().
split
(
'
.
'
)[
1
].
length
;
}
catch
(
e
)
{
r1
=
0
;
}
catch
(
e
)
{}
try
{
r2
=
arg2
.
toString
().
split
(
'
.
'
)[
1
].
length
;
}
catch
(
e
)
{
r2
=
0
;
r2
=
arg2
.
toString
().
split
(
'
.
'
)[
1
].
length
;
}
catch
(
e
)
{}
m
=
Math
.
pow
(
10
,
Math
.
max
(
r1
,
r2
));
var
m
=
Math
.
pow
(
10
,
Math
.
max
(
r1
,
r2
));
return
(
Math
.
round
(
arg1
*
m
)
+
Math
.
round
(
arg2
*
m
))
/
m
;
}
...
...
src/util/ecAnimation.js
浏览文件 @
fdecbddc
...
...
@@ -18,45 +18,46 @@ define(function (require) {
* @param {tring} easing
*/
function
pointList
(
zr
,
oldShape
,
newShape
,
duration
,
easing
)
{
var
newPointList
;
var
newPointList
=
newShape
.
style
.
pointList
;
var
newPointListLen
=
newPointList
.
length
;
var
oldPointList
;
if
(
!
oldShape
)
{
// add
newPointList
=
[];
var
len
=
newShape
.
style
.
pointList
.
length
;
oldPointList
=
[];
if
(
newShape
.
_orient
!=
'
vertical
'
)
{
var
y
=
new
Shape
.
style
.
p
ointList
[
0
][
1
];
for
(
var
i
=
0
;
i
<
l
en
;
i
++
)
{
newPointList
[
i
]
=
[
newShape
.
style
.
p
ointList
[
i
][
0
],
y
];
var
y
=
new
P
ointList
[
0
][
1
];
for
(
var
i
=
0
;
i
<
newPointListL
en
;
i
++
)
{
oldPointList
[
i
]
=
[
newP
ointList
[
i
][
0
],
y
];
}
}
else
{
var
x
=
new
Shape
.
style
.
p
ointList
[
0
][
0
];
for
(
var
i
=
0
;
i
<
l
en
;
i
++
)
{
newPointList
[
i
]
=
[
x
,
newShape
.
style
.
p
ointList
[
i
][
1
]];
var
x
=
new
P
ointList
[
0
][
0
];
for
(
var
i
=
0
;
i
<
newPointListL
en
;
i
++
)
{
oldPointList
[
i
]
=
[
x
,
newP
ointList
[
i
][
1
]];
}
}
if
(
newShape
.
type
==
'
half-smooth-polygon
'
)
{
newPointList
[
len
-
1
]
=
zrUtil
.
clone
(
newShape
.
style
.
pointList
[
l
en
-
1
]);
newPointList
[
len
-
2
]
=
zrUtil
.
clone
(
newShape
.
style
.
pointList
[
l
en
-
2
]);
oldPointList
[
newPointListLen
-
1
]
=
zrUtil
.
clone
(
newPointList
[
newPointListL
en
-
1
]);
oldPointList
[
newPointListLen
-
2
]
=
zrUtil
.
clone
(
newPointList
[
newPointListL
en
-
2
]);
}
oldShape
=
{
style
:
{
pointList
:
new
PointList
}};
oldShape
=
{
style
:
{
pointList
:
old
PointList
}};
}
newPointList
=
newShape
.
style
.
pointList
;
if
(
oldShape
.
style
.
pointList
.
length
==
newPointList
.
length
)
{
newShape
.
style
.
pointList
=
oldShape
.
style
.
pointList
;
oldPointList
=
oldShape
.
style
.
pointList
;
var
oldPointListLen
=
oldPointList
.
length
;
if
(
oldPointListLen
==
newPointListLen
)
{
newShape
.
style
.
pointList
=
oldPointList
;
}
else
if
(
old
Shape
.
style
.
pointList
.
length
<
newPointList
.
length
)
{
else
if
(
old
PointListLen
<
newPointListLen
)
{
// 原来短,新的长,补全
newShape
.
style
.
pointList
=
oldShape
.
style
.
pointList
.
concat
(
newPointList
.
slice
(
oldShape
.
style
.
pointList
.
length
)
);
newShape
.
style
.
pointList
=
oldPointList
.
concat
(
newPointList
.
slice
(
oldPointListLen
));
}
else
{
// 原来长,新的短,截断
newShape
.
style
.
pointList
=
oldShape
.
style
.
pointList
.
slice
(
0
,
newPointList
.
length
);
newShape
.
style
.
pointList
=
oldPointList
.
slice
(
0
,
newPointListLen
);
}
zr
.
addShape
(
newShape
);
zr
.
animate
(
newShape
.
id
,
'
style
'
)
.
when
(
...
...
@@ -66,6 +67,22 @@ define(function (require) {
.
start
(
easing
);
}
/**
* 复制样式
*
* @inner
* @param {Object} target 目标对象
* @param {Object} source 源对象
* @param {...string} props 复制的属性列表
*/
function
cloneStyle
(
target
,
source
)
{
var
len
=
arguments
.
length
;
for
(
var
i
=
2
;
i
<
len
;
i
++
)
{
var
prop
=
arguments
[
i
];
target
.
style
[
prop
]
=
source
.
style
[
prop
];
}
}
/**
* 方型动画
*
...
...
@@ -76,29 +93,31 @@ define(function (require) {
* @param {tring} easing
*/
function
rectangle
(
zr
,
oldShape
,
newShape
,
duration
,
easing
)
{
var
newShapeStyle
=
newShape
.
style
;
if
(
!
oldShape
)
{
// add
oldShape
=
{
style
:
{
x
:
newShape
.
s
tyle
.
x
,
x
:
newShape
S
tyle
.
x
,
y
:
newShape
.
_orient
==
'
vertical
'
?
newShape
.
style
.
y
+
newShape
.
s
tyle
.
height
:
newShape
.
s
tyle
.
y
,
?
newShape
Style
.
y
+
newShapeS
tyle
.
height
:
newShape
S
tyle
.
y
,
width
:
newShape
.
_orient
==
'
vertical
'
?
newShape
.
s
tyle
.
width
:
0
,
?
newShape
S
tyle
.
width
:
0
,
height
:
newShape
.
_orient
!=
'
vertical
'
?
newShape
.
s
tyle
.
height
:
0
?
newShape
S
tyle
.
height
:
0
}
};
}
var
newX
=
newShape
.
style
.
x
;
var
newY
=
newShape
.
style
.
y
;
var
newWidth
=
newShape
.
style
.
width
;
var
newHeight
=
newShape
.
style
.
height
;
newShape
.
style
.
x
=
oldShape
.
style
.
x
;
newShape
.
style
.
y
=
oldShape
.
style
.
y
;
newShape
.
style
.
width
=
oldShape
.
style
.
width
;
newShape
.
style
.
height
=
oldShape
.
style
.
height
;
var
newX
=
newShapeStyle
.
x
;
var
newY
=
newShapeStyle
.
y
;
var
newWidth
=
newShapeStyle
.
width
;
var
newHeight
=
newShapeStyle
.
height
;
cloneStyle
(
newShape
,
oldShape
,
'
x
'
,
'
y
'
,
'
width
'
,
'
height
'
);
zr
.
addShape
(
newShape
);
zr
.
animate
(
newShape
.
id
,
'
style
'
)
.
when
(
...
...
@@ -218,8 +237,10 @@ define(function (require) {
var
startAngle
=
newShape
.
style
.
startAngle
;
var
endAngle
=
newShape
.
style
.
endAngle
;
newShape
.
style
.
startAngle
=
oldShape
.
style
.
startAngle
;
newShape
.
style
.
endAngle
=
oldShape
.
style
.
endAngle
;
cloneStyle
(
newShape
,
oldShape
,
'
startAngle
'
,
'
endAngle
'
);
zr
.
addShape
(
newShape
);
zr
.
animate
(
newShape
.
id
,
'
style
'
)
...
...
@@ -257,8 +278,10 @@ define(function (require) {
var
x
=
newShape
.
style
.
x
;
var
y
=
newShape
.
style
.
y
;
newShape
.
style
.
x
=
oldShape
.
style
.
x
;
newShape
.
style
.
y
=
oldShape
.
style
.
y
;
cloneStyle
(
newShape
,
oldShape
,
'
x
'
,
'
y
'
);
zr
.
addShape
(
newShape
);
zr
.
animate
(
newShape
.
id
,
'
style
'
)
...
...
@@ -325,10 +348,10 @@ define(function (require) {
var
target1
=
newShape
.
style
.
target1
;
if
(
oldShape
.
style
)
{
newShape
.
style
.
source0
=
oldShape
.
style
.
source0
;
newShape
.
style
.
source1
=
oldShape
.
style
.
source1
;
newShape
.
style
.
target0
=
oldShape
.
style
.
target0
;
newShape
.
style
.
target1
=
oldShape
.
style
.
target1
;
cloneStyle
(
newShape
,
oldShape
,
'
source0
'
,
'
source1
'
,
'
target0
'
,
'
target1
'
)
;
}
zr
.
addShape
(
newShape
);
...
...
@@ -391,6 +414,7 @@ define(function (require) {
newShape
.
style
.
_y
=
newShape
.
style
.
y
;
newShape
.
style
.
_width
=
newShape
.
style
.
width
;
newShape
.
style
.
_height
=
newShape
.
style
.
height
;
if
(
!
oldShape
)
{
// add
var
x
=
newShape
.
_x
||
0
;
var
y
=
newShape
.
_y
||
0
;
...
...
@@ -431,10 +455,12 @@ define(function (require) {
var
xEnd
=
newShape
.
style
.
xEnd
;
var
yStart
=
newShape
.
style
.
yStart
;
var
yEnd
=
newShape
.
style
.
yEnd
;
newShape
.
style
.
xStart
=
oldShape
.
style
.
xStart
;
newShape
.
style
.
xEnd
=
oldShape
.
style
.
xEnd
;
newShape
.
style
.
yStart
=
oldShape
.
style
.
yStart
;
newShape
.
style
.
yEnd
=
oldShape
.
style
.
yEnd
;
cloneStyle
(
newShape
,
oldShape
,
'
xStart
'
,
'
xEnd
'
,
'
yStart
'
,
'
yEnd
'
);
zr
.
addShape
(
newShape
);
zr
.
animate
(
newShape
.
id
,
'
style
'
)
.
when
(
...
...
src/util/ecData.js
浏览文件 @
fdecbddc
...
...
@@ -22,15 +22,12 @@ define(function() {
)
{
var
value
;
if
(
typeof
data
!=
'
undefined
'
)
{
if
(
typeof
data
.
value
!=
'
undefined
'
)
{
value
=
data
.
value
;
}
else
{
value
=
data
;
}
value
=
data
.
value
==
null
?
data
:
data
.
value
;
}
shape
.
_echartsData
=
{
shape
.
_echartsData
=
{
'
_series
'
:
series
,
'
_seriesIndex
'
:
seriesIndex
,
'
_data
'
:
data
,
...
...
@@ -56,21 +53,14 @@ define(function() {
switch
(
key
)
{
case
'
series
'
:
return
data
&&
data
.
_series
;
case
'
seriesIndex
'
:
return
data
&&
data
.
_seriesIndex
;
case
'
data
'
:
return
data
&&
data
.
_data
;
case
'
dataIndex
'
:
return
data
&&
data
.
_dataIndex
;
case
'
name
'
:
return
data
&&
data
.
_name
;
case
'
value
'
:
return
data
&&
data
.
_value
;
case
'
special
'
:
return
data
&&
data
.
_special
;
case
'
special2
'
:
return
data
&&
data
.
_special2
;
return
data
&&
data
[
'
_
'
+
key
]
;
}
return
null
;
...
...
@@ -86,28 +76,14 @@ define(function() {
shape
.
_echartsData
=
shape
.
_echartsData
||
{};
switch
(
key
)
{
case
'
series
'
:
// 当前系列值
shape
.
_echartsData
.
_series
=
value
;
break
;
case
'
seriesIndex
'
:
// 系列数组位置索引
shape
.
_echartsData
.
_seriesIndex
=
value
;
break
;
case
'
data
'
:
// 当前数据值
shape
.
_echartsData
.
_data
=
value
;
break
;
case
'
dataIndex
'
:
// 数据数组位置索引
shape
.
_echartsData
.
_dataIndex
=
value
;
break
;
case
'
name
'
:
shape
.
_echartsData
.
_name
=
value
;
break
;
case
'
value
'
:
shape
.
_echartsData
.
_value
=
value
;
break
;
case
'
special
'
:
shape
.
_echartsData
.
_special
=
value
;
break
;
case
'
special2
'
:
shape
.
_echartsData
.
_special2
=
value
;
shape
.
_echartsData
[
'
_
'
+
key
]
=
value
;
break
;
}
}
...
...
src/util/ecQuery.js
浏览文件 @
fdecbddc
...
...
@@ -14,22 +14,24 @@ define(function() {
*/
function
query
(
optionTarget
,
optionLocation
)
{
if
(
typeof
optionTarget
==
'
undefined
'
)
{
return
undefined
;
return
;
}
if
(
!
optionLocation
)
{
return
optionTarget
;
}
optionLocation
=
optionLocation
.
split
(
'
.
'
);
optionLocation
=
optionLocation
.
split
(
'
.
'
);
var
length
=
optionLocation
.
length
;
var
curIdx
=
0
;
while
(
curIdx
<
length
)
{
optionTarget
=
optionTarget
[
optionLocation
[
curIdx
]];
if
(
typeof
optionTarget
==
'
undefined
'
)
{
return
undefined
;
return
;
}
curIdx
++
;
}
return
optionTarget
;
}
...
...
@@ -45,7 +47,6 @@ define(function() {
return
finalOption
;
}
}
return
undefined
;
}
/**
...
...
@@ -54,10 +55,9 @@ define(function() {
*/
function
deepMerge
(
ctrList
,
optionLocation
)
{
var
finalOption
;
var
tempOption
;
var
len
=
ctrList
.
length
;
while
(
len
--
)
{
tempOption
=
query
(
ctrList
[
len
],
optionLocation
);
var
tempOption
=
query
(
ctrList
[
len
],
optionLocation
);
if
(
typeof
tempOption
!=
'
undefined
'
)
{
if
(
typeof
finalOption
==
'
undefined
'
)
{
finalOption
=
zrUtil
.
clone
(
tempOption
);
...
...
@@ -69,6 +69,7 @@ define(function() {
}
}
}
return
finalOption
;
}
...
...
src/util/kwargs.js
浏览文件 @
fdecbddc
...
...
@@ -23,7 +23,8 @@ define(function (){
// Check the existance of the kwargs
if
(
kwargs
&&
kwargs
.
constructor
===
Object
)
{
args
.
pop
();
}
else
{
}
else
{
kwargs
=
{};
}
...
...
@@ -32,7 +33,8 @@ define(function (){
var
name
=
names
[
i
];
if
(
name
in
kwargs
)
{
args
[
i
]
=
kwargs
[
name
];
}
else
if
(
name
in
defaults
&&
args
[
i
]
===
undefined
){
}
else
if
(
name
in
defaults
&&
args
[
i
]
==
null
){
args
[
i
]
=
defaults
[
name
];
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录