Socket
Book a DemoInstallSign in
Socket

d3-dragrect

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

d3-dragrect

A JavaScript D3 drag selection rectangle component.

latest
Source
npmnpm
Version
0.0.2
Version published
Maintainers
1
Created
Source

JavaScript - d3-dragrect

A JavaScript D3 drag selection rectangle component. Only horizontal at the moment.

This essentially allows you to use a graph that you created in D3 and then drag and visually select portions of the graph. You can create multiple selections.

Screenshots and examples coming when the API stabilizes a bit.

Install

Script

<script src="/path/to/d3-dragrect.js"></script>

Browserify

npm install --save d3-dragrect

Component

component install jprichardson/d3-dragrect

Usage

Example

//only use 'require' if using browserify or component
var d3dragrect = require('d3-dragrect') 

//'svg' is your svg element, typically 'height' would be the height of 'svg'
var dragBehavior = d3dragrect(d3, svg, xScale, height)

svg.call(dragBehavior)

Methods

dragBehavior.createRect(x, y, width, height, [id])

dragBehavior.isPointInAnyRect(pt)

dragBehavior.getLastRectData()

dragBehavior.deleteAllSelected(callback)

dragBehavior.on('dragstart|drag|dragend', callback)

Styling

The default styling will be very ugly. This makes it look alright:

.d3-dragrect {
  stroke: steelblue;
  stroke-dasharray: 5,5;
  fill: aliceblue;
  fill-opacity: 0.5;
  hover: ;
}

.d3-dragrect:hover {
  stroke: red;
  fill-opacity: 0.7;
  stroke-dasharray: 1,1;
}

.d3-dragrect.selected {
  stroke: red;
  fill-opacity: 0.5;
}

License

(MIT License)

Copyright 2013, JP Richardson jprichardson@gmail.com

FAQs

Package last updated on 03 Jul 2013

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