Skip to content

Commit 3ad4736

Browse files
authored
Committed the example project.
1 parent 4ef56c5 commit 3ad4736

File tree

10 files changed

+363
-2
lines changed

10 files changed

+363
-2
lines changed

README.md

+14-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,14 @@
1-
# How-to-Add-and-Customize-Connectors-in-the-Vue-Diagram-Component
2-
A quick start Vue project that shows how to add connectors in the Syncfusion Vue Diagram component. This project includes code snippets for adding a connector both programmatically and using the drawing tool. It also includes code snippets for adding different types of connectors and decorator shapes.
1+
# How to Add and Customize Connectors in the Vue Diagram Component
2+
3+
A quick start Vue project that shows how to add connectors in the Syncfusion [Vue Diagram](https://www.syncfusion.com/vue-components/vue-diagram?utm_source=github&utm_medium=listing&utm_campaign=vue-diagram-connectors-sample) component. This project includes code snippets for adding a connector both programmatically and using the drawing tool. It also includes code snippets for adding different types of connectors and decorator shapes.
4+
5+
Watch the video: Coming soon…
6+
7+
Refer to the following documentation to learn about the Vue Diagram component: https://ej2.syncfusion.com/vue/documentation/diagram/connectors
8+
9+
Check out this online example of the Vue Diagram component: https://ej2.syncfusion.com/vue/documentation/diagram/connectors
10+
11+
Make sure you have the latest versions of Node.js and Visual Studio Code on your machine before working on this project.
12+
13+
## How to run this application
14+
To run this application, you need to clone the `How-to-Add-and-Customize-Connectors-in-the-Vue-Diagram-Component` repository and then open it in Visual Studio Code. After that, just install all the necessary Vue packages in your project using the `npm install` command and run your project using the `npm run dev` command.

index.html

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7+
<title>Vite + Vue</title>
8+
</head>
9+
<body>
10+
<div id="app"></div>
11+
<script type="module" src="/src/main.js"></script>
12+
</body>
13+
</html>

package.json

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"name": "myvueapp",
3+
"private": true,
4+
"version": "0.0.0",
5+
"type": "module",
6+
"scripts": {
7+
"dev": "vite",
8+
"build": "vite build",
9+
"preview": "vite preview"
10+
},
11+
"dependencies": {
12+
"@syncfusion/ej2-vue-buttons": "^25.1.39",
13+
"@syncfusion/ej2-vue-diagrams": "^25.1.39",
14+
"vue": "^3.4.21"
15+
},
16+
"devDependencies": {
17+
"@vitejs/plugin-vue": "^5.0.4",
18+
"vite": "^5.2.8"
19+
}
20+
}

public/vite.svg

+1
Loading

src/App.vue

