d3 cheatsheet generator add color syntax highlighting to the code examples script src cdnjs cloudflare com ajax libs highlight js 10 1 1 highlight min js script link rel stylesheet href cdnjs cloudflare com ajax libs highlight js 10 1 1 styles default min css script let cheats let keywords d3 range let description returns an array of evenly spaced numbers let example let r d3 range 0 10 2 console log range r let result range 0 2 4 6 8 cheats push keywords keywords description description example example result result let keywords d3 ticks let description returns an array of nicely rounded numbers inside an interval start stop count let example let ticks d3 ticks 0 1 5 console log ticks ticks let result ticks 0 0 2 0 4 0 6 0 8 1 cheats push keywords keywords description description example example result result let keywords d3 extent let description returns min max in a single pass over the input let example let data 0 243 0 584 0 987 0 153 0 433 let extent d3 extent data console log extent extent let result extent 0 153 0 987 cheats push keywords keywords description description example example result result document body style minHeight 400px var table document createElement table table style border 1px solid black document body appendChild table insert headers var row table insertRow 0 let items Object entries cheats 0 for let k 0 k items length k var cell row insertCell 1 cell innerHTML items k 0 toUpperCase for let i 0 i cheats length i let cheat cheats i let row table insertRow 1 let items Object entries cheat for let k 0 k items length k let content let title items k 0 if title result content pre code if title example content pre code content items k 1 trim if title example content code pre if title result content code pre var cell row insertCell 1 cell innerHTML content let codes document getElementsByTagName code for let i 0 i codes length i hljs highlightBlock codes i console log ready script
tent data console log extent extent let result extent 0 153 0 987 cheats push keywords keywords description description example example result result document body style minHeight 400px var table document createElement table table style border 1px solid black document body appendChild table insert headers var row table insertRow 0 let items Object entries cheats 0 for let k 0 k items length k var cell row insertCell 1 cell innerHTML items k 0 toUpperCase for let i 0 i cheats length i let cheat cheats i let row table insertRow 1 let items Object entries cheat for let k 0 k items length k let content let title items k 0 if title result content pre code if title example content pre code content items k 1 trim if title example content code pre if title result content code pre var cell row insertCell 1 cell innerHTML content let codes document getElementsByTagName code for let i 0 i codes length i hljs highlightBlock codes i console log ready script