Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
x649585723
incubator-echarts
提交
10bdc9d0
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,发现更多精彩内容 >>
提交
10bdc9d0
编写于
1月 12, 2018
作者:
S
sushuang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Support setData and getData in stream.
上级
e7500374
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
107 addition
and
121 deletion
+107
-121
src/component/dataZoom/AxisProxy.js
src/component/dataZoom/AxisProxy.js
+2
-5
src/model/Series.js
src/model/Series.js
+38
-4
src/processor/dataSample.js
src/processor/dataSample.js
+1
-1
src/stream/Scheduler.js
src/stream/Scheduler.js
+18
-78
src/stream/task.js
src/stream/task.js
+15
-2
test/scatter-random-stream.html
test/scatter-random-stream.html
+2
-2
test/scatter-weibo.html
test/scatter-weibo.html
+31
-29
未找到文件。
src/component/dataZoom/AxisProxy.js
浏览文件 @
10bdc9d0
...
...
@@ -345,11 +345,10 @@ AxisProxy.prototype = {
else
{
each
(
dataDims
,
function
(
dim
)
{
if
(
filterMode
===
'
empty
'
)
{
api
.
setTaskOutpu
tData
(
seriesModel
.
se
tData
(
seriesData
.
map
(
dim
,
function
(
value
)
{
return
!
isInWindow
(
value
)
?
NaN
:
value
;
}),
seriesModel
})
);
}
else
{
...
...
@@ -362,8 +361,6 @@ AxisProxy.prototype = {
seriesData
.
setApproximateExtent
(
valueWindow
,
dim
);
});
}
api
.
setTaskOutputEnd
(
seriesData
.
count
(),
seriesModel
);
});
function
isInWindow
(
value
)
{
...
...
src/model/Series.js
浏览文件 @
10bdc9d0
...
...
@@ -198,19 +198,34 @@ var SeriesModel = ComponentModel.extend({
},
/**
* Consider some method like `filter`, `map` need make new data,
* We should make sure that `seriesModel.getData()` get correct
* data in the stream procedure. So we fetch data from upstream
* each time `task.perform` called.
* @param {string} [dataType]
* @return {module:echarts/data/List}
*/
getData
:
function
(
dataType
)
{
var
data
=
inner
(
this
).
data
;
return
dataType
==
null
?
data
:
data
.
getLinkedData
(
dataType
);
var
task
=
getCurrentTask
(
this
);
if
(
task
)
{
var
data
=
task
.
context
.
data
;
return
dataType
==
null
?
data
:
data
.
getLinkedData
(
dataType
);
}
},
/**
* @param {module:echarts/data/List} data
*/
setData
:
function
(
data
)
{
inner
(
this
).
data
=
data
;
var
task
=
getCurrentTask
(
this
);
if
(
task
)
{
var
context
=
task
.
context
;
// Consider case: filter, data sample.
if
(
context
.
data
!==
data
)
{
task
.
setOutputEnd
(
data
.
count
());
}
task
.
context
.
outputData
=
data
;
}
},
/**
...
...
@@ -295,7 +310,7 @@ var SeriesModel = ComponentModel.extend({
return
encodeHTML
(
addCommas
(
val
));
}
var
data
=
inner
(
this
).
data
;
var
data
=
this
.
getData
()
;
var
tooltipDims
=
data
.
mapDimension
(
'
defaultedTooltip
'
,
true
);
var
tooltipDimLen
=
tooltipDims
.
length
;
var
value
=
this
.
getRawValue
(
dataIndex
);
...
...
@@ -430,6 +445,7 @@ var SeriesModel = ComponentModel.extend({
});
zrUtil
.
mixin
(
SeriesModel
,
dataFormatMixin
);
zrUtil
.
mixin
(
SeriesModel
,
colorPaletteMixin
);
...
...
@@ -475,4 +491,22 @@ function dataTaskProgress(param, context) {
}
}
function
getCurrentTask
(
seriesModel
)
{
var
scheduler
=
(
seriesModel
.
ecModel
||
{}).
scheduler
;
var
pipeline
=
scheduler
&&
scheduler
.
getPipeline
(
seriesModel
.
uid
);
if
(
pipeline
)
{
// When pipline finished, the currrentTask keep the last
// task (renderTask).
var
task
=
pipeline
.
currentTask
;
if
(
task
)
{
var
agentStubMap
=
task
.
agentStubMap
;
if
(
agentStubMap
)
{
task
=
agentStubMap
.
get
(
seriesModel
.
uid
);
}
}
return
task
;
}
}
export
default
SeriesModel
;
src/processor/dataSample.js
浏览文件 @
10bdc9d0
...
...
@@ -69,7 +69,7 @@ export default function (seriesType) {
sampler
=
sampling
;
}
if
(
sampler
)
{
api
.
setTaskOutpu
tData
(
data
.
downSample
(
seriesModel
.
se
tData
(
data
.
downSample
(
valueAxis
.
dim
,
1
/
rate
,
sampler
,
indexSampler
));
}
...
...
src/stream/Scheduler.js
浏览文件 @
10bdc9d0
...
...
@@ -39,11 +39,11 @@ var proto = Scheduler.prototype;
// If seriesModel provided, incremental threshold is check by series data.
proto
.
getPerformArgs
=
function
(
task
,
isBlock
)
{
// For overall task
if
(
!
task
.
__pipeline
Id
)
{
if
(
!
task
.
__pipeline
)
{
return
;
}
var
pipeline
=
this
.
_pipelineMap
.
get
(
task
.
__pipeline
I
d
);
var
pipeline
=
this
.
_pipelineMap
.
get
(
task
.
__pipeline
.
i
d
);
var
pCtx
=
pipeline
.
context
;
var
incremental
=
!
isBlock
&&
pipeline
.
progressiveEnabled
...
...
@@ -53,6 +53,10 @@ proto.getPerformArgs = function (task, isBlock) {
return
{
step
:
incremental
?
pipeline
.
step
:
null
};
};
proto
.
getPipeline
=
function
(
pipelineId
)
{
return
this
.
_pipelineMap
.
get
(
pipelineId
);
};
/**
* Current, progressive rendering starts from visual and layout.
* Always detect render mode in the same stage, avoiding that incorrect
...
...
@@ -79,12 +83,13 @@ proto.restorePipelines = function (ecModel) {
var
scheduler
=
this
;
var
pipelineMap
=
scheduler
.
_pipelineMap
=
createHashMap
();
ecModel
.
eachSeries
(
function
(
seriesModel
)
{
var
dataTask
=
seriesModel
.
dataTask
;
var
progressive
=
seriesModel
.
getProgressive
();
var
pipelineId
=
seriesModel
.
uid
;
pipelineMap
.
set
(
seriesModel
.
uid
,
{
head
:
dataTask
,
tail
:
dataTask
,
pipelineMap
.
set
(
pipelineId
,
{
id
:
pipelineId
,
head
:
null
,
tail
:
null
,
threshold
:
seriesModel
.
getProgressiveThreshold
(),
progressiveEnabled
:
progressive
&&
!
(
seriesModel
.
preventIncremental
&&
seriesModel
.
preventIncremental
()),
...
...
@@ -93,8 +98,7 @@ proto.restorePipelines = function (ecModel) {
count
:
1
});
dataTask
.
__pipelineId
=
seriesModel
.
uid
;
dataTask
.
__idxInPipeline
=
0
;
pipe
(
scheduler
,
seriesModel
,
seriesModel
.
dataTask
);
});
};
...
...
@@ -194,7 +198,7 @@ function performStageTasks(scheduler, stageHandlers, ecModel, payload, opt) {
});
function
needSetDirty
(
opt
,
task
)
{
return
opt
.
setDirty
&&
(
!
opt
.
dirtyMap
||
opt
.
dirtyMap
.
get
(
task
.
__pipeline
I
d
));
return
opt
.
setDirty
&&
(
!
opt
.
dirtyMap
||
opt
.
dirtyMap
.
get
(
task
.
__pipeline
.
i
d
));
}
scheduler
.
unfinished
|=
unfinished
;
...
...
@@ -257,7 +261,6 @@ function createSeriesStageTask(scheduler, stageHandler, stageHandlerRecord, ecMo
if
(
!
task
)
{
task
=
createTask
({
reset
:
seriesTaskReset
,
plan
:
seriesTaskPlan
,
count
:
seriesTaskCount
},
{
model
:
seriesModel
,
...
...
@@ -346,57 +349,12 @@ function createOverallStageTask(scheduler, stageHandler, stageHandlerRecord, ecM
}
function
overallTaskReset
(
context
)
{
mountTaskMethods
(
this
);
context
.
overallReset
(
context
.
ecModel
,
context
.
api
,
context
.
payload
);
unmountTaskMethods
(
this
);
}
function
mountTaskMethods
(
task
)
{
var
context
=
task
.
context
;
var
api
=
context
.
api
;
api
.
setTaskOutputData
=
setTaskOutputData
;
api
.
setTaskOutputEnd
=
setTaskOutputEnd
;
api
.
__task
=
task
;
}
function
unmountTaskMethods
(
task
)
{
var
api
=
task
.
context
.
api
;
api
.
setTaskOutputData
=
api
.
setTaskOutputEnd
=
null
;
}
function
setTaskOutputData
(
data
,
seriesModel
)
{
var
task
=
this
.
__task
;
var
context
=
task
.
context
;
if
(
__DEV__
)
{
assert
(
!
task
.
agentStubMap
||
seriesModel
);
}
if
(
!
task
.
agentStubMap
)
{
context
.
model
.
setData
(
context
.
outputData
=
data
);
}
else
{
var
stub
=
task
.
agentStubMap
.
get
(
seriesModel
.
uid
);
seriesModel
.
setData
(
stub
.
context
.
outputData
=
data
);
}
}
function
setTaskOutputEnd
(
end
,
seriesModel
)
{
var
task
=
this
.
__task
;
if
(
__DEV__
)
{
assert
(
!
task
.
agentStubMap
||
seriesModel
);
}
if
(
!
task
.
agentStubMap
)
{
task
.
setOutputEnd
(
end
);
}
else
{
var
stub
=
task
.
agentStubMap
.
get
(
seriesModel
.
uid
);
stub
.
setOutputEnd
(
end
);
}
}
function
stubReset
(
context
,
upstreamContext
)
{
pullData
(
context
,
upstreamContext
);
return
context
.
overallProgress
&&
stubProgress
;
}
...
...
@@ -409,15 +367,6 @@ function stubOnDirty() {
this
.
agent
&&
this
.
agent
.
dirty
();
}
function
seriesTaskPlan
(
context
,
upstreamContext
)
{
// ???! setData can be called in plan, progress, overalltask, how to deal with that
prepareData
(
context
,
upstreamContext
);
return
context
.
plan
&&
context
.
plan
(
context
.
model
,
context
.
ecModel
,
context
.
api
,
context
.
payload
);
}
function
prepareData
(
context
,
upstreamContext
)
{
// Consider some method like `filter`, `map` need make new data,
// We should make sure that `seriesModel.getData()` get correct
...
...
@@ -426,23 +375,13 @@ function prepareData(context, upstreamContext) {
context
.
model
.
setData
(
context
.
data
);
}
function
pullData
(
context
,
upstreamContext
)
{
context
.
model
.
setData
(
context
.
data
=
context
.
outputData
=
upstreamContext
.
outputData
);
}
function
seriesTaskReset
(
context
,
upstreamContext
)
{
pullData
(
context
,
upstreamContext
);
if
(
context
.
useClearVisual
)
{
context
.
data
.
clearAllVisual
();
}
mountTaskMethods
(
this
);
var
resetDefines
=
context
.
resetDefines
=
normalizeToArray
(
context
.
reset
(
context
.
model
,
context
.
ecModel
,
context
.
api
,
context
.
payload
));
unmountTaskMethods
(
this
);
if
(
resetDefines
.
length
)
{
return
seriesTaskProgress
;
}
...
...
@@ -452,7 +391,6 @@ function seriesTaskProgress(params, context) {
var
data
=
context
.
data
;
var
resetDefines
=
context
.
resetDefines
;
mountTaskMethods
(
this
);
for
(
var
k
=
0
;
k
<
resetDefines
.
length
;
k
++
)
{
var
resetDefine
=
resetDefines
[
k
];
if
(
resetDefine
&&
resetDefine
.
dataEach
)
{
...
...
@@ -464,7 +402,6 @@ function seriesTaskProgress(params, context) {
resetDefine
.
progress
(
params
,
data
);
}
}
unmountTaskMethods
(
this
);
}
function
seriesTaskCount
(
context
)
{
...
...
@@ -474,10 +411,11 @@ function seriesTaskCount(context) {
function
pipe
(
scheduler
,
seriesModel
,
task
)
{
var
pipelineId
=
seriesModel
.
uid
;
var
pipeline
=
scheduler
.
_pipelineMap
.
get
(
pipelineId
);
pipeline
.
tail
.
pipe
(
task
);
!
pipeline
.
head
&&
(
pipeline
.
head
=
task
);
pipeline
.
tail
&&
pipeline
.
tail
.
pipe
(
task
);
pipeline
.
tail
=
task
;
task
.
__idxInPipeline
=
pipeline
.
count
++
;
task
.
__pipeline
Id
=
pipelineId
;
task
.
__pipeline
=
pipeline
;
}
Scheduler
.
wrapStageHandler
=
function
(
stageHandler
,
visualType
)
{
...
...
@@ -494,6 +432,8 @@ Scheduler.wrapStageHandler = function (stageHandler, visualType) {
return
stageHandler
;
};
/**
* Only some legacy stage handlers (usually in echarts extensions) are pure function.
* To ensure that they can work normally, they should work in block mode, that is,
...
...
src/stream/task.js
浏览文件 @
10bdc9d0
...
...
@@ -39,9 +39,23 @@ var taskProto = Task.prototype;
* @param {number} [performArgs.skip] Skip customer perform call.
*/
taskProto
.
perform
=
function
(
performArgs
)
{
var
upTask
=
this
.
_upstream
;
// TODO some refactor.
// Pull data.
if
(
this
.
_dirty
&&
upTask
)
{
var
context
=
this
.
context
;
context
.
data
=
context
.
outputData
=
upTask
.
context
.
outputData
;
}
if
(
this
.
__pipeline
)
{
this
.
__pipeline
.
currentTask
=
this
;
}
var
planResult
;
if
(
this
.
_plan
)
{
planResult
=
this
.
_plan
(
this
.
context
,
this
.
_upstream
&&
this
.
_upstream
.
context
);
planResult
=
this
.
_plan
(
this
.
context
);
}
if
(
this
.
_dirty
||
planResult
===
'
reset
'
)
{
...
...
@@ -51,7 +65,6 @@ taskProto.perform = function (performArgs) {
var
step
=
performArgs
&&
performArgs
.
step
;
var
upTask
=
this
.
_upstream
;
if
(
upTask
)
{
if
(
__DEV__
)
{
assert
(
upTask
.
_outputDueEnd
!=
null
);
...
...
test/scatter-random-stream.html
浏览文件 @
10bdc9d0
...
...
@@ -169,7 +169,7 @@
});
chart
.
on
(
'
finished
'
,
function
()
{
console
.
log
(
'
Render finished
'
);
//
console.log('Render finished');
var
url
=
chart
.
getDataURL
();
var
snapshotEl
=
document
.
getElementById
(
'
snapshot
'
);
snapshotEl
.
src
=
url
;
...
...
@@ -183,7 +183,7 @@
if
(
chunkCount
++
<
chunkMax
)
{
var
newData
=
genData1
(
100000
,
chunkCount
);
chart
.
appendData
({
seriesIndex
:
0
,
data
:
newData
});
console
.
log
(
'
Data loaded
'
);
//
console.log('Data loaded');
setTimeout
(
next
,
3000
);
}
}
...
...
test/scatter-weibo.html
浏览文件 @
10bdc9d0
...
...
@@ -69,6 +69,7 @@
},
geo
:
{
map
:
'
china
'
,
roam
:
true
,
label
:
{
emphasis
:
{
show
:
false
...
...
@@ -98,39 +99,40 @@
}
},
data
:
weiboData
[
0
]
//
}, {
//
name: '中',
//
type: 'scatter',
//
coordinateSystem: 'geo',
//
symbolSize: 1,
//
large: true,
//
itemStyle: {
//
normal: {
//
shadowBlur: 2,
//
shadowColor: 'rgba(14, 241, 242, 0.8)',
//
color: 'rgba(14, 241, 242, 0.8)'
//
}
//
},
//
data: weiboData[1]
//
}, {
//
name: '强',
//
type: 'scatter',
//
coordinateSystem: 'geo',
//
symbolSize: 1,
//
large: true,
//
itemStyle: {
//
normal: {
//
shadowBlur: 2,
//
shadowColor: 'rgba(255, 255, 255, 0.8)',
//
color: 'rgba(255, 255, 255, 0.8)'
//
}
//
},
//
data: weiboData[2]
},
{
name
:
'
中
'
,
type
:
'
scatter
'
,
coordinateSystem
:
'
geo
'
,
symbolSize
:
1
,
large
:
true
,
itemStyle
:
{
normal
:
{
shadowBlur
:
2
,
shadowColor
:
'
rgba(14, 241, 242, 0.8)
'
,
color
:
'
rgba(14, 241, 242, 0.8)
'
}
},
data
:
weiboData
[
1
]
},
{
name
:
'
强
'
,
type
:
'
scatter
'
,
coordinateSystem
:
'
geo
'
,
symbolSize
:
1
,
large
:
true
,
itemStyle
:
{
normal
:
{
shadowBlur
:
2
,
shadowColor
:
'
rgba(255, 255, 255, 0.8)
'
,
color
:
'
rgba(255, 255, 255, 0.8)
'
}
},
data
:
weiboData
[
2
]
}]
};
testHelper
.
create
(
echarts
,
'
main0
'
,
{
option
:
option
option
:
option
,
height
:
500
});
});
});
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录