npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

d3-electrophoresis

v1.0.3

Published

D3.js plugin to simulate electrophoresis by cutting text.

Downloads

100

Readme

d3-electrophoresis

A D3.js plugin to simulate electrophoresis which is a basic biotechnological technique to visualize length of DNA segments cut by restriction enzyme. Using this plugin, you can cut not only DNA sequence, but also any text, by words.

Examples

Cutting text by words

result_text_name1_small1.png

You can change text and words in the showcases.

Using SVG for CGI

By SVG Crowbar, you can download the resulted DNA bands as SVG. And the SVG can be used for, such as 3D object in Blender. The CGI image below was made with Blender, including SVG bands in the gel.

The detail and other images are on the blog: New D3.js plugin: D3-electrophoresis released. electrophoresis_trump-speech_cleanbench1_up1_smal1.jpg

Install

  1. Download d3-electrophoresis.js from right click, or use npm npm install d3-electrophoresis and get it in "src" folder.
  2. In HTML, load D3.js (v.4) and d3-electrophoresis.js with <script>tags, like the code below.
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/4.5.0/d3.min.js" charset="utf-8"></script>
<script src="d3-electrophoresis.js"></script>

Basic Usage

var gel = electrophoresis();

var svg = d3.select("body").append("svg")
  .attr("width", 460)
  .attr("height", 500)
  .call(gel.makeGel); // Make black background first.

var text = "AGCGCCCAATACGCAAACCGCCTCTCCCCGCGCGTTGGCCGATTCACGTTTACGAGTTGGAAACGA";
var words = [[1,5,10,15,20,30,40,50,70,100],"CAAA","GTTGG","GGATCC", "GA",["GT","CCT"],"ACC", "GAAA"];
var names = ["marker", "1", "2", "3", "4", "5", "6", "7"];
// You can set every parameter by dictionary or method-chain. Example: {DNA: text} or .DNA(text).
gel = electrophoresis().DNA(text).enzymes(words).names(names);
svg.call(gel);

Parameters

You can set every parameter by dictionary input:

var gel  = electrophoresis({DNA:"agtctatcacg", enzymes:["ac","gca"]});

and/or by method-chain:

var gel = electrophoresis().DNA("agtctatcacg").enzymes(["ac","gca"]);

Tips

Changing scale

result_scale_200-400_1.png

To change vertical scale of band, like changing gel concentration, use .scale() chain, and input d3's scale object.

For example, to make band within y=200~400 in linear scale, add scale() chain after electrophoresis().~, and input d3-scale object:

var yScale = d3.scaleLinear().range([200,400]);
gel = electrophoresis({DNA: text}).enzymes(words).names(names).scale(yScale);

API Reference

# electrophoresis.DNA([text])

Target text to be cut.

Default: "AGCGCCCAATACGCAAACCGCCTCTCCCCGCGCGTTGGCCGATTCACGTTTACGAGTTGGAAACGA".

# electrophoresis.enzymes([list])

Word list to cut target text.

When the word list includes a number list as a element, (e.g. ["AC",[10,15,20]]), the numbers are directly used as resulted length of cut segmented text without cutting text. When the word list includes a word list as a element, (e.g. ["AC",["GT","CCT"]]), target text is cut by both of the two words all together.

Default: [[1,5,10,15,20,30,40,50,70,100],"CAAA","GTTGG","GGATCC", "GA",["GT","CCT"],"ACC", "GAAA"].

# electrophoresis.names([list])

Name list of enzymes. They appear as tooltips on each resulted lane.

Default: ["marker", "1", "2", "3", "4", "5", "6", "7"].

# electrophoresis.scale([obj])

A scale to map length values of segmented texts from top to the bottom. The input must be a scale object in D3-v.4 syntax, such as d3.scaleSqrt(), d3.scaleLinear(), d3.scalePow() .etc. See how to use d3/d3-scale.

To make band within height of 200-500 in linear scale, for example, use d3.scaleLinear().range([200, 500])).

Default: d3.scaleLinear().

# electrophoresis.lane_number([int])

Max number of lanes.

Default: 8.

# electrophoresis.gel_margin([dict])

Margin size from edges of background.

Default: {top: 40, right: 20, bottom: 30, left: 20}.

# electrophoresis.duration([float])

Time to finish animation.

Default: 6000.

# electrophoresis.band_width([float])

Width of bands.

Default: 38.

# electrophoresis.band_blur([float])

Blur of bands.

Default: 2.

# electrophoresis.band_thick_min([float])

Minimum thickness of bands.

Default: 1.

# electrophoresis.band_thick_rate([float])

How bands turns less thick as the bands go down.

Default: 0.04

# electrophoresis.tooltip_name_on([str])

"on" or "off" for tooltips of enzyme name on upper side.

Default: "on".

# electrophoresis.tooltip_name_size([float])

Size of name tooltips.

Default: 17.

# electrophoresis.tooltip_name_offsetX([float])

Horizontal offset of name tooltips.

Default: 0.

# electrophoresis.tooltip_name_offsetY([float])

Vertical Offset of name tooltips.

Default: 20.

# electrophoresis.tooltip_band_on([str])

"on" or "off" for tooltips of band length.

Default: "on";

# electrophoresis.tooltip_band_size([float])

size of band tooltips.

Default: 13.

# electrophoresis.tooltip_band_offsetX([float])

Horizontal offset of band tooltips.

Default: 0.

# electrophoresis.tooltip_band_offsetY([float])

Vertical offset of band tooltips.

Default: 0.