Coder Social home page Coder Social logo

rizqevo / angularjs-flowchart Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ashleydavis/angularjs-flowchart

0.0 2.0 0.0 1.43 MB

An example/template WebUI control for visualizing and editing flow charts

CSS 3.99% JavaScript 91.00% HTML 5.01%

angularjs-flowchart's Introduction

AngularJS-FlowChart

A WebUI control for visualizing and editing flow charts.

This isn't designed to be completely general purpose, but it will be a good basis if you need an SVG flowchart and you are willing to work with AngularJS.

Code Project Article

http://www.codeproject.com/Articles/709340/Implementing-a-Flowchart-with-SVG-and-AngularJS

How to use it

Include the following Javascript in your HTML file:

	<script src="flowchart/svg_class.js" type="text/javascript"></script>
	<script src="flowchart/mouse_capture_service.js" type="text/javascript"></script>
	<script src="flowchart/dragging_service.js" type="text/javascript"></script>
	<script src="flowchart/flowchart_viewmodel.js" type="text/javascript"></script>
	<script src="flowchart/flowchart_directive.js" type="text/javascript"></script>

Make a dependency on the the flowchart's AngularJS module from your application (or other module):

	angular.module('app', ['flowChart', ])

In your application (or other) controller setup a data-model for the initial flowchart (or AJAX the data-model in from a JSON resource):

	var chartDataModel = {

		nodes: [
			{
				name: "Example Node 1",
				id: 0,
				x: 0,
				y: 0,
				inputConnectors: [
					{
						name: "A",
					},
					{
						name: "B",
					},
					{
						name: "C",
					},
				],
				outputConnectors: [
					{
						name: "A",
					},
					{
						name: "B",
					},
					{
						name: "C",
					},
				],
			},

			{
				name: "Example Node 2",
				id: 1,
				x: 400,
				y: 200,
				inputConnectors: [
					{
						name: "A",
					},
					{
						name: "B",
					},
					{
						name: "C",
					},
				],
				outputConnectors: [
					{
						name: "A",
					},
					{
						name: "B",
					},
					{
						name: "C",
					},
				],
			},

		],

		connections: [
			{
				source: {
					nodeID: 0,
					connectorIndex: 1,
				},

				dest: {
					nodeID: 1,
					connectorIndex: 2,
				},
			},


		]
	};

Also in your controller, wrap the data-model in a view-model and add it to the AngularJS scope:

	$scope.chartViewModel = new flowchart.ChartViewModel(chartDataModel);

Your code is in direct control of creation of the view-model, so you can interact with it in almost anyway you want.

Finally instantiate the flowchart's AngularJS directive in your HTML:

    <flow-chart
		style="margin: 5px; width: 100%; height: 100%;"
      	chart="chartViewModel"
      	>
    </flow-chart>

Be sure to bind your view-model as the 'chart' attribute!

Have fun and please contribute!

angularjs-flowchart's People

Contributors

abariatti avatar ashleydavis avatar bridge-nauphal avatar claud1nho avatar kyleledbetter avatar matthewha avatar sintrb avatar tawanda avatar

Watchers

 avatar  avatar

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.