提交 752a288d 编写于 作者: S sushuang

Fix stack on time axis.

上级 44c157fb
...@@ -72,10 +72,16 @@ export function enableDataStack(seriesModel, dimensionInfoList, opt) { ...@@ -72,10 +72,16 @@ export function enableDataStack(seriesModel, dimensionInfoList, opt) {
} }
}); });
if (stackedDimInfo && !byIndex && !stackedByDimInfo) {
// Compatible with previous design, value axis (time axis) only stack by index.
// It may make sense if the user provides elaborately constructed data.
byIndex = true;
}
// Add stack dimension, they can be both calculated by coordinate system in `unionExtent`. // Add stack dimension, they can be both calculated by coordinate system in `unionExtent`.
// That put stack logic in List is for using conveniently in echarts extensions, but it // That put stack logic in List is for using conveniently in echarts extensions, but it
// might not be a good way. // might not be a good way.
if (stackedDimInfo && (byIndex || stackedByDimInfo)) { if (stackedDimInfo) {
// Use a weird name that not duplicated with other names. // Use a weird name that not duplicated with other names.
stackResultDimension = '__\0ecstackresult'; stackResultDimension = '__\0ecstackresult';
stackedOverDimension = '__\0ecstackedover'; stackedOverDimension = '__\0ecstackedover';
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
<div id="main0"></div> <div id="main0"></div>
<div id="main1"></div> <div id="main1"></div>
<div id="main2"></div>
...@@ -400,5 +400,165 @@ ...@@ -400,5 +400,165 @@
</script> </script>
<script>
var chart;
var myChart;
var option;
require(['echarts'], function (echarts) {
var data = [
[["2016-10-4",44],["2016-10-5",54],["2016-10-6",47],["2016-10-7",37],["2016-10-8",36],["2016-10-9",30],["2016-10-10",20],["2016-10-11",21],["2016-10-12",29]],
[["2016-10-4",28],["2016-10-5",38],["2016-10-6",44],["2016-10-7",40],["2016-10-8",42],["2016-10-9",39],["2016-10-10",46],["2016-10-11",50],["2016-10-12",46]]
];
var option = {
legend: {
},
tooltip: {
triggerOn: 'none',
position: function (pt) {
return [pt[0], 130];
}
},
toolbox: {
left: 'center',
itemSize: 25,
top: 55,
feature: {
dataZoom: {
yAxisIndex: 'none'
},
restore: {}
}
},
xAxis: {
type: 'time',
axisPointer: {
value: '2016-10-7',
snap: true,
lineStyle: {
color: '#004E52',
opacity: 0.5,
width: 2
},
label: {
show: true,
formatter: function (params) {
return echarts.format.formatTime('yyyy-MM-dd', params.value);
},
backgroundColor: '#004E52'
},
handle: {
show: true,
color: '#004E52'
}
},
splitLine: {
show: false
}
},
yAxis: {
type: 'value',
axisTick: {
inside: true
},
splitLine: {
show: false
},
axisLabel: {
inside: true,
formatter: '{value}\n'
},
z: 10
},
grid: {
top: 110,
left: 15,
right: 15,
height: 160
},
dataZoom: [{
type: 'inside',
throttle: 50
}],
series: [
{
name:'line1',
type:'line',
smooth: true,
symbol: 'circle',
symbolSize: 5,
sampling: 'average',
itemStyle: {
normal: {
color: '#8ec6ad'
}
},
stack: 'a',
areaStyle: {
normal: {
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
offset: 0,
color: '#8ec6ad'
}, {
offset: 1,
color: '#ffe'
}])
}
},
data: data[0]
},
{
name:'line2',
type:'line',
smooth:true,
stack: 'a',
symbol: 'circle',
symbolSize: 5,
sampling: 'average',
itemStyle: {
normal: {
color: '#d68262'
}
},
areaStyle: {
normal: {
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
offset: 0,
color: '#d68262'
}, {
offset: 1,
color: '#ffe'
}])
}
},
data: data[1]
}
]
};
testHelper.create(echarts, 'main2', {
title: 'Stack on time axis (byIndex)',
option: option
});
});
</script>
</body> </body>
</html> </html>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册