Skip to content

Committed the example project. #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 12, 2024
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
15 changes: 13 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,13 @@
# How-to-Create-and-Customize-Nodes-in-the-Vue-Diagram-Component
A quick start Vue project that shows how to create a node and customize it in the Syncfusion Vue Diagram Component. This project includes code snippets to create a node programmatically and use the drawing tool.
# How to Create and Customize Nodes in the Vue Diagram Component

A quick start Vue project that shows how to create a node and customize it in the Syncfusion [Vue Diagram]( https://www.syncfusion.com/vue-components/vue-diagram?utm_source=github&utm_medium=listing&utm_campaign=vue-diagram-nodes-sample). This project includes code snippets to create a node programmatically and use the drawing tool.

Watch the video: Coming soon…

Refer to the following documentation to learn about the Vue Diagram component: https://ej2.syncfusion.com/vue/documentation/diagram/nodes <br/>
Check out this online example of the Vue Diagram component: https://ej2.syncfusion.com/vue/demos/#/material3/diagram/node.html

Make sure you have the latest versions of Node.js and Visual Studio Code on your machine before working on this project.

## How to run this application
To run this application, you need to clone the `How-to-Create-and-Customize-Nodes-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.
13 changes: 13 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite + Vue</title>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.js"></script>
</body>
</html>
20 changes: 20 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "myvueapp",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build",
"preview": "vite preview"
},
"dependencies": {
"@syncfusion/ej2-vue-buttons": "^24.2.5",
"@syncfusion/ej2-vue-diagrams": "^24.2.5",
"vue": "^3.3.11"
},
"devDependencies": {
"@vitejs/plugin-vue": "^4.5.2",
"vite": "^5.0.8"
}
}
1 change: 1 addition & 0 deletions public/vite.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
75 changes: 75 additions & 0 deletions src/App.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<template>
<div class="container" >
<ejs-button class="button" @click="drawNode">Draw Node</ejs-button>
<ejs-button class="button" @click="editNode">Edit Node</ejs-button>
<ejs-button class="button" @click="removeNode">Remove Node</ejs-button>
</div>
<ejs-diagram ref="diagramObject" :width="width" :height="height" />
</template>

<script>
import {
DiagramComponent, DiagramTools
} from '@syncfusion/ej2-vue-diagrams';
import { ButtonComponent } from '@syncfusion/ej2-vue-buttons';

let nodes = [
{
offsetX: 300,
offsetY: 250,
width: 200,
height: 100,
//annotations: [{content: "Basic"},{content: "Rectangle", offset: {y:0.6}}],
annotations: [{content: "Flow"},{content: "Terminator", offset: {y:0.6}}],
style: { fill: 'lightblue', strokeColor: 'white'},
shape: { type:'Flow', shape: 'Terminator'}
}
];

let diagramInstance;

export default {
name: 'App',
components: {
"ejs-diagram": DiagramComponent,
"ejs-button": ButtonComponent
},
data() {
return {
width: '1302px',
height: '602px',
//nodes: nodes
drawNode: () => {
diagramInstance.tool = DiagramTools.DrawOnce;
diagramInstance.drawingObject = { shape: { type: 'Basic', shape: 'Rectangle' } };
},
editNode: ()=> {
diagramInstance.nodes[0].width = 400;
diagramInstance.nodes[0].height = 200;
diagramInstance.nodes[0].annotations[0].content = "Changed Text";
diagramInstance.nodes[0].style = { fill: 'Orange', strokeColor: 'Blue' }
},
removeNode: ()=> {
diagramInstance.remove(diagramInstance.nodes[0]);
}
};
},
mounted: function () {
diagramInstance = this.$refs.diagramObject.ej2Instances;
diagramInstance.add(nodes[0]);
}
};
</script>

<style>
@import '../node_modules/@syncfusion/ej2-vue-diagrams/styles/material.css';
@import '../node_modules/@syncfusion/ej2-vue-buttons/styles/material.css';

.container {
text-align: left;
margin-bottom: 10px;
}
.button {
margin-right: 10px;
}
</style>
1 change: 1 addition & 0 deletions src/assets/vue.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
40 changes: 40 additions & 0 deletions src/components/HelloWorld.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<script setup>
import { ref } from 'vue'

defineProps({
msg: String,
})

const count = ref(0)
</script>

<template>
<h1>{{ msg }}</h1>

<div class="card">
<button type="button" @click="count++">count is {{ count }}</button>
<p>
Edit
<code>components/HelloWorld.vue</code> to test HMR
</p>
</div>

<p>
Check out
<a href="https://vuejs.org/guide/quick-start.html#local" target="_blank"
>create-vue</a
>, the official Vue + Vite starter
</p>
<p>
Install
<a href="https://github.com/vuejs/language-tools" target="_blank">Volar</a>
in your IDE for a better DX
</p>
<p class="read-the-docs">Click on the Vite and Vue logos to learn more</p>
</template>

<style scoped>
.read-the-docs {
color: #888;
}
</style>
6 changes: 6 additions & 0 deletions src/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { createApp } from 'vue'
import './style.css'
import App from './App.vue'
import { registerLicense } from '@syncfusion/ej2-base'
registerLicense('Ngo9BigBOggjHTQxAR8/V1NAaF5cWWRCf1FpRmJGdld5fUVHYVZUTXxaS00DNHVRdkdnWX5cdHRRQmBZVUN/XUQ=')
createApp(App).mount('#app')
79 changes: 79 additions & 0 deletions src/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
:root {
font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
line-height: 1.5;
font-weight: 400;

color-scheme: light dark;
color: rgba(255, 255, 255, 0.87);
background-color: #242424;

font-synthesis: none;
text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}

a {
font-weight: 500;
color: #646cff;
text-decoration: inherit;
}
a:hover {
color: #535bf2;
}

body {
margin: 0;
display: flex;
place-items: center;
min-width: 320px;
min-height: 100vh;
}

h1 {
font-size: 3.2em;
line-height: 1.1;
}

button {
border-radius: 8px;
border: 1px solid transparent;
padding: 0.6em 1.2em;
font-size: 1em;
font-weight: 500;
font-family: inherit;
background-color: #1a1a1a;
cursor: pointer;
transition: border-color 0.25s;
}
button:hover {
border-color: #646cff;
}
button:focus,
button:focus-visible {
outline: 4px auto -webkit-focus-ring-color;
}

.card {
padding: 2em;
}

#app {
max-width: 1280px;
margin: 0 auto;
padding: 2rem;
text-align: center;
}

@media (prefers-color-scheme: light) {
:root {
color: #213547;
background-color: #ffffff;
}
a:hover {
color: #747bff;
}
button {
background-color: #f9f9f9;
}
}
7 changes: 7 additions & 0 deletions vite.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'

// https://vitejs.dev/config/
export default defineConfig({
plugins: [vue()],
})