export polyline config

This commit is contained in:
huangtong.ht 2018-08-10 11:26:56 +08:00
parent d639057e03
commit 731b17da86
3 changed files with 9 additions and 11 deletions

View File

@ -72,6 +72,9 @@
[0.5, 1]
]
});
G6.registerEdge('polyline', {
offset: 20
});
const data = {
roots: [{
main: '主指标一',

View File

@ -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');

View File

@ -91,7 +91,7 @@ class Graph extends Base {
* renderer canvas or svg
* @type {string}
*/
renderer: 'canvas',
renderer: 'svg',
_controllers: {},
_timers: {},