From fee48f03aee254c3ea7586f96c7e29a8bad4cb7d Mon Sep 17 00:00:00 2001 From: TomHuangCN <418466938@qq.com> Date: Fri, 10 Aug 2018 11:26:56 +0800 Subject: [PATCH] export polyline config --- demos/gallery-Indicator-card.html | 3 +++ plugins/edge.polyline/index.js | 15 +++++---------- src/graph.js | 2 +- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/demos/gallery-Indicator-card.html b/demos/gallery-Indicator-card.html index 0af03f8600..0c1c248eea 100644 --- a/demos/gallery-Indicator-card.html +++ b/demos/gallery-Indicator-card.html @@ -72,6 +72,9 @@ [0.5, 1] ] }); + G6.registerEdge('polyline', { + offset: 20 + }); const data = { roots: [{ main: '主指标一', diff --git a/plugins/edge.polyline/index.js b/plugins/edge.polyline/index.js index 2b337a341b..800980c3a6 100644 --- a/plugins/edge.polyline/index.js +++ b/plugins/edge.polyline/index.js @@ -6,11 +6,6 @@ const G6 = require('@antv/g6'); const Util = G6.Util; -const DEFAULT_STYLE = { - offset: 10, - borderRadius: 10 -}; - function isHorizontalPort(port, bbox) { const dx = Math.abs(port.x - bbox.centerX); const dy = Math.abs(port.y - bbox.centerY); @@ -416,6 +411,7 @@ function getPathWithBorderRadiusByPolyline(points, borderRadius) { } G6.registerEdge('polyline', { + offset: 10, getPath(item) { const points = item.getPoints(); const source = item.getSource(); @@ -423,21 +419,20 @@ G6.registerEdge('polyline', { return this.getPathByPoints(points, source, target); }, getPathByPoints(points, source, target) { - const { offset } = Util.merge({}, DEFAULT_STYLE); - const polylinePoints = getPolylinePoints(points[0], points[points.length - 1], source, target, offset); + const polylinePoints = getPolylinePoints(points[0], points[points.length - 1], source, target, this.offset); // FIXME default return Util.pointsToPolygon(polylinePoints); } }); G6.registerEdge('polyline-round', { + borderRadius: 10, getPathByPoints(points, source, target) { - const { offset, borderRadius } = Util.merge({}, DEFAULT_STYLE); const polylinePoints = simplifyPolyline( - getPolylinePoints(points[0], points[points.length - 1], source, target, offset) + getPolylinePoints(points[0], points[points.length - 1], source, target, this.offset) ); // FIXME default - return getPathWithBorderRadiusByPolyline(polylinePoints, borderRadius); + return getPathWithBorderRadiusByPolyline(polylinePoints, this.borderRadius); } }, 'polyline'); diff --git a/src/graph.js b/src/graph.js index 4da4201a52..a182095c82 100755 --- a/src/graph.js +++ b/src/graph.js @@ -91,7 +91,7 @@ class Graph extends Base { * renderer canvas or svg * @type {string} */ - renderer: 'canvas', + renderer: 'svg', _controllers: {}, _timers: {},