提交 c570b50a 编写于 作者: O Ovilia

fix(fill-container): fix waterLevel bug when width is less than height in fill-container mode

上级 bc2cacfb
......@@ -6,6 +6,7 @@ module.exports = echarts.graphic.extendShape({
shape: {
waveLength: 0,
radius: 0,
radiusY: 0,
cx: 0,
cy: 0,
waterLevel: 0,
......@@ -15,6 +16,10 @@ module.exports = echarts.graphic.extendShape({
},
buildPath: function (ctx, shape) {
if (shape.radiusY == null) {
shape.radiusY = shape.radius;
}
/**
* We define a sine wave having 4 waves, and make sure at least 8 curves
* is drawn. Otherwise, it may cause blank area for some waves when
......@@ -78,8 +83,8 @@ module.exports = echarts.graphic.extendShape({
* 3. draws this line -> | | <- 1. draws this line
* ~~~~~~~~
*/
ctx.lineTo(waveRight + left, shape.cy - shape.radius);
ctx.lineTo(left, shape.cy - shape.radius);
ctx.lineTo(waveRight + left, shape.cy - shape.radiusY);
ctx.lineTo(left, shape.cy - shape.radiusY);
ctx.lineTo(left, shape.waterLevel);
}
else {
......@@ -93,8 +98,8 @@ module.exports = echarts.graphic.extendShape({
* |
* 2. draws this line
*/
ctx.lineTo(waveRight + left, shape.cy + shape.radius);
ctx.lineTo(left, shape.cy + shape.radius);
ctx.lineTo(waveRight + left, shape.cy + shape.radiusY);
ctx.lineTo(left, shape.cy + shape.radiusY);
ctx.lineTo(left, shape.waterLevel);
}
......
......@@ -67,8 +67,8 @@ echarts.extendChartView({
];
radius = [
innerRadius[0] - paddingRadius[0],
innerRadius[1] - paddingRadius[1]
Math.max(innerRadius[0] - paddingRadius[0], 0),
Math.max(innerRadius[1] - paddingRadius[1], 0)
];
}
else {
......@@ -100,7 +100,7 @@ echarts.extendChartView({
var wave = getWave(idx, false);
var waterLevel = wave.shape.waterLevel;
wave.shape.waterLevel = isFillContainer ? radius[1] : radius;
wave.shape.waterLevel = isFillContainer ? height / 2 : radius;
echarts.graphic.initProps(wave, {
shape: {
waterLevel: waterLevel
......@@ -139,6 +139,10 @@ echarts.extendChartView({
}
}
if (isFillContainer) {
shape.radiusY = height / 2;
}
// changes with animation
echarts.graphic.updateProps(waveElement, {
shape: shape,
......@@ -275,7 +279,7 @@ echarts.extendChartView({
*/
function getWave(idx, isInverse, oldWave) {
var radiusX = isFillContainer ? radius[0] : radius;
var radiusY = isFillContainer ? radius[1] : radius;
var radiusY = isFillContainer ? height / 2 : radius;
var itemModel = data.getItemModel(idx);
var itemStyleModel = itemModel.getModel('itemStyle');
......@@ -301,6 +305,7 @@ echarts.extendChartView({
shape: {
waveLength: waveLength,
radius: radiusX,
radiusY: radiusY,
cx: x,
cy: 0,
waterLevel: waterLevel,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册