Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
x649585723
incubator-echarts
提交
4492edc4
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,发现更多精彩内容 >>
提交
4492edc4
编写于
2月 28, 2017
作者:
L
lang
浏览文件
操作
浏览文件
下载
差异文件
Merge remote-tracking branch 'origin/master'
上级
7e7a775f
0b10a15a
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
135 addition
and
22 deletion
+135
-22
src/component/axis/AxisBuilder.js
src/component/axis/AxisBuilder.js
+13
-3
src/coord/axisHelper.js
src/coord/axisHelper.js
+5
-2
src/layout/points.js
src/layout/points.js
+5
-1
src/util/format.js
src/util/format.js
+14
-7
src/util/model.js
src/util/model.js
+6
-1
src/util/number.js
src/util/number.js
+40
-7
test/ut/spec/util/number.js
test/ut/spec/util/number.js
+52
-1
未找到文件。
src/component/axis/AxisBuilder.js
浏览文件 @
4492edc4
...
@@ -284,7 +284,7 @@ define(function (require) {
...
@@ -284,7 +284,7 @@ define(function (require) {
tickCoord
,
tickCoord
,
opt
.
labelOffset
+
opt
.
labelDirection
*
labelMargin
opt
.
labelOffset
+
opt
.
labelDirection
*
labelMargin
];
];
var
label
BeforeFormat
=
axis
.
scale
.
getLabel
(
tickVal
);
var
label
Str
=
axis
.
scale
.
getLabel
(
tickVal
);
var
textEl
=
new
graphic
.
Text
({
var
textEl
=
new
graphic
.
Text
({
...
@@ -296,7 +296,17 @@ define(function (require) {
...
@@ -296,7 +296,17 @@ define(function (require) {
textAlign
:
itemTextStyleModel
.
get
(
'
align
'
,
true
)
||
labelLayout
.
textAlign
,
textAlign
:
itemTextStyleModel
.
get
(
'
align
'
,
true
)
||
labelLayout
.
textAlign
,
textVerticalAlign
:
itemTextStyleModel
.
get
(
'
baseline
'
,
true
)
||
labelLayout
.
verticalAlign
,
textVerticalAlign
:
itemTextStyleModel
.
get
(
'
baseline
'
,
true
)
||
labelLayout
.
verticalAlign
,
textFont
:
itemTextStyleModel
.
getFont
(),
textFont
:
itemTextStyleModel
.
getFont
(),
fill
:
typeof
textColor
===
'
function
'
?
textColor
(
labelBeforeFormat
)
:
textColor
fill
:
typeof
textColor
===
'
function
'
?
textColor
(
// Compatible with previous version, which always returns labelStr.
// But in interval scale labelStr is like '223,445', which maked
// user repalce ','. So we modify it to return original val but remain
// it as 'string' to avoid error in replacing.
axis
.
type
===
'
category
'
?
labelStr
:
axis
.
type
===
'
value
'
?
tickVal
+
''
:
tickVal
,
index
,
{
value
:
tickVal
,
index
:
index
,
label
:
labelStr
}
)
:
textColor
},
},
position
:
pos
,
position
:
pos
,
rotation
:
labelLayout
.
rotation
,
rotation
:
labelLayout
.
rotation
,
...
@@ -308,7 +318,7 @@ define(function (require) {
...
@@ -308,7 +318,7 @@ define(function (require) {
if
(
triggerEvent
)
{
if
(
triggerEvent
)
{
textEl
.
eventData
=
makeAxisEventDataBase
(
axisModel
);
textEl
.
eventData
=
makeAxisEventDataBase
(
axisModel
);
textEl
.
eventData
.
targetType
=
'
axisLabel
'
;
textEl
.
eventData
.
targetType
=
'
axisLabel
'
;
textEl
.
eventData
.
value
=
label
BeforeFormat
;
textEl
.
eventData
.
value
=
label
Str
;
}
}
// FIXME
// FIXME
...
...
src/coord/axisHelper.js
浏览文件 @
4492edc4
...
@@ -228,9 +228,12 @@ define(function (require) {
...
@@ -228,9 +228,12 @@ define(function (require) {
}
}
else
if
(
typeof
labelFormatter
===
'
function
'
)
{
else
if
(
typeof
labelFormatter
===
'
function
'
)
{
return
zrUtil
.
map
(
ticks
,
function
(
tick
,
idx
)
{
return
zrUtil
.
map
(
ticks
,
function
(
tick
,
idx
)
{
var
labelStr
=
scale
.
getLabel
(
tick
);
return
labelFormatter
(
return
labelFormatter
(
axis
.
type
===
'
category
'
?
scale
.
getLabel
(
tick
)
:
tick
,
// Have to be compatible with previous version.
idx
axis
.
type
===
'
category
'
?
labelStr
:
tick
,
idx
,
{
value
:
tick
,
index
:
idx
,
label
:
labelStr
}
);
);
},
this
);
},
this
);
}
}
...
...
src/layout/points.js
浏览文件 @
4492edc4
define
(
function
(
require
)
{
define
(
function
(
require
)
{
var
zrUtil
=
require
(
'
zrender/core/util
'
);
return
function
(
seriesType
,
ecModel
)
{
return
function
(
seriesType
,
ecModel
)
{
ecModel
.
eachSeriesByType
(
seriesType
,
function
(
seriesModel
)
{
ecModel
.
eachSeriesByType
(
seriesType
,
function
(
seriesModel
)
{
var
data
=
seriesModel
.
getData
();
var
data
=
seriesModel
.
getData
();
var
coordSys
=
seriesModel
.
coordinateSystem
;
var
coordSys
=
seriesModel
.
coordinateSystem
;
if
(
coordSys
)
{
if
(
coordSys
)
{
var
dims
=
coordSys
.
dimensions
;
var
dims
=
zrUtil
.
map
(
coordSys
.
dimensions
,
function
(
dimItem
)
{
return
zrUtil
.
isObject
(
dimItem
)
?
dimItem
.
name
:
dimItem
;
});
if
(
dims
.
length
===
1
)
{
if
(
dims
.
length
===
1
)
{
data
.
each
(
dims
[
0
],
function
(
x
,
idx
)
{
data
.
each
(
dims
[
0
],
function
(
x
,
idx
)
{
...
...
src/util/format.js
浏览文件 @
4492edc4
...
@@ -123,9 +123,15 @@ define(function (require) {
...
@@ -123,9 +123,15 @@ define(function (require) {
* ISO Date format
* ISO Date format
* @param {string} tpl
* @param {string} tpl
* @param {number} value
* @param {number} value
* @param {boolean} [isLocal=false] Default use UTC
* Why default UTC? In most case, time provided by user is
* understood in UTC. For example, new Date('2012-01-01')
* or a string '2012-01-01' or a timestamp. So it is
* recommended to format time in UTC.
* (see `echarts/util/number.js#parseDate`);
* @inner
* @inner
*/
*/
formatUtil
.
formatTime
=
function
(
tpl
,
value
)
{
formatUtil
.
formatTime
=
function
(
tpl
,
value
,
isLocal
)
{
if
(
tpl
===
'
week
'
if
(
tpl
===
'
week
'
||
tpl
===
'
month
'
||
tpl
===
'
month
'
||
tpl
===
'
quarter
'
||
tpl
===
'
quarter
'
...
@@ -136,12 +142,13 @@ define(function (require) {
...
@@ -136,12 +142,13 @@ define(function (require) {
}
}
var
date
=
numberUtil
.
parseDate
(
value
);
var
date
=
numberUtil
.
parseDate
(
value
);
var
y
=
date
.
getFullYear
();
var
utc
=
isLocal
?
''
:
'
UTC
'
;
var
M
=
date
.
getMonth
()
+
1
;
var
y
=
date
[
'
get
'
+
utc
+
'
FullYear
'
]();
var
d
=
date
.
getDate
();
var
M
=
date
[
'
get
'
+
utc
+
'
Month
'
]()
+
1
;
var
h
=
date
.
getHours
();
var
d
=
date
[
'
get
'
+
utc
+
'
Date
'
]();
var
m
=
date
.
getMinutes
();
var
h
=
date
[
'
get
'
+
utc
+
'
Hours
'
]();
var
s
=
date
.
getSeconds
();
var
m
=
date
[
'
get
'
+
utc
+
'
Minutes
'
]();
var
s
=
date
[
'
get
'
+
utc
+
'
Seconds
'
]();
tpl
=
tpl
.
replace
(
'
MM
'
,
s2d
(
M
))
tpl
=
tpl
.
replace
(
'
MM
'
,
s2d
(
M
))
.
toLowerCase
()
.
toLowerCase
()
...
...
src/util/model.js
浏览文件 @
4492edc4
...
@@ -92,7 +92,12 @@ define(function(require) {
...
@@ -92,7 +92,12 @@ define(function(require) {
return
value
;
return
value
;
}
}
if
(
dimType
===
'
time
'
&&
!
isFinite
(
value
)
&&
value
!=
null
&&
value
!==
'
-
'
)
{
if
(
dimType
===
'
time
'
// spead up when using timestamp
&&
typeof
value
!==
'
number
'
&&
value
!=
null
&&
value
!==
'
-
'
)
{
value
=
+
nubmerUtil
.
parseDate
(
value
);
value
=
+
nubmerUtil
.
parseDate
(
value
);
}
}
...
...
src/util/number.js
浏览文件 @
4492edc4
...
@@ -190,8 +190,22 @@ define(function (require) {
...
@@ -190,8 +190,22 @@ define(function (require) {
return
val
>
-
RADIAN_EPSILON
&&
val
<
RADIAN_EPSILON
;
return
val
>
-
RADIAN_EPSILON
&&
val
<
RADIAN_EPSILON
;
};
};
var
TIME_REG
=
/^
(?:(\d{4})(?:[
-
\/](\d{1,2})(?:[
-
\/](\d{1,2})(?:[
T
](\d{1,2})(?:
:
(\d\d)(?:
:
(\d\d)(?:[
.,
](\d
+
))?)?)?(?:
Z|
([\+\-]\d\d)
:
?\d\d)?)?)?)?)?
$/
;
// jshint ignore:line
var
TIMEZONE_OFFSET
=
(
new
Date
()).
getTimezoneOffset
();
/**
/**
* @param {string|Date|number} value
* @param {string|Date|number} value These values can be accepted:
* + An instance of Date, represent a time in its own time zone.
* + Or string in a subset of ISO 8601, only including:
* + only year, month, date: '2012-03', '2012-03-01', '2012-03-01 05', '2012-03-01 05:06',
* + separated with T or space: '2012-03-01T12:22:33.123', '2012-03-01 12:22:33.123',
* + time zone: '2012-03-01T12:22:33Z', '2012-03-01T12:22:33+8000', '2012-03-01T12:22:33-05:00',
* all of which will be treated as they reperent a time in UTC
* if time zone is not specified.
* + Or other string format, including:
* '2012', '2012-3-1', '2012/3/1', '2012/03/01',
* '2009/6/12 2:00', '2009/6/12 2:05:08', '2009/6/12 2:05:08.123'
* + a timestamp, which represent a time in UTC.
* @return {Date} date
* @return {Date} date
*/
*/
number
.
parseDate
=
function
(
value
)
{
number
.
parseDate
=
function
(
value
)
{
...
@@ -199,13 +213,32 @@ define(function (require) {
...
@@ -199,13 +213,32 @@ define(function (require) {
return
value
;
return
value
;
}
}
else
if
(
typeof
value
===
'
string
'
)
{
else
if
(
typeof
value
===
'
string
'
)
{
// Treat as ISO format. See issue #3623
// Different browsers parse date in different way, so we parse it manually.
var
ret
=
new
Date
(
value
);
// Some other issues:
if
(
isNaN
(
+
ret
))
{
// new Date('1970-01-01') is UTC,
// FIXME new Date('1970-01-01') is UTC, new Date('1970/01/01') is local
// new Date('1970/01/01') and new Date('1970-1-01') is local.
ret
=
new
Date
(
new
Date
(
value
.
replace
(
/-/g
,
'
/
'
))
-
new
Date
(
'
1970/01/01
'
));
// See issue #3623
var
match
=
TIME_REG
.
exec
(
value
);
if
(
!
match
)
{
// return Invalid Date.
return
new
Date
(
NaN
);
}
}
return
ret
;
// match[n] can only be string or undefined.
// But take care of '12' + 1 => '121'.
return
new
Date
(
+
match
[
1
],
+
(
match
[
2
]
||
1
)
-
1
,
+
match
[
3
]
||
1
,
+
match
[
4
]
||
0
,
+
(
match
[
5
]
||
0
)
-
(
match
[
8
]
||
0
)
*
60
-
TIMEZONE_OFFSET
,
+
match
[
6
]
||
0
,
+
match
[
7
]
||
0
);
}
else
if
(
value
==
null
)
{
return
new
Date
(
NaN
);
}
}
return
new
Date
(
Math
.
round
(
value
));
return
new
Date
(
Math
.
round
(
value
));
...
...
test/ut/spec/util/number.js
浏览文件 @
4492edc4
...
@@ -193,8 +193,59 @@ describe('util/number', function () {
...
@@ -193,8 +193,59 @@ describe('util/number', function () {
var
result
=
numberUtil
.
linearMap
(
40
,
[
43.55454545
,
43.55454545
],
range
,
clamp
);
var
result
=
numberUtil
.
linearMap
(
40
,
[
43.55454545
,
43.55454545
],
range
,
clamp
);
expect
(
result
).
toEqual
(
1221212.1221372238
);
expect
(
result
).
toEqual
(
1221212.1221372238
);
}
}
})
});
});
describe
(
'
parseDate
'
,
function
()
{
testCase
(
'
parseDate
'
,
function
(
numberUtil
)
{
// Invalid Date
expect
(
''
+
numberUtil
.
parseDate
(
null
)).
toEqual
(
'
Invalid Date
'
);
expect
(
''
+
numberUtil
.
parseDate
(
void
0
)).
toEqual
(
'
Invalid Date
'
);
expect
(
''
+
numberUtil
.
parseDate
(
'
asdf
'
)).
toEqual
(
'
Invalid Date
'
);
expect
(
''
+
numberUtil
.
parseDate
(
NaN
)).
toEqual
(
'
Invalid Date
'
);
expect
(
''
+
numberUtil
.
parseDate
(
'
-
'
)).
toEqual
(
'
Invalid Date
'
);
expect
(
''
+
numberUtil
.
parseDate
(
'
20120304
'
)).
toEqual
(
'
Invalid Date
'
);
// Input instance of Date or timestamp
expect
(
+
numberUtil
.
parseDate
(
new
Date
(
'
2012-03-04
'
))).
toEqual
(
1330819200000
);
expect
(
+
numberUtil
.
parseDate
(
1330819200000
)).
toEqual
(
1330819200000
);
expect
(
+
numberUtil
.
parseDate
(
1330819199999.99
)).
toEqual
(
1330819200000
);
expect
(
+
numberUtil
.
parseDate
(
1330819200000.01
)).
toEqual
(
1330819200000
);
// ISO string
expect
(
+
numberUtil
.
parseDate
(
'
2012-03
'
)).
toEqual
(
1330560000000
);
expect
(
+
numberUtil
.
parseDate
(
'
2012-03-04
'
)).
toEqual
(
1330819200000
);
expect
(
+
numberUtil
.
parseDate
(
'
2012-03-04 05
'
)).
toEqual
(
1330837200000
);
expect
(
+
numberUtil
.
parseDate
(
'
2012-03-04T05
'
)).
toEqual
(
1330837200000
);
expect
(
+
numberUtil
.
parseDate
(
'
2012-03-04 05:06
'
)).
toEqual
(
1330837560000
);
expect
(
+
numberUtil
.
parseDate
(
'
2012-03-04T05:06
'
)).
toEqual
(
1330837560000
);
expect
(
+
numberUtil
.
parseDate
(
'
2012-03-04 05:06:07
'
)).
toEqual
(
1330837567000
);
expect
(
+
numberUtil
.
parseDate
(
'
2012-03-04T05:06:07
'
)).
toEqual
(
1330837567000
);
expect
(
+
numberUtil
.
parseDate
(
'
2012-03-04T05:06:07.123
'
)).
toEqual
(
1330837567123
);
expect
(
+
numberUtil
.
parseDate
(
'
2012-03-04T05:06:07,123
'
)).
toEqual
(
1330837567123
);
expect
(
+
numberUtil
.
parseDate
(
'
2012-03-04T05:06:07.12
'
)).
toEqual
(
1330837567012
);
expect
(
+
numberUtil
.
parseDate
(
'
2012-03-04T05:06:07.1
'
)).
toEqual
(
1330837567001
);
expect
(
+
numberUtil
.
parseDate
(
'
2012-03-04T05:06:07,123Z
'
)).
toEqual
(
1330837567123
);
expect
(
+
numberUtil
.
parseDate
(
'
2012-03-04T05:06:07.123+0800
'
)).
toEqual
(
1330808767123
);
expect
(
+
numberUtil
.
parseDate
(
'
2012-03-04T05:06:07.123+08:00
'
)).
toEqual
(
1330808767123
);
expect
(
+
numberUtil
.
parseDate
(
'
2012-03-04T05:06:07.123-0700
'
)).
toEqual
(
1330862767123
);
expect
(
+
numberUtil
.
parseDate
(
'
2012-03-04T05:06:07.123-07:00
'
)).
toEqual
(
1330862767123
);
// Other string
expect
(
+
numberUtil
.
parseDate
(
'
2012
'
)).
toEqual
(
1325376000000
);
expect
(
+
numberUtil
.
parseDate
(
'
2012/03
'
)).
toEqual
(
1330560000000
);
expect
(
+
numberUtil
.
parseDate
(
'
2012/03/04
'
)).
toEqual
(
1330819200000
);
expect
(
+
numberUtil
.
parseDate
(
'
2012-3-4
'
)).
toEqual
(
1330819200000
);
expect
(
+
numberUtil
.
parseDate
(
'
2012/3
'
)).
toEqual
(
1330560000000
);
expect
(
+
numberUtil
.
parseDate
(
'
2012/3/4
'
)).
toEqual
(
1330819200000
);
expect
(
+
numberUtil
.
parseDate
(
'
2012/3/4 2:05
'
)).
toEqual
(
1330826700000
);
expect
(
+
numberUtil
.
parseDate
(
'
2012/03/04 2:05
'
)).
toEqual
(
1330826700000
);
expect
(
+
numberUtil
.
parseDate
(
'
2012/3/4 2:05:08
'
)).
toEqual
(
1330826708000
);
expect
(
+
numberUtil
.
parseDate
(
'
2012/03/04 2:05:08
'
)).
toEqual
(
1330826708000
);
expect
(
+
numberUtil
.
parseDate
(
'
2012/3/4 2:05:08.123
'
)).
toEqual
(
1330826708123
);
expect
(
+
numberUtil
.
parseDate
(
'
2012/03/04 2:05:08.123
'
)).
toEqual
(
1330826708123
);
});
});
});
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录