21
H517 Visualization Design, Analysis, & Evaluation Khairi Reda | [email protected] School of Informa5cs & Compu5ng, IUPUI Week 2: Intro to HTML, JavaScript, and D3

H517 Visualization Design, Analysis, & Evaluationkhreda.com/teaching/2018/H517/slides/w02_d3_intro.pdf · memorability and engagement with the visualization. This week Intro to HTML,

  • Upload
    others

  • View
    4

  • Download
    0

Embed Size (px)

Citation preview

Page 1: H517 Visualization Design, Analysis, & Evaluationkhreda.com/teaching/2018/H517/slides/w02_d3_intro.pdf · memorability and engagement with the visualization. This week Intro to HTML,

H517 Visualization Design, Analysis, & Evaluation

KhairiReda|[email protected]&Compu5ng,IUPUI

Week 2: Intro to HTML, JavaScript, and D3

Page 2: H517 Visualization Design, Analysis, & Evaluationkhreda.com/teaching/2018/H517/slides/w02_d3_intro.pdf · memorability and engagement with the visualization. This week Intro to HTML,

Last week…

Page 3: H517 Visualization Design, Analysis, & Evaluationkhreda.com/teaching/2018/H517/slides/w02_d3_intro.pdf · memorability and engagement with the visualization. This week Intro to HTML,

Why use vision to analyze information?

1.Visionisthehighestbandwidthchannelintoourbrain

2.Cogni5onislimited.Percep5onbeatscogni5on

3.Workingmemoryislimited;externalrepresenta5onsexpandourmemory

4.Visualsareanintegralpartofourculture

Page 4: H517 Visualization Design, Analysis, & Evaluationkhreda.com/teaching/2018/H517/slides/w02_d3_intro.pdf · memorability and engagement with the visualization. This week Intro to HTML,
Page 5: H517 Visualization Design, Analysis, & Evaluationkhreda.com/teaching/2018/H517/slides/w02_d3_intro.pdf · memorability and engagement with the visualization. This week Intro to HTML,

CharlesMenard.Napoleon’s1812campaigntoMoscow

Page 6: H517 Visualization Design, Analysis, & Evaluationkhreda.com/teaching/2018/H517/slides/w02_d3_intro.pdf · memorability and engagement with the visualization. This week Intro to HTML,

0"

5"

10"

15"

20"

25"

30"

1978" 1979" 1980" 1981" 1982" 1983" 1984" 1985"

Miles"per"gallon"

Page 7: H517 Visualization Design, Analysis, & Evaluationkhreda.com/teaching/2018/H517/slides/w02_d3_intro.pdf · memorability and engagement with the visualization. This week Intro to HTML,

Based on reporting by the Guardian (https://www.theguardian.com/technology/blog/2008/jan/21/liesdamnliesandstevejobs) Via Miriah Meyer

Page 8: H517 Visualization Design, Analysis, & Evaluationkhreda.com/teaching/2018/H517/slides/w02_d3_intro.pdf · memorability and engagement with the visualization. This week Intro to HTML,

USsmartphonemarketshare

Slide by Miriah Meyer

Page 9: H517 Visualization Design, Analysis, & Evaluationkhreda.com/teaching/2018/H517/slides/w02_d3_intro.pdf · memorability and engagement with the visualization. This week Intro to HTML,

Last weekPrinciplesofVisualIntegrity

Usedetailedandclearlabelingtodefeatgraphicaldistor5ons

“Therepresenta5onofnumbers,asphysicallymeasuredonthesurfaceofthegraphicitself,shouldbedirectlypropor5onaltothenumericalquan55esrepresented”

Maximizedata-inkra5o

Avoidchartjunk*

* Visual embellishment can in some cases improve memorability and engagement with the visualization

Page 10: H517 Visualization Design, Analysis, & Evaluationkhreda.com/teaching/2018/H517/slides/w02_d3_intro.pdf · memorability and engagement with the visualization. This week Intro to HTML,

This weekIntrotoHTML,JavaScript,andD3

Page 11: H517 Visualization Design, Analysis, & Evaluationkhreda.com/teaching/2018/H517/slides/w02_d3_intro.pdf · memorability and engagement with the visualization. This week Intro to HTML,

D3: Data-Driven Documents

Page 12: H517 Visualization Design, Analysis, & Evaluationkhreda.com/teaching/2018/H517/slides/w02_d3_intro.pdf · memorability and engagement with the visualization. This week Intro to HTML,

The D3 stack

HTML SVG

Hypertext markup language Scalable Vector graphics

JavaScript

D3

Page 13: H517 Visualization Design, Analysis, & Evaluationkhreda.com/teaching/2018/H517/slides/w02_d3_intro.pdf · memorability and engagement with the visualization. This week Intro to HTML,

HTML example

Page 14: H517 Visualization Design, Analysis, & Evaluationkhreda.com/teaching/2018/H517/slides/w02_d3_intro.pdf · memorability and engagement with the visualization. This week Intro to HTML,

SVG

X

Y

(200,100)

Page 15: H517 Visualization Design, Analysis, & Evaluationkhreda.com/teaching/2018/H517/slides/w02_d3_intro.pdf · memorability and engagement with the visualization. This week Intro to HTML,

SVG

Page 16: H517 Visualization Design, Analysis, & Evaluationkhreda.com/teaching/2018/H517/slides/w02_d3_intro.pdf · memorability and engagement with the visualization. This week Intro to HTML,

SVG: a bar chart

Page 17: H517 Visualization Design, Analysis, & Evaluationkhreda.com/teaching/2018/H517/slides/w02_d3_intro.pdf · memorability and engagement with the visualization. This week Intro to HTML,

Chrome Web Server

https://tinyurl.com/y9k9hc441) Download extension from: 2) Create folder (e.g., on Desktop)

3) Choose folder from extension

4) Open URL

Page 18: H517 Visualization Design, Analysis, & Evaluationkhreda.com/teaching/2018/H517/slides/w02_d3_intro.pdf · memorability and engagement with the visualization. This week Intro to HTML,

Exercise:CreateabarchartinSVGtovisualizethefollowingdataset:

UsethefollowingSVGelements:

<rect x=“” y=“” width=“” height=“”/>

<line x1=“” x2=“” y1=“” y2=“” />

<text x=“” y=“”>Label here</text>

cats 45

dogs 21

iguanas 102

Petsanimalsfromaneighborhoodsurvey:

Page 19: H517 Visualization Design, Analysis, & Evaluationkhreda.com/teaching/2018/H517/slides/w02_d3_intro.pdf · memorability and engagement with the visualization. This week Intro to HTML,

Exercise 2:Repeatthepreviousexercise.Insteadof“hardcoding”thea_ributesofSVGelements,adjustthemprogramma5callyusingJavaScript

For loop to iterate through dataset

Pets dataset as an array

Adjust “height” attribute

Get a reference to a “rect” element

Page 20: H517 Visualization Design, Analysis, & Evaluationkhreda.com/teaching/2018/H517/slides/w02_d3_intro.pdf · memorability and engagement with the visualization. This week Intro to HTML,

Exercise 3:Repeatthepreviousexercise.InsteadofusingpureJavaScript,useD3selec5ons

selection and data binding

selection and data binding

Page 21: H517 Visualization Design, Analysis, & Evaluationkhreda.com/teaching/2018/H517/slides/w02_d3_intro.pdf · memorability and engagement with the visualization. This week Intro to HTML,

http://vis.ninja/teaching/2018/H517/d3-excercises/

Exercise 4:LoadingaCSVfileandvisualizingthedata