Skip to content

Commit 6e56f7b

Browse files
authored
Committed the example project.
1 parent cd4166c commit 6e56f7b

File tree

10 files changed

+279
-2
lines changed

10 files changed

+279
-2
lines changed

README.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,14 @@
1-
# How-to-Create-an-Organization-Chart-Using-Vue-Diagram
2-
"A quick-start Vue project that shows how to create an organization chart using the Syncfusion Vue Diagram component. This project also includes code snippets for binding JSON data and a remote data source and customizing the nodes and connectors in the diagram.
1+
# How to Create an Organization Chart Using Vue Diagram
2+
3+
A quick-start Vue project that shows how to create an organization chart using the Syncfusion [Vue Diagram]( https://www.syncfusion.com/vue-components/vue-diagram?utm_source=github&utm_medium=listing&utm_campaign=vue-diagram-orgchart-sample) component. This project also includes code snippets for binding JSON data and a remote data source and customizing the nodes and connectors in the diagram.
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/automatic-layout#organizational-chart
8+
Check out this online example of the Vue Diagram component: https://ej2.syncfusion.com/vue/demos/#/material3/diagram/organization-model.html
9+
10+
11+
Make sure you have the latest versions of Node.js and Visual Studio Code on your machine before working with this project.
12+
13+
## How to run this application
14+
To run this application, you need to clone the `How-to-Create-an-Organization-Chart-Using-Vue-Diagram` 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

Lines changed: 13 additions & 0 deletions
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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
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-diagrams": "^24.1.47",
13+
"vue": "^3.3.11"
14+
},
15+
"devDependencies": {
16+
"@vitejs/plugin-vue": "^4.5.2",
17+
"vite": "^5.0.8"
18+
}
19+
}

public/vite.svg

Lines changed: 1 addition & 0 deletions
Loading

src/App.vue

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
<template>
2+
<ejs-diagram :width="width" :height="height" :layout="layout"
3+
:dataSourceSettings="dataSourceSettings" :getNodeDefaults="getNodeDefaults"
4+
:getConnectorDefaults="getConnectorDefaults" :snapSettings="snapSettings" />
5+
</template>
6+
7+
<script>
8+
import {
9+
DiagramComponent,
10+
DataBinding,
11+
HierarchicalTree,
12+
SnapConstraints
13+
} from '@syncfusion/ej2-vue-diagrams';
14+
import { DataManager } from '@syncfusion/ej2-data';
15+
16+
const employeeData = [
17+
{ Name: 'Elizabeth', Role: 'Director' },
18+
{ Name: 'Christina', ReportingPerson: 'Elizabeth', Role: 'Manager' },
19+
{ Name: 'Yoshi', ReportingPerson: 'Christina', Role: 'Lead' },
20+
{ Name: 'Philip', ReportingPerson: 'Christina', Role: 'SalesExecutive' },
21+
{ Name: 'John', ReportingPerson: 'Yoshi', Role: 'Engineer' },
22+
{ Name: 'James', ReportingPerson: 'Yoshi', Role: 'Engineer' },
23+
{ Name: 'Robert', ReportingPerson: 'Christina', Role: 'Lead' },
24+
{ Name: 'David', ReportingPerson: 'Robert', Role: 'Engineer' },
25+
{ Name: 'Yang', ReportingPerson: 'Elizabeth', Role: 'Manager' },
26+
{ Name: 'Roland', ReportingPerson: 'Yang', Role: 'Lead' },
27+
{ Name: 'Paul', ReportingPerson: 'Roland', Role: 'Engineer' },
28+
{ Name: 'Yvonne', ReportingPerson: 'Yang', Role: 'Lead' },
29+
{ Name: 'Jack', ReportingPerson: 'Yvonne', Role: 'Engineer' }
30+
];
31+
32+
export default {
33+
name: 'App',
34+
components: {
35+
"ejs-diagram": DiagramComponent
36+
},
37+
data() {
38+
return {
39+
width: '1302px',
40+
height: '602px',
41+
snapSettings: { constraints: SnapConstraints.None },
42+
getNodeDefaults: function (node) {
43+
node.height = 60;
44+
node.width = 150;
45+
},
46+
getConnectorDefaults: function (connector) {
47+
connector.type = 'Orthogonal';
48+
connector.style = {
49+
strokeColor: '#6f409f',
50+
fill: '#6f409f',
51+
strokeWidth: 2
52+
};
53+
connector.targetDecorator = {
54+
style: {
55+
fill: '#6f409f',
56+
strokeColor: '#6f409f'
57+
}
58+
};
59+
},
60+
layout: {
61+
type: 'OrganizationalChart'
62+
},
63+
dataSourceSettings: {
64+
id: 'Name',
65+
parentId: 'ReportingPerson',
66+
dataSource: new DataManager(employeeData),
67+
/* id: "Id",
68+
parentId: "ParentId",
69+
dataSource: new DataManager(
70+
{
71+
url: "https://services.syncfusion.com/vue/production/api/RemoteData",
72+
crossDomain: true
73+
}), */
74+
doBinding: (nodeModel, data) => {
75+
nodeModel.annotations = [
76+
{
77+
content: data.Name,
78+
//content: data["Label"],
79+
offset: { x: 0.5, y: 0.4 },
80+
style: { color: 'white' }
81+
},
82+
{
83+
content: "(" + data.Role + ")",
84+
offset: { x: 0.5, y: 0.7 },
85+
style: { color: "white" }
86+
}
87+
];
88+
nodeModel.style = { fill: '#048785', strokeWidth: 0 };
89+
}
90+
}
91+
};
92+
},
93+
provide: { diagram: [DataBinding, HierarchicalTree] }
94+
};
95+
</script>
96+
97+
<style>
98+
@import '../node_modules/@syncfusion/ej2-vue-diagrams/styles/material.css';
99+
</style>

