Skip to content

Instantly share code, notes, and snippets.

@cool-Blue
cool-Blue / README.md
Last active August 29, 2015 14:22
querySelector camel case textPath in Chrome

In Chrome
If you use camelCase, the textPath works but you can't select it.
If you use lowercase, the textpath doesn't work but you can select it.

Cannot find camelCase element, will not render text on textPath if the element is inserted in lower case.
@cool-Blue
cool-Blue / README.md
Last active August 29, 2015 14:23 — forked from mbostock/.block
Gradient Along Stroke

This example demonstrates how to create a gradient that follows a stroke. This technique is sometimes used to indicate directionality along a curved edge, such as with hierarchical edge bundling.

To start, take any SVG path element and uniformly sample points along the path using getPointAtLength. (This method can also be used for path tweening.) Then, for each segment between adjacent points, compute the miter joint via line-line intersection. Lastly fill each segment by interpolating the start and end colors, here green to red, using the normalized length t along the path. Although each segment is a constant color, there are many segments to give the appearance of a continuous gradient.

This example uses a thin stroke in addition to filling the segments. This avoids antialiasing artifacts due to most

@cool-Blue
cool-Blue / README.md
Last active July 30, 2023 20:39 — forked from mbostock/.block
Variable width bar chart with matching, data driven, variable width wordwrap

This example, using satirical data from The Onion, demonstrates how to wrap long axis labels to fit on multiple lines.

  1. Modified wrap to acept text wrap width as a function of data and index.
  2. Made bar widths proportional to values.

Note: The second point is not recommended practice but serves to ilustrate the variable wrap feature!

@cool-Blue
cool-Blue / data.json
Last active August 29, 2015 14:23
nodesNaN
{
"nodes":[
{"name":"a", "group":1},
{"name":"b", "group":2},
{"name":"c", "group":3},
{"name":"d", "group":4},
{"name":"e", "group":5},
{"name":"f", "group":6},
{"name":"g", "group":7},
{"name":"h", "group":1},
@cool-Blue
cool-Blue / index.html
Last active November 23, 2015 02:36 — forked from mbostock/.block
Layered gravity with weak side constraints, mass and wind-up
<!DOCTYPE html>
<meta charset="utf-8">
<style>
body {
/*margin: 200px 500px 100px 500px;*/
}
#inputs {
display: inline-block;
margin: 0 0 0 100px;
border: none;
@cool-Blue
cool-Blue / fps.xlsx
Last active September 28, 2015 15:58
d3 force layout inertial drag
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html lang="en">
<head>
<meta charset="utf-8">
<title>Force based label placement</title>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.js?2.6.0"></script>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.layout.js?2.6.0"></script>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.geom.js?2.6.0"></script>
</head>
<body>
@cool-Blue
cool-Blue / data-alt.csv
Last active August 29, 2015 14:24 — forked from d3noob/.block
Transitioning a line chart, but with data bound to the path element
date close
10-May-12 99.55
8-May-12 76.86
6-May-12 67.62
4-May-12 64.48
2-May-12 60.98
1-May-12 58.13
30-Apr-12 53.98
27-Apr-12 67.00
26-Apr-12 89.70
@cool-Blue
cool-Blue / index.html
Last active August 29, 2015 14:24
svg path clipped by filter element
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
<style>
svg {
outline: 1px solid black;
}
</style>