vue-flowy前端流程图绘制工具

vue-flowy

 

翻译来源:https://gitee.com/yunwisdoms/vue-flowy

 

基于Vue的智能流程图创建。

适用于Vue 2

 

安装

通过NPM安装

$ npm install vue-flowy -save

通过纱安装

$ yarn add vue-flowy

注册为组件

import {VueFlowy} from 'vue-flowy'

export default {
  name: 'App',

  components: {
    VueFlowy
  }
}

注册为插件

import Vue from 'vue'
import {VueFlowy} from 'vue-flowy'

Vue.component(VueFlowy)

用法

屏幕截图

快速示例

CodeSandbox观看演示

<template>
  <VueFlowy :chart='chart'></VueFlowy>
</template>

<script>
import {VueFlowy, FlowChart} from 'vue-flowy'

export default {
  name: 'App',

  components: {
    VueFlowy
  },

  data: () => ({
    chart: new FlowChart()
  }),
  mounted() {
    const idea = this.chart.addElement('idea')
    const A = this.chart.addElement('A', {label: 'vscode'})
    const B = this.chart.addElement('B', {label: 'github'})
    const C = this.chart.addElement('C', {label: 'npm'})
    idea.leadsTo(A).leadsTo(B)
    A.leadsTo(C)

    A.on('click', function() {
      console.log('click!')
    })
  },
}
</script>

 

道具

道具描述需要类型默认
图表图表数据(流程图类型)真正流程图-

 

API

每个FlowChart都通过使用类创建一个新的FlowChart实例开始FlowChart

 

流程图

data() {
  return {
    chart: new FlowChart()
  }
}

该创建当前允许以下选项:

选项描述类型默认
方向图表建立的方向。可以是LR,TB,BT,RLLR

现在您可以使用新的图表变量

<FlowChart> .addElement(id,[options])

用于向图表添加节点。每个节点都需要一个ID,因此此字段为必填字段。 返回类FlowElement

可用的选项有:

选项描述类型默认
标签显示在节点上的标签ID

 

流元素

FlowElement由<FlowChart> .addElement返回。它代表一个节点

<FlowElement>.leadsTo(<FlowElement>, [options])

用于将两个元素与边连接。

可用的选项有:

选项描述类型默认
标签出现在边缘的标签''

<FlowElement>.on(event, callback)

<FlowElement>.on(事件,回调)

用于将事件添加到FlowElements。可以是任何事件。

 

执照

Vue-Flowy是根据MIT许可获得许可的开源软件

 

贡献

由于时间有限,如果有人为这个项目做贡献,我会很高兴。只需克隆存储库即可开始开发。最后运行yarn build构建程序包以对其进行测试。

然后使用yarn link vue 链接该包。由于vue是对等依赖项,因此我还不得不链接vue进行开发和测试:

cd node_modules/vue
yarn link
cd ../../

现在进入示例目录并使用那里的链接

cd example
yarn link "vue-flowy"
yarn link "vue"

现在运行该应用程序进行测试

yarn serve

 

支持

您好,我是我的业余时间该项目的维护者Patrick(如今这种情况正在减少),如果该项目确实以任何方式对您有所帮助,请考虑为我提供拉取请求。谢谢:笑脸:

 


 

英文原文

 

Smart flowchart creation based on Vue.

Works with Vue 2.*

Installation

Install via NPM

$ npm install vue-flowy --save

Install via yarn

$ yarn add vue-flowy

Register as Component

import {VueFlowy} from 'vue-flowy'

export default {
  name: 'App',

  components: {
    VueFlowy
  }
}

Register as plugin

import Vue from 'vue'
import {VueFlowy} from 'vue-flowy'

Vue.component(VueFlowy)

Usage

screenshot

Quick example

See a demo on CodeSandbox

<template>
  <VueFlowy :chart='chart'></VueFlowy>
</template>

<script>
import {VueFlowy, FlowChart} from 'vue-flowy'

export default {
  name: 'App',

  components: {
    VueFlowy
  },

  data: () => ({
    chart: new FlowChart()
  }),
  mounted() {
    const idea = this.chart.addElement('idea')
    const A = this.chart.addElement('A', {label: 'vscode'})
    const B = this.chart.addElement('B', {label: 'github'})
    const C = this.chart.addElement('C', {label: 'npm'})
    idea.leadsTo(A).leadsTo(B)
    A.leadsTo(C)

    A.on('click', function() {
      console.log('click!')
    })
  },
}
</script>

Props

PropsDescriptionRequiredTypeDefault
chartThe Chart data (type of FlowChart)trueFlowChart-

API

Every FlowChart starts by creating a new FlowChart instance with the FlowChart class:

FlowChart

data() {
  return {
    chart: new FlowChart()
  }
}

The creation currently allows the following options:

optionDescriptionTypeDefault
directionThe direction in which the chart is built. Can be LR, TB, BT, RLstringLR

Now you can work with the new chart variable

<FlowChart>.addElement(id, [options])

Used to add nodes to the chart. Every node needs an id, so this field is required. returns class FlowElement

Available options are:

optionDescriptionTypeDefault
labelA label which shows up on the nodestringid

FlowElement

A FlowElement is returned by <FlowChart>.addElement. It represents one node

<FlowElement>.leadsTo(<FlowElement>, [options])

Used to connect two elements with an edge.

Available options are:

optionDescriptionTypeDefault
labelA label which shows up on the edgestring''

<FlowElement>.on(event, callback)

Used to add events to FlowElements. Can be any event.

License

Vue-Flowy is open-sourced software licensed under the MIT license

Contributing

As my time is limited, I would be happy if someone contributes to this project. Simply clone the repo and start developing. At the end run yarn build to build the package to test it.

Then link the package using yarn link As vue is a peer dependency, I also had to link vue for development and testing:

cd node_modules/vue
yarn link
cd ../../

Now go into the example directory and use the links there

cd example
yarn link "vue-flowy"
yarn link "vue"

Now run the app to test it out

yarn serve

Support

Hello, I'm Patrick the maintainer of this project in my free time (which is getting lessen these days), if this project does help you in any way please consider to support me with pull requests. Thanks :smiley:

  • 3
    点赞
  • 28
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值