Coder Social home page Coder Social logo

vue-workflow-chart / vue-workflow-chart Goto Github PK

View Code? Open in Web Editor NEW
83.0 3.0 13.0 2.15 MB

Create Workflow-Charts with Vue.js

License: GNU General Public License v3.0

JavaScript 69.48% Vue 26.84% HTML 0.94% SCSS 2.73%
js jest sonar npm yarn gplv3 github-actions

vue-workflow-chart's Introduction

Workflow Charts for vue.js Build Status NPM version License: GPL v3

Workflow Chart of an investment proposal

What is vue-workflow-chart?

Vue-Workflow-Chart is developed to visualize processes or workflows. In a company for example, workflows can get complicated and confusing very easily, so an illustration can help to understand the process.

As Workflows consist of states and transitions, these elements must be passed to vue-workflow-chart. The given data will be modeled and rendered.

As an OpenSource - project, vue-workflow-chart comes under the GPLv3 - license.

Requirements

  • npm
  • starting from 0.5.x this package supports Vue 3.x only

Installation

Just get the npm package with

npm i vue-workflow-chart

for the latest version.

Example

A minimal example with two states and a transition from one to the other.

<template>
    <div id="app">
        <workflow-chart
            :transitions="transitions"
            :states="states" />
    </div>
</template>

<script>
import WorkflowChart from 'vue-workflow-chart';

export default {
    name: "App",
    components: {
        WorkflowChart,
    },
    data: () => ({
        states: [{
            "id": "state_1",
            "label": "State 1",
        }, {
            "id": "state_2",
            "label": "State 2",
        }],
        transitions: [{
            "id": "transition_1",
            "label": "this is a transition",
            "target": "state_2",
            "source": "state_1",
        }],
    }),
};
</script>

For a more complex example see example/App.vue.

Click events

As you click on a state or a transition, these elements emit an event. For a state, this will be a 'state-click' with the id of the element as parameter. Transitions emit a 'transition-click' with id.

See the minimal example below:

<template>
    <div id="app">
        <workflow-chart
            :transitions=[]
            :states="states"
            @state-click="onStateClick($event)" />
    </div>
</template>

<script>
import WorkflowChart from 'vue-workflow-chart';

export default {
    name: "App",
    components: {
        WorkflowChart,
    },
    data: () => ({
        states: [{
            "id": "state_1",
            "label": "State 1",
        }],
    }),
    methods: {
        onStateClick(id) {
            alert(`Clicked on state with id: ${id}`);
        },
    },
};
</script>

Clicking the state will trigger the state-click event. In the workflow-chart, this event will fire the 'onStateClick' - method. As a result, the alert with text "Clicked on state with id: state_1" will show.

For another example see example/App.vue.

Styling

The workflow-chart styles can be changed with the classes

  • .vue-workflow-chart-state
  • .vue-workflow-chart-transition-arrow
  • .vue-workflow-chart-transition-path
  • .vue-workflow-chart-transition-label

Giving states a semantic

Single states can be given a special semantic by passing an additional class name. The state and its targeting transitions can be styled accordingly.

The classes to be styled with its suffixes are

  • .vue-workflow-chart-state- for the state
  • .vue-workflow-chart-transition-arrow- for the arrow of the transition path
  • .vue-workflow-chart-transition-path- for the transition path
<template>
    <workflow-chart
        :transitions="transitions"
        :states="states"
        :stateSemantics="stateSemantics" />
</template>
<script>
import WorkflowChart from 'vue-workflow-chart';

export default {
    components: {
        WorkflowChart,
    },
    data: () => ({
        states: [{
            "id": "static_state_deleted",
            "label": "Deleted",
        }, {
            "id": "static_state_new",
            "label": "New",
        }],
        transitions: [{
            'id': 'delete',
            'label': 'delete',
            'target': 'static_state_deleted',
            'source': 'static_state_new',
        }],
        stateSemantics: [{
            "classname": "delete",
            "id":"static_state_deleted",
        }],
    }),
};
</script>
<style lang="scss">
@import '~vue-workflow-chart/dist/vue-workflow-chart.css';

