Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
半栈学徒
incubator-echarts
提交
85559537
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,发现更多精彩内容 >>
提交
85559537
编写于
12月 23, 2015
作者:
P
pah100
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
axis method retrieval
上级
75974d6c
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
58 addition
and
97 deletion
+58
-97
src/component/axis/AxisBuilder.js
src/component/axis/AxisBuilder.js
+9
-23
src/coord/axisModelCommonMixin.js
src/coord/axisModelCommonMixin.js
+6
-25
src/coord/cartesian/axisLabelInterval.js
src/coord/cartesian/axisLabelInterval.js
+8
-36
src/scale/Time.js
src/scale/Time.js
+3
-12
src/util/number.js
src/util/number.js
+32
-1
未找到文件。
src/component/axis/AxisBuilder.js
浏览文件 @
85559537
...
...
@@ -3,9 +3,10 @@ define(function (require) {
var
zrUtil
=
require
(
'
zrender/core/util
'
);
var
graphic
=
require
(
'
../../util/graphic
'
);
var
Model
=
require
(
'
../../model/Model
'
);
var
numberUtil
=
require
(
'
../../util/number
'
);
var
remRadian
=
numberUtil
.
remRadian
;
var
isRadianAroundZero
=
numberUtil
.
isRadianAroundZero
;
var
EPSILON
=
1
e
-
4
;
var
PI2
=
Math
.
PI
*
2
;
var
PI
=
Math
.
PI
;
/**
...
...
@@ -40,8 +41,8 @@ define(function (require) {
* @param {number} [opt.labelDirection=1] 1 or -1
* @param {number} [opt.labelOffset=0] Usefull when onZero.
* @param {string} [opt.axisName] default get from axisModel.
* @param {number} [opt.lab
le
Rotation] by degree, default get from axisModel.
* @param {number} [opt.lab
le
Interval] Default label interval when label
* @param {number} [opt.lab
el
Rotation] by degree, default get from axisModel.
* @param {number} [opt.lab
el
Interval] Default label interval when label
* interval from model is null or 'auto'.
* @param {number} [opt.strokeContainThreshold] Default label interval when label
* @param {number} [opt.silent=true]
...
...
@@ -311,11 +312,11 @@ define(function (require) {
var
textAlign
;
var
textBaseline
;
if
(
isAroundZero
(
rotationDiff
))
{
// Label is parallel with axis line.
if
(
is
Radian
AroundZero
(
rotationDiff
))
{
// Label is parallel with axis line.
textBaseline
=
direction
>
0
?
'
top
'
:
'
bottom
'
;
textAlign
=
'
center
'
;
}
else
if
(
isAroundZero
(
rotationDiff
-
PI
))
{
// Label is inverse parallel with axis line.
else
if
(
is
Radian
AroundZero
(
rotationDiff
-
PI
))
{
// Label is inverse parallel with axis line.
textBaseline
=
direction
>
0
?
'
bottom
'
:
'
top
'
;
textAlign
=
'
center
'
;
}
...
...
@@ -348,11 +349,11 @@ define(function (require) {
var
onLeft
=
(
textPosition
===
'
start
'
&&
!
inverse
)
||
(
textPosition
!==
'
start
'
&&
inverse
);
if
(
isAroundZero
(
rotationDiff
-
PI
/
2
))
{
if
(
is
Radian
AroundZero
(
rotationDiff
-
PI
/
2
))
{
textBaseline
=
onLeft
?
'
bottom
'
:
'
top
'
;
textAlign
=
'
center
'
;
}
else
if
(
isAroundZero
(
rotationDiff
-
PI
*
1.5
))
{
else
if
(
is
Radian
AroundZero
(
rotationDiff
-
PI
*
1.5
))
{
textBaseline
=
onLeft
?
'
top
'
:
'
bottom
'
;
textAlign
=
'
center
'
;
}
...
...
@@ -394,21 +395,6 @@ define(function (require) {
return
interval
;
};
/**
* @inner
*/
function
isAroundZero
(
val
)
{
return
val
>
-
EPSILON
&&
val
<
EPSILON
;
}
/**
* @inner
*/
function
remRadian
(
radian
)
{
// To 0 - 2 * PI, considering negative radian.
return
(
radian
%
PI2
+
PI2
)
%
PI2
;
}
return
AxisBuilder
;
});
\ No newline at end of file
src/coord/axisModelCommonMixin.js
浏览文件 @
85559537
define
(
function
(
require
)
{
var
zrUtil
=
require
(
'
zrender/core/util
'
);
var
axisHelper
=
require
(
'
./axisHelper
'
);
function
getName
(
obj
)
{
if
(
zrUtil
.
isObject
(
obj
)
&&
obj
.
value
!=
null
)
{
...
...
@@ -22,31 +23,11 @@ define(function (require) {
* Format labels
* @return {Array.<string>}
*/
function
getFormattedLabels
()
{
var
labelFormatter
=
this
.
get
(
'
axisLabel.formatter
'
);
var
axis
=
this
.
axis
;
var
scale
=
axis
.
scale
;
var
labels
=
scale
.
getTicksLabels
();
var
ticks
=
scale
.
getTicks
();
if
(
typeof
labelFormatter
===
'
string
'
)
{
labelFormatter
=
(
function
(
tpl
)
{
return
function
(
val
)
{
return
tpl
.
replace
(
'
{value}
'
,
val
);
};
})(
labelFormatter
);
return
zrUtil
.
map
(
labels
,
labelFormatter
);
}
else
if
(
typeof
labelFormatter
===
'
function
'
)
{
return
zrUtil
.
map
(
ticks
,
function
(
tick
,
idx
)
{
return
labelFormatter
(
axis
.
type
===
'
category
'
?
scale
.
getLabel
(
tick
)
:
tick
,
idx
);
},
this
);
}
else
{
return
labels
;
}
function
getFormattedLabels
()
{
return
axisHelper
.
getFormattedLabels
(
this
.
axis
,
this
.
get
(
'
axisLabel.formatter
'
)
);
}
return
{
...
...
src/coord/cartesian/axisLabelInterval.js
浏览文件 @
85559537
...
...
@@ -5,7 +5,8 @@
define
(
function
(
require
)
{
'
use strict
'
;
var
textContain
=
require
(
'
zrender/contain/text
'
);
var
zrUtil
=
require
(
'
zrender/core/util
'
);
var
axisHelper
=
require
(
'
../axisHelper
'
);
return
function
(
axis
)
{
var
axisModel
=
axis
.
model
;
...
...
@@ -19,40 +20,11 @@ define(function(require) {
return
labelInterval
===
'
auto
'
?
0
:
labelInterval
;
}
var
ticks
=
axis
.
scale
.
getTicks
();
var
labels
=
axisModel
.
getFormattedLabels
();
var
font
=
labelModel
.
getModel
(
'
textStyle
'
).
getFont
();
var
textSpaceTakenRect
;
var
autoLabelInterval
=
0
;
var
accumulatedLabelInterval
=
0
;
var
isAxisHorizontal
=
axis
.
isHorizontal
();
for
(
var
i
=
0
;
i
<
ticks
.
length
;
i
++
)
{
var
tick
=
ticks
[
i
];
var
tickCoord
=
axis
.
dataToCoord
(
tick
);
var
rect
=
textContain
.
getBoundingRect
(
labels
[
i
],
font
,
'
center
'
,
'
top
'
);
rect
[
isAxisHorizontal
?
'
x
'
:
'
y
'
]
+=
tickCoord
;
rect
[
isAxisHorizontal
?
'
width
'
:
'
height
'
]
*=
1.5
;
if
(
!
textSpaceTakenRect
)
{
textSpaceTakenRect
=
rect
.
clone
();
}
// There is no space for current label;
else
if
(
textSpaceTakenRect
.
intersect
(
rect
))
{
accumulatedLabelInterval
++
;
autoLabelInterval
=
Math
.
max
(
autoLabelInterval
,
accumulatedLabelInterval
);
}
else
{
textSpaceTakenRect
.
union
(
rect
);
// Reset
accumulatedLabelInterval
=
0
;
}
}
return
autoLabelInterval
;
return
axisHelper
.
getAxisLabelInterval
(
zrUtil
.
map
(
axis
.
scale
.
getTicks
(),
axis
.
dataToCoord
,
axis
),
axisModel
.
getFormattedLabels
(),
labelModel
.
getModel
(
'
textStyle
'
).
getFont
(),
axis
.
isHorizontal
()
);
};
});
\ No newline at end of file
src/scale/Time.js
浏览文件 @
85559537
...
...
@@ -6,6 +6,7 @@
define
(
function
(
require
)
{
var
zrUtil
=
require
(
'
zrender/core/util
'
);
var
numberUtil
=
require
(
'
../util/number
'
);
var
IntervalScale
=
require
(
'
./Interval
'
);
...
...
@@ -28,16 +29,6 @@ define(function (require) {
return
lo
;
};
/**
* @param {string|Date|number} value
* @inner
*/
var
parseDate
=
function
(
value
)
{
return
value
instanceof
Date
?
value
:
new
Date
(
typeof
value
==
'
string
'
?
value
.
replace
(
/-/g
,
'
/
'
)
:
value
);
};
/**
* @param {string} str
* @return {string}
...
...
@@ -63,7 +54,7 @@ define(function (require) {
tpl
=
'
MM-dd
\n
yyyy
'
;
}
var
date
=
parseDate
(
value
);
var
date
=
numberUtil
.
parseDate
(
value
);
var
y
=
date
.
getFullYear
();
var
M
=
date
.
getMonth
()
+
1
;
var
d
=
date
.
getDate
();
...
...
@@ -129,7 +120,7 @@ define(function (require) {
zrUtil
.
each
([
'
contain
'
,
'
normalize
'
],
function
(
methodName
)
{
TimeScale
.
prototype
[
methodName
]
=
function
(
val
)
{
val
=
+
parseDate
(
val
);
val
=
+
numberUtil
.
parseDate
(
val
);
return
intervalScaleProto
[
methodName
].
call
(
this
,
val
);
};
});
...
...
src/util/number.js
浏览文件 @
85559537
...
...
@@ -8,8 +8,11 @@ define(function (require) {
var
zrUtil
=
require
(
'
zrender/core/util
'
);
var
number
=
{};
var
RADIAN_EPSILON
=
1
e
-
4
;
function
_trim
(
str
)
{
return
str
.
replace
(
/^
\s
+/
,
''
).
replace
(
/
\s
+$/
,
''
);
}
return
str
.
replace
(
/^
\s
+/
,
''
).
replace
(
/
\s
+$/
,
''
);
}
/**
* Linear mapping a value from domain to range
...
...
@@ -114,5 +117,33 @@ define(function (require) {
// Number.MAX_SAFE_INTEGER, ie do not support.
number
.
MAX_SAFE_INTEGER
=
9007199254740991
;
/**
* To 0 - 2 * PI, considering negative radian.
* @param {number} radian
* @return {number}
*/
number
.
remRadian
=
function
(
radian
)
{
var
pi2
=
Math
.
PI
*
2
;
return
(
radian
%
pi2
+
pi2
)
%
pi2
;
};
/**
* @param {type} radian
* @return {boolean}
*/
number
.
isRadianAroundZero
=
function
(
val
)
{
return
val
>
-
RADIAN_EPSILON
&&
val
<
RADIAN_EPSILON
;
};
/**
* @param {string|Date|number} value
* @return {number} timestamp
*/
number
.
parseDate
=
function
(
value
)
{
return
value
instanceof
Date
?
value
:
new
Date
(
typeof
value
===
'
string
'
?
value
.
replace
(
/-/g
,
'
/
'
)
:
value
);
};
return
number
;
});
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录