Git Product home page Git Product logo

hachart's Introduction

Hachart

HaHa, this is a flowchart generator.

online edit website

example

install

npm install ha-chart --save

quick start

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>flow-draw</title>
  </head>
  <body>
    <div id="container"></div>
  </body>
</html>
const {compiler, layout, Container} = require('ha-chart')

const code = `
type CondStyle struct{
  "extend": "deafultShape",
  "fill": "#fcb738"
}

def start("action")
  () -> cond
end

def cond:CondStyle("is 10?")
  ("yes") -> step1
  ("no") -> step2
end

def step1("step 1")
end

def step2("step 2")
end
`

const output = layout(compiler(code))
const container = new Container({containerID: "container"})
container.draw(output)

example

API

compiler(code, options)

code

//create new style, you can extends default style to create new style
type style struct{
  "extend": "deafultShape",
  "fill": "#fcb738"
}

// create a chart
def name:style("string")
  () -> nextShape
end

options

you can change the default style at compiler code using options.

{
  type: {
    deafultShape: {
      fill: '#3ab882',
      cornerRadius: 10,
      maxWidth: 180,
      fontType: {
        fontSize: 16,
        fontFamily: 'Calibri',
        padding: 20,
        fill: '#fff',
        fontStyle: 'bold',
        align: 'center'
      }
    },
    defaultAnnotation: {
      fill: '#fff',
      fontType: {
        fontSize: 16,
        fontFamily: 'Calibri',
        padding: 5,
        fill: '#8699a3',
        fontStyle: 'bold',
        align: 'center'
      }
    },
    defaultFontType: {
      'fontSize': 16,
      'fontFamily': 'Calibri',
      'fill': '#fff',
      'fontStyle': 'bold',
      'align': 'center',
      'padding': 20
    },
    defaultArrow: {
      stroke: '#8699a3',
      strokeWidth: 3,
      lineCap: 'round',
      lineJoin: 'round'
    }
  }
}

draw with konvajs

more defaultShape and defaultAnnotation Parameters

more defaultArrow Parameters

more default fontType parameters

layout(input, options)

input

const input = compiler(code)

options

name defaultValue description
rankdir TB Direction for rank nodes. Can be TB, BT, LR, or RL, where T = top, B = bottom, L = left, and R = right.
align TB Alignment for rank nodes. Can be UL, UR, DL, or DR, where U = up, D = down, L = left, and R = right.
nodesep 50 Number of pixels that separate nodes horizontally in the layout.
edgesep 10 Number of pixels that separate edges horizontally in the layout.
ranksep 50 Number of pixels between each rank in the layout.
marginx 0 Number of pixels to use as a margin around the left and right of the graph.
marginy 0 Number of pixels to use as a margin around the top and bottom of the graph.
acyclicer undefined If set to greedy, uses a greedy heuristic for finding a feedback arc set for a graph. A feedback arc set is a set of edges that can be removed to make a graph acyclic.
ranker network-simplex Type of algorithm to assigns a rank to each node in the input graph. Possible values: network-simplex, tight-tree or longest-path

Container

constructor({containerID: "string"})

containerID: the id of document node.

draw(input)

draw the compiler code

hachart's People

Contributors

lellansin 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

hachart's Issues

How to run this?

I created a seperate index.html and added a the code on the readme. Also, I added the js snippet to the index.js file. Then i added the js file to the index.html . I used a python server to host this. I couldn't see a result. Can you please help me?

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.