Data Visualization on the Web with D3

Similar documents
Introduction to WEB PROGRAMMING

welcome to BOILERCAMP HOW TO WEB DEV

Dreamweaver CS4. Introduction. References :

UI Course HTML: (Html, CSS, JavaScript, JQuery, Bootstrap, AngularJS) Introduction. The World Wide Web (WWW) and history of HTML

HTML and CSS COURSE SYLLABUS

HTML + CSS. ScottyLabs WDW. Overview HTML Tags CSS Properties Resources

Web Design & Dev. Combo. By Alabian Solutions Ltd , 2016

Index. alt, 38, 57 class, 86, 88, 101, 107 href, 24, 51, 57 id, 86 88, 98 overview, 37. src, 37, 57. backend, WordPress, 146, 148

Frontend UI Training. Whats App :

Welcome Please sit on alternating rows. powered by lucid & no.dots.nl/student

The Structure of the Web. Jim and Matthew

Learn Web Development CodersTrust Polska course outline. Hello CodersTrust! Unit 1. HTML Structuring the Web Prerequisites Learning pathway.

Index LICENSED PRODUCT NOT FOR RESALE

Block & Inline Elements

Using Dreamweaver CC. Logo. 4 Creating a Template. Page Heading. Page content in this area. About Us Gallery Ordering Contact Us Links

Taking Fireworks Template and Applying it to Dreamweaver

HTML5. HTML5 Introduction. Form Input Types. Semantic Elements. Form Attributes. Form Elements. Month Number Range Search Tel Url Time Week

The course also includes an overview of some of the most popular frameworks that you will most likely encounter in your real work environments.

Software. Full Stack Web Development Intensive, Fall Lecture Topics. Class Sessions. Grading

Lecture : 3. Practical : 2. Course Credit. Tutorial : 0. Total : 5. Course Learning Outcomes

Basics of Web Technologies

Web Development. With PHP. Web Development With PHP

Adobe Dreamweaver CS6 Digital Classroom

Standard 1 The student will author web pages using the HyperText Markup Language (HTML)

PHP & My SQL Duration-4-6 Months

Chapter 1 Getting Started with HTML 5 1. Chapter 2 Introduction to New Elements in HTML 5 21

Using AJAX to Easily Integrate Rich Media Elements

This course is designed for web developers that want to learn HTML5, CSS3, JavaScript and jquery.

BEFORE CLASS. If you haven t already installed the Firebug extension for Firefox, download it now from

DATABASE SYSTEMS. Introduction to web programming. Database Systems Course, 2016

Using Dreamweaver CS6

Styles, Style Sheets, the Box Model and Liquid Layout

Data Visualization (CIS/DSC 468)

Website Design (Weekend) By Alabian Solutions Ltd , 2016

Introduction to HTML & CSS. Instructor: Beck Johnson Week 2

Index. grouped (see Grouped bar chart) horizontal, jqplot library, 128 stacked bar charts (see Stacked bar charts) Bubble chart,

INTRODUCTION TO HTML5! CSS Styles!

Page Layout Using Tables

Designing the Home Page and Creating Additional Pages

PHP,HTML5, CSS3, JQUERY SYLLABUS

Advanced Dreamweaver CS6

WEB DESIGNING CURRICULUM

Frontend guide. Everything you need to know about HTML, CSS, JavaScript and DOM. Dejan V Čančarević

Siteforce Pilot: Best Practices

Chapter 1 Introduction to Dreamweaver CS3 1. About Dreamweaver CS3 Interface...4. Creating New Webpages...10

Website Design (Weekday) By Alabian Solutions Ltd , 2016

2. Write style rules for how you d like certain elements to look.

HTML5, CSS3, JQUERY SYLLABUS

SASS Variables and Mixins Written by Margaret Rodgers. Variables. Contents. From Web Team. 1 Variables

How to lay out a web page with CSS

HTML & CSS. Rupayan Neogy

the missing manual0 O'REILLY Third Edition David Sawyer McFarland Beijing Cambridge The book that should have been in the box Farnham

Mobile Site Development

week8 Tommy MacWilliam week8 October 31, 2011

AGENDA. EMBEDDING FONTS [ Font Files & CSS font-family ] :: Online Font Converter :: ADD font-family css code to style.css

CSC309 Winter Lecture 2. Larry Zhang


COMSC-031 Web Site Development- Part 2

Helpline No WhatsApp No.:

CORE PHP CURRICULUM. Introductory Session Web Architecture Overview of PHP Platform Origins of PHP in the open source community

ICT IGCSE Practical Revision Presentation Web Authoring

Introduction to HTML & CSS. Instructor: Beck Johnson Week 5

TUTORIAL: D3 (1) Basics. Christoph Kralj Manfred Klaffenböck

WEB DEVELOPER BLUEPRINT

Table Basics. The structure of an table

EXPLORE MODERN RESPONSIVE WEB DESIGN TECHNIQUES

FRONT END DEVELOPER CAREER BLUEPRINT