src/assets/vue.svg

Lines changed: 1 addition & 0 deletions
Loading

src/components/HelloWorld.vue

Lines changed: 40 additions & 0 deletions
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

Lines changed: 6 additions & 0 deletions
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/V1NAaF5cWWRCf1FpRmJGdld5fUVHYVZUTXxaS00DNHVRdkdnWX5cdHRRQmBZVUN/XUQ=')
6+
createApp(App).mount('#app')

src/style.css

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
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+
a:hover {
22+
color: #535bf2;
23+
}
24+
25+
body {
26+
margin: 0;
27+
display: flex;
28+
place-items: center;
29+
min-width: 320px;
30+
min-height: 100vh;
31+
}
32+
33+
h1 {
34+
font-size: 3.2em;
35+
line-height: 1.1;
36+
}
37+
38+
button {
39+
border-radius: 8px;
40+
border: 1px solid transparent;
41+
padding: 0.6em 1.2em;
42+
font-size: 1em;
43+
font-weight: 500;
44+
font-family: inherit;
45+
background-color: #1a1a1a;
46+
cursor: pointer;
47+
transition: border-color 0.25s;
48+
}
49+
button:hover {
50+
border-color: #646cff;
51+
}
52+
button:focus,
53+
button:focus-visible {
54+
outline: 4px auto -webkit-focus-ring-color;
55+
}
56+
57+
.card {
58+
padding: 2em;
59+
}
60+
61+
#app {
62+
max-width: 1280px;
63+
margin: 0 auto;
64+
padding: 2rem;
65+
text-align: center;
66+
}
67+
68+
@media (prefers-color-scheme: light) {
69+
:root {
70+
color: #213547;
71+
background-color: #ffffff;
72+
}
73+
a:hover {
74+
color: #747bff;
75+
}
76+
button {
77+
background-color: #f9f9f9;
78+
}
79+
}

vite.config.js

Lines changed: 7 additions & 0 deletions
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)