项目作者: tsv2013

项目描述 :
Algorithm block diagram visualization and editing widget (jQuery+KnockoutJS)
高级语言: TypeScript
项目地址: git://github.com/tsv2013/algorithm.git
创建时间: 2015-05-11T20:41:29Z
项目社区:https://github.com/tsv2013/algorithm

开源协议:MIT License

下载


tsvw-algorithm

Build Status Coverage Status GitHub version Bower version Standard Version

Algorithm block diagram visualization and editing widget (jQuery+KnockoutJS)

Live demo at: http://tsv2013.github.io/algorithm/

NPM

How to visualize algorithm block diagram

  1. Add the following markup to your page:

    1. <div data-bind="algorithm: { value: algorithm }"></div>
  2. Define algorithm via JSON, for instance:

    1. var model = {
    2. algorithm: {
    3. items: [
    4. { id: 9, text: "finish" },
    5. { id: 6, text: "is condition true?" },
    6. { id: 3, text: "block is in progress", state: "inprogress" },
    7. { id: 7, text: "this block has a number", num: 1 },
    8. { id: 2, text: "this is a simple block with a very very content string" },
    9. { id: 1, text: "start", comment: "This is the start block." },
    10. { id: 4, text: "this block is completed", state: "completed" },
    11. { id: 5, text: "an intermediate block" },
    12. { id: 8, text: "pre-end simple block" },
    13. ],
    14. transitions: [
    15. { iid: 1, exit1: 2, exit2: null },
    16. { iid: 2, exit1: 3, exit2: null },
    17. { iid: 2, exit1: 5, exit2: null },
    18. { iid: 3, exit1: 4, exit2: null },
    19. { iid: 4, exit1: 6, exit2: null },
    20. { iid: 5, exit1: 6, exit2: null },
    21. { iid: 6, exit1: 7, exit2: 8 },
    22. { iid: 7, exit1: 9, exit2: null },
    23. { iid: 8, exit1: 9, exit2: null },
    24. ]
    25. }
    26. };
  3. Bind model via KnockoutJS:

    1. ko.applyBindings(model);

How to modify algorithm block diagram

While hovering mouse over algorithm blocks you will see control points to add blocks above and below, delete block and drag to link this block with other one.

Building tsvw-algorithm from sources

  1. Clone the repo from GitHub

    1. git clone https://github.com/tsv2013/algorithm.git
    2. cd algorithm
  2. Acquire build dependencies. Make sure you have Node.js installed on your workstation. This is only needed to build algorithm from sources.

    1. npm install -g karma-cli
    2. npm install
  3. Build the library

    1. npm run build

    After that you should have the library at ‘dist’ directory.

  4. Run unit tests

    1. karma start

    This command will run unit tests usign Karma