Varargs Training & Software Development Centre Private Limited, Module: HTML5, CSS3 & JavaScript

Etanova Enterprise Solutions

Data Visualization (DSC 530/CIS )

django-baton Documentation

COURSE OUTLINE MOC 20480: PROGRAMMING IN HTML5 WITH JAVASCRIPT AND CSS3

Create a three column layout using CSS, divs and floating

Microsoft Expression Web Quickstart Guide

HTML and CSS a further introduction

IN Development in Platform Ecosystems Lecture 2: HTML, CSS, JavaScript

Unit 20 - Client Side Customisation of Web Pages. Week 2 Lesson 3 Introduction to CSS

LING 408/508: Computational Techniques for Linguists. Lecture 14

Creating a Website: Advanced Dreamweaver

Unveiling the Basics of CSS and how it relates to the DataFlex Web Framework

Zen Garden. CSS Zen Garden

Creating a Job Aid using HTML and CSS

READSPEAKER ENTERPRISE HIGHLIGHTING 2.5

FROM 4D WRITE TO 4D WRITE PRO INTRODUCTION. Presented by: Achim W. Peschke

CSS worksheet. JMC 105 Drake University

ACA Dreamweaver Exam Notes

Webomania Solutions Pvt. Ltd. 2017

How to lay out a web page with CSS

AGENDA :: MULTIMEDIA TOOLS :: CLASS NOTES

CSS (CASCADING STYLE SHEETS) LAYOUT: INTRODUCTION ON PAGE BACKGROUNDS. By Ted Mitchell

HTML TIPS FOR DESIGNING.

COMS 359: Interactive Media

NEW WEBMASTER HTML & CSS FOR BEGINNERS COURSE SYNOPSIS

ADOBE 9A Adobe Dreamweaver CS4 ACE.

Make a Website. A complex guide to building a website through continuing the fundamentals of HTML & CSS. Created by Michael Parekh 1

Static Webpage Development

Lesson 5 Introduction to Cascading Style Sheets

WEBSITE PROJECT 2 PURPOSE: INSTRUCTIONS: REQUIREMENTS:

Magazine-style websites often have lots of small items on a page. First you re going to create a heading and background for your magazine.

a Very Short Introduction to AngularJS

Transcription:

Data Visualization on the Web with D3 Bowen Yu April 11, 16 Big Data Analysis

Interactive Analysis After dataprocessingwith BD techniques, itis necessary to visualize the data so that human analyst can be involvedfor decision making. Today we will go through the necessary tools for creating an interactive web visualization. 2

HTML 3

HTML HyperText Markup Language (HTML) Tags and content: <{tag}>{content}</{tag}> Layout tags <p> paragraph <div> division <h2> header Style tags <b> bold text <i> italic text Content tags <img> images <iframe> embedded form/video 4

A Simple Page index.html 5

Web Forms 6

Styling Your HTML A plaintext page is boring. Use CSS (cascading style sheet) to make a page appear nicer. 7

CSS Stylesheet 8

List of Common CSS Styles Text: color, font-size,font-family, font-weight word-wrap RenderingStyle: border background Layout: width, height,line-height left, right, bottom, top margin, padding position, float z-index Interaction: Pointer-events Search for details! e.g. http://www.w3schools.com/css/default.asp 9

CSS Syntax Selection + Style Settings Selection: CSS expression that selects a group of DOM elements Selections are typically on tags, classes, ids, DOM order. Tags: body,div, p Classes:elements of a same category your design Id: unique identifier for element your design 10

CSS Examples Class selection begins with a dot. Id selection begins with a hash. 11

Working with HTML Hierarchy {parent selection} {child selection} Add a space between selections to define containing relations 12

Working with HTML Hierarchy {parent selection} {child selection} Add a space between selections to define containing relations Note that the using space the selected child does not need to be immediate. 13

Working with HTML Hierarchy {parent selection} > {child selection} Add a larger sign between selections to define immediate containing relations 14

Compound Selection You may select the DOMs that satisfy multiple criteria. All paragraphs The paragraphs with class highlighted The paragraph with id focused (typically unique) Paragraphs and links (OR condition with comma) 15

Often CSS becomes nasty when you have complicated hierarchy L 16

Augmented CSS: SASS http://sass-lang.com/ Now instead of You can write sassy nested code. J style.css style.scss 17

