Skip to content

Commit

Permalink
Fix #8003 (yAxis extent do not updated when some of stacked bar serie…
Browse files Browse the repository at this point in the history
…s hide)
  • Loading branch information
100pah committed Apr 18, 2018
1 parent 5f156ad commit 2fddc7f
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 58 deletions.
35 changes: 21 additions & 14 deletions src/data/List.js
Expand Up @@ -47,21 +47,29 @@ function cloneChunk(originalChunk) {
}

var TRANSFERABLE_PROPERTIES = [
'hasItemOption', '_nameList', '_idList', '_calculationInfo', '_invertedIndicesMap',
'_rawData', '_rawExtent', '_chunkSize', '_chunkCount',
'_dimValueGetter', '_count', '_rawCount', '_nameDimIdx', '_idDimIdx'
'hasItemOption', '_nameList', '_idList', '_invertedIndicesMap',
'_rawData', '_chunkSize', '_chunkCount', '_dimValueGetter',
'_count', '_rawCount', '_nameDimIdx', '_idDimIdx'
];
var CLONE_PROPERTIES = [
'_extent', '_approximateExtent', '_rawExtent'
];

function transferProperties(a, b) {
zrUtil.each(TRANSFERABLE_PROPERTIES.concat(b.__wrappedMethods || []), function (propName) {
if (b.hasOwnProperty(propName)) {
a[propName] = b[propName];
function transferProperties(target, source) {
zrUtil.each(TRANSFERABLE_PROPERTIES.concat(source.__wrappedMethods || []), function (propName) {
if (source.hasOwnProperty(propName)) {
target[propName] = source[propName];
}
});

a.__wrappedMethods = b.__wrappedMethods;
}
target.__wrappedMethods = source.__wrappedMethods;

zrUtil.each(CLONE_PROPERTIES, function (propName) {
target[propName] = zrUtil.clone(source[propName]);
});

target._calculationInfo = zrUtil.extend(source._calculationInfo);
}



Expand Down Expand Up @@ -1441,15 +1449,17 @@ function cloneListForMapAndSample(original, excludeDimensions) {

var storage = list._storage = {};
var originalStorage = original._storage;
var rawExtent = zrUtil.extend({}, original._rawExtent);

// Init storage
for (var i = 0; i < allDimensions.length; i++) {
var dim = allDimensions[i];
if (originalStorage[dim]) {
// Notice that we do not reset invertedIndicesMap here, becuase
// there is no scenario of mapping or sampling ordinal dimension.
if (zrUtil.indexOf(excludeDimensions, dim) >= 0) {
storage[dim] = cloneDimStore(originalStorage[dim]);
rawExtent[dim] = getInitialExtent();
list._rawExtent[dim] = getInitialExtent();
list._extent[dim] = null;
}
else {
// Direct reference for other dimensions
Expand Down Expand Up @@ -1855,9 +1865,6 @@ listProto.cloneShallow = function (list) {
}
list.getRawIndex = list._indices ? getRawIndexWithIndices : getRawIndexWithoutIndices;

list._extent = zrUtil.clone(this._extent);
list._approximateExtent = zrUtil.clone(this._approximateExtent);

return list;
};

Expand Down
47 changes: 6 additions & 41 deletions test/bar-stack.html
Expand Up @@ -12,57 +12,19 @@
</head>
<body>
<style>
h1 {
line-height: 60px;
height: 60px;
background: #146402;
text-align: center;
font-weight: bold;
color: #eee;
font-size: 14px;
}
.chart {
height: 500px;
}
</style>


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


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


<script>

require([
'echarts'
// 'echarts/chart/line',
// 'echarts/chart/bar',
// 'echarts/chart/pie',
// 'echarts/chart/scatter',
// 'echarts/chart/map',
// 'echarts/chart/parallel',
// 'echarts/chart/radar',
// 'echarts/component/grid',
// 'echarts/component/polar',
// 'echarts/component/geo',
// 'echarts/component/singleAxis',
// 'echarts/component/legend',
// 'echarts/component/tooltip',
// 'echarts/component/toolbox',
// 'echarts/component/visualMap',
// 'echarts/component/dataZoom'
], function (echarts) {

var option = {
"title": {
"text": "简单柱状图标题",
"left": 16,
"textStyle": {
"fontSize": 14
},
"show": true
},
"tooltip": {
"trigger": "axis",
"axisPointer": {
Expand Down Expand Up @@ -128,7 +90,7 @@
"data": [
["哪有那么多审批", 66],
["审批中", 66],
["撤回",200],
["撤回",150],
["barMinHeight:10px", 100]
],
"name": "zly0031"
Expand All @@ -142,7 +104,10 @@
}
};

testHelper.createChart(echarts, 'main0', option);
testHelper.create(echarts, 'main0', {
title: 'Click the first legend (to hide the bottom series), yAxis extent should be changed',
option: option
});
});

</script>
Expand Down
4 changes: 2 additions & 2 deletions test/candlestick-large2.html
Expand Up @@ -235,10 +235,10 @@
dimension: 6,
pieces: [{
value: 1,
color: downColor
color: upColor
}, {
value: -1,
color: upColor
color: downColor
}]
},
series: [
Expand Down
3 changes: 2 additions & 1 deletion test/lib/reset.css
Expand Up @@ -12,7 +12,8 @@ body > .main {

.test-title {
padding: 20px;
background: rgb(182, 120, 7);
background: #0a6d01;
/* background: rgb(182, 120, 7); */
color: #fff;
font-weight: normal;
text-align: center;
Expand Down

0 comments on commit 2fddc7f

Please sign in to comment.