提交 600d74cc 编写于 作者: S sushuang

Fix map and data zoom in empty mode.

上级 7b8d9695
......@@ -63,6 +63,12 @@ var AxisProxy = function (dimName, axisIndex, dataZoomModel, ecModel) {
* @type {module: echarts/component/dataZoom/DataZoomModel}
*/
this._dataZoomModel = dataZoomModel;
/**
* @readOnly
* @private
*/
this.hasSeriesStacked;
};
AxisProxy.prototype = {
......@@ -238,10 +244,18 @@ AxisProxy.prototype = {
return;
}
var targetSeries = this.getTargetSeriesModels();
// Culculate data window and data extent, and record them.
this._dataExtent = calculateDataExtent(
this, this._dimName, this.getTargetSeriesModels()
);
this._dataExtent = calculateDataExtent(this, this._dimName, targetSeries);
this.hasSeriesStacked = false;
each(targetSeries, function (series) {
var data = series.getData();
var dataDim = data.mapDimension(this._dimName);
if (data.isStacked(dataDim)) {
this.hasSeriesStacked = true;
}
}, this);
var dataWindow = this.calculateDataWindow(dataZoomModel.option);
......@@ -294,11 +308,14 @@ AxisProxy.prototype = {
var otherAxisModel = this.getOtherAxisModel();
if (dataZoomModel.get('$fromToolbox')
&& otherAxisModel
&& otherAxisModel.get('type') === 'category'
&& otherAxisModel.hasSeriesStacked
) {
filterMode = 'empty';
}
// TODO
// filterMode 'weakFilter' and 'empty' is not optimized for huge data yet.
// Process series data
each(seriesModels, function (seriesModel) {
var seriesData = seriesModel.getData();
......
......@@ -664,7 +664,7 @@ listProto.getDataExtent = function (dim, stack) {
var dimData = this._storage[dim];
var initialExtent = [Infinity, -Infinity];
stack = (stack || false) && isStacked(this, dim);
stack = (stack || false) && this.isStacked(dim);
if (!dimData) {
return initialExtent;
......@@ -721,10 +721,10 @@ listProto.setApproximateExtent = function (extent, dim, stack) {
this._approximateExtent[dim] = extent.slice();
};
function isStacked(list, concreteDim) {
var dimensionInfo = list._dimensionInfos[concreteDim];
return dimensionInfo && dimensionInfo.stackable && list.stackedOn;
}
listProto.isStacked = function (concreteDim) {
var dimensionInfo = this._dimensionInfos[concreteDim];
return dimensionInfo && dimensionInfo.stackable && this.stackedOn;
};
/**
* Get sum of data in one dimension
......@@ -1157,7 +1157,7 @@ listProto.selectRange = function (range, stack) {
}
if (!quickFinished) {
if (dimSize === 1) {
stack = stack || isStacked(this, dim0);
stack = stack || this.isStacked(dim0);
for (var i = 0; i < originalCount; i++) {
var rawIndex = this.getRawIndex(i);
var val = stack ? this.get(dim0, i, true) : this._getFast(dim0, rawIndex);
......@@ -1283,17 +1283,28 @@ listProto.map = function (dimensions, cb, stack, context) {
var tmpRetValue = [];
var chunkSize = this._chunkSize;
this.each(dimensions, function () {
var idx = arguments[arguments.length - 1];
var retValue = cb && cb.apply(this, arguments);
var dimSize = dimensions.length;
var dataCount = this.count();
var values = [];
for (var dataIndex = 0; dataIndex < dataCount; dataIndex++) {
for (var dimIndex = 0; dimIndex < dimSize; dimIndex++) {
values[dimIndex] = this.get(dimensions[dimIndex], dataIndex, stack);
}
values[dimSize] = dataIndex;
var retValue = cb && cb.apply(context, values);
if (retValue != null) {
// a number
if (typeof retValue === 'number') {
// a number or string (in oridinal dimension)?
if (typeof retValue !== 'object') {
tmpRetValue[0] = retValue;
retValue = tmpRetValue;
}
var chunkIndex = Math.floor(idx / chunkSize);
var chunkOffset = idx % chunkSize;
var rawIndex = this.getRawIndex(dataIndex);
var chunkIndex = Math.floor(rawIndex / chunkSize);
var chunkOffset = rawIndex % chunkSize;
for (var i = 0; i < retValue.length; i++) {
var dim = dimensions[i];
var dimStore = storage[dim];
......@@ -1302,7 +1313,7 @@ listProto.map = function (dimensions, cb, stack, context) {
}
}
}
}, stack, context);
}
return list;
};
......
......@@ -22,11 +22,11 @@
<!-- <div id="layout0"></div>
<div id="layout0"></div>
<div id="layout1"></div>
<div id="layout2"></div>
<div id="layout3"></div>
<div id="layout4"></div> -->
<div id="layout4"></div>
<div id="layout5"></div>
......@@ -67,6 +67,14 @@
[55.2, 67.1, 69.2, 72.4, 53.9, 39.1]
];
var arrayRowsPairValueColumns = [
['2012', null, '2013', null, '2014', 'amount'],
[41.1, 2585, 30.4, 2473, 65.1, 3418],
[86.5, 2316, 92.1, 3255, 85.7, 2485],
[24.1, 1532, 67.2, 1452, 79.5, 4689],
[55.2, 5312, 67.1, 3266, 69.2, 1354]
];
// No 北京 上海 江苏
var nameValueGeo0 = [
{name: '天津', value: 514},
......@@ -354,26 +362,26 @@
var option = {
legend: {},
tooltip: {},
xAxis: {},
yAxis: {},
dataset: [{
source: arrayRowsNoColumnHeader
}, {
source: arrayRowsNoRowHeader
source: arrayRowsPairValueColumns
}],
series: [{
type: 'scatter',
radius: 50,
center: ['25%', '25%'],
sourceHeader: false
type: 'scatter'
}, {
type: 'scatter'
}, {
type: 'scatter'
}]
};
testHelper.create(echarts, 'layout5', {
title: 'no sourceHeader',
title: 'column (dimension name duplicated)',
height: 400,
option: option,
dataTables: [
arrayRowsNoColumnHeader,
arrayRowsNoRowHeader
arrayRowsPairValueColumns
],
info: {
legend: '<default>',
......
<html>
<head>
<meta charset="utf-8">
<script src="lib/esl.js"></script>
<script src="lib/config.js"></script>
<script src="lib/testHelper.js"></script>
<script src="lib/jquery.min.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="stylesheet" href="lib/reset.css" />
</head>
<body>
<style>
.test-title {
background: rgb(0, 112, 6);
color: #fff;
}
</style>
<div id="layout0"></div>
<script>
var arrayRows0 = [
['product', '2015', '2016', '2017'],
['Matcha Latte', 43.3, 85.8, 93.7],
['Milk Tea', 83.1, 73.4, 55.1],
['Cheese Cocoa', 86.4, 65.2, 82.5],
['Walnut Brownie', 72.4, 53.9, 39.1]
];
var arrayRows1 = [
['product', '2012', '2013', '2014', '2015', '2016', '2017'],
['Matcha Latte', 41.1, 30.4, 65.1, 53.3, 83.8, 98.7],
['Milk Tea', 86.5, 92.1, 85.7, 83.1, 73.4, 55.1],
['Cheese Cocoa', 24.1, 67.2, 79.5, 86.4, 65.2, 82.5],
['Walnut Brownie', 55.2, 67.1, 69.2, 72.4, 53.9, 39.1]
];
function loadLifeData(cb) {
$.getJSON('data/life-expectancy-table.json', function (data) {
cb(data);
})
}
</script>
<script>
require(['echarts'], function (echarts) {
loadLifeData(function (data) {
var sizeValue = '57%';
var option = {
legend: {},
tooltip: {},
toolbox: {
feature: {
dataZoom: {}
}
},
grid: [
{right: sizeValue, bottom: sizeValue},
{left: sizeValue, bottom: sizeValue},
{right: sizeValue, top: sizeValue},
{left: sizeValue, top: sizeValue}
],
xAxis: [
{type: 'value', gridIndex: 0, name: 'Income'},
{type: 'category', gridIndex: 1, name: 'Country', boundaryGap: false, axisLabel: {rotate: 50, interval: 0}},
{type: 'category', gridIndex: 2, name: 'Year', boundaryGap: false},
{type: 'category', gridIndex: 3, name: 'Country', boundaryGap: false, axisLabel: {rotate: 50, interval: 0}}
],
yAxis: [
{type: 'value', gridIndex: 0, name: 'Life Expectency'},
{type: 'value', gridIndex: 1, name: 'Income'},
{type: 'value', gridIndex: 2, name: 'Population'},
{type: 'category', gridIndex: 3, name: 'Year', boundaryGap: false}
],
dataset: {
source: data
},
series: [
{
type: 'scatter',
symbolSize: 3,
xAxisIndex: 0,
yAxisIndex: 0,
encode: {
x: 'Income',
y: 'Life Expectency'
}
},
{
type: 'scatter',
symbolSize: 3,
xAxisIndex: 1,
yAxisIndex: 1,
encode: {
x: 'Country',
y: 'Income'
}
},
{
type: 'scatter',
symbolSize: 3,
xAxisIndex: 2,
yAxisIndex: 2,
encode: {
x: 'Year',
y: 'Population'
}
},
{
type: 'scatter',
symbolSize: 3,
xAxisIndex: 3,
yAxisIndex: 3,
encode: {
x: 'Country',
y: 'Year'
}
}
]
};
testHelper.create(echarts, 'layout0', {
option: option,
height: 700,
dataTable: data
});
});
});
</script>
</body>
</html>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册