Using SASS Note that you cannot directly include.scss files in the HTML as HTML only recognizes standard CSS. You must run sass tool to compile SCSS into CSS and then load the generated CSS in your HTML. There are other cool features such as functions (mixins) in SASS. More details can be found at the SASS website. Alternative: LESS (http://lesscss.org/) 18

Use Well-Designed Templates http://getbootstrap.com/ http://startbootstrap.com/ 19

Dynamic Pages HTML + CSS are good for creating static nice pages. However, static pages most ofthe time cannot meet the needsofweb usage today. Consider the scenario that you want to access your personal bank account summary: The bankmust determine who you are and then serve the page properly. Obviously, some scripting isneeded to achieve dynamic pages. 20

PHP Solution to Dynamic Pages PHP: a general-purpose scripting language running at the server side. ThePHP scriptisinaccessibletotheclient. Theclient mayonlyaccess the PHP output. When the client requests a PHP page, the PHP script determines the identityofthe client (by cookies, login credentials, etc.) and then return a dynamicallygenerated page. Loose typing. Line by line execution. PHP providegood security.however, it is hard to providepage interactionsattheclient side. 21

JavaScript Solution to Dynamic Pages JavaScript (JS): Programming language that runs in a client s browser. Manipulate DOM elements directlyin the browser. Perform requeststo the server and updatethepage without a refresh. Loose typing. Line by line execution. Not much related to Java J Today we will be focusing on using JS to render visualizations in the web. 22

Run Your JS Include the script file in your HTML (head or body) 23

Test and Debug Your JS Use your browser s console 24

JS 101 Number and Strings 25

JS 101 - Arrays and Objects 26

JS 101 - Loops 27

JS 101 - Functions 28

JS 101 Nested Types 29

JS 101 - Class 30

Go Deeper in JS Search for JS documentation. Play in yourbrowser s console (seeing is believing). Challenge: How to get numerical value 123 in JS in one command with nomore than 50 characters, if youcan only use 4 types of characters: []!+ Hint: +!![] gives you the number 1 31

Manipulate DOMs with JS Old-schoolmethods Returned values are the selected DOM Element(s). (not HTML strings) 32

Manipulate DOMs with JS Modern practice: use the jquery library (http://jquery.com/) Include jquery BEFORE yourcode. 33

jquery Selection Use the jquery namespace $ Note that the returned values are jquery selections (compound objects, not strings, not DOM element). You can select anything with CSS selection rules. 34

Manipulate the jquery Selection 35

Listen for Interaction 36

Generate Selection List from Data 37

AJAX Request jquery provideshandy AJAXrequest wrapper so that youcan perform queries without refreshing the page. 38

Visualization with jquery Theoreticallyyou can use jquery to manipulate any element on the web page. Therefore you may for every data object create a corresponding visualized data point. However it is non-trivial to perform updates, since elements can beadded, removed, changed 39

D3.js Data-Driven Documents https://d3js.org/ Core concept: Mappingdata to itsvisual representations. D3 provides other handy utilitiesas well, e.g. Visualization layout:treemap, force-directed graph, histogram Axis with ticks Scales, color mapping Transition 40

D3 Site 41

D3 Usage D3 works with SVG (scalable vector graphics), which does not suffer from lower resolution when resized. 42

D3 Selection Pretty much the same as jquery Note that rect and rects are D3 selections, not jquery selections, not DOM elements. 43

Binding Data 44

Binding Data (Add) 45

Binding Data (Remove) 46

Binding Data (Modify) 47

D3 Data Mapping Suppose on the canvas we have elements {1, 2, 3, 4, 5} Now the new data is {1, 2, 3, 6, 7}. Then we have: Entering: {6, 7} Exiting: {4, 5} Updating: {1, 2, 3} 48

Mapping Rendering Properties 49

Working with Updates Let s add some data updates. Once the update button is pressed, we try to update the bar chart with a new array of values. 50

But But when we pressed the button, nothing happened! Why? Because we only set the rendering properties for the enter(), which contain only those newly entering data points. 51

Use the Updating Selection 52

Use the Exiting Selection 53

Custom Data Mapping Default data binding uses array index. But it is possible to bind data items by other properties, usually ids. This is particularly useful for rendering data in a form of compound objects. We may add a functional mapping as: 54

Custom Data Mapping Each data item passed to the rendering is now the object, instead of the original numerical values. 55

D3 Scale Linear Scale 56

D3 Scale Color Scale 57

D3 Axis CSS 58

Loading Data with D3 D3 has built-in utilities for loading data, e.g. CSV and JSON. 59

D3 Layout A fastest way to get started with D3 layouts is to click on an example in the gallery and then look at the source code. Here we use an example of d3.layout.force, from http://bl.ocks.org/mbostock/4062045 60

Force-Directed Layout Edges pull nodes closer Nodes repulse each other Create a force 61

Using the Force-Directed Layout 62

D3 Interactions 63

D3 Zoom There are multiple ways to achieve zooming. We take an example at http://bl.ocks.org/mbostock/3680999 64

Package Management Including a lot of library codes here and there will make your code messy and unstable (e.g. a CDN may go down). It would be safer to have the library files located on your server. However, you don t want to include them as your source code. You want the user of your code to be able to easily get started with your code. Therefore, we use package management systems for frontend development. 65

Bower bower is a front-end package management system You may create a package specification by running bower init This creates a package spec called bower.json 66

Install Your Packages First look for package names at http://bower.io/. For jquery and D3: bower install --save jquery d3 Save means that you want to update your bower.json to include those libraries as your dependencies, so that another user (after cloning your code) can just run bower install to get all required dependencies. 67

Use Bower Components Now include the downloaded bower components to replace the CDN sources. DO NOT commit bower components folder to Git! (only commit bower.json) 68