Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
半栈学徒
incubator-echarts
提交
7360f721
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,体验更适合开发者的 AI 搜索 >>
提交
7360f721
编写于
3月 18, 2020
作者:
1
100pah
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'typescript' of github.com:apache/incubator-echarts into typescript
上级
9e5b6396
ad794812
变更
7
展开全部
隐藏空白更改
内联
并排
Showing
7 changed file
with
514 addition
and
303 deletion
+514
-303
src/component/timeline/SliderTimelineModel.ts
src/component/timeline/SliderTimelineModel.ts
+19
-9
src/component/timeline/SliderTimelineView.ts
src/component/timeline/SliderTimelineView.ts
+255
-157
src/component/timeline/TimelineAxis.ts
src/component/timeline/TimelineAxis.ts
+20
-39
src/component/timeline/TimelineModel.ts
src/component/timeline/TimelineModel.ts
+196
-83
src/component/timeline/TimelineView.ts
src/component/timeline/TimelineView.ts
+6
-5
src/component/timeline/timelineAction.ts
src/component/timeline/timelineAction.ts
+18
-8
src/component/timeline/typeDefaulter.ts
src/component/timeline/typeDefaulter.ts
+0
-2
未找到文件。
src/component/timeline/SliderTimelineModel.ts
浏览文件 @
7360f721
...
...
@@ -17,20 +17,24 @@
* under the License.
*/
// @ts-nocheck
import
*
as
zrUtil
from
'
zrender/src/core/util
'
;
import
TimelineModel
from
'
./TimelineModel
'
;
import
TimelineModel
,
{
TimelineOption
}
from
'
./TimelineModel
'
;
import
DataFormatMixin
from
'
../../model/mixin/dataFormat
'
;
import
ComponentModel
from
'
../../model/Component
'
;
import
{
mixin
}
from
'
zrender/src/core/util
'
;
import
List
from
'
../../data/List
'
;
interface
SliderTimelineOption
extends
TimelineOption
{
}
var
SliderTimelineModel
=
TimelineModel
.
extend
(
{
class
SliderTimelineModel
extends
TimelineModel
{
type
:
'
timeline.slider
'
,
static
type
=
'
timeline.slider
'
type
=
SliderTimelineModel
.
type
/**
* @protected
*/
defaultOption
:
{
static
defaultOption
:
SliderTimelineOption
=
{
backgroundColor
:
'
rgba(0,0,0,0)
'
,
// 时间轴背景颜色
borderColor
:
'
#ccc
'
,
// 时间轴边框颜色
...
...
@@ -117,8 +121,14 @@ var SliderTimelineModel = TimelineModel.extend({
data
:
[]
}
});
}
interface
SliderTimelineModel
extends
DataFormatMixin
{
getData
():
List
<
SliderTimelineModel
>
}
mixin
(
SliderTimelineModel
,
DataFormatMixin
.
prototype
);
zrUtil
.
mixin
(
SliderTimelineModel
,
DataFormatMixin
.
prototype
);
ComponentModel
.
registerClass
(
SliderTimelineModel
);
export
default
SliderTimelineModel
;
\ No newline at end of file
src/component/timeline/SliderTimelineView.ts
浏览文件 @
7360f721
此差异已折叠。
点击以展开。
src/component/timeline/TimelineAxis.ts
浏览文件 @
7360f721
...
...
@@ -17,62 +17,43 @@
* under the License.
*/
// @ts-nocheck
import
*
as
zrUtil
from
'
zrender/src/core/util
'
;
import
Axis
from
'
../../coord/Axis
'
;
import
Scale
from
'
../../scale/Scale
'
;
import
TimelineModel
from
'
./TimelineModel
'
;
import
{
LabelOption
}
from
'
../../util/types
'
;
import
Model
from
'
../../model/Model
'
;
/**
* Extend axis 2d
* @constructor module:echarts/coord/cartesian/Axis2D
* @extends {module:echarts/coord/cartesian/Axis}
* @param {string} dim
* @param {*} scale
* @param {Array.<number>} coordExtent
* @param {string} axisType
* @param {string} position
*/
var
TimelineAxis
=
function
(
dim
,
scale
,
coordExtent
,
axisType
)
{
class
TimelineAxis
extends
Axis
{
Axis
.
call
(
this
,
dim
,
scale
,
coordExtent
);
type
:
'
category
'
|
'
time
'
|
'
value
'
/**
* Axis type
* - 'category'
* - 'value'
* - 'time'
* - 'log'
* @type {string}
*/
this
.
type
=
axisType
||
'
value
'
;
/**
* Axis model
* @param {module:echarts/component/TimelineModel}
*/
this
.
model
=
null
;
};
// Not using the model.
model
:
never
TimelineAxis
.
prototype
=
{
timelineModel
:
TimelineModel
constructor
:
TimelineAxis
,
constructor
(
dim
:
string
,
scale
:
Scale
,
coordExtent
:
[
number
,
number
],
axisType
:
'
category
'
|
'
time
'
|
'
value
'
)
{
super
(
dim
,
scale
,
coordExtent
);
this
.
type
=
axisType
||
'
value
'
;
}
/**
* @override
*/
getLabelModel
:
function
()
{
return
this
.
model
.
getModel
(
'
label
'
);
},
getLabelModel
()
{
// Force override
return
this
.
timelineModel
.
getModel
(
'
label
'
)
as
Model
<
LabelOption
>
;
}
/**
* @override
*/
isHorizontal
:
function
()
{
return
this
.
m
odel
.
get
(
'
orient
'
)
===
'
horizontal
'
;
isHorizontal
()
{
return
this
.
timelineM
odel
.
get
(
'
orient
'
)
===
'
horizontal
'
;
}
};
zrUtil
.
inherits
(
TimelineAxis
,
Axis
);
}
export
default
TimelineAxis
;
\ No newline at end of file
src/component/timeline/TimelineModel.ts
浏览文件 @
7360f721
...
...
@@ -17,89 +17,154 @@
* under the License.
*/
// @ts-nocheck
import
*
as
zrUtil
from
'
zrender/src/core/util
'
;
import
ComponentModel
from
'
../../model/Component
'
;
import
List
from
'
../../data/List
'
;
import
*
as
modelUtil
from
'
../../util/model
'
;
import
{
ComponentOption
,
BoxLayoutOptionMixin
,
LayoutOrient
,
SymbolOptionMixin
,
LineStyleOption
,
ItemStyleOption
,
LabelOption
,
OptionDataValue
,
ZRColor
,
ColorString
,
CommonTooltipOption
,
CallbackDataParams
,
ZREasing
}
from
'
../../util/types
'
;
import
Model
from
'
../../model/Model
'
;
import
GlobalModel
from
'
../../model/Global
'
;
import
{
each
,
isObject
,
clone
,
isString
}
from
'
zrender/src/core/util
'
;
export
interface
TimelineControlStyle
extends
ItemStyleOption
{
show
?:
boolean
showPlayBtn
?:
boolean
showPrevBtn
?:
boolean
showNextBtn
?:
boolean
itemSize
?:
number
itemGap
?:
number
position
?:
'
left
'
|
'
right
'
|
'
top
'
|
'
bottom
'
playIcon
?:
string
stopIcon
?:
string
prevIcon
?:
string
nextIcon
?:
string
}
export
interface
TimelineCheckpointStyle
extends
ItemStyleOption
,
SymbolOptionMixin
{
animation
?:
boolean
animationDuration
?:
number
animationEasing
?:
ZREasing
}
interface
TimelineLineStyleOption
extends
LineStyleOption
{
show
?:
boolean
}
interface
TimelineLabelOption
extends
Omit
<
LabelOption
,
'
position
'
>
{
show
?:
boolean
// number can be distance to the timeline axis. sign will determine the side.
position
?:
'
auto
'
|
'
left
'
|
'
right
'
|
'
top
'
|
'
bottom
'
|
number
interval
?:
'
auto
'
|
number
}
export
interface
TimelineDataItemOption
extends
SymbolOptionMixin
{
value
?:
OptionDataValue
itemStyle
?:
ItemStyleOption
label
?:
TimelineLabelOption
checkpointStyle
?:
TimelineCheckpointStyle
emphasis
?:
{
itemStyle
?:
ItemStyleOption
label
?:
TimelineLabelOption
checkpointStyle
?:
TimelineCheckpointStyle
}
var
TimelineModel
=
ComponentModel
.
extend
({
tooltip
?:
boolean
}
type
:
'
timeline
'
,
export
interface
TimelineOption
extends
ComponentOption
,
BoxLayoutOptionMixin
,
SymbolOptionMixin
{
layoutMode
:
'
box
'
,
backgroundColor
?:
ZRColor
borderColor
?:
ColorString
borderWidth
?:
number
/**
* @protected
*/
defaultOption
:
{
tooltip
?:
CommonTooltipOption
<
CallbackDataParams
>
&
{
trigger
?:
'
item
'
}
zlevel
:
0
,
// 一级层叠
z
:
4
,
// 二级层叠
show
:
true
,
show
?:
boolean
axisType
:
'
time
'
,
// 模式是时间类型,支持 value, category
axisType
?:
'
category
'
|
'
time
'
|
'
value
'
realtime
:
true
,
currentIndex
?:
number
left
:
'
20%
'
,
top
:
null
,
right
:
'
20%
'
,
bottom
:
0
,
width
:
null
,
height
:
40
,
padding
:
5
,
autoPlay
?:
boolean
controlPosition
:
'
left
'
,
// 'left' 'right' 'top' 'bottom' 'none'
autoPlay
:
false
,
rewind
:
false
,
// 反向播放
loop
:
true
,
playInterval
:
2000
,
// 播放时间间隔,单位ms
rewind
?:
boolean
currentIndex
:
0
,
loop
?:
boolean
itemStyle
:
{},
label
:
{
color
:
'
#000
'
},
playInterval
?:
number
data
:
[]
},
realtime
?:
boolean
/**
* @override
*/
init
:
function
(
option
,
parentModel
,
ecModel
)
{
controlPosition
?:
'
left
'
|
'
right
'
|
'
top
'
|
'
bottom
'
/**
* @private
* @type {module:echarts/data/List}
*/
this
.
_data
;
padding
?:
number
|
number
[]
/**
* @private
* @type {Array.<string>}
*/
this
.
_names
;
orient
?:
LayoutOrient
this
.
mergeDefaultAndTheme
(
option
,
ecModel
);
this
.
_initData
();
},
inverse
?:
boolean
lineStyle
?:
TimelineLineStyleOption
itemStyle
?:
ItemStyleOption
checkpointStyle
?:
TimelineCheckpointStyle
controlStyle
?:
TimelineControlStyle
label
?:
TimelineLabelOption
emphasis
?:
{
lineStyle
?:
TimelineLineStyleOption
itemStyle
?:
ItemStyleOption
checkpointStyle
?:
TimelineCheckpointStyle
controlStyle
?:
TimelineControlStyle
label
?:
TimelineLabelOption
}
data
?:
(
OptionDataValue
|
TimelineDataItemOption
)[]
}
class
TimelineModel
extends
ComponentModel
<
TimelineOption
>
{
static
type
=
'
timeline
'
type
=
TimelineModel
.
type
layoutMode
=
'
box
'
private
_data
:
List
<
TimelineModel
>
private
_names
:
string
[]
/**
* @override
*/
mergeOption
:
function
(
option
)
{
TimelineModel
.
superApply
(
this
,
'
mergeOption
'
,
arguments
);
init
(
option
:
TimelineOption
,
parentModel
:
Model
,
ecModel
:
GlobalModel
)
{
this
.
mergeDefaultAndTheme
(
option
,
ecModel
);
this
.
_initData
();
}
,
}
/**
* @
param {number} [currentIndex]
* @
override
*/
setCurrentIndex
:
function
(
currentIndex
)
{
mergeOption
(
option
:
TimelineOption
)
{
super
.
mergeOption
.
apply
(
this
,
arguments
as
any
);
this
.
_initData
();
}
setCurrentIndex
(
currentIndex
:
number
)
{
if
(
currentIndex
==
null
)
{
currentIndex
=
this
.
option
.
currentIndex
;
}
...
...
@@ -114,91 +179,139 @@ var TimelineModel = ComponentModel.extend({
}
this
.
option
.
currentIndex
=
currentIndex
;
}
,
}
/**
* @return {number} currentIndex
*/
getCurrentIndex
:
function
()
{
getCurrentIndex
()
{
return
this
.
option
.
currentIndex
;
}
,
}
/**
* @return {boolean}
*/
isIndexMax
:
function
()
{
isIndexMax
()
{
return
this
.
getCurrentIndex
()
>=
this
.
_data
.
count
()
-
1
;
}
,
}
/**
* @param {boolean} state true: play, false: stop
*/
setPlayState
:
function
(
state
)
{
setPlayState
(
state
:
boolean
)
{
this
.
option
.
autoPlay
=
!!
state
;
}
,
}
/**
* @return {boolean} true: play, false: stop
*/
getPlayState
:
function
()
{
getPlayState
()
{
return
!!
this
.
option
.
autoPlay
;
}
,
}
/**
* @private
*/
_initData
:
function
()
{
_initData
()
{
var
thisOption
=
this
.
option
;
var
dataArr
=
thisOption
.
data
||
[];
var
axisType
=
thisOption
.
axisType
;
var
names
=
this
.
_names
=
[];
var
names
:
string
[]
=
this
.
_names
=
[];
var
processedDataArr
:
TimelineOption
[
'
data
'
];
if
(
axisType
===
'
category
'
)
{
var
idx
Arr
=
[];
zrUtil
.
each
(
dataArr
,
function
(
item
,
index
)
{
processedData
Arr
=
[];
each
(
dataArr
,
function
(
item
,
index
)
{
var
value
=
modelUtil
.
getDataItemValue
(
item
);
var
newItem
;
if
(
zrUtil
.
isObject
(
item
))
{
newItem
=
zrUtil
.
clone
(
item
);
newItem
.
value
=
index
;
if
(
isObject
(
item
))
{
newItem
=
clone
(
item
);
(
newItem
as
TimelineDataItemOption
)
.
value
=
index
;
}
else
{
newItem
=
index
;
}
idx
Arr
.
push
(
newItem
);
processedData
Arr
.
push
(
newItem
);
if
(
!
zrUtil
.
isString
(
value
)
&&
(
value
==
null
||
isNaN
(
value
)))
{
if
(
!
isString
(
value
)
&&
(
value
==
null
||
isNaN
(
value
as
number
)))
{
value
=
''
;
}
names
.
push
(
value
+
''
);
});
dataArr
=
idxArr
;
}
else
{
processedDataArr
=
dataArr
;
}
var
dimType
=
({
category
:
'
ordinal
'
,
time
:
'
time
'
})[
axisType
]
||
'
number
'
;
var
dimType
=
({
category
:
'
ordinal
'
,
time
:
'
time
'
,
value
:
'
number
'
})[
axisType
]
||
'
number
'
;
var
data
=
this
.
_data
=
new
List
([{
name
:
'
value
'
,
type
:
dimType
}],
this
);
var
data
=
this
.
_data
=
new
List
([{
name
:
'
value
'
,
type
:
dimType
}],
this
);
data
.
initData
(
d
ataArr
,
names
);
}
,
data
.
initData
(
processedD
ataArr
,
names
);
}
getData
:
function
()
{
getData
()
{
return
this
.
_data
;
}
,
}
/**
* @public
* @return {Array.<string>} categoreis
*/
getCategories
:
function
()
{
getCategories
()
{
if
(
this
.
get
(
'
axisType
'
)
===
'
category
'
)
{
return
this
.
_names
.
slice
();
}
}
});
/**
* @protected
*/
static
defaultOption
:
TimelineOption
=
{
zlevel
:
0
,
// 一级层叠
z
:
4
,
// 二级层叠
show
:
true
,
axisType
:
'
time
'
,
// 模式是时间类型,支持 value, category
realtime
:
true
,
left
:
'
20%
'
,
top
:
null
,
right
:
'
20%
'
,
bottom
:
0
,
width
:
null
,
height
:
40
,
padding
:
5
,
controlPosition
:
'
left
'
,
// 'left' 'right' 'top' 'bottom' 'none'
autoPlay
:
false
,
rewind
:
false
,
// 反向播放
loop
:
true
,
playInterval
:
2000
,
// 播放时间间隔,单位ms
currentIndex
:
0
,
itemStyle
:
{},
label
:
{
color
:
'
#000
'
},
data
:
[]
}
}
ComponentModel
.
registerClass
(
TimelineModel
);
export
default
TimelineModel
;
\ No newline at end of file
src/component/timeline/TimelineView.ts
浏览文件 @
7360f721
...
...
@@ -17,10 +17,11 @@
* under the License.
*/
// @ts-nocheck
import
ComponentView
from
'
../../view/Component
'
;
export
default
ComponentView
.
extend
({
type
:
'
timeline
'
});
class
TimelineView
extends
ComponentView
{
static
type
=
'
timeline
'
type
=
TimelineView
.
type
}
export
default
TimelineView
;
src/component/timeline/timelineAction.ts
浏览文件 @
7360f721
...
...
@@ -17,18 +17,28 @@
* under the License.
*/
// @ts-nocheck
import
*
as
echarts
from
'
../../echarts
'
;
import
*
as
zrUtil
from
'
zrender/src/core/util
'
;
import
GlobalModel
from
'
../../model/Global
'
;
import
TimelineModel
from
'
./TimelineModel
'
;
import
{
defaults
}
from
'
zrender/src/core/util
'
;
import
{
Payload
}
from
'
../../util/types
'
;
export
interface
TimelineChangePayload
extends
Payload
{
type
:
'
timelineChange
'
currentIndex
:
number
}
export
interface
TimelinePlayChangePayload
extends
Payload
{
type
:
'
timelinePlayChange
'
playState
:
boolean
}
echarts
.
registerAction
(
{
type
:
'
timelineChange
'
,
event
:
'
timelineChanged
'
,
update
:
'
prepareAndUpdate
'
},
function
(
payload
,
ec
Model
)
{
function
(
payload
:
TimelineChangePayload
,
ecModel
:
Global
Model
)
{
var
timelineModel
=
ecModel
.
getComponent
(
'
timeline
'
);
var
timelineModel
=
ecModel
.
getComponent
(
'
timeline
'
)
as
TimelineModel
;
if
(
timelineModel
&&
payload
.
currentIndex
!=
null
)
{
timelineModel
.
setCurrentIndex
(
payload
.
currentIndex
);
...
...
@@ -40,7 +50,7 @@ echarts.registerAction(
// Set normalized currentIndex to payload.
ecModel
.
resetOption
(
'
timeline
'
);
return
zrUtil
.
defaults
({
return
defaults
({
currentIndex
:
timelineModel
.
option
.
currentIndex
},
payload
);
}
...
...
@@ -50,8 +60,8 @@ echarts.registerAction(
{
type
:
'
timelinePlayChange
'
,
event
:
'
timelinePlayChanged
'
,
update
:
'
update
'
},
function
(
payload
,
ec
Model
)
{
var
timelineModel
=
ecModel
.
getComponent
(
'
timeline
'
);
function
(
payload
:
TimelinePlayChangePayload
,
ecModel
:
Global
Model
)
{
var
timelineModel
=
ecModel
.
getComponent
(
'
timeline
'
)
as
TimelineModel
;
if
(
timelineModel
&&
payload
.
playState
!=
null
)
{
timelineModel
.
setPlayState
(
payload
.
playState
);
}
...
...
src/component/timeline/typeDefaulter.ts
浏览文件 @
7360f721
...
...
@@ -17,8 +17,6 @@
* under the License.
*/
// @ts-nocheck
import
Component
from
'
../../model/Component
'
;
Component
.
registerSubTypeDefaulter
(
'
timeline
'
,
function
()
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录