# d3-container

> Graphic container

Latest version **0.0.1** (published 2016-05-16) · BSD-3-Clause license · 0 weekly downloads

## Install

```sh
npm install d3-container
pnpm add d3-container
yarn add d3-container
bun add d3-container
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 0.0.1 |
| Published | 2016-05-16 |
| First published | 2016-05-16 |
| Weekly downloads | 0 |
| License | BSD-3-Clause |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 5 |
| Maintainers | binaworks |
| Keywords | d3, container, margin |

## Links

- npm: https://www.npmjs.com/package/d3-container
- Repository: https://github.com/binaworks/d3-container
- Issues: https://github.com/binaworks/d3-container/issues
- npm.io page: https://npm.io/package/d3-container

## Alternatives

- [d3-force-3d](https://npm.io/package/d3-force-3d.md) — 1.0M weekly downloads
- [ng2-charts](https://npm.io/package/ng2-charts.md) — 486.8K weekly downloads
- [@arcgis/core](https://npm.io/package/@arcgis/core.md) — 257.8K weekly downloads
- [react-sparklines](https://npm.io/package/react-sparklines.md) — 249.3K weekly downloads
- [react-native-gifted-charts](https://npm.io/package/react-native-gifted-charts.md) — 182.3K weekly downloads

## Recent versions

- 0.0.1 (latest) — 2016-05-16

## README

# d3-container

Graphic container 
 
A D3 plugin for the margin convention. See https://bl.ocks.org/mbostock/3019563.

## API Reference

<a name="_container" href="#_container">#</a> <i>container</i>(<i>context</i>)

Create container content, a g element appended to the given *context*, a D3 [selection](https://github.com/d3/d3-selection). 
Content is offset from context according to the container's left and top [margin](#container_margin) specification.

<a name="container_contentHeight" href="#container_contentHeight">#</a> <i>container</i>.<b>contentHeight</b>()

If content has been created, returns the content height. Otherwise, returns 0.

<a name="container_contentWidth" href="#container_contentWidth">#</a> <i>container</i>.<b>contentWidth</b>()

If content has been created, returns the content width. Otherwise, returns 0.

<a name="container_height" href="#container_height">#</a> <i>container</i>.<b>height</b>(<i>size</i>)

If *size* is specified, sets the container height to the specified value and returns the container. If *size* is not specified, returns the current height, which defaults to 0.

<a name="container_margin" href="#container_margin">#</a> <i>container</i>.<b>margin</b>(<i>top</i>,<i>right</i>,<i>bottom</i>, <i>left</i>)

If arguments are specified, updates container margin sizes as specified and returns the container. 
Margin sizes default to 0 and are specified as in CSS.
- If only *top* is specified, then top, right, bottom and left margin sizes are set to *top*.
- If *top* and *right* are specified, then top and bottom margins are set to *top*, and
right and left margins are set to *right*.
- If only *top*, *right* and *left* are specified, then top and bottom margins are set to *top*, 
right margin is set to *right* and left margins is set to *left*.

If arguments are not specified, returns the container's margin object which has getter/setter functions for top, right,
bottom, and left sizes.

<a name="container_width" href="#container_width">#</a> <i>container</i>.<b>width</b>(<i>size</i>)

If *size* is specified, sets the container width to the specified value and returns the container. If *size* is not specified, returns the current width, which defaults to 0.



### Sample Usage

```js
var container = d3_container.container();

container
    .height(1000)
    .width(650)
    .margin(30, 10, 10);
    
svg.call(container);

var content = container.content();

content.append("rect")
       .attr("height", container.contentHeight())
       .attr("width", container.contentWidth())
       .attr("stroke", "green")
       .attr("stroke-width",5);

```

---
_Source: https://npm.io/package/d3-container · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
