Skip to content

Instantly share code, notes, and snippets.

View musically-ut's full-sized avatar
🐙
🐢 🎣 🐠

Utkarsh Upadhyay musically-ut

🐙
🐢 🎣 🐠
View GitHub Profile
@musically-ut
musically-ut / flare.json
Last active December 28, 2015 15:39 — forked from mbostock/.block
Tree layout with root collapsed
{
"name": "flare",
"children": [
{
"name": "analytics",
"children": [
{
"name": "cluster",
"children": [
{"name": "AgglomerativeCluster", "size": 3938},
@musically-ut
musically-ut / README.md
Last active December 28, 2015 12:58 — forked from mbostock/.block
Set the initial zoom level of a brush.

This examples demonstrates how to use D3's brush component to implement focus + context zooming. Click and drag in the small chart below to pan or zoom.

@musically-ut
musically-ut / README.md
Last active December 28, 2015 12:49 — forked from mbostock/.block

This examples demonstrates how to use D3's brush component to implement focus + context zooming. Click and drag in the small chart below to pan or zoom.

@musically-ut
musically-ut / arePointsInsideWedge.js
Created November 7, 2013 22:39
Do all four corners lie inside a wedge?
g.append("text")
.attr("transform", function(d) { return "translate(" + arc.centroid(d) + ")"; })
.attr("dy", ".35em")
.style("text-anchor", "middle")
.text(function(d) { return d.data.age; })
.each(function (d) {
var bb = this.getBBox(),
center = arc.centroid(d);
var topLeft = {
@musically-ut
musically-ut / pointInArc.js
Created November 7, 2013 22:35
Function to figure out whether a point lies inside an arc
function pointIsInArc(pt, ptData, d3Arc) {
// Center of the arc is assumed to be 0,0
// (pt.x, pt.y) are assumed to be relative to the center
var r1 = arc.innerRadius()(ptData), // Note: Using the innerRadius
r2 = arc.outerRadius()(ptData),
theta1 = arc.startAngle()(ptData),
theta2 = arc.endAngle()(ptData);
var dist = pt.x * pt.x + pt.y * pt.y,
angle = Math.atan2(pt.x, -pt.y); // Note: different coordinate system.
@musically-ut
musically-ut / README.md
Last active July 7, 2016 18:56
Bubble treemap with better labels

This is an example of how one might place the intermediate labels on circle-packing graphs using the circle-text plugin.

Transitions on position and radius of the path are now possible. Click on the circles to see them in action.

@musically-ut
musically-ut / README.md
Last active December 15, 2015 14:59
The circle-text plugin.

A demo for the circle-text plugin, which can place text aligned along the bottom of circles.

@musically-ut
musically-ut / README.md
Last active December 12, 2015 08:59 — forked from mbostock/.block
Interacting with elements on brushes

This examples demonstrates how to use D3's brush component to implement focus + context zooming. Click and drag in the small chart below to pan or zoom.

@musically-ut
musically-ut / README.md
Last active December 12, 2015 08:49 — forked from mbostock/.block

This is an adaption of a Zoomable sunburst example with an added text box showing which item was last clicked.


Click on any arc to zoom in. Click on the center circle to zoom out.

A sunburst is similar to a treemap, except it uses a radial layout. The root node of the tree is at the center, with leaves on the circumference. The area (or angle, depending on implementation) of each arc corresponds to its value. Sunburst design by John Stasko. Data courtesy Jeff Heer.

@musically-ut
musically-ut / README.md
Last active March 8, 2016 16:27 — forked from mbostock/.block
SunBurst with selection rotation

This example is an extension of the original example with the additional feature that clicking on a part of the graph will select it and rotate it to 90 deg.


A sunburst is similar to the treemap, except it uses a radial layout. The root node of the tree is at the center, with leaves on the circumference. The area (or angle, depending on implementation) of each arc corresponds to its value. Sunburst design by John Stasko. Data courtesy Jeff Heer.