How to create a diagram connector as Arc?

Hi Syncfusion Support Team!
I want to insert a diagram connector as ARC in diagram control from symbol palette as below image
Image_7381_1721797381491
I have used the connector with the 'Bezier' type to create connector but it's not working
I cannot create a connector as Arc 
Image_4696_1721797357556

Do you have any solution to do this one?
Please help me
Thanks!
Sy


7 Replies

VG Vivisa Ganesan Syncfusion Team July 25, 2024 03:05 PM UTC

Hi,

Currently we don’t have support to render arc connector. We have logged it as a feature, we don’t have any immediate plan to implement this feature. We are closing this forum now. You can communicate with us or track the status of the feature using the below feedback link.


https://www.syncfusion.com/feedback/59859/support-to-render-the-arc-connector


Regards,

Vivisa



PV Pham Van Sy replied to Vivisa Ganesan July 26, 2024 03:04 AM UTC

Thank for your reply

I know, although you don't support creating the connector as an Arc, but do you have any way to create arc from the available entities?

For example, I have used devexpress library to created points close together and connect these points to create a polyline, base on the trajectory of a circle
Image_5032_1721962272418

I have tried using syncfusion library in the same way, but the results did not meet my expectations

Below is my code I have implemented

const segments = generatePoints(100, 100);
  console.log(segments);
  let width = 150;
  let height = 80;
  let labelsShape =
    {
      id: 'informationlabel',
      addInfo: { menuId: "edit", title: 'Information Label', tooltip: 'Information Label' },
      type: 'polyline',
      sourcePoint: {
        x: 0,
        y: 0,
      },
      targetPoint: {
        x: 100.0,
        y: 100.0,
      },
      segments: segments,
      targetDecorator: {
        shape: 'Arrow',
        style: {
          fill: 'black',
          strokeColor: 'black'
        }
      },
      annotations: [
        {
          content: "Label",
          alignment: "Before"
        },
      ],

      tooltip: {
        content: 'Show More Entity Info',
        position: 'RightCenter'
      },
      style: {
        fill: 'black',
        strokeColor: 'black',
        strokeWidth: 1
      },
      constraints: ConnectorConstraints.Tooltip | ConnectorConstraints.Default | ConnectorConstraints.AllowDrop,
      with: 100,
      height: 100
    };
export function generatePoints(width: number, height: number): StraightSegmentModel[]
{
  let segments: StraightSegmentModel[] = [];
  const angpha = Math.PI / 40;

  let startSegment: PointModel = {};
  startSegment.x = 0.0;
  startSegment.y = 0.0;

  for (let i = 1; i < 20; i++) {
    const xValue = startSegment.x + width * Math.cos(Math.PI * 0.5 - angpha * i);
    const yValue = startSegment.y + height - height * Math.sin(Math.PI * 0.5 - angpha * i);

    const seg: any = {
      type: 'Straight',
      point: { x: xValue, y: yValue }
    };
    segments.push(seg);

    startSegment.x = xValue;
    startSegment.y = yValue;
  }

  return segments;
}

Please let me know your comments

Thanks!

Sy



VG Vivisa Ganesan Syncfusion Team July 26, 2024 11:47 AM UTC

Hi,

On further analysis, we don’t have any workaround for arc connector. As said earlier, we consider it as a feature request. We have checked with our freehand and polyline connector but still could not achieve the expected output. Please find the sample below for your reference.

Sample:

https://stackblitz.com/edit/angular-j6sa6q?file=src%2Fapp.component.html,src%2Fapp.component.ts


Regards,

Vivisa



PV Pham Van Sy replied to Vivisa Ganesan July 26, 2024 03:13 PM UTC

Hi Vivisa

As you can see on below image. I can create a connector as arc
Image_7017_1722005872130
I have added my code into your sample, it's  can create a connector as arc

