0.4.1 • Published 4 years ago

@yosichikaw/vue-flowchart v0.4.1

Weekly downloads
-
License
MIT
Repository
github
Last release
4 years ago

vue-flowchart

A Mobile-friendly drag and pinchable flowchart components in Vue.js.

demo

demo

This is a demo application combined with BootstrapVue. https://vue-flowchart.ichi-dev.info/

Usage

Install via npm

npm install @yosichikaw/vue-flowchart

Add to your application

import Vue from 'vue';
import VueFlowchart from "@yosichikaw/vue-flowchart";

Vue.use(VueFlowchart);

Example code

<template>
  <div id="app">
    <VueFlowchart
      :flow="flow"
      :selected_node_ids="selectedNodeIds"
      :options="options"
      @onTouch="onTouch"
    />
</template>
<script>
export default {
  data() {
    return {
      flow: {
        nodes: [
          {id: 1, title: "title1", bodies: ["item1", "item2"], x: 10, y:500},
          {id: 1, title: "title2", bodies: ["item3"], x: 200, y:700},
        ],
        links: [
          { from: 1, index: 1, to: 2 },
        ],
      },
      selected_nodes: [],
      options:{},
    };
  },
  computed: {
    selectedNodeIds() {
      return this.selected_nodes.map((n) => n.id);
    },
  },
  methods: {
    onTouch({node_id}){
      // do something
    },
  }
};
</script>

Parameters

ParameterDefaultTypeDescription
id"vue-flowchart"StringThe ID of SVG element.
flowsee belowObjectFlowchart display data.
selected_node_ids[]ArrayList of IDs of selected nodes.
optionssee belowObjectOptions.

Define the default Parameters. https://github.com/IchikawaYoshihiro/vue-flowchart/blob/master/src/const.js

flow

ParameterTypeDefaultDescription
nodesArray[]
nodes.*.idString, Numbernull
nodes.*.titleString""
nodes.*.bodiesArray[]
nodes.*.bodies.*String""Message
nodes.*.xNumber0
nodes.*.yNumber0
liksArray[]
liks.*.fromString,Number0ID of the source node.
liks.*.indexNumber0The index of the bodies of the linking source node.
liks.*.toString,Number0ID of the linked node.

selected_node_ids

ID array of the selected node.

options

ParameterTypeDefaultDescription
draggableBooleantrueThe value of whether the background can be dragged.
pinchableBooleantrue
enable_gridBooleantrueThe value to display the grid.
enable_filterBooleantrueValue whether to apply shadow filter, if true, drawing performance will be reduced on low specs.
canvas.scaleNumber0.75
canvas.gridNumber10
canvas.grid_colorString"#bbb"
node.draggableBooleantrueThe value of whether the node can be dragged.
node.fit_gridBooleantrueThe value to align to the grid when the node is moved.
node.bgcolorString"#fff"
node.border_colorString"#40b883"
node.border_widthNumber1.5
node.max_widthNumber300
node.font_size.titleNumber16
node.font_size.bodyNumber12
node.default_text.titleString"No title"
node.default_text.bodyString"No message"
node.text_color.titleString"#111"
node.text_color.bodyString"#000"
link.border_colorString"#40b883"
link.border_widthNumber1.5
link.typeline, key_line, curve"line"
control.detect_double_touch_msecNumber500The value of how many milliseconds it is judged to be a double touch when it is touched twice.
control.detect_long_touch_msecNumber500The value of how many milliseconds or more of continuous touch is judged to be long touch.
control.detect_move_pxNumber10The range of whether you are tapping the same spot. If you make it too small, a slight shift of your finger will be judged as a move and the long tap will not fire.
control.drag_fpsNumber60Drag event firing frequency. If you set it above 120, all movement events will fire, which may result in a performance degradation.

Events

EventArgmentsDescription
onTouch{ node_id }When touched.
onLongTouch{ node_id }When long-touched.
onDoubleTouch{ node_id }When touched twice.
onTouchEnd{ node_id }When the touch is over.
onDrag{ dx, dy }When draggable is enabled and the cursor is moved.
onBackgroundDrag{ dx, dy }When draggable is enabled and the cursor is moved in a blank space.
onPinch{ dr, dh, dv, dl, cx, cy }When pinching or mouse wheel is used.dr: Rotation angle. dh, dv : Difference between horizontal and vertical movement.dl: Difference in touch distance or wheel travel distance. cx,cy: Touch intermediate coordinates or wheeled coordinates.

Slots

grid

Custom grids can be added. If enable_grid is disabled, it is not visible. The ID of the pattern element must be specified as "grid".

Example

Dotted Grid.

<VueFlowchart>
  <template v-slot:grid="{ options, gridScale }">
    <defs>
      <pattern
        id="grid"
        x="0"
        y="0"
        :width="gridScale.x"
        :height="gridScale.y"
      >
        <circle cx="0" cy="0" r="1" :stroke="options.canvas.grid_color" />
      </pattern>
    </defs>
  </template>
</VueFlowchart>

filter

Allows you to add a custom filter. Not visible if enable_filter is disabled. The ID of the pattern element must be specified as "filter".

Example

An embossable filter sample.

<VueFlowchart>
  <template v-slot:filter">
    <defs>
      <filter id="filter">
        <feConvolveMatrix order="3 3" kernelMatrix="3 0 0 0 1 0 0 0 -3" />
      </filter>
    </defs>
  </template>
</VueFlowchart>

Change Log

CHANGELOG.md

0.4.1

4 years ago

0.4.0

4 years ago

0.3.2

4 years ago

0.3.0

4 years ago

0.3.1

4 years ago

0.2.0

4 years ago

0.1.4

4 years ago

0.1.6

4 years ago

0.1.5

4 years ago

0.1.2

4 years ago

0.1.3

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago