This is an automated email from the ASF dual-hosted git repository. sushuang pushed a commit to branch release in repository https://gitbox.apache.org/repos/asf/incubator-echarts.git
The following commit(s) were added to refs/heads/release by this push: new 04c3d88 tweak: clip rect in custom series. 04c3d88 is described below commit 04c3d887ea8fe9a7cb02dedcf196d15da45bd41c Author: sushuang <sushuang0...@gmail.com> AuthorDate: Thu Sep 6 05:30:34 2018 +0800 tweak: clip rect in custom series. --- src/util/graphic.js | 4 ++++ test/custom.html | 26 ++++++++++++++------------ 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/src/util/graphic.js b/src/util/graphic.js index a6e9dd2..20beb9c 100644 --- a/src/util/graphic.js +++ b/src/util/graphic.js @@ -1077,6 +1077,8 @@ export function groupTransition(g1, g2, animatableModel, cb) { * @return {Array.<Array.<number>>} A new clipped points. */ export function clipPointsByRect(points, rect) { + // FIXME: this way migth be incorrect when grpahic clipped by a corner. + // and when element have border. return zrUtil.map(points, function (point) { var x = point[0]; x = mathMax(x, rect.x); @@ -1099,6 +1101,8 @@ export function clipRectByRect(targetRect, rect) { var y = mathMax(targetRect.y, rect.y); var y2 = mathMin(targetRect.y + targetRect.height, rect.y + rect.height); + // If the total rect is cliped, nothing, including the border, + // should be painted. So return undefined. if (x2 >= x && y2 >= y) { return { x: x, diff --git a/test/custom.html b/test/custom.html index d0f8074..b778da9 100644 --- a/test/custom.html +++ b/test/custom.html @@ -132,19 +132,21 @@ under the License. var end = api.coord([api.value(2), categoryIndex]); var height = api.size([0, 1])[1] * 0.6; - return { + var rectShape = echarts.graphic.clipRectByRect({ + x: start[0], + y: start[1] - height / 2, + width: end[0] - start[0], + height: height + }, { + x: params.coordSys.x, + y: params.coordSys.y, + width: params.coordSys.width, + height: params.coordSys.height + }); + + return rectShape && { type: 'rect', - shape: echarts.graphic.clipRectByRect({ - x: start[0], - y: start[1] - height / 2, - width: end[0] - start[0], - height: height - }, { - x: params.coordSys.x, - y: params.coordSys.y, - width: params.coordSys.width, - height: params.coordSys.height - }), + shape: rectShape, style: api.style() }; } --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@echarts.apache.org For additional commands, e-mail: commits-h...@echarts.apache.org