GithubHelp home page GithubHelp logo

d3-legend's Introduction

d3-legend

Full documentation: http://d3-legend.susielu.com

Usage

Using just the minified file

You must inclue the d3 library before including the legend file. Then you can simply add the compiled js file to your website:

  • d3-legend.min.js
  • d3-legend.js (Human readable version)

Using CDN

You can also add latest version of d3-legend hosted on cdnjs.

Using npm

Already using d3? Great! You can add the d3 legend as a node module by running:

npm i d3-svg-legend -S

If not, install both this way:

npm i d3@^3.0.0 d3-svg-legend -S

Please note, d3 is now a peer dependency, you will have to have the npm d3 module separately. This component works with any 3.x version of d3.

If you require('d3-svg-legend') we attach to d3 as d3.legend. If you'd like to use d3-legend without extending d3, require('d3-svg-legend/no-extend'). For example:

var d3 = require('d3')
var legend = require('d3-svg-legend/no-extend')

var svg = d3.select("#svg-color-quant");

var quantize = d3.scale.quantize()
    .domain([ 0, 0.15 ])
    .range(d3.range(9).map(function(i) { return "q" + i + "-9"; }));

svg.append("g")
  .attr("class", "legendQuant")
  .attr("transform", "translate(20,20)");

var colorLegend = legend.color()
    .labelFormat(d3.format(".2f"))
    .useClass(true)
    .scale(quantize);

svg.select(".legendQuant")
  .call(colorLegend);

Feedback

I would love to hear from you about any additional features that would be useful, please say hi on twitter @DataToViz.

d3-legend's People

Contributors

susielu avatar floribon avatar colineberhardt avatar seripap avatar hypercubed avatar eversojk avatar tamc avatar

Watchers

James Cloos 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.