fix: polyline with rect and radius=0 problem. chore: update hierarchy to solve the children ordering problem for indented tree layout.

This commit is contained in:
Yanyan-Wang 2020-08-17 17:46:39 +08:00 committed by Yanyan Wang
parent 275655a148
commit 0822fb19c9
4 changed files with 15 additions and 10 deletions

View File

@ -1,5 +1,5 @@
import { Point } from '@antv/g-base/lib/types';
import Hierarchy from '@antv/hierarchy';
import Hierarchy from '@antv/hierarchy/lib';
import { each, isString } from '@antv/util/lib';
import { ITreeGraph } from '../interface/graph';
import { GraphData, Item, NodeConfig, ShapeStyle, TreeGraphData, GraphOptions } from '../types';

View File

@ -35,6 +35,7 @@ Shape.registerEdge(
labelPosition: 'center',
drawShape(cfg: EdgeConfig, group: Group) {
const shapeStyle = (this as any).getShapeStyle(cfg);
if (shapeStyle.radius === 0) delete shapeStyle.radius;
const keyShape = group.addShape('path', {
className: 'edge-shape',
name: 'edge-shape',
@ -109,7 +110,8 @@ Shape.registerEdge(
polylinePoints = simplifyPolyline(
getPolylinePoints(points[0], points[points.length - 1], source, target, offset),
);
return getPathWithBorderRadiusByPolyline(polylinePoints, radius);
const res = getPathWithBorderRadiusByPolyline(polylinePoints, radius)
return res;
}
polylinePoints = getPolylinePoints(
points[0],

View File

@ -16,7 +16,9 @@ const substitute = (str: string, o: any): string => {
if (match.charAt(0) === '\\') {
return match.slice(1);
}
return o[name] || '';
let res = o[name];
if (res === 0) res = '0';
return res || '';
});
};

View File

@ -7,6 +7,7 @@ const data = {
{
id: '1',
name: 'name1',
size: [10, 20]
},
{
id: '2',
@ -131,16 +132,16 @@ const DagreLayout = () => {
ranksep: 70,
},
defaultNode: {
type: 'sql',
type: 'rect',
},
defaultEdge: {
type: 'cubic',
type: 'polyline',
style: {
radius: 20,
offset: 45,
endArrow: true,
lineWidth: 2,
stroke: '#C2C8D5',
radius: 0,
endArrow: {
path: 'M 0,0 L 0,4 L 8,-4 Z',
fill: '#ddd'
}
},
},
modes: {