MCPcopy Create free account
hub / github.com/apache/echarts / drawEdge

Function drawEdge

src/chart/tree/TreeView.ts:480–559  ·  view source on GitHub ↗
(
    seriesModel: TreeSeriesModel,
    node: TreeNode,
    virtualRoot: TreeNode,
    symbolEl: TreeSymbol,
    sourceOldLayout: TreeNodeLayout,
    sourceLayout: TreeNodeLayout,
    targetLayout: TreeNodeLayout,
    group: graphic.Group
)

Source from the content-addressed store, hash-verified

478}
479
480function drawEdge(
481 seriesModel: TreeSeriesModel,
482 node: TreeNode,
483 virtualRoot: TreeNode,
484 symbolEl: TreeSymbol,
485 sourceOldLayout: TreeNodeLayout,
486 sourceLayout: TreeNodeLayout,
487 targetLayout: TreeNodeLayout,
488 group: graphic.Group
489) {
490 const itemModel = node.getModel<TreeSeriesNodeItemOption>();
491 const edgeShape = seriesModel.get('edgeShape');
492 const layout = seriesModel.get('layout');
493 const orient = seriesModel.getOrient();
494 const curvature = seriesModel.get(['lineStyle', 'curveness']);
495 const edgeForkPosition = seriesModel.get('edgeForkPosition');
496 const lineStyle = itemModel.getModel('lineStyle').getLineStyle();
497 let edge = symbolEl.__edge;
498 // curve edge from node -> parent
499 // polyline edge from node -> children
500 if (edgeShape === 'curve') {
501 if (node.parentNode && node.parentNode !== virtualRoot) {
502 if (!edge) {
503 edge = symbolEl.__edge = new graphic.BezierCurve({
504 shape: getEdgeShape(layout, orient, curvature, sourceOldLayout, sourceOldLayout)
505 });
506 }
507
508 graphic.updateProps(edge as Path, {
509 shape: getEdgeShape(layout, orient, curvature, sourceLayout, targetLayout)
510 }, seriesModel);
511 }
512 }
513 else if (edgeShape === 'polyline') {
514 if (layout === 'orthogonal') {
515 if (node !== virtualRoot && node.children && (node.children.length !== 0) && (node.isExpand === true)) {
516 const children = node.children;
517 const childPoints = [];
518 for (let i = 0; i < children.length; i++) {
519 const childLayout = children[i].getLayout();
520 childPoints.push([childLayout.x, childLayout.y]);
521 }
522
523 if (!edge) {
524 edge = symbolEl.__edge = new TreePath({
525 shape: {
526 parentPoint: [targetLayout.x, targetLayout.y],
527 childPoints: [[targetLayout.x, targetLayout.y]],
528 orient: orient,
529 forkPosition: edgeForkPosition
530 }
531 });
532 }
533 graphic.updateProps(edge as Path, {
534 shape: {
535 parentPoint: [targetLayout.x, targetLayout.y],
536 childPoints: childPoints
537 }

Callers 1

updateNodeFunction · 0.85

Calls 9

setStatesStylesFromModelFunction · 0.90
setDefaultStateProxyFunction · 0.90
getEdgeShapeFunction · 0.85
getLineStyleMethod · 0.80
getLayoutMethod · 0.65
getModelMethod · 0.45
getMethod · 0.45
getOrientMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected