Notebook - Welcome to Notebook

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












D3 Example using COVID Data focus on Twitter data Taking small selection of tweets which have the term coronavirus in over a short person of time 8weeks Explore and try to visualize patterns document body style height 100px workaround for async loading var promise await fetch https d3js org d3 v7 min js var d3script await promise text var script document createElement script script type text javascript script innerHTML d3script script async false document body appendChild script grab the data let dataurl https notebook xbdev net var resources twittercovid csv Format Tweet Id Tweet URL Tweet Posted Time UTC Tweet Content Tweet Type Client Retweets Received Likes Received Tweet Location Lat Long Tweet Language User Id Name Screen Name User Bio Verified or Non Verified Profile URL Protected or Non protected User Followers User Following User Account Creation Date 1233417783175778304 https twitter com Giussi92 status 1233417783175778304 28 Feb 2020 15 44 49 Also the entire Swiss Football League is on hold Postponing games from the professional and amateur level coronavirus https t co UShMuqnAVC Tweet Twitter for iPhone 0 0 English 1556856595 Giuseppe Gentile Giussi92 Verified https twitter com Giussi92 Non Protected 3071 100 30 Jun 2013 00 27 50 get the date and tweet content let datain await d3 csv dataurl function d const tdate d Tweet Posted Time UTC const tcontent d Tweet Content const date new Date tdate getTime datain push date date value tcontent console log total tweets datain length Start by grouping tweeks into days how many tweeks for a day document body style height 500px workaround for async loading var promise await fetch https d3js org d3 v7 min js var d3script await promise text var script document createElement script script type text javascript script innerHTML d3script script async false document body appendChild script grab the data let dataurl https notebook xbdev net var resources twittercovid csv get the date and tweet content let datain await d3 csv dataurl function d const tdate d Tweet Posted Time UTC const tcontent d Tweet Content const dt new Date tdate const date dt getFullYear dt getMonth 1 dt getDate if datain date datain date 1 else datain date 1 map data to name value pair let data Object entries datain map d return date d 0 value d 1 console log days data length console log day 0 data 0 value console log day 1 data 1 value console log day 2 data 2 value console log day 20 data 20 value console log data range d3 extent data d d value Simple bar chart const leftmargin 50 const topmargin 50 const width 400 const height 400 var svg d3 select body append svg attr width width attr height height attr transform translate leftmargin topmargin append g Define x axis and y axis let x d3 scaleBand domain data map function d return d date range 0 width padding 0 3 let y d3 scaleLinear domain d3 extent data d d value range height 0 Bars svg selectAll mybar data data enter append rect attr x function d return x d date attr y function d return y d value 50 attr width x bandwidth attr height function d return height y d value attr fill 69b3a2 Draw the axis svg append g attr transform translate 0 height 50 call d3 axisBottom x selectAll text attr transform translate 10 10 rotate 90 style text anchor end style font size 7 style fill 69a3b2 console log ready Plot for the number of tweets about COVID 19 doesn t really work for a linear scale after a couple of weeks the number of tweeks drops Change over to a log scale for the y axis document body style height 500px workaround for async loading var promise await fetch https d3js org d3 v7 min js var d3script await promise text var script document createElement script script type text javascript script innerHTML d3script script async false document body appendChild script grab the data let dataurl https notebook xbdev net var resources twittercovid csv get the date and tweet content let datain await d3 csv dataurl function d const tdate d Tweet Posted Time UTC const tcontent d Tweet Content const dt new Date tdate const date dt getFullYear dt getMonth 1 dt getDate if datain date datain date 1 else datain date 1 map data to name value pair let data Object entries datain map d return date d 0 value d 1 console log days data length console log day 0 data 0 value console log day 1 data 1 value console log day 2 data 2 value console log day 20 data 20 value console log data range d3 extent data d d value Simple bar chart const leftmargin 50 const topmargin 50 const width 400 const height 400 var svg d3 select body append svg attr width width attr height height attr transform translate leftmargin topmargin append g Define x axis and y axis let x d3 scaleBand domain data map function d return d date range 0 width padding 0 3 let y d3 scaleLog domain d3 extent data d d value range height 0 base 10 Bars svg selectAll mybar data data enter append rect attr x function d return x d date 20 attr y function d return y d value 50 attr width x bandwidth attr height function d return height y d value attr fill 69b3a2 Draw bottom axis svg append g attr transform translate 20 height 50 call d3 axisBottom x selectAll text attr transform translate 10 10 rotate 90 style text anchor end style font size 7 style fill 69a3b2 Draw left y axis svg append g attr transform translate 20 0 This controls the vertical position of the Axis call d3 axisLeft y console log ready Organise the Tweet words frequency of the most popular document body style height 500px workaround for async loading var promise await fetch https d3js org d3 v7 min js var d3script await promise text var script document createElement script script type text javascript script innerHTML d3script script async false document body appendChild script grab the data let dataurl https notebook xbdev net var resources twittercovid csv get the date and tweet content let datain await d3 csv dataurl function d const tdate d Tweet Posted Time UTC const tcontent d Tweet Content const dt new Date tdate const date dt getFullYear dt getMonth 1 dt getDate get list of words remove non ascii chars let content tcontent replace a zA Z g make all lower case content content toLowerCase remove extra spaces content content replace split into words let words content split remove words fewer than 3 chars words words filter function d if d d trim length 3 return true return false for let i 0 i words length i const word words i won t include the index word to find tweets if word coronavirus continue if datain word datain word 1 else datain word 1 console log total words Object keys datain length sort the words array into the most popular convert to list let wordlist Object entries datain wordlist wordlist sort a b return b 1 a 1 print top 5 words here for checking for let k 0 k 5 k console log word wordlist k only going to display top 20 words wordlist wordlist splice 0 20 build d3 bar chart set the dimensions and margins of the graph var margin top 20 right 20 bottom 60 left 60 var width 500 margin left margin right var height 500 margin top margin bottom append the svg object to the body of the page var svg d3 select body append svg attr width width margin left margin right attr height height margin top margin bottom append g attr transform translate margin left margin top Add X axis var x d3 scaleLinear domain d3 extent wordlist d d 1 range 0 width svg append g attr transform translate 0 height call d3 axisBottom x selectAll text attr transform translate 10 0 rotate 45 style text anchor end Y axis var y d3 scaleBand range 0 height domain wordlist map function d return d 0 padding 1 svg append g call d3 axisLeft y Bars svg selectAll myRect data wordlist enter append rect attr x x 0 40 attr y function d return y d 0 attr width function d return x d 1 attr height y bandwidth attr fill 69b3a2 console log ready

