Giter Club home page Giter Club logo

qd-formatters's Introduction

qd-formatters

This library formats numbers and currencies up to large numbers in the trillions.

Getting Started

Install

npm install --save git+https://github.com/QuickDash/qd-formatters

Require in your code

//pass your parent app's d3 object into the require
var formatters = require('qd-formatters')(d3);

//using the formatter
formatters.currencyFormat(32724); //prints $32,724
formatters.bigCurrencyFormat(12343); //prints $12k
formatters.numberFormat(32724); //prints 32,724
formatters.bigNumberFormat(12343); //prints 12k

API Reference

.currencyFormat(number)

Pass a number to currencyFormat and a dollar sign will be prepended to the number. Comma separators will also be added to separate thousands, millions, billions etc.

.bigCurrencyFormat(number)

Pass a number to bigCurrencyFormat and a dollar sign will be prepended to the number. The number will then be formatted to 3 digits or less. A letter will be added to indicate the size of the number. k for thousands, m for millions, b for billions, t for trillions.

.numberFormat(number)

Pass a number to numberFormat. Comma separators will also be added to separate thousands, millions, billions etc.

.bigNumberFormat(number)

Pass a number to bigNumberFormat. The number will then be formatted to 3 digits or less. A letter will be added to indicate the size of the number. k for thousands, m for millions, b for billions, t for trillions.

qd-formatters's People

Contributors

ajessee avatar jackcompton avatar tehandyb 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.