Notebook - Welcome to Notebook

Contact/Report Bugs
You can contact me at: bkenwright@xbdev.net












Colors in D3 1 Basic color single color Hard code the color using a number of ways hex value color name rgba or rgb value 5839fa red rgba 100 200 0 0 5 rgb 255 0 255 2 Color scales Sequential Give 2 colors as a range Use scaleLinear var myColor d3 scaleLinear domain 1 10 range white blue var myColor d3 scaleSequential domain 1 10 interpolator d3 interpolatePuRd var myColor d3 scaleSequential domain 1 10 interpolator d3 interpolateViridis Categorical e g var colours d3 scaleOrdinal d3 schemeCategory10 or if you want to map the range to limits domain var colours d3 scaleOrdinal d3 schemeCategory10 domain foo bar baz foobar Color Schemes used by scale d3 schemeCategory10 array of ten categorical colors which is returned as RGB hexadecimal strings d3 schemeAccent array of eight categorical colors which is returned as RGB hexadecimal strings 37 schemes schemeAccent schemeBlues schemeBrBG schemeBuGn schemeBuPu schemeCategory10 schemeDark2 schemeGnBu schemeGreens schemeGreys schemeOrRd schemeOranges schemePRGn schemePaired schemePastel1 schemePastel2 schemePiYG schemePuBu schemePuBuGn schemePuOr schemePuRd schemePurples schemeRdBu schemeRdGy schemeRdPu schemeRdYlBu schemeRdYlGn schemeReds schemeSet1 schemeSet2 schemeSet3 schemeSpectral schemeTableau10 schemeYlGn schemeYlGnBu schemeYlOrBr schemeYlOrRd Interpolation which return a string of RGB color from a double 0 to 1 d3 interpolateRainbow t t 0 0 to 1 0 d3 interpolateBlues d3 interpolateGreens 38 types interpolateBlues interpolateBrBG interpolateBuGn interpolateBuPu interpolateCividis interpolateCool interpolateCubehelixDefault interpolateGnBu interpolateGreens interpolateGreys interpolateInferno interpolateMagma interpolateOrRd interpolateOranges interpolatePRGn interpolatePiYG interpolatePlasma interpolatePuBu interpolatePuBuGn interpolatePuOr interpolatePuRd interpolatePurples interpolateRainbow interpolateRdBu interpolateRdGy interpolateRdPu interpolateRdYlBu interpolateRdYlGn interpolateReds interpolateSinebow interpolateSpectral interpolateTurbo interpolateViridis interpolateWarm interpolateYlGn interpolateYlGnBu interpolateYlOrBr interpolateYlOrRd D3 modular color demo Color categorical schemes window frameElement style height 500px let container document createElement div container className container document body appendChild container let categoricalButtons document createElement div categoricalButtons className categoricalButtons document body appendChild categoricalButtons const d3 await Promise all import https unpkg com d3 array module import https unpkg com d3 axis module import https unpkg com d3 brush module import https unpkg com d3 chord module import https unpkg com d3 color module import https unpkg com d3 contour module import https unpkg com d3 delaunay module import https unpkg com d3 dispatch module import https unpkg com d3 drag module import https unpkg com d3 dsv module import https unpkg com d3 ease module import https unpkg com d3 fetch module import https unpkg com d3 force module import https unpkg com d3 format module import https unpkg com d3 geo module import https unpkg com d3 hierarchy module import https unpkg com d3 interpolate module import https unpkg com d3 path module import https unpkg com d3 polygon module import https unpkg com d3 quadtree module import https unpkg com d3 random module import https unpkg com d3 scale module import https unpkg com d3 scale chromatic module import https unpkg com d3 selection module import https unpkg com d3 shape module import https unpkg com d3 time module import https unpkg com d3 time format module import https unpkg com d3 timer module import https unpkg com d3 transition module import https unpkg com d3 zoom module then d3 Object assign d3 var categorical name schemeAccent n 8 name schemeDark2 n 8 name schemePastel2 n 8 name schemeSet2 n 8 name schemeSet1 n 9 name schemePastel1 n 9 name schemeCategory10 n 10 name schemeSet3 n 12 name schemePaired n 12 name schemeCategory20 n 20 not supported with v5 name schemeCategory20b n 20 see https github com d3 d3 blob main CHANGES md name schemeCategory20c n 20 Instead of hardcoding them let s grab them all from the module var categorical import as d3scalechromatic from https unpkg com d3 scale chromatic module for let i 0 i Object keys d3scalechromatic length i let colName new String Object keys d3scalechromatic i if colName includes scheme continue let numColors Object keys d3 colName length console log name colName num colors numColors categorical push name colName n numColors console log number color schemes categorical length console log range d3 schemeAccent range let test d3 categorical 0 name d3 scaleOrdinal categorical 0 name console log domain Object keys test var width 700 var height 300 var svg d3 select body append svg attr width width attr height height append g var colorScale d3 scaleOrdinal d3 categorical 0 name var n categorical 0 n var unit width n var bars svg selectAll bars data d3 range n function d return d enter append rect attr class bars attr x function d i return i unit attr y 0 attr height height attr width unit style fill function d i return colorScale d var sequentialButtons d3 select categoricalButtons selectAll button data categorical enter append button text function d return d name on click function i buttonValue console log name buttonValue name n buttonValue n var colorScale d3 scaleOrdinal d3 buttonValue name var bars svg selectAll bars data d3 range buttonValue n function d return d bars exit remove bars transition attr x function d i return i width buttonValue n attr width width buttonValue n style fill function d i return colorScale i bars enter append rect attr class bars attr y 0 attr height height attr x function d i return i width buttonValue n attr width width buttonValue n style fill function d i return colorScale i console log ready Do some word coloring shows the modular nature of D3 just use the color scale part window frameElement style height 150px import as d3 from https unpkg com d3 scale module scaleLinear scaleTime scaleOrdinal let col d3 scaleOrdinal 383867 584c77 33431e a36629 92462f b63e36 b74a70 946943 const data The wise old fox can learn more from the young fool than the young fool could ever learn from the wise old fox split let div document createElement div document body appendChild div for let i 0 i data length i let word data i let str span style background col word padding 5px line height 2 0 font size 150 word span div innerHTML str console log ready Color interpolations window frameElement style height 500px let container document createElement div container className container document body appendChild container let categoricalButtons document createElement div categoricalButtons className sequentialButtons document body appendChild categoricalButtons const d3 await Promise all import https unpkg com d3 array module import https unpkg com d3 axis module import https unpkg com d3 brush module import https unpkg com d3 chord module import https unpkg com d3 color module import https unpkg com d3 contour module import https unpkg com d3 delaunay module import https unpkg com d3 dispatch module import https unpkg com d3 drag module import https unpkg com d3 dsv module import https unpkg com d3 ease module import https unpkg com d3 fetch module import https unpkg com d3 force module import https unpkg com d3 format module import https unpkg com d3 geo module import https unpkg com d3 hierarchy module import https unpkg com d3 interpolate module import https unpkg com d3 path module import https unpkg com d3 polygon module import https unpkg com d3 quadtree module import https unpkg com d3 random module import https unpkg com d3 scale module import https unpkg com d3 scale chromatic module import https unpkg com d3 selection module import https unpkg com d3 shape module import https unpkg com d3 time module import https unpkg com d3 time format module import https unpkg com d3 timer module import https unpkg com d3 transition module import https unpkg com d3 zoom module then d3 Object assign d3 var interpolators These are from d3 scale Viridis Inferno Magma Plasma Warm Cool Rainbow CubehelixDefault These are from d3 scale chromatic Blues Greens Greys Oranges Purples Reds BuGn BuPu GnBu OrRd PuBuGn PuBu PuRd RdPu YlGnBu YlGn YlOrBr YlOrRd Instead of hardcoding them let s grab them all from the module var interpolators import as d3scalechromatic from https unpkg com d3 scale chromatic module for let i 0 i Object keys d3scalechromatic length i let colName new String Object keys d3scalechromatic i if colName includes interpolate continue interpolators push colName replace interpolate console log number interpolate color schemes interpolators length var width 800 var height 300 var svg d3 select body append svg attr width width attr height height append g var colorScale d3 scaleSequential d3 interpolateInferno domain 0 width var bars svg selectAll bars data d3 range width function d return d enter append rect attr class bars attr x function d i return i attr y 0 attr height height attr width 1 style fill function d i return colorScale d var sequentialButtons d3 select sequentialButtons selectAll button data interpolators enter append button text function d return d on click function g buttonValue var colorScale d3 scaleSequential d3 interpolate buttonValue domain 0 width svg selectAll bars transition style fill function d return colorScale d console log ready

