GithubHelp home page GithubHelp logo

rsoares / pie-chart Goto Github PK

View Code? Open in Web Editor NEW

This project forked from n3-charts/pie-chart

0.0 1.0 0.0 1.64 MB

Yummy pies and donuts for AngularJS

Home Page: n3-charts.github.io/pie-chart/

License: MIT License

JavaScript 99.34% CSS 0.66%

pie-chart's Introduction

n3-charts.pie-chart Build Status

Yummy pies and donuts for AngularJS applications. Built on top of the wonderful D3.js library.

Here is a demo page.

How to install

  • Copy pie-chart.min.js wherever you want
  • Reference it in your index.html file
  • Reference the module in your app file : angular.module('myApp', [ 'n3-pie-chart' ])

How to use

A pie chart is called using this syntax :

<pie-chart data="data" options="options"></pie-chart>

The pie chart directives needs two attributes : data and options. If one is missing, nothing happens.

Data

Your data must be an array. Depending whether you wan a pie/donut or a gauge, the array can contain at least two rows, or only one.

Standard
$scope.data = [
  {label: "one", value: 12.2, color: "red"}, 
  {label: "two", value: 45, color: "#00ff00"},
  {label: "three", value: 10, color: "rgb(0, 0, 255)"}
];
Gauge
$scope.gauge_data = [
  {label: "CPU", value: 75, suffix: "%", color: "steelblue"}
];
  • complementBrightness : optional (disabled by default). Expects a number between 0 and 100. If set, it will take the color of the chart, increase the brightness by a given percentage and use the new color for the complement.
  • colorComplement : optional (default is "white"). Defines the color of the complement. Will be ignored if complementBrightness is set.

Options

Options must be an object. Depending whether you want a pie/donut or a gauge, additional settings can be required.

Standard
$scope.options = {thickness: 10};
  • thickness : optional (default is 10). Defines the chart's thickness and has an impact on the legend display (thicker chart means less space for legend).
Gauge
$scope.gauge_options = {thickness: 5, mode: "gauge", total: 100};
  • thickness : optional (default is 10). Defines the chart's thickness and has an impact on the legend display (thicker chart means less space for legend).
  • mode : optional (default is ""). Can be "gauge" or anything else (but anything else will default to standard pie/donut mode). "gauge" only works when there is exactly one data row in the chart's data attribute.
  • total : optional (default is 100). Ignored if mode is not "gauge". Make the chart able to display the data relatively to a maximum (for instance, if you want to display a percentage, the maximum should be 100).

Building

Fetch the repo :

$ git clone https://github.com/angular-d3/pie-chart.git

Install stuff :

$ npm install

Install moar stuff :

$ bower install

Install teh uterz stuff :

$ grunt

Hack.

Testing

AngularJS is designed to be testable, and so is this project. It has a good coverage rate (between 85% and 95%), and we want to keep it this way.

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.