+176
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,176 @@
1+
<template>
2+
<div class="container">
3+
<ejs-button class="button" @click="drawConnector">Draw Connector</ejs-button>
4+
<ejs-button class="button" @click="editConnector">Edit Connector</ejs-button>
5+
<ejs-button class="button" @click="removeConnector">Remove Connector</ejs-button>
6+
</div>
7+
<ejs-diagram ref="diagramObject" :width="width" :height="height" :nodes="nodes" :getNodeDefaults="getNodeDefaults"
8+
:connectors="connectors"></ejs-diagram>
9+
</template>
10+
<script>
11+
12+
let diagramInstance;
13+
14+
let ports = [{
15+
id: 'rightMidPort',
16+
offset: {
17+
x: 1,
18+
y: 0.5
19+
}
20+
}];
21+
22+
let nodes = [
23+
{
24+
id: "startNode",
25+
offsetY: 80,
26+
shape: { type: "Flow", shape: "Terminator" },
27+
annotations: [
28+
{
29+
content: "Start"
30+
}
31+
]
32+
},
33+
{
34+
id: "processNode",
35+
offsetY: 220,
36+
shape: { type: "Flow", shape: "Process" },
37+
annotations: [
38+
{
39+
content: "Process"
40+
}
41+
],
42+
ports: ports
43+
},
44+
{
45+
id: "decisionNode",
46+
offsetY: 360,
47+
shape: { type: "Flow", shape: "Decision" },
48+
annotations: [
49+
{
50+
content: "Decision"
51+
}
52+
],
53+
ports: ports
54+
},
55+
{
56+
id: "endNode",
57+
offsetY: 500,
58+
shape: { type: "Flow", shape: "Terminator" },
59+
annotations: [
60+
{
61+
content: "End"
62+
}
63+
]
64+
}
65+
];
66+
67+
let connectors = [
68+
{
69+
id: 'startToProcessConnector',
70+
sourceID: 'startNode',
71+
targetID: 'processNode',
72+
style: { strokeColor: 'Orange', strokeWidth: 5 },
73+
sourceDecorator: {
74+
shape: 'Diamond',
75+
style: { fill: 'Orange' }
76+
},
77+
targetDecorator: {
78+
shape: 'Diamond',
79+
style: { fill: 'Orange' }
80+
}
81+
},
82+
{
83+
id: 'decisionToProcessConnector',
84+
sourceID: 'decisionNode',
85+
targetID: 'processNode',
86+
type: 'Bezier',
87+
segments: [
88+
{
89+
type: "Bezier",
90+
point1: {
91+
x: 750,
92+
y: 350
93+
},
94+
point2: {
95+
x: 750,
96+
y: 250
97+
}
98+
}
99+
],
100+
/* type: "Orthogonal",
101+
segments: [
102+
{
103+
type: "Orthogonal",
104+
direction: "Right",
105+
length: 50
106+
}
107+
], */
108+
targetPortID: 'rightMidPort',
109+
sourcePortID: 'rightMidPort',
110+
annotations: [{ content: 'No', style: { fill: 'white' } }]
111+
},
112+
{
113+
id: 'decisionToEndConnector',
114+
sourceID: 'decisionNode',
115+
targetID: 'endNode',
116+
annotations: [{ content: 'Yes', style: { fill: 'white' } }]
117+
}
118+
];
119+
120+
import {
121+
DiagramComponent, DiagramTools
122+
} from '@syncfusion/ej2-vue-diagrams';
123+
import { ButtonComponent } from '@syncfusion/ej2-vue-buttons';
124+
125+
export default {
126+
components: {
127+
'ejs-diagram': DiagramComponent,
128+
'ejs-button': ButtonComponent
129+
},
130+
data: function () {
131+
return {
132+
width: '1102px',
133+
height: '602px',
134+
nodes: nodes,
135+
connectors: connectors,
136+
getNodeDefaults: (node) => {
137+
node.height = 80;
138+
node.width = 150;
139+
node.offsetX = 500;
140+
},
141+
drawConnector: () => {
142+
diagramInstance.tool = DiagramTools.DrawOnce;
143+
diagramInstance.drawingObject = { id: 'dynamicConnector', type: 'Polyline' }; //Straight //Freehand
144+
},
145+
editConnector: () => {
146+
diagramInstance.connectors[0].style = { strokeColor: 'Black', strokeWidth: 1 }
147+
},
148+
removeConnector: () => {
149+
diagramInstance.remove(diagramInstance.connectors[0]);
150+
}
151+
};
152+
},
153+
mounted: function () {
154+
diagramInstance = this.$refs.diagramObject.ej2Instances;
155+
diagramInstance.addConnector({
156+
id: 'processToDecisionConnector',
157+
sourceID: 'processNode',
158+
targetID: 'decisionNode'
159+
});
160+
}
161+
};
162+
</script>
163+
164+
<style>
165+
@import "../node_modules/@syncfusion/ej2-vue-diagrams/styles/material.css";
166+
@import "../node_modules/@syncfusion/ej2-vue-buttons/styles/material.css";
167+
168+
.container {
169+
text-align: left;
170+
margin-bottom: 20px;
171+
}
172+
173+
.button {
174+
margin-right: 10px;
175+
}
176+
</style>