ange n function d return d enter append rect attr class bars attr x function d i return i unit attr y 0 attr height height attr width unit style fill function d i return colorScale d var sequentialButtons d3 select categoricalButtons selectAll button data categorical enter append button text function d return d name on click function i buttonValue console log name buttonValue name n buttonValue n var colorScale d3 scaleOrdinal d3 buttonValue name var bars svg selectAll bars data d3 range buttonValue n function d return d bars exit remove bars transition attr x function d i return i width buttonValue n attr width width buttonValue n style fill function d i return colorScale i bars enter append rect attr class bars attr y 0 attr height height attr x function d i return i width buttonValue n attr width width buttonValue n style fill function d i return colorScale i console log ready Do some word coloring shows the modular nature of D3 just use the color scale part window frameElement style height 150px import as d3 from https unpkg com d3 scale module scaleLinear scaleTime scaleOrdinal let col d3 scaleOrdinal 383867 584c77 33431e a36629 92462f b63e36 b74a70 946943 const data The wise old fox can learn more from the young fool than the young fool could ever learn from the wise old fox split let div document createElement div document body appendChild div for let i 0 i data length i let word data i let str span style background col word padding 5px line height 2 0 font size 150 word span div innerHTML str console log ready Color interpolations window frameElement style height 500px let container document createElement div container className container document body appendChild container let categoricalButtons document createElement div categoricalButtons className sequentialButtons document body appendChild categoricalButtons const d3 await Promise all import https unpkg com d3 array module import https unpkg com d3 axis module import https unpkg com d3 brush module import https unpkg com d3 chord module import https unpkg com d3 color module import https unpkg com d3 contour module import https unpkg com d3 delaunay module import https unpkg com d3 dispatch module import https unpkg com d3 drag module import https unpkg com d3 dsv module import https unpkg com d3 ease module import https unpkg com d3 fetch module import https unpkg com d3 force module import https unpkg com d3 format module import https unpkg com d3 geo module import https unpkg com d3 hierarchy module import https unpkg com d3 interpolate module import https unpkg com d3 path module import https unpkg com d3 polygon module import https unpkg com d3 quadtree module import https unpkg com d3 random module import https unpkg com d3 scale module import https unpkg com d3 scale chromatic module import https unpkg com d3 selection module import https unpkg com d3 shape module import https unpkg com d3 time module import https unpkg com d3 time format module import https unpkg com d3 timer module import https unpkg com d3 transition module import https unpkg com d3 zoom module then d3 Object assign d3 var interpolators These are from d3 scale Viridis Inferno Magma Plasma Warm Cool Rainbow CubehelixDefault These are from d3 scale chromatic Blues Greens Greys Oranges Purples Reds BuGn BuPu GnBu OrRd PuBuGn PuBu PuRd RdPu YlGnBu YlGn YlOrBr YlOrRd Instead of hardcoding them let s grab them all from the module var interpolators import as d3scalechromatic from https unpkg com d3 scale chromatic module for let i 0 i Object keys d3scalechromatic length i let colName new String Object keys d3scalechromatic i if colName includes interpolate continue interpolators push colName replace interpolate console log number interpolate color schemes interpolators length var width 800 var height 300 var svg d3 select body append svg attr width width attr height height append g var colorScale d3 scaleSequential d3 interpolateInferno domain 0 width var bars svg selectAll bars data d3 range width function d return d enter append rect attr class bars attr x function d i return i attr y 0 attr height height attr width 1 style fill function d i return colorScale d var sequentialButtons d3 select sequentialButtons selectAll button data interpolators enter append button text function d return d on click function g buttonValue var colorScale d3 scaleSequential d3 interpolate buttonValue domain 0 width svg selectAll bars transition style fill function d return colorScale d console log ready