import { ComponentViewEncapsulationViewChild } from '@angular/core';
import { ChangeEventArgs as CheckBoxChangeEventArgs } from '@syncfusion/ej2-buttons';
import {
  DiagramComponent,
  NodeModel,
  ConnectorModel,
  NodeConstraints,
  BasicShapeModel,
  SnapSettingsModel,
  SnapConstraints,
  GradientType,
  GradientModel,
  LinearGradientModel,
  RadialGradientModel,
  DiagramModule,
from '@syncfusion/ej2-angular-diagrams';

import { CheckBoxModule } from '@syncfusion/ej2-angular-buttons';
import { StraightSegmentModelPointModel } from '@syncfusion/ej2-angular-diagrams';

/**
 * Sample for Nodes Component
 */

 @Component({
  selector: 'app-root',
  templateUrl: 'app.component.html',
  styleUrls: ['app.component.css'],
  encapsulation: ViewEncapsulation.None,
  standalone: true,
  imports: [DiagramModuleCheckBoxModule],
})
export class AppComponent {
  @ViewChild('diagram'public diagramDiagramComponent;

  public shapeTypeBasicShapeModel = { type: 'Basic'shape: 'Ellipse' };

  public nodeDefaults(objNodeModel): NodeModel {
    obj.style = { fill: '#37909A'strokeColor: '#024249' };
    obj.annotations[0].margin = { left: 10right: 10 };
    obj.annotations[0].style = {
      color: 'white',
      fill: 'none',
      strokeColor: 'none',
    };
    return obj;
  }

  public connDefaults(objConnectorModel): void {
    obj.targetDecorator.style = { fill: '#024249'strokeColor: '#024249' };
    obj.style = { strokeColor: '#024249'strokeWidth: 2 };
  }

  public segments = this.generatePoints(100100);

  public connectorsConnectorModel[] = [
    {
      id: 'connector1',
      type: 'Bezier',
      sourcePoint: { x: 100y: 100 },
      targetPoint: { x: 200y: 200 },
      segments: [
        {
          type: 'Bezier',
          point1: { x: 150y: 50 },
          point2: { x: 250y: 150 },
        },
      ],
      style: {
        strokeColor: '#6BA5D7',
        strokeWidth: 2,
      },
      targetDecorator: {
        shape: 'Arrow',
        style: { fill: '#6BA5D7'strokeColor: '#6BA5D7' },
      },
      annotations: [
        { content: 'Communicate'offset: 0.5alignment: 'Before' },
      ],
    },
    {
      id: 'connector2',
      type: 'Bezier',
      sourcePoint: { x: 100y: 300 },
      targetPoint: { x: 200y: 400 },
      segments: [
        {
          type: 'Bezier',
          point1: { x: 150y: 250 },
          point2: { x: 250y: 350 },
        },
      ],
      style: {
        strokeColor: '#6BA5D7',
        strokeWidth: 2,
      },
      targetDecorator: {
        shape: 'Arrow',
        style: { fill: '#6BA5D7'strokeColor: '#6BA5D7' },
      },
      annotations: [{ content: 'Label'offset: 0.5alignment: 'Before' }],
    },
    {
      id: 'informationlabel',
      type: 'Straight',
      segments: this.segments,
      sourcePoint: {
        x: 0,
        y: 0,
      },
      targetPoint: {
        x: 100,
        y: 100,
      },
      targetDecorator: {
        shape: 'Arrow',
        style: {
          fill: 'black',
          strokeColor: 'black'
        }
      },
      annotations: [
        {
          content: "Label",
          alignment: "Before"
        },
      ],

      tooltip: {
        content: 'Show More Entity Info',
        position: 'RightCenter'
      },
      style: {
        fill: 'black',
        strokeColor: 'black',
        strokeWidth: 1
      }
    }
  ];

public generatePoints(widthnumberheightnumber): StraightSegmentModel[]
 {
   let segmentsStraightSegmentModel[] = [];
   const angpha = Math.PI / 40;
 
   let startSegmentPointModel = {};
   startSegment.x = 0.0;
   startSegment.y = 0.0;

   for (let i = 1i < 20i++) {
     const xValue = width * Math.cos(Math.PI * 0.5 - angpha * i);
     const yValue = height - height * Math.sin(Math.PI * 0.5 - angpha * i);
 
     const segStraightSegmentModel = {
       type: 'Straight',
       point: { x: xValuey: yValue }
     };
     segments.push(seg);
 
     startSegment.x = xValue;
     startSegment.y = yValue;
   }
 
   return segments;
 }
}


But when I add this code into my project and when I drag and drop arc object from symbol palette, the results is not good, the start and end points is incorrect

Image_3894_1722006352841


Do you know what's the cause of this problem?
Thanks!
Sy



VG Vivisa Ganesan Syncfusion Team July 29, 2024 01:53 PM UTC

Hi,

We have created a sample to render an arc connector using Syncfusion's diagram component. This is achieved by utilizing Bezier vector points to form the arc. In the palette we rendered the connector as the image node. When dragging and dropping from the palette, drop event gets triggered. In this event, we remove the dropped node and create a new one using the add method. Refer to the sample and code snippet below.


Code-snippet:


   public drop(arg: IDropEventArgs): void {

    if ((arg.element as any).shape.type === 'Image') {

      arg.cancel = true;

      let connector = {

        id: 'connector1',

        type: 'Bezier',

        sourcePoint: { x: 200, y: 100 },

        targetPoint: { x: 400, y: 300 },

        constraints:

          ConnectorConstraints.Default | ConnectorConstraints.DragSegmentThumb,

        segments: [

          {

            type: 'Bezier',

            vector1: {

              distance: 150,

              angle: 350,

            },

            vector2: {

              distance: 150,

              angle: 290,

            },

          },

        ],

        bezierSettings: {

          controlPointsVisibility:

            ControlPointsVisibility.Source | ControlPointsVisibility.Target,

        },

      };

      this.diagram.add(connector);

    }

  }

 


UG: https://ej2.syncfusion.com/angular/documentation/diagram/connectors#bezier


Sample:

https://stackblitz.com/edit/angular-hwez84-kzj23t?file=src%2Fapp.component.html,src%2Fapp.component.ts


Regards,


Vivisa



PV Pham Van Sy July 29, 2024 02:53 PM UTC

Thank for your solution
I will try it and get back to you if have any questions
Thanks!

Sy



VG Vivisa Ganesan Syncfusion Team July 30, 2024 04:34 AM UTC

Hi,

Thank you for the update. We will wait for your response.


Regards,

Vivisa


Loader.
Up arrow icon