There are several ways to create and manage D3 Blocks at bl.ocks.org. The easiest is probably to use Blockbuilder. One can also copy/paste code directly into the Gist ui at gist.github.com.
However, if you want to use git
from from the command line to manage your Blocks (just like you manage your regular Github repos), follow these steps:
ssh
keys in your Github account, as https
no longer works for accessing the Gist repo from the command line or SourceTree etc. Please see here for instructionsREADME.md
file and add some text (you can add modify later)cfa24192d5d624f702446f194c1a7708
(which happens to be the unique id of this particular Gist)git clone git@gist.github.com:YOUR_UNIQUE_GIST_ID
8. This will create a new directory with the name of the Gist unique id
9. Rename the directory to something sensible
10. Navigate into the just-created directory
11. Verify the remote
git configuration with the command git remote -v
12. Open up the README.md
file in your text editor, make some changes, then save
13. From the command line, issue the command git status
, and you’ll see that the README.md
file has been changed
14. Stage the file by the command git add .
15. Commit the file with the command git commit -m "Updated README.me"
16. Push the commit to the Gist repo with the command: git push
17. Head back to the Gist session in the browser and refresh the page. You’ll see that the content of the README.md
file has changed.
index.html
with a max window size of 960x500 pixels, b) there should be an README.md
file that describes your visualization, and c) there can also be a thumbnail.png
file with the size of 230x120 pixelsindex.html
file in this Gist repo loads three files: styles.css
file which configures the window to the correct size for a D3 Block index.js
file. The file is currently almost empty (only console logs the d3 version). Put your visualization code in this file. The file is loaded by the index.html
with the defer
attribute, so the DOM is fully loaded by the time the index.js
begins executionindex.js
file. Test your work in process by opening up the index.html
file in your browser. Keep iterating until donegit add .
(please note the period). This command which will stage all changes (and any additional files that you may have added). Commit the staged file(s) with the command git commit -m "Commit message..."
(customize the commit message to describe the actual work you’re committing)git push
index.html
, index.js
, styles.css
) and any other files that you may have addedhttps://bl.ocks.org/YOUR_GIT_ID
. After a few minutes you should be able to see your new Block!Additional Resources:
https://bl.ocks.org/emmasaunders/2ac8e418958f4c681f229f82729c9647 https://miningthedetails.com/blog/d3/CreatingD3Blocks/
/* By Bo Ericsson, https://www.linkedin.com/in/boeric00/ */
/* eslint-disable no-console */
/* global d3 */
console.log('d3-version', d3.version);
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Gist Template</title>
<link rel="stylesheet" href="styles.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/5.16.0/d3.min.js"></script>
<script src="index.js" defer></script>
</head>
<body>
<div>
Gist/Block Template
</div>
</body>
</html>
body {
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
font-size: 16px;
font-style: normal;
font-variant: normal;
font-weight: normal;
height: 460px;
margin: 10px;
max-height: 460px;
max-width: 920px;
padding: 10px;
outline: 1px solid lightgray;
overflow: scroll;
width: 920px;
}