src/assets/vue.svg

+1
Loading

src/components/HelloWorld.vue

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<script setup>
2+
import { ref } from 'vue'
3+
4+
defineProps({
5+
msg: String,
6+
})
7+
8+
const count = ref(0)
9+
</script>
10+
11+
<template>
12+
<h1>{{ msg }}</h1>
13+
14+
<div class="card">
15+
<button type="button" @click="count++">count is {{ count }}</button>
16+
<p>
17+
Edit
18+
<code>components/HelloWorld.vue</code> to test HMR
19+
</p>
20+
</div>
21+
22+
<p>
23+
Check out
24+
<a href="https://vuejs.org/guide/quick-start.html#local" target="_blank"
25+
>create-vue</a
26+
>, the official Vue + Vite starter
27+
</p>
28+
<p>
29+
Install
30+
<a href="https://github.com/vuejs/language-tools" target="_blank">Volar</a>
31+
in your IDE for a better DX
32+
</p>
33+
<p class="read-the-docs">Click on the Vite and Vue logos to learn more</p>
34+
</template>
35+
36+
<style scoped>
37+
.read-the-docs {
38+
color: #888;
39+
}
40+
</style>

src/main.js

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { createApp } from 'vue'
2+
import './style.css'
3+
import App from './App.vue'
4+
import { registerLicense } from '@syncfusion/ej2-base'
5+
registerLicense('Ngo9BigBOggjHTQxAR8/V1NBaF5cXmRCf1FpRmJGdld5fUVHYVZUTXxaS00DNHVRdkdnWXxcd3RTQ2FfV0N+XkM=')
6+
createApp(App).mount('#app')

src/style.css

+85
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
:root {
2+
font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
3+
line-height: 1.5;
4+
font-weight: 400;
5+
6+
color-scheme: light dark;
7+
color: rgba(255, 255, 255, 0.87);
8+
background-color: #242424;
9+
10+
font-synthesis: none;
11+
text-rendering: optimizeLegibility;
12+
-webkit-font-smoothing: antialiased;
13+
-moz-osx-font-smoothing: grayscale;
14+
}
15+
16+
a {
17+
font-weight: 500;
18+
color: #646cff;
19+
text-decoration: inherit;
20+
}
21+
22+
a:hover {
23+
color: #535bf2;
24+
}
25+
26+
body {
27+
/*margin: 0;
28+
display: flex;
29+
place-items: center; */
30+
margin-left: 180px;
31+
min-width: 320px;
32+
min-height: 97vh;
33+
}
34+
35+
h1 {
36+
font-size: 3.2em;
37+
line-height: 1.1;
38+
}
39+
40+
button {
41+
border-radius: 8px;
42+
border: 1px solid transparent;
43+
padding: 0.6em 1.2em;
44+
font-size: 1em;
45+
font-weight: 500;
46+
font-family: inherit;
47+
background-color: #1a1a1a;
48+
cursor: pointer;
49+
transition: border-color 0.25s;
50+
}
51+
52+
button:hover {
53+
border-color: #646cff;
54+
}
55+
56+
button:focus,
57+
button:focus-visible {
58+
outline: 4px auto -webkit-focus-ring-color;
59+
}
60+
61+
.card {
62+
padding: 2em;
63+
}
64+
65+
#app {
66+
max-width: 1280px;
67+
margin: 0 auto;
68+
padding: 2rem;
69+
text-align: center;
70+
}
71+
72+
@media (prefers-color-scheme: light) {
73+
:root {
74+
color: #213547;
75+
background-color: #ffffff;
76+
}
77+
78+
a:hover {
79+
color: #747bff;
80+
}
81+
82+
button {
83+
background-color: #f9f9f9;
84+
}
85+
}

vite.config.js

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { defineConfig } from 'vite'
2+
import vue from '@vitejs/plugin-vue'
3+
4+
// https://vitejs.dev/config/
5+
export default defineConfig({
6+
plugins: [vue()],
7+
})

0 commit comments

Comments
 (0)