Git Product home page Git Product logo

angular-paths's Introduction

angular-paths

Does the usual small things to "angularize" paths.js:

  • wraps the paths global in an injectable Paths service
  • provides a bunch of directives for paths' high-level API

In addition

The directives pre-compute svg paths for line, area, sector and polygon, and make them accessible from curve._line, curve._area, curve._sector and curve._polygon respectively.

The traditional paths approach of calling curve.<shape>.path.print() in a template would't match well with angular digest cycle performance-wise (especially in the typical ng-repeat scenario).

Install

bower install angular-paths

Usage

Declare the paths dependency somewhere in your app, and either inject the Paths service in order to access all paths APIs or use any of the paths-<graph> directives as in

<div paths-bar="barConfig">
    <svg ng-attr-width="{{viewport.width}}" ng-attr-height="{{viewport.height}}">
      <path ng-repeat="curve in curves" ng-attr-d="{{curve._line}}"/>
    </svg>
</div>

where

  • the paths-<graph> attribute specifies what to pass to the path.<Graph> constructor, e.g.:

    scope.barConfig = {
      data: [
        [
          { name: 'Italy', population: 59859996 },
          { name: 'Spain', population: 46704314 },
          { name: 'France', population: 65806000 },
          { name: 'Romania', population: 20121641 },
          { name: 'Greece', population: 10815197 }
        ],
        [
          { name: 'Zambia', population: 14580290 },
          { name: 'Cameroon', population: 20386799 },
          { name: 'Nigeria', population: 173615000 },
          { name: 'Ethiopia', population: 86613986 },
          { name: 'Ghana', population: 24658823 }
        ]
      ],
      accessor: function(x) { return x.population; },
      gutter: 10,
      height: 100,
      template: 'templates/bar.html'
    };
    

    see paths docs for each specific graph options.

  • barConfig.data is two-way binded (and the computed paths updated accordingly)

  • viewport always contains width and height. By default, those are equal to the element computed size, but can be overidden using paths own width and height options

  • templates can be embedded inside the paths-<graph> element directly or inlined/included using the paths-template attribute or the config.template option.

See working examples for more details.

angular-paths's People

Contributors

calippo avatar giogonzo avatar

Stargazers

 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.