Socket
Socket
Sign inDemoInstall

d3-funnel

Package Overview
Dependencies
Maintainers
1
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

d3-funnel

A library for rendering SVG funnel charts using D3.js


Version published
Weekly downloads
4.2K
decreased by-1.93%
Maintainers
1
Weekly downloads
 
Created
Source

D3 Funnel

D3Funnel is an extensible, open-source JavaScript library for rendering funnel charts using the D3.js library.

D3Funnel is focused on providing practical and visually appealing funnels through a variety of customization options. Check out the examples page to get a showcasing of the several possible options.

Usage

To use this library, you must include the source files for D3.js and D3Funnel.

<script src="/path/to/d3.min.js"></script>
<script src="/path/to/d3-funnel.js"></script>

You must also create a container element and instantiate a new chart:

<div id="funnel"></div>

<script>
    var data = [
        ['Plants',     5000],
        ['Flowers',    2500],
        ['Perennials', 200],
        ['Roses',      50]
    ];
    var options = {};

    var chart = new D3Funnel('#funnel');
    chart.draw(data, options);
</script>

Options

OptionDescriptionTypeDefault
widthThe pixel width of the chart.intContainer's width
heightThe pixel height of the chart.intContainer's height
bottomWidthThe percent of total width the bottom should be.float1 / 3
bottomPinchHow many sections to pinch on the bottom to create a "neck".int0
isCurvedWhether the funnel is curved.boolfalse
curveHeightThe curvature amount (if isCurved is true).int20
fillTypeEither "solid" or "gradient".string'solid'
isInvertedWhether the funnel is inverted (like a pyramid).boolfalse
hoverEffectsWhether the funnel has effects on hover.boolfalse
dynamicAreaWhether block areas are calculated by counts (as opposed to static height).boolfalse
minHeightThe minimum pixel height of a block.int/boolfalse
animationThe load animation speed in milliseconds.int/boolfalse
label.fontSizeAny valid font size for the labels.string'14px'
label.fillAny valid hex color for the label colorstring'#fff'
onItemClickEvent handler if one of the items is clicked.functionfunction(d, i) {}

Advanced Data

You can specify overriding colors for any data point (hex only):

var data = [
    ['Teal',      12000, '#008080' '#080800'],
    ['Byzantium', 4000,  '#702963'],
    ['Persimmon', 2500,  '#ff634d' '#6f34fd'],
    ['Azure',     1500,  '#007fff' '#07fff0']
    //         Background ---^         ^--- Label
];

If you want to pass formatted values to be shown in the funnel, pass in an array containing the value and formatted value:

var data = [
    ['Teal',      [12000, 'USD 12,000']],
    ['Byzantium', [4000,  'USD 4,000']],
    ['Persimmon', [2500,  'USD 2,500']],
    ['Azure',     [1500,  'USD 1,500']]
];

License

MIT license.

FAQs

Package last updated on 13 Jun 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc