d3-attrs

1.0.4 • Public • Published

D3-attrs

Allows to set attributes and styles for d3 selection as objects. Works fine with D3 v7 (d3-selection v3) and NodeJS v16.

Install

$ npm i d3-attrs -s

Use

import 'd3-attrs';

d3.select( 'svg' ).append( 'line' )
  .attrs({
    class: 'red_line',
    x1: d => d.x1,
    y1: 0,
    x2: 100, y2: 50
  })
  .styles( d => ({
    stroke: `#${ d.color }`,
    'stroke-width': d.width
  }) );

Package Sidebar

Install

npm i d3-attrs

Weekly Downloads

3

Version

1.0.4

License

ISC

Unpacked Size

1.6 kB

Total Files

3

Last publish

Collaborators

  • frolov_fsoft