.vue-workflow-chart-state-delete {
    color: white;
    background: red;
}

.vue-workflow-chart-transition-arrow-delete {
    fill: red;
}

.vue-workflow-chart-transition-path-delete {
    stroke: red;
}
</style>

Contributing

Contributing

Code of conduct

Code of Conduct

LICENSE

License

vue-workflow-chart's People

Contributors

dependabot[bot] avatar friederike-cil avatar kevsommer avatar marcel-postel avatar quitejonny avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

vue-workflow-chart's Issues

Global size

Created object doesn't have size
The created object is made all with absolute positions, so if I include the chart in a page, I can't set the layout

Expected behavior
I would expect to have a container div with a height

anyting is blank ?

Describe the bug

<style lang="scss"> @import '~vue-workflow-chart/dist/vue-workflow-chart.css'; </style> <script> import WorkflowChart from "vue-workflow-chart";

export default {
data() {
return {
states: [
{
id: "state_1",
label: "State 1"
},
{
id: "state_2",
label: "State 2"
}
],
transitions: [
{
id: "transition_1",
label: "this is a transition",
target: "state_2",
source: "state_1"
}
]
};
},
computed: {},
components: {
WorkflowChart
},
methods: {
onStateClick(id) {
alert(Clicked on state with id: ${id});
},
},
mounted() {},

filters: {}
};

Screenshots
display nothing on the page?

Desktop (please complete the following information):

  • OS: [MACOS]
  • Browser [chrome, safari]
  • Version [e.g. 22]

Additional context
anyting problem?

Subflows

I have in my workflows (I am using symfony workflow) many subflows and I want to validate this workflows (with workflows) with my users.
Many these flows have subflows and the complexity should be validated with my users soon. If I have a way to create with javascript a wokflow map (and not have to use adobe xd, figma ou any other) my user can view and give a response about this map. I can reactory this thing soon and create a better solution to them.

Add hacktoberfest's tag to the project
I have create this solution. This solucionate my problem and should solucionate other's problem. I have created the code and will PR with example.
This problem I have found many months ago, but I remembered today and coded solution to this problem.

You can create a array of states
A simple state become a complex state (with a sub states and subflows)

Add moveability for nodes and drag and extend connection

Is your feature request related to a problem? Please describe.
The diagram generated automatically, but it is generated Horizontally whereas most users wish to have their charts generated vertically, also they wish to changes the position of nodes so that they could be easy for understanding. Also, the availability to create transitions by drag gives easy way and more comfortable way to create the connection.

Describe the solution you'd like
I like to see, ability to

  1. Make connections or transitions by drag it from one node to another node and also a way to add custom looking transition lines and arrows.
  2. Move the nodes inside the drawing plane and accordingly change the position of the transitions corresponding to it.
  3. Add the custom-designed node diagrams to the chart.

Describe alternatives you've considered
I have tried many paid and open-source lib but very few are compatible with Vue.js and further very few have such flexibility to change component looks by CSS or SCSS very easily.
I have tried https://github.com/joyceworks/flowchart-vue but it is SVG, providing no flexibility to change the look and feel of Nodes.

Script in Browser

vue-workflow-chart not rendered when used as script in browser
I tried to use it as script in browser using unpkg, but it's not rendering. Just an empty html custom element "workflow-chart"

To Reproduce
Steps to reproduce the behavior:

  1. Add reference using unpkg 'https://unpkg.com/[email protected]/dist/vue-workflow-chart.umd.min.js'
  2. Register component globally 'Vue.component('vue-workflow-chart');'
  3. Add custom html element
  4. Setup data

Expected behavior
States and transitions to be rendered

Desktop (please complete the following information):

  • OS: [windows 10 64]
  • Browser [e.g. chrome v 80]
  • Version [0.4.5]
  • Vue Version [2.5]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.