2dracecargame
3dplot
a4print
about
acecustomkeywords
acecustomkeywords2
acejs
acejs2
acejs3
aessecurity
angularjs
animbackgroundimage
aseformat
assert
asteroidsjs
backgrounds01
backgrounds02
backgrounds03
barnsleyfern
base26
base64
bib
binary
bodypix
bouncy
box2dweb
breakoutjs
browserversion
buslanes
busybutton
bvhreader
calendar
candycrush
candycrush2
canvas
canvas2
canvas3
canvasmandelbrot
canvasmandelbrot2
canvasnumbers
canvaszoom
capsule
car2dsimulationphysics
car2dsimulationphysics2
changingimages
chaosgame
chaosrandom
chaosrandomhisto
chaosrandomhisto2
chatgptusingopenai
chatgptusingopenai2
chatgptusingopenai3
checkboxtoggle
chinesetiles
classes
classfeatures
clipboardbutton
clonenode
codedropdown
codemirror
codemirror2
collada
colorpick
columnresizer
contextmenu
convnet
cookiebanner
countdown
countdown2
countdown3
crop
css3dbarchart
css3dbarchart2
css3dbook
css3dscene
csscube
csscube2
csscube3
csscubevideos
cssfilelist
csshas
csspulse
cssresizeaspect
cssspin
csszooming
csvtoarray
curleffect
customcheckbox
d3datamap
d3js
d3js10
d3js11
d3js2
d3js3
d3js4
d3js5
d3js6
d3js7
d3js8
d3js9
d3jsanimatedgrid
d3jsarctransition
d3jsarctransition2
d3jsaxis
d3jsaxischanging
d3jsbars
d3jsbrushing
d3jsbuslanes
d3jsbuslanes2
d3jscalendar
d3jscheat
d3jsclock
d3jscloudmap
d3jscogs
d3jscolors
d3jscovid
d3jscovid2
d3jscovid3
d3jsdashboard
d3jsdashboard2
d3jsdashboard3
d3jsdatakeyfunction
d3jsdensity
d3jsdragresizing
d3jsdragresizing2
d3jseach
d3jsease
d3jsevents
d3jsflower
d3jsforcegroups
d3jsforces
d3jsforces2
d3jsfractaltree
d3jsgeo
d3jsgroupbars
d3jsgroups
d3jsheatmap
d3jshex
d3jshierarchies
d3jshierarchies2
d3jshistogram
d3jshistogram2
d3jshistogram3
d3jshistogram4
d3jsinterpolate
d3jsjoin
d3jskmean
d3jskmean2
d3jsline
d3jsline2
d3jsline3
d3jsline4
d3jslinetransition
d3jslinetransition0
d3jslinetransition2
d3jsmaplocations
d3jsmaps
d3jsmaps2
d3jsmaps3
d3jsmisc
d3jsmisc2
d3jsmodule
d3jsmodulecolor
d3jsmultistyles
d3jsnobel
d3jsoverlappinggraphs
d3jspanel
d3jspie
d3jspieinterpolate
d3jssankey
d3jssankey2
d3jsscatter
d3jsshapes
d3jsslider
d3jsspending
d3jsspending2
d3jsspiralplot
d3jsspirograph
d3jssquare
d3jsstack
d3jsstackedbar
d3jsstackedbar2
d3jssunburst
d3jssunmoon
d3jssvglines
d3jssymbols
d3jstimelines
d3jsuk
d3jsvoronoi
d3scatterplot
d3timeline
d3timeline2
datalist
datamuse
date
dblclickhighlight
deviceorientation
dictionaryapi
dockermenu
doodlepad
downloadgif
dragdroplistitems
dragrotateresizediv
dragrotateresizediv2
dragrotateresizediv3
dragrotateresizediv4
dragrotateresizefontsize
dragselectbrush
drawlinesdiv
dropdown
dualquaternionimages
dynamicgrid
easefunctions
easeinterpolate3dplots
echart
echart2
echart3
encapsulation
epubviewer
errorstack
excalidraw
excalidraw2
excalidraw3
excalidraw5
expandable
faker
fetchplus
fileupload
fixedtopbar
fluiddynamics
fluiddynamics2
fluiddynamics3
fluidgaswatergl
fluidsmokedynamics
fluidsmokedynamics2
fonts
fonts2
footerbar
fractalmaze
fractalmaze2
fractalnoiseimage
fractals
fractals2
fractaltree
freesvg
fresnel
froggerjs
gantt
gifgiphyapi
gifhex
gltffromscratch
gradients
griditems
griditems2
griditems3
griditems4
gridworms
happyfont
heat
hexview
hexview2
highlight
icons
icons2
iframes
ik
imagetracertosvg
imgur
inputfile
invadersjs
ipynb
ipynb2
ipynb3
ipynb4
isbn13
isbn2
jpghex
jquery
jquery2
jqueryui
jqueryui2
jsdraganddrop
jsfire
jslint
jsobfuscate
jsraytracer
jstree
jstree2
jszip
jszipimages
jszipread
keyboardpiano
keyframes
l2dwidget
lcpsolverrigidbodies
lda
leftmenu
less
less2
lineargradientimage
linenumbers
loadimagefromfile
makepdf
maps
markdown
markdown2
markdown3
markdownalerts
markdownalerts2
markdownbookmarks
markovimage
markovpixelblocks
mathjax
matrices
matsandvects
mazegamejs
md2tex
metrotiles
metrowindows
milestones
minkowski2dboxes
misc
misc2
modules
myipdetails
mymodplotly
neataptic
networkstructures
networkstructures2
neural_network_drawshape
neural_network_plot_in_vs_out
neuralnetworkarrays
neuralnetworkblocks
neuralnetworksinewave
neuralnetworksnolibs
neuralnetworkvisualization
noiseflowfield
noiseflowfield2
noiseflowfield3
noiseflowfield4
noiseflowfield5
noiseflowfield6
number
obj
objtojson
openaiimages
opencv
opencv2
opencv3
opencv4
opencv5
outline
p2
p5fractalleaf
p5fractalshape
p5js
p5js2
p5js3
p5jsanimatedcover
p5mengercube
p5snowflakes
palindrome
panel
parallax
paste
paste2
pasteimgfromurl
pdfjs
pdfjs2
pdfkit
pdfkit2
pdfkit3
pdfkit4
pdfkit5
pdfkit6
pdfmake
pdfmake2
pdfmake3
pdfmake4
pdfmake5
pdfmake6
perlin
perlin2
perlin3
perspective
pexels
pixelgridpattern
playground
plotly
plotlynoise
plotlyranddist
plyloader
plyloader2
pngtxtencoder
pongjs
pptxgenjs
prettycode
prism
prn
problems
progress
pseudorandom
px2svg
python
quotes
racergame
random
randomcalcpie
randomgenerator
randomprofilepatterns
randomsinhistogram
randomstring
rating
rayambient
raymonte
raymonteprogressive
raymonteprogressive2
raymontewarmstart
reexpcross
reexpcross2
regex
regexbib
regexpfixbib
regexpmultiline
repeatwordsregexp
resizabletable
resizabletable2
revealjs
revealjs2
revealjsmulti
rigidbodyspheres2d
rigidbodyspheres3
rigidbodysphereslopetangent
ritalanguage
ritalanguage2
ritalanguage3
rotateimg
rough
rsapublicprivatekeys
rss
rss2
sankey
scrappingsvg
scrolltext
scrolltext2
scrollwidth
sdf2dcanvas
sdfboxinboxtwist
sdfchessbishop
sdfchessking
sdfchessknight
sdfchesspawn
sdfchessqueen
sdfchessrook
sdfhollowbox
setintervalexception
shareurl
shuffle
sidecomment
similarity
simplehighlighter
simpleplatformgamejs
sinecanvas
sliderpopout
slides
smileys
snowfall
snowman
sound
soundsignal
sphererayintersection
springs
sqljs
steganography
stereogram
stringmatching
sudoku
sudoku2
sudoku3
svg
svgchaos
svgdragresize
svgdragresize2
svgdragresize3
svgdragrotate
svgdrawing
svglines
svglines2
svglines3
svglines4
svglines5
svglinesmandelbrot
svgpathsdragrotate
svgpathsdragrotateresize
svgpie
svgpie2
svgpie3
svgpiepath
svgpiepath2
svgrandomfaces
symbols
synaptic
synaptic2
synonyms
tablerotatecells
tablerotatecells2
tablerotatecells3
tablerotatecells3b
tablerotatecells4
tables
tablezebra
tabularjs
tabularjs2
tabulatordownload
tagcanvas
tensorflowgan
tensorflowjs
tensorflowjsbasic
tensorflowjscnn
tensorflowjssinewave
tensorflowjssound
tensorflowmobilenet
tetrahedronfractal
tetrahedronfractalfolding
tetris
textarea
textareaauto
textareadiv
textareadiv2
textmaskimage
theirorthere
thesaurus
threejs
threejs2
threejs3
threejs4
threejsgltf
threejstokyo
tiles
toaster
tooltip
transition
transitionexpandabledropdown
treeview
treeview2
tricks
tshirt
tshirt2
tshirt3
turningpages
unsplash
urlblob
urlblob2
userdefinepoints
vector
videos
videos2
visualsort
vue
w2ui
w2uientertextdialog
webcam
webgl
webgl2
webgl3
webgl4
webgl5
webglbasic1
webglbasic2
webglcube
webglfov
webglfrustum
webgljson
webglleaves
webgllighting
webglorthographic
webglpoints1
webglpoints2
webglpoints3
webglsquare
webgltexture1
webgltexture2
webgltexture3
webgltransforms
webgltriangle
webgpu
webgpu10
webgpu11
webgpu12
webgpu13
webgpu14
webgpu15
webgpu16
webgpu17
webgpu2
webgpu3
webgpu4
webgpu5
webgpu6
webgpu7
webgpu8
webgpu9
webgpubars
webgpubuffers
webgpubuffers2
webgpucellnoise
webgpuclouds
webgpuclydescope
webgpucompute
webgpucubemap
webgpucubemap2
webgpudeferred
webgpudepth
webgpudof
webgpudrops
webgpuetha
webgpufire
webgpufractalcubes
webgpuglassrain
webgpugltf
webgpugltf2
webgpugrass
webgpugrid
webgpukernel
webgpukleinian
webgpulabupdates
webgpulighting
webgpumandelbrot
webgpumeta3d
webgpumetaballs
webgpumouse
webgpunoise
webgpunormalmapping
webgpuobj
webgpuparallax
webgpuparallax2
webgpuparallax3
webgpuparallaxshadow
webgpuparallaxshadow2
webgpupixel
webgpuquad
webgpuray1
webgpuraytracing
webgpuraytracing2
webgpushadowmaps
webgpushadowmaps2
webgpusierpinski2d
webgpusierpinski3d
webgpusinusoid
webgpussao
webgpustadiumobj
webgpuswirl
webgputestpipe3
webgputoon
webgputopology
webgputt
webgpuvolcloud
webgpuwater
webgpuwireframe
webgpuwireframe2
webpcanvas
webworkers
webxr
webxr2
wiggly
wikipedia