From b52f70888bf1a2e8400c236463bb2f14087cde94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=B4=A2=E4=B8=98?= Date: Mon, 18 May 2020 14:24:12 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0geom=20draw=20?= =?UTF-8?q?=E4=BA=8B=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/chart/chart.js | 6 +++++- src/chart/const.js | 4 ++++ src/chart/controller/scale.js | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/chart/chart.js b/src/chart/chart.js index 69e1dabb8..200089fc6 100644 --- a/src/chart/chart.js +++ b/src/chart/chart.js @@ -6,6 +6,8 @@ import { EVENT_AFTER_DATA_CHANGE, EVENT_AFTER_SIZE_CHANGE, EVENT_AFTER_GEOM_INIT, + EVENT_BEFORE_GEOM_DRAW, + EVENT_AFTER_GEOM_DRAW, EVENT_CLEAR, EVENT_CLEAR_INNER } from './const'; @@ -592,12 +594,14 @@ class Chart extends Base { middlePlot.attr('clip', clip); } + this.emit(EVENT_BEFORE_GEOM_DRAW); for (let i = 0, length = geoms.length; i < length; i++) { const geom = geoms[i]; geom.paint(); } - + this.emit(EVENT_AFTER_GEOM_DRAW); Chart.plugins.notify(this, 'afterGeomDraw'); + canvas.sort(); this.get('frontPlot').sort(); Chart.plugins.notify(this, 'beforeCanvasDraw'); diff --git a/src/chart/const.js b/src/chart/const.js index 90d4e97a5..424b3f180 100644 --- a/src/chart/const.js +++ b/src/chart/const.js @@ -9,6 +9,8 @@ const EVENT_AFTER_DATA_CHANGE = 'afterdatachange'; const EVENT_AFTER_SIZE_CHANGE = '_aftersizechange'; const EVENT_AFTER_GEOM_INIT = '_aftergeominit'; +const EVENT_BEFORE_GEOM_DRAW = 'beforegeomdraw'; +const EVENT_AFTER_GEOM_DRAW = 'aftergeomdraw'; const EVENT_CLEAR = 'clear'; const EVENT_CLEAR_INNER = 'clearinner'; @@ -21,6 +23,8 @@ export { EVENT_AFTER_DATA_CHANGE, EVENT_AFTER_SIZE_CHANGE, EVENT_AFTER_GEOM_INIT, + EVENT_BEFORE_GEOM_DRAW, + EVENT_AFTER_GEOM_DRAW, EVENT_CLEAR, EVENT_CLEAR_INNER }; diff --git a/src/chart/controller/scale.js b/src/chart/controller/scale.js index 5830765bd..0c8b8e5d1 100644 --- a/src/chart/controller/scale.js +++ b/src/chart/controller/scale.js @@ -129,7 +129,7 @@ class ScaleController { } } else { // 为了让图形居中,所以才设置range - offset = 1 / count * 1 / 2; + offset = 1 / count * 0.5; // 这里可能用0.25会更合理 cfg.range = [ offset, 1 - offset ]; } }