未验证 提交 ea5a850a 编写于 作者: Y Yi Shen 提交者: GitHub

Merge pull request #14813 from apache/fix-line-clip

fix(clip): line chart will throw an error when `clip` is set as `false`.
......@@ -980,31 +980,33 @@ class LineView extends ChartView {
let start;
let end;
let current;
if (isCoordSysPolar) {
const polarClip = clipShape as PolarArea;
const coord = (coordSys as Polar).pointToCoord(point);
if (isHorizontalOrRadial) {
start = polarClip.startAngle;
end = polarClip.endAngle;
current = -coord[1] / 180 * Math.PI;
}
else {
start = polarClip.r0;
end = polarClip.r;
current = coord[0];
}
}
else {
const gridClip = clipShape as Cartesian2DArea;
if (isHorizontalOrRadial) {
start = gridClip.x;
end = gridClip.x + gridClip.width;
current = symbol.x;
if (clipShape) {
if (isCoordSysPolar) {
const polarClip = clipShape as PolarArea;
const coord = (coordSys as Polar).pointToCoord(point);
if (isHorizontalOrRadial) {
start = polarClip.startAngle;
end = polarClip.endAngle;
current = -coord[1] / 180 * Math.PI;
}
else {
start = polarClip.r0;
end = polarClip.r;
current = coord[0];
}
}
else {
start = gridClip.y + gridClip.height;
end = gridClip.y;
current = symbol.y;
const gridClip = clipShape as Cartesian2DArea;
if (isHorizontalOrRadial) {
start = gridClip.x;
end = gridClip.x + gridClip.width;
current = symbol.x;
}
else {
start = gridClip.y + gridClip.height;
end = gridClip.y;
current = symbol.y;
}
}
}
let ratio = end === start ? 0 : (current - start) / (end - start);
......
......@@ -1391,5 +1391,37 @@ under the License.
})
</script>
<div class="chart" id="line-clip"></div>
<script>
require([
'echarts'
], function (echarts) {
var option = {
xAxis: {
type: 'category',
boundaryGap: false,
data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
},
yAxis: {
type: 'value'
},
series: [{
data: [820, 932, 901, 934, 1290, 1330, 1320],
type: 'line',
areaStyle: {},
clip: false
}]
};
var chart = testHelper.create(echarts, 'line-clip', {
title: [
'The line chart should be rendered without any error in console when `**clip**` is set as `**false**`'
],
option: option,
height: 400
});
});
</script>
</body>
</html>
\ No newline at end of file
</html>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册