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

@redsift/d3-rs-legends

Package Overview
Dependencies
Maintainers
23
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@redsift/d3-rs-legends

Generates legends for charts using D3v4.

  • 0.5.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
23
Created
Source

d3-rs-legends

d3-rs-legends generate a legend for charts.

Builds

Circle CI

Example

View @redsift/d3-rs-legends on Codepen

Default

![Default bottom orientation](https://bricks.redsift.io/reusable/d3-rs-legends.svg?_datum=['A', 'B', 'C'])

Left

![Left orientation](https://bricks.redsift.io/reusable/d3-rs-legends.svg?_datum=['A', 'B', 'C']&orientation=left)

Right

![Right orientation](https://bricks.redsift.io/reusable/d3-rs-legends.svg?_datum=['A Short', 'B', 'C Long']&orientation=right)

Top, rounded and spaced out

![Top orientation](https://bricks.redsift.io/reusable/d3-rs-legends.svg?_datum=['A', 'B', 'C']&orientation=top&radius=10&padding=40)

Usage

Browser

<script src="//static.redsift.io/reusable/d3-rs-legends/latest/d3-rs-legends.umd-es2015.min.js"></script>
<script>
	var chart = d3_rs_legends.html();
	d3.select('body').datum([ 'A', 'B' ]).call(chart);
</script>

ES6

import { chart } from "@redsift/d3-rs-legends";
let eml = chart.html();
...

Require

var chart = require("@redsift/d3-rs-legends");
var eml = chart.html();
...

Datum

  • Simplest form, array of strings: ['A', 'B', 'C', ...]

Parameters

PropertyDescriptionTransitionPreview
classedString SVG custom classN
width, height, size, scaleInteger SVG container sizes. Typically, use size to scale the chartY
marginObject, Number Margin affecting all chart elements
insetObject, Number Margin affecting the legend
styleString Custom CSS to inject into chartN
backgroundColor
theme*lightdark*
orientationString Location of the legend, one of top, bottom, left, rightN
legendSizeInteger Size of the color sampleN
spacingInteger Estimator of the amount of space to resere of each char in the text label
paddingInteger Pixels between each legend element
radiusInteger Radius of the legend rectangle. Rounds the element
fillArray, Function Colors to assign to legend in order
toggleableBoolean If true will add a new Checkbox on the left side of the color square to add capability to enable/disable legend items.N
onEnabledLegendItemsChangeFunction To be called whenever enabled legend items changed. It's called passing an array of the enabled legend indexesN
tintColorString Color to use for checkboxN

Keywords

FAQs

Package last updated on 15 Aug 2023

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