Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

d3kit

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

d3kit

A kit of tools to speed D3 related project development.

  • 3.0.0-6
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
552
decreased by-12.8%
Maintainers
1
Weekly downloads
 
Created
Source

d3Kit

NPM version Build Status Dependency Status

d3Kit provides thin scaffold for creating reusable charts and utilities for speeding visualization development with D3. It aims to relieve you from the same groundwork tasks you found yourself doing again and again. Writing code in d3Kit way also help you create reusable and responsive components easily.

For developers who have tried d3Kit v1-2, d3Kit v3 was rewritten to support D3 v4, consider several new use cases (<canvas>, for example) and use ES6 class for the implementation, making every chart can be extended easily.

Install

# via npm
npm install d3-selection d3-dispatch d3kit --save
# or bower
bower install d3 d3kit --save

Why should you use d3Kit?

P1: You are tired of copying the boilerplate d3.select('body').append('svg')... from D3 examples.

There is SvgChart for that.

P2: You want to create a chart on <canvas> but never remember how to handle different screen resolution (retina display).

There is CanvasChart for that.

P2: You want to create a reusable chart in D3.

You can extends from SvgChart, CanvasChart, or AbstractChart.

P3: You want to create a responsive chart, but are tired of listening to window resize or manually polling for changes of element size by yourself.

If your chart extends from SvgChart, CanvasChart or AbstractChart, you get that ability for free.

P4: You want to make a responsive chart that maintains aspect ratio.

If your chart extends from SvgChart, CanvasChart or AbstractChart, you get that ability for free.

P5: You use D3's margin convention and are tired of copy pasting from Mike's block

If your chart extends from SvgChart, CanvasChart or AbstractChart, you get that ability for free.

P6: You are familiar with creating charts in D3 and want to adapt them easily into React or angular components.

Currently there are react-d3kit and angular-d3kit-adapter that can convert any chart written in d3Kit into React and angular components, respectively, in a few lines of code.

What is d3Kit?

The core of d3Kit are base classes for creating a chart. Currently there are SvgChart and CanvasChart, both extends from AbstractChart. (This was revised and improved from the Skeleton in d3Kit v1-2.)

AbstractChart

  • takes a target container (usually a <div>) and helps you build a chart inside.
  • encapsulates D3's margin convention [P5]
  • can listen to resize (either window or element) and update the chart size to fit and maintain given aspect ratio. Once the chart is resized, it will dispatch event resize. [P3, P4]
  • defines two main input channels .data(...) and .options(...) and dispatch event data and options when they are changed, respectively.
  • assumes little about how you implement a chart. You can extends it and implements it the way you want.

Most of the time you will not need to access AbstractChart directly, but you will use one of its children: SvgChart or CanvasChart.

SvgChart

  • create <svg> boilerplate inside the container

CanvasChart

  • create <canvas> inside the container. It also handles different screen resolution for you (retina display vs. standard display).

Other features

LayerOrganizer

Help you manage layers.

Chartlet

d3Kit v1-2 also helps you create reusable subcomponent (a.k.a. Chartlet). We have not ported it to v3 yet.

Examples

Here are a few examples of d3Kit in action:

For more examples, check out our gallery.

Documentation

Want to learn more?

Appendix

A diagram explaining D3's margin convention

Authors

License

© 2015-2016 Twitter, Inc. MIT License

Keywords

FAQs

Package last updated on 14 Oct 2016

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