Socket
Book a DemoInstallSign in
Socket

d3-exporter

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
Package was removed
Sorry, it seems this package was removed from the registry

d3-exporter

A D3.js plugin for exporting animations.

0.1.0
unpublished
latest
Source
npmnpm
Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

d3-exporter

A D3.js plugin for exporting animations.

Installation

npm install d3-exporter

Getting Started

import * as d3 from 'd3';
import Exporter from 'd3-exporter';

(async function() {
    const width = window.innerWidth;
    const height = window.innerHeight;
    const radius = 50;

    const svg = d3.create('svg')
        .attr('viewBox', [0, 0, width, height])
        .style('height', '100%')
        .style('width', '100%')

    svg.append('circle')
        .attr('cx', width / 2 - radius / 2)
        .attr('cy', height / 2 - radius / 2)
        .style('fill', '#000')
        .transition()
            .duration(1000)
            .ease(d3.easeCubicOut)
            .attrTween('r', () => d3.interpolate(0, radius))

    document.body.appendChild(svg.node());
    await Exporter.sequence(svg);
})();

API

Exporter.render(element, options: RenderOptions) : []Blob

Renders a frame sequence and returns an array of image blobs.

RenderOptions

An object of options to pass into Exporter.render.

FieldTypeDefault ValueDescription
frameCountNumber60The number of frames to run the exporter for.
frameRateNumber60The frame rate of the exporter.
backgroundColorString#FFFA background color for the exported image.

Exporter.sequence(element, options: SequenceOptions)

Exports a frame sequence from a D3 animation.

SequenceOptions

An object of options to pass into Exporter.sequence.

FieldTypeDefault ValueDescription
imageTypeStringjpegA file format for the image output.
frameCountNumber60The number of frames to run the exporter for.
frameRateNumber60The frame rate of the exporter.
backgroundColorString#FFFA background color for the exported image.

Exporter.frame(element, options: FrameOptions)

Exports a frame from a D3 animation.

FrameOptions

An object of options to pass into Exporter.frame.

FieldTypeDefault ValueDescription
imageTypeStringjpegA file format for the image output.
frameIndexNumber0The frame index to export.
frameCountNumberframeIndex + 1The number of frames to run the exporter for.
frameRateNumber60The frame rate of the exporter.
backgroundColorString#FFFA background color for the exported image.

Author

Kazi Jawad

Acknowledgements

html-to-image

FAQs

Package last updated on 02 Jan 2022

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.