atain date datain date 1 else datain date 1 map data to name value pair let data Object entries datain map d return date d 0 value d 1 console log days data length console log day 0 data 0 value console log day 1 data 1 value console log day 2 data 2 value console log day 20 data 20 value console log data range d3 extent data d d value Simple bar chart const leftmargin 50 const topmargin 50 const width 400 const height 400 var svg d3 select body append svg attr width width attr height height attr transform translate leftmargin topmargin append g Define x axis and y axis let x d3 scaleBand domain data map function d return d date range 0 width padding 0 3 let y d3 scaleLog domain d3 extent data d d value range height 0 base 10 Bars svg selectAll mybar data data enter append rect attr x function d return x d date 20 attr y function d return y d value 50 attr width x bandwidth attr height function d return height y d value attr fill 69b3a2 Draw bottom axis svg append g attr transform translate 20 height 50 call d3 axisBottom x selectAll text attr transform translate 10 10 rotate 90 style text anchor end style font size 7 style fill 69a3b2 Draw left y axis svg append g attr transform translate 20 0 This controls the vertical position of the Axis call d3 axisLeft y console log ready Organise the Tweet words frequency of the most popular document body style height 500px workaround for async loading var promise await fetch https d3js org d3 v7 min js var d3script await promise text var script document createElement script script type text javascript script innerHTML d3script script async false document body appendChild script grab the data let dataurl https notebook xbdev net var resources twittercovid csv get the date and tweet content let datain await d3 csv dataurl function d const tdate d Tweet Posted Time UTC const tcontent d Tweet Content const dt new Date tdate const date dt getFullYear dt getMonth 1 dt getDate get list of words remove non ascii chars let content tcontent replace a zA Z g make all lower case content content toLowerCase remove extra spaces content content replace split into words let words content split remove words fewer than 3 chars words words filter function d if d d trim length 3 return true return false for let i 0 i words length i const word words i won t include the index word to find tweets if word coronavirus continue if datain word datain word 1 else datain word 1 console log total words Object keys datain length sort the words array into the most popular convert to list let wordlist Object entries datain wordlist wordlist sort a b return b 1 a 1 print top 5 words here for checking for let k 0 k 5 k console log word wordlist k only going to display top 20 words wordlist wordlist splice 0 20 build d3 bar chart set the dimensions and margins of the graph var margin top 20 right 20 bottom 60 left 60 var width 500 margin left margin right var height 500 margin top margin bottom append the svg object to the body of the page var svg d3 select body append svg attr width width margin left margin right attr height height margin top margin bottom append g attr transform translate margin left margin top Add X axis var x d3 scaleLinear domain d3 extent wordlist d d 1 range 0 width svg append g attr transform translate 0 height call d3 axisBottom x selectAll text attr transform translate 10 0 rotate 45 style text anchor end Y axis var y d3 scaleBand range 0 height domain wordlist map function d return d 0 padding 1 svg append g call d3 axisLeft y Bars svg selectAll myRect data wordlist enter append rect attr x x 0 40 attr y function d return y d 0 attr width function d return x d 1 attr height y bandwidth attr fill 69b3a2 console log ready

3dplot
a4print
about
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
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
fluidsmokedynamics
fluidsmokedynamics2
fonts
fonts2
footerbar
fractalmaze
fractalmaze2
fractalnoiseimage
fractals
fractals2
fractaltree
freesvg
fresnel
froggerjs
gantt
gifgiphyapi
gifhex
gltffromscratch
gradients
griditems
griditems2
griditems3
griditems4
gridworms
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
keyframes
l2dwidget
lda
leftmenu
less
less2
lineargradientimage
linenumbers
loadimagefromfile
makepdf
maps
markdown
markdown2
markdownalerts
markdownalerts2
markdownbookmarks
markovimage
markovpixelblocks
mathjax
matrices
matsandvects
mazegamejs
md2tex
metrotiles
metrowindows
milestones
minkowski2dboxes
misc
misc2
modules
myipdetails
neataptic
networkstructures
networkstructures2
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
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
ritalanguage
ritalanguage2
ritalanguage3
rotateimg
rough
rsapublicprivatekeys
rss
rss2
sankey
scrappingsvg
scrolltext
scrolltext2
scrollwidth
sdfboxinboxtwist
sdfhollowbox
setintervalexception
shareurl
shuffle
sidecomment
similarity
simplehighlighter
simpleplatformgamejs
sinecanvas
sliderpopout
slides
smileys
snowfall
snowman
sound
soundsignal
sphererayintersection
springs
sqljs
steganography
stereogram
stringmatching
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