Skip to content

Commit

Permalink
Fix sampling in stream.
Browse files Browse the repository at this point in the history
  • Loading branch information
100pah committed Mar 25, 2018
1 parent 7d62bf3 commit 81fb75e
Show file tree
Hide file tree
Showing 6 changed files with 88 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/component/dataZoom/dataZoomProcessor.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ echarts.registerProcessor({
return seriesModelMap;
},

isOverallFilter: true,
modifyOutputEnd: true,

// Consider appendData, where filter should be performed. Because data process is
// in block mode currently, it is not need to worry about that the overallProgress
Expand Down
2 changes: 1 addition & 1 deletion src/model/Series.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ var SeriesModel = ComponentModel.extend({
if (task) {
var context = task.context;
// Consider case: filter, data sample.
if (context.data !== data && task.isOverallFilter) {
if (context.data !== data && task.modifyOutputEnd) {
task.setOutputEnd(data.count());
}
context.outputData = data;
Expand Down
4 changes: 4 additions & 0 deletions src/processor/dataSample.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,11 @@ var indexSampler = function (frame, value) {

export default function (seriesType) {
return {

seriesType: seriesType,

modifyOutputEnd: true,

reset: function (seriesModel, ecModel, api) {
var data = seriesModel.getData();
var sampling = seriesModel.get('sampling');
Expand Down
6 changes: 3 additions & 3 deletions src/stream/Scheduler.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @module echarts/stream/Scheduler
*/

import {each, isArray, isFunction, createHashMap, noop, assert} from 'zrender/src/core/util';
import {each, isFunction, createHashMap, noop} from 'zrender/src/core/util';
import {createTask} from './task';
import {getUID} from '../util/component';
import GlobalModel from '../model/Global';
Expand Down Expand Up @@ -347,7 +347,7 @@ function createOverallStageTask(scheduler, stageHandler, stageHandlerRecord, ecM
var seriesType = stageHandler.seriesType;
var getTargetSeries = stageHandler.getTargetSeries;
var overallProgress = true;
var isOverallFilter = stageHandler.isOverallFilter;
var modifyOutputEnd = stageHandler.modifyOutputEnd;

// An overall task with seriesType detected or has `getTargetSeries`, we add
// stub in each pipelines, it will set the overall task dirty when the pipeline
Expand Down Expand Up @@ -382,7 +382,7 @@ function createOverallStageTask(scheduler, stageHandler, stageHandlerRecord, ecM
stub.context = {
model: seriesModel,
overallProgress: overallProgress,
isOverallFilter: isOverallFilter
modifyOutputEnd: modifyOutputEnd
};
stub.agent = overallTask;
stub.__block = overallProgress;
Expand Down
4 changes: 0 additions & 4 deletions src/stream/task.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,6 @@ taskProto.perform = function (performArgs) {
if (__DEV__) {
assert(upTask._outputDueEnd != null);
}
// ??? FIXME move to schedueler?
// this._dueEnd = Math.max(upTask._outputDueEnd, this._dueEnd);
this._dueEnd = upTask._outputDueEnd;
}
// DataTask or overallTask
Expand Down Expand Up @@ -198,14 +196,12 @@ taskProto.getDownstream = function () {
};

taskProto.setOutputEnd = function (end) {
// ??? FIXME: check
// This only happend in dataTask, dataZoom, map, currently.
// where dataZoom do not set end each time, but only set
// when reset. So we should record the setted end, in case
// that the stub of dataZoom perform again and earse the
// setted end by upstream.
this._outputDueEnd = this._settedOutputEnd = end;
// this._outputDueEnd = end;
};


Expand Down
79 changes: 79 additions & 0 deletions test/line-large.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1" />
<script src="lib/esl.js"></script>
<script src="lib/config.js"></script>
<script src="lib/jquery.min.js"></script>
<script src="lib/facePrint.js"></script>
<script src="lib/testHelper.js"></script>
<link rel="stylesheet" href="lib/reset.css" />
</head>
<body>
<style>
.test-title {
background: #146402;
color: #fff;
}
</style>


<div id="main0"></div>


<script>

var chart;
var myChart;
var option;

require([
'echarts'/*, 'map/js/china' */
], function (echarts) {

var count = 1e6;

function randomData() {
value = value + Math.random() * 21 - 10;
return [
xValue += 1,
Math.round(value)
];
}

var data = [];
var xValue = 100;
var value = Math.random() * 1000;
for (var i = 0; i < count; i++) {
data.push(randomData());
}


var option = {
tooltip: {
trigger: 'axis'
},
legend: {},
xAxis: {
},
yAxis: {
},
dataZoom: [{}, {type: 'inside'}],
series: [{
name: 'large-line',
type: 'line',
showSymbol: false,
sampling: 'max',
data: data
}]
};

chart = myChart = testHelper.create(echarts, 'main0', {
option: option
});
});

</script>
</body>
</html>

0 comments on commit 81fb75e

Please sign in to comment.