Coder Social home page Coder Social logo

angular-viz's Introduction

angular-viz.js

This is a module for using Viz.js on AngularJS.

example

# app.coffee

app = angular.module("app", ["atVizJs"])

# using provider.
app.config(["vizJsProvider", (provider)->
	# set common option.
	provider.option(
		format: "svg"
		engine: "dot"
	)

	# enable language-dot directive.
	provider.enableLanguageDirective()
])


# using on controller.
app.controller("ctrl", ["$scope", "$sce", "vizJs", ($scope, $sce, viz)->
	$scope.svg = $sce.trustAsHtml(viz.render("digraph { a -> b; }"))
])
<!doctype html>
<html ng-app="app">
    <head>
        <script src="bower_components/viz/index.js"></script>
        <script src="bower_components/angular/angular.js"></script>
        <script src="bower_components/angular-viz/angular-viz.js"></script>
        <script src="app.js"></script>
    </head>
    <body>
        <!-- using on controller. -->
        <div ng-controller="ctrl">
            <div ng-bind-html="svg"></div>
        </div>

        <!-- using directive by element. -->
        <dot>
            digraph { c -> d; }
        </dot>

        <!-- using directive by attribute. -->
        <div dot>
            digraph { e -> f; }
        </div>

        <!-- using directive by attribute with value. -->
        <div ng-init="code='digraph { g -> h; }'" dot="{{code}}">
        </div>

        <!-- using directive by class "language-dot". -->
        <pre><code class="language-dot">
            digraph { i -> j; }
        </code></pre>
    </body>
</html>

Note: If you want to use the rave.js, please use the ones that adopted this change.

angular-viz's People

Contributors

atomita avatar

Stargazers

Gianluca Esposito avatar Thomas L. Kjeldsen avatar Matthew McLeod avatar Denis Stoyanov avatar  avatar

Watchers

James Cloos avatar Denis Stoyanov 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.