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. |
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
This example, using satirical data from The Onion, demonstrates how to wrap long axis labels to fit on multiple lines.
- Modified wrap to acept text wrap width as a function of data and index.
- Made bar widths proportional to values.
Note: The second point is not recommended practice but serves to ilustrate the variable wrap feature!
{ | |
"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}, |
<!DOCTYPE html> | |
<meta charset="utf-8"> | |
<style> | |
body { | |
/*margin: 200px 500px 100px 500px;*/ | |
} | |
#inputs { | |
display: inline-block; | |
margin: 0 0 0 100px; | |
border: none; |
<!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> |
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 |
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title></title> | |
<style> | |
svg { | |
outline: 1px solid black; | |
} | |
</style> |