D3.js starter
D3.js v7: a data-driven bar chart with scales, axes, and transitions.
Open in editor Free. No install, no sign-up.
- d3
The code
Three files, exactly what you get in the editor.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>D3 starter</title>
</head>
<body>
<main class="page">
<header>
<a href="https://d3js.org" target="_blank"
><svg class="logo" role="img" viewBox="0 0 128 128">
<linearGradient
id="d3js-original-a"
gradientUnits="userSpaceOnUse"
x1="-201.009"
y1="376.844"
x2="-200.098"
y2="375.873"
gradientTransform="matrix(82.4907 0 0 -81.4303 16634.416 30700.326)"
>
<stop offset="0" stop-color="#f9a03c" />
<stop offset="1" stop-color="#f7974e" />
</linearGradient>
<path
fill="url(#d3js-original-a)"
d="M126.334 90.59a37.18 37.18 0 00.128-1.647C126.5 88.288 87.094 50.9 87.094 50.9h-.942s39.94 42.13 40.182 39.69z"
/>
<linearGradient
id="d3js-original-b"
gradientUnits="userSpaceOnUse"
x1="-199.257"
y1="373.615"
x2="-197.514"
y2="371.916"
gradientTransform="matrix(40.2105 0 0 -40.4122 8003.203 15127)"
>
<stop offset="0" stop-color="#f9a03c" />
<stop offset="1" stop-color="#f7974e" />
</linearGradient>
<path
fill="url(#d3js-original-b)"
d="M42.26 77.62a26.282 26.282 0 01-.328.702c-1.256 2.62 17.585 21.038 19.1 18.8.07-.098.14-.202.208-.3.077-.118.152-.23.228-.348 1.213-1.84-18.67-20.05-19.207-18.854z"
/>
<linearGradient
id="d3js-original-c"
gradientUnits="userSpaceOnUse"
x1="-199.836"
y1="374.252"
x2="-198.286"
y2="372.475"
gradientTransform="matrix(41.0403 0 0 -39.9333 8224.5 14997.683)"
>
<stop offset="0" stop-color="#f9a03c" />
<stop offset="1" stop-color="#f7974e" />
</linearGradient>
<path
fill="url(#d3js-original-c)"
d="M68.886 103.52c-.053.118-.433.76-.78 1.098-.058.117 18.394 18.417 18.394 18.417h1.66c.002 0-17.32-18.74-19.274-19.514z"
/>
<linearGradient
id="d3js-original-d"
gradientUnits="userSpaceOnUse"
x1="-201.143"
y1="379.263"
x2="-200.795"
y2="378.804"
gradientTransform="matrix(255.8347 0 0 -242.016 51476.605 91789.102)"
>
<stop offset="0" stop-color="#f26d58" />
<stop offset="1" stop-color="#f9a03c" />
</linearGradient>
<path
fill="url(#d3js-original-d)"
d="M126.488 88.61c-.863 19.13-16.69 34.425-36.024 34.425H87.85l-19.31-19.022a69.313 69.313 0 004.38-6.98h17.544c5.55 0 10.064-4.514 10.064-10.065 0-5.55-4.515-10.064-10.064-10.064H80.082A69.373 69.373 0 0081.306 64c0-4.48-.44-8.852-1.26-13.1h6.45l39.88 39.295a48.62 48.62 0 00.112-1.585zM11.962 4.772H1.472v26.003h10.49c18.32 0 33.23 14.903 33.23 33.225 0 4.984-1.113 9.716-3.088 13.964L61.24 96.82A58.882 58.882 0 0071.2 64c0-32.658-26.574-59.228-59.236-59.228z"
/>
<linearGradient
id="d3js-original-e"
gradientUnits="userSpaceOnUse"
x1="-200.962"
y1="378.553"
x2="-200.452"
y2="378.218"
gradientTransform="matrix(160.7307 0 0 -174.8133 32360.78 66184.883)"
>
<stop offset="0" stop-color="#b84e51" />
<stop offset="1" stop-color="#f68e48" />
</linearGradient>
<path
fill="url(#d3js-original-e)"
d="M90.464 4.772H47.986a69.81 69.81 0 0124.82 26.003h17.658c5.55 0 10.064 4.513 10.064 10.064 0 5.55-4.515 10.06-10.064 10.06h-3.968l39.88 39.296a36.65 36.65 0 00.152-3.228c0-8.766-3.146-16.807-8.368-23.066 5.223-6.256 8.368-14.3 8.368-23.063 0-19.887-16.177-36.068-36.064-36.068z"
/>
<linearGradient
id="d3js-original-f"
gradientUnits="userSpaceOnUse"
x1="-200.619"
y1="377.137"
x2="-200.595"
y2="376.532"
gradientTransform="matrix(176.7653 0 0 -92.6293 35504.598 35022.56)"
>
<stop offset="0" stop-color="#f9a03c" />
<stop offset="1" stop-color="#f7974e" />
</linearGradient>
<path
fill="url(#d3js-original-f)"
d="M87.85 123.035H48.29a69.95 69.95 0 0020.25-19.022l19.31 19.022zM61.24 96.82L42.106 77.965c-5.287 11.362-16.807 19.264-30.143 19.264H1.472v26h10.49c20.53 0 38.648-10.5 49.28-26.407z"
/></svg
></a>
<div>
<h1>Letter frequency</h1>
<p>
How often each letter appears in English text.
<button id="sort">Sort by frequency</button>
</p>
</div>
</header>
<figure id="chart"></figure>
</main>
</body>
</html>
Questions
Can I use D3.js without a build step?
Yes. This starter loads D3.js straight from a CDN, so it runs in the browser with no npm install, bundler, or config.
How do I start a D3.js project online?
Click Open in editor. HTMLDrop copies this starter into a new drop with index.html, style.css, and script.js, and the preview updates as you edit.
Is it free?
Yes. Public drops, live collaboration, versions, and embeds are free, and you do not need an account to start.
Can I share or embed my D3.js demo?
Yes. Every drop gets a public link and an embed code, and you can invite others to edit it with you in real time.