Skip to content

Instantly share code, notes, and snippets.

@christophermanning
christophermanning / README.md
Last active December 14, 2015 03:29 — forked from gtb104/README.markdown
d3.js polybrush.js

Forked from: https://gist.github.com/gtb104/3667340

Here's a d3 plugin that allows you to create a polygon selection. You instantiate it just like d3.svg.brush.

var brush = d3.svg.polybrush();

It has an extra public method that 'brush' does not, and that's 'isWithinExtent(x, y)'. You can use this method to test if a given point falls within the drawn extent.

if (brush.isWithinExtent(x, y)) {
 console.log("I'm inside!");
@christophermanning
christophermanning / octocat.svg
Last active May 11, 2024 08:31 — forked from johan/octocat.svg
octocat.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@christophermanning
christophermanning / README.md
Last active December 22, 2019 10:32 — forked from tmcw/index.html
Unknown Pleasures

Forked from Tom MacWright and updated by Christopher Manning

Summary

This adds simplex noise to the waves. The 3D noise uses the parameters x and y. z is a function of the velocity and frame from d3.timer.

Controls

  • Drag up and down to adjust the height of the noise
@christophermanning
christophermanning / README.md
Created October 1, 2012 03:20 — forked from mbostock/.block
General Update Pattern, III

By adding transitions, we can more easily follow the elements as they are entered, updated and exited. Separate transitions are defined for each of the three states.

Note that no transition is applied to the merged enter + update selection; this is because it would supersede the transition already scheduled on entering and updating elements. It's possible to schedule concurrent elements by using transition.transition or by setting transition.id, but it's simpler here to only transition the x-position on update; for entering elements, the x-position is assigned statically.

Want to read more? Try these tutorials: