Vue.js
This document shows you haw you can add FlowChart JS in a Vue.js project.
-
Create a new project named flowchart:
npm init vue@latest
-
Go to the project root folder:
cd flowchart
-
Install dependencies
npm install
- Download the package and copy flowchart.js in \src\assets folder.
-
Add this in the end of the file:
export default FlowChart
-
Create file FlowChart.vue in /src/components folder with the following content:
<template> <div id="chart" ref="chart"></div> </template> <script> import FlowChart from "../assets/flowchart"; export default { name: 'chart', methods: { mychart: function (domEl, x) { this.chart = new FlowChart(domEl, { }); this.chart.load( { nodes: [ { id: 1, templateId: 'startEnd', x: 400, y: 150, text: "Start" }, ] } ); } }, mounted() { this.mychart(this.$refs.chart) } } </script>
-
Change App.vue as follows:
<template> <FlowChart /> </template> <script> import FlowChart from './components/FlowChart.vue' export default { name: 'app', components: { FlowChart, } } </script> <style> #app { grid-template-columns: auto; } #chart { width: 100%; height: 700px; } </style>
- Remove the imported CSS from the main.js file
-
Start the project:
npm run dev