From 5b791d7ca67f08ecc80b5cbbd3e55225c682dd92 Mon Sep 17 00:00:00 2001 From: lang Date: Thu, 7 Jan 2016 20:08:43 +0800 Subject: [PATCH] MarkPoint symbolSize support function --- src/chart/line/LineView.js | 31 ++++++++++++++++++++------- src/component/marker/MarkPointView.js | 9 +++++++- 2 files changed, 31 insertions(+), 9 deletions(-) diff --git a/src/chart/line/LineView.js b/src/chart/line/LineView.js index b90204e17..4c8735743 100644 --- a/src/chart/line/LineView.js +++ b/src/chart/line/LineView.js @@ -92,22 +92,37 @@ define(function(require) { function createGridClipShape(cartesian, hasAnimation, seriesModel) { var xExtent = getAxisExtentWithGap(cartesian.getAxis('x')); var yExtent = getAxisExtentWithGap(cartesian.getAxis('y')); - + var isHorizontal = cartesian.getBaseAxis().isHorizontal(); + + var x = xExtent[0]; + var y = yExtent[0]; + var width = xExtent[1] - x; + var height = yExtent[1] - y; + // Expand clip shape to avoid line value exceeds axis + if (isHorizontal) { + height *= 10; + y -= height / 2; + } + else { + width *= 10; + x -= width / 2; + } + isHorizontal ? (height *= 10) : (width *= 10); var clipPath = new graphic.Rect({ shape: { - x: xExtent[0], - y: yExtent[0], - width: xExtent[1] - xExtent[0], - height: yExtent[1] - yExtent[0] + x: x, + y: y, + width: width, + height: height } }); if (hasAnimation) { - clipPath.shape[cartesian.getBaseAxis().isHorizontal() ? 'width' : 'height'] = 0; + clipPath.shape[isHorizontal ? 'width' : 'height'] = 0; graphic.initProps(clipPath, { shape: { - width: xExtent[1] - xExtent[0], - height: yExtent[1] - yExtent[0] + width: width, + height: height } }, seriesModel); } diff --git a/src/component/marker/MarkPointView.js b/src/component/marker/MarkPointView.js index 9b03e8884..8f41b9b5f 100644 --- a/src/component/marker/MarkPointView.js +++ b/src/component/marker/MarkPointView.js @@ -104,8 +104,15 @@ define(function (require) { mpData.setItemLayout(idx, point); + var symbolSize = itemModel.getShallow('symbolSize'); + if (typeof symbolSize === 'function') { + // FIXME 这里不兼容 ECharts 2.x,2.x 貌似参数是整个数据? + symbolSize = symbolSize( + mpModel.getRawValue(idx), mpModel.getDataParams(idx) + ); + } mpData.setItemVisual(idx, { - symbolSize: itemModel.getShallow('symbolSize'), + symbolSize: symbolSize, color: itemModel.get('itemStyle.normal.color') || seriesData.getVisual('color'), symbol: itemModel.getShallow('symbol') -- GitLab