Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@(Html.EJS().Diagram("container").Width("100%").Height("580px"))
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Syncfusion.EJ2.Diagrams;
using System.Drawing;

namespace EJ2MVCSampleBrowser.Controllers.Diagram
{
public partial class DiagramController : Controller
{
public ActionResult Nodes()
{
List<DiagramNode> nodes = new List<DiagramNode>();
List<DiagramNodeAnnotation> annotation1 = new List<DiagramNodeAnnotation>();
annotation1.Add(new DiagramNodeAnnotation()
{
Content = "node1",
});
List<DiagramNodeAnnotation> annotation2 = new List<DiagramNodeAnnotation>();
annotation2.Add(new DiagramNodeAnnotation()
{
Content = "node2",
});
nodes.Add(new DiagramNode()
{
Id = "sourcenode",
Width = 150,
Height = 50,
Style = new NodeStyleNodes()
{
Fill = "#6BA5D7",
StrokeColor = "white",
},
OffsetX = 350,
OffsetY = 50,
Annotations = annotation1,
});
nodes.Add(new DiagramNode()
{
Id = "targetnode",
Width = 150,
Height = 50,
Style = new NodeStyleNodes()
{
Fill = "#6BA5D7",
StrokeColor = "white",
},
OffsetX = 200,
OffsetY = 250,
Annotations = annotation2,
});
ViewBag.nodes = nodes;
List<DiagramConnector> connectors = new List<DiagramConnector>();
connectors.Add(new DiagramConnector()
{
Id = "connector1",
SourceID = "sourcenode",
TargetID = "targetnode",
Type = Segments.Orthogonal,
Segments = new List<ConnectorSegment>
{
new ConnectorSegment { Type = Segments.Orthogonal, Direction = "Left", Length = 100 },
new ConnectorSegment { Type = Segments.Orthogonal, Direction = "Bottom", Length = 100 },
new ConnectorSegment { Type = Segments.Orthogonal, Direction = "Right", Length = 100 },
new ConnectorSegment { Type = Segments.Orthogonal, Direction = "Bottom", Length = 50 },
},
});
ViewBag.connectors = connectors;
return View();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<ejs-diagram id="container" width="100%" height="700px" connectors="@ViewBag.connectors" nodes="@ViewBag.nodes">
</ejs-diagram>
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
@(Html.EJS().Diagram("container").Width("100%").Height("580px"))
@(Html.EJS().Diagram("container").Width("100%").Height("580px"))

Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Syncfusion.EJ2.Diagrams;
using System.Drawing;

namespace EJ2MVCSampleBrowser.Controllers.Diagram
{
public partial class DiagramController : Controller
{
public ActionResult Nodes()
{
List<DiagramNode> flowShapes = new List<DiagramNode>();
flowShapes.Add(new DiagramNode() { Id = "Terminator", Shape = new DiagramFlowShape() { Type = Syncfusion.EJ2.Diagrams.Shapes.Flow, Shape = FlowShapes.Terminator } });
flowShapes.Add(new DiagramNode() { Id = "Process", Shape = new DiagramFlowShape() { Type = Syncfusion.EJ2.Diagrams.Shapes.Flow, Shape = FlowShapes.Process } });
flowShapes.Add(new DiagramNode() { Id = "Decision", Shape = new DiagramFlowShape() { Type = Syncfusion.EJ2.Diagrams.Shapes.Flow, Shape = FlowShapes.Decision } });
flowShapes.Add(new DiagramNode() { Id = "Document", Shape = new DiagramFlowShape() { Type = Syncfusion.EJ2.Diagrams.Shapes.Flow, Shape = FlowShapes.Document } });
flowShapes.Add(new DiagramNode() { Id = "PreDefinedProcess", Shape = new DiagramFlowShape() { Type = Syncfusion.EJ2.Diagrams.Shapes.Flow, Shape = FlowShapes.PreDefinedProcess } });
flowShapes.Add(new DiagramNode() { Id = "DirectData", Shape = new DiagramFlowShape() { Type = Syncfusion.EJ2.Diagrams.Shapes.Flow, Shape = FlowShapes.DirectData } });
flowShapes.Add(new DiagramNode() { Id = "SequentialData", Shape = new DiagramFlowShape() { Type = Syncfusion.EJ2.Diagrams.Shapes.Flow, Shape = FlowShapes.SequentialData } });
flowShapes.Add(new DiagramNode() { Id = "Sort", Shape = new DiagramFlowShape() { Type = Syncfusion.EJ2.Diagrams.Shapes.Flow, Shape = FlowShapes.Sort } });
ViewBag.flowShapes = flowShapes;

List<DiagramNode> basicShapes = new List<DiagramNode>();
basicShapes.Add(new DiagramNode() { Id = "Rectangle", Shape = new DiagramBasicShape() { Type = Syncfusion.EJ2.Diagrams.Shapes.Basic, Shape = BasicShapes.Rectangle } });
basicShapes.Add(new DiagramNode() { Id = "Ellipse", Shape = new DiagramBasicShape() { Type = Syncfusion.EJ2.Diagrams.Shapes.Basic, Shape = BasicShapes.Ellipse } });
basicShapes.Add(new DiagramNode() { Id = "Hexagon", Shape = new DiagramBasicShape() { Type = Syncfusion.EJ2.Diagrams.Shapes.Basic, Shape = BasicShapes.Hexagon } });
basicShapes.Add(new DiagramNode() { Id = "Star", Shape = new DiagramBasicShape() { Type = Syncfusion.EJ2.Diagrams.Shapes.Basic, Shape = BasicShapes.Star } });
basicShapes.Add(new DiagramNode() { Id = "Diamond", Shape = new DiagramBasicShape() { Type = Syncfusion.EJ2.Diagrams.Shapes.Basic, Shape = BasicShapes.Diamond } });
basicShapes.Add(new DiagramNode() { Id = "Pentagon", Shape = new DiagramBasicShape() { Type = Syncfusion.EJ2.Diagrams.Shapes.Basic, Shape = BasicShapes.Pentagon } });
basicShapes.Add(new DiagramNode() { Id = "Heptagon", Shape = new DiagramBasicShape() { Type = Syncfusion.EJ2.Diagrams.Shapes.Basic, Shape = BasicShapes.Heptagon } });
ViewBag.basicShapes = basicShapes;

List<SymbolPalettePalette> palettes = new List<SymbolPalettePalette>();
palettes.Add(new SymbolPalettePalette() { Id = "flow", Expanded = true, Symbols = flowShapes, Title = "Flow Shapes" });
palettes.Add(new SymbolPalettePalette() { Id = "basic", Expanded = true, Symbols = basicShapes, Title = "Basic Shapes" });
ViewBag.palettes = palettes;
ViewBag.getSymbolInfo = "getSymbolInfo";
return View();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<ejs-symbolpalette id="symbolpalette" width="700px" height="300px" getSymbolInfo="@ViewBag.getSymbolInfo"
getNodeDefaults="@ViewBag.getNodeDefaults" palettes="@ViewBag.palettes"
symbolMargin="new SymbolPaletteMargin() { Left=15,Right=15,Top=15,Bottom=15}" symbolHeight="70" symbolWidth="70"
expandMode="@ViewBag.Multiple">
</ejs-symbolpalette>
40 changes: 40 additions & 0 deletions ej2-asp-core-mvc/diagram/connectors.md
Original file line number Diff line number Diff line change
Expand Up @@ -876,6 +876,46 @@ The connectors [`zIndex`](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusi
{% endtabs %}
{% endif %}

## Undo/Redo support for connector segments

The Diagram control provides comprehensive undo and redo functionality for all connector segment operations. This includes reversible actions such as dragging, resizing, and rotating source or target nodes, as well as modifying segment points and endpoints.

Key undo/redo capabilities include:

* Modifying and adjusting segment points.
* Changing connector endpoints between nodes or ports.
* Performing node operations that affect connected segments.
* Adding, removing, or reordering segments.

This functionality ensures consistent editing behavior across all connector types and interactions, enabling users to experiment with complex routing configurations while retaining the ability to revert changes.

The following example demonstrates undo and redo functionality for connector segments:

{% if page.publishingplatform == "aspnet-core" %}

{% tabs %}
{% highlight cshtml tabtitle="CSHTML" %}
{% include code-snippet/diagram/connectors/connectors-segundo/tagHelper %}
{% endhighlight %}
{% highlight c# tabtitle="segment.cs" %}
{% include code-snippet/diagram/connectors/connectors-segundo/segment.cs %}
{% endhighlight %}
{% endtabs %}

{% elsif page.publishingplatform == "aspnet-mvc" %}

{% tabs %}
{% highlight c# tabtitle="segment.cs" %}
{% include code-snippet/diagram/connectors/connectors-segundo/segment.cs %}
{% endhighlight %}
{% endtabs %}
{% endif %}

``` javascript
var diagram = document.getElementById("container").ej2_instances[0];
diagram.undo();
diagram.redo();
```


## See Also
Expand Down
43 changes: 43 additions & 0 deletions ej2-asp-core-mvc/diagram/symbol-palette.md
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,49 @@ Here, the code provided below demonstrates how to define tooltip content to symb
{% endif %}


### How to enable or disable the default tooltip for shapes in the symbol palette

By default, the symbol ID is displayed as a tooltip when hovering over a symbol in the Symbol Palette. To disable this default tooltip, you can use the [`showTooltip`](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Diagrams.SymbolPalette.html#Syncfusion_EJ2_Diagrams_SymbolPalette_SymbolInfo) property within the `getSymbolInfo` method. The `showTooltip` property is set to **true** by default, which enables the tooltip.

The following example demonstrates how to configure selective tooltip display:

{% if page.publishingplatform == "aspnet-core" %}

{% tabs %}
{% highlight cshtml tabtitle="CSHTML" %}
{% include code-snippet/diagram/symbol-palette/defaulttooltip/tagHelper %}
{% endhighlight %}
{% highlight c# tabtitle="Description.cs" %}
{% include code-snippet/diagram/symbol-palette/defaulttooltip/description.cs %}
{% endhighlight %}
{% endtabs %}

{% elsif page.publishingplatform == "aspnet-mvc" %}

{% tabs %}
{% highlight c# tabtitle="Description.cs" %}
{% include code-snippet/diagram/symbol-palette/defaulttooltip/description.cs %}
{% endhighlight %}
{% endtabs %}
{% endif %}

```javascript

function getNodeDefaults(symbol) {
symbol.style = {
strokeColor = '#6495ED',
fill = '#6495ED'
};
}
function getSymbolInfo(symbol) {
return { showTooltip: true };
}

```

N> This property is effective only when tooltip constraints are disabled for the symbol palette element.


### How to provide different tooltip for Symbol palette and diagram elements.

Differentiate the tooltips between symbols in the symbol palette and dropped nodes by utilizing the dragEnter event. When a custom tooltip is defined for a symbol, it will be displayed for both the symbol and the dropped node in the diagram canvas. However, to provide distinct tooltips for symbols in the palette and dropped nodes, capture the dragEnter event and assign specific tooltips dynamically.
Expand Down