CS 990: Topics in Scientific Visualization

Slides:



Advertisements
Similar presentations
JavaScript I. JavaScript is an object oriented programming language used to add interactivity to web pages. Different from Java, even though bears some.
Advertisements

Advanced JS The World's Most Misunderstood Programming Language ) Douglas Crockford( Shimon Dahan
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall
Road Map Introduction to object oriented programming. Classes
Evan Korth New York University Computer Science I Classes and Objects Professor: Evan Korth New York University.
CSM-Java Programming-I Spring,2005 Introduction to Objects and Classes Lesson - 1.
Unobtrusive JavaScript
Tutorial 2 Variables and Objects. Working with Variables and Objects Variables (or identifiers) –Values stored in computer memory locations –Value can.
Introduction to JavaScript Gordon Tian
Object Oriented JavaScript. JavaScript Really only 4 types in JavaScript – number, string, boolean – Object (includes arrays) Remember that an object.
WDMD 170 – UW Stevens Point 1 WDMD 170 Internet Languages eLesson: Variables, Functions and Events (there is an audio component to this eLesson) © Dr.
Functions Reusable Parts of Code SoftUni Team Technical Trainers Software University
Working with Forms and Regular Expressions Validating a Web Form with JavaScript.
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
Creating PHP Pages Chapter 6 PHP Variables, Constants and Operators.
Data And Variables Chapter Names vs. Values Michael Jordan name (the letter sequence used to refer to something) value (the thing itself)
Rich Internet Applications 2. Core JavaScript. The importance of JavaScript Many choices open to the developer for server-side Can choose server technology.
1 Variables and Arithmetic Operators in JavaScript.
MTA EXAM HTML5 Application Development Fundamentals.
MIT-AITI: Functions Defining and Invoking Functions Functions as Data Function Scope: The call Object Function Arguments: The arguments objects Function.
JavaScript and Ajax (JavaScript Data Types) Week 2 Web site:
Object Oriented JavaScript. JavaScript Really only 4 types in JavaScript – number, string, boolean – Object (includes arrays) Remember that an object.
Microsoft Visual Basic 2012: Reloaded Fifth Edition Chapter One An Introduction to Visual Basic 2012.
JavaScript Variables. Definition A variable is a "container" for information you want to store. A variable's value can change during the script.
© 2010 Robert K. Moniot1 Chapter 6 Introduction to JavaScript.
CST 1101 Problem Solving Using Computers
What is a Function Expression?
Topic: Recursion – Part 2
Chapter 6 JavaScript: Introduction to Scripting
>> JavaScript: Location, Functions and Objects
Names and Attributes Names are a key programming language feature
Chapter 1: An Introduction to Visual Basic 2015
Variables and Arithmetic Operators in JavaScript
Data types and variables
CNIT 133 Interactive Web Pags – JavaScript and AJAX
Modern JavaScript Develop And Design
SEEM4570 Tutorial 05: JavaScript as OOP
Dr. Charles W. Kann III JavaScript Objects Dr. Charles W. Kann III
Scope, Objects, Strings, Numbers
JavaScript Syntax and Semantics
Road Map Introduction to object oriented programming. Classes
Programming Fundamentals Lecture #7 Functions
Web Programming– UFCFB Lecture 19-20
Functions Declarations, Function Expressions and IIFEs
COSC051: Computer Science I
Revision.
Object Oriented Programming
Lecture 23 Polymorphism Richard Gesick.
Chapter 3 Introduction to Classes, Objects Methods and Strings
CMPE 152: Compiler Design September 18 Class Meeting
CIS16 Application Development Programming with Visual Basic
Introduction to JavaScript
Unit-1 Introduction to Java
HCI Lab 2.
Advanced Programming Behnam Hatami Fall 2017.
Functions, Regular expressions and Events
Variables Kevin Harville.
Python Primer 1: Types and Operators
JavaScript CS 4640 Programming Languages for Web Applications
Javascript Chapter 19 and 20 5/3/2019.
Classes and Objects Imran Rashid CTO at ManiWeber Technologies.
Writing Function Rules
Unit-2 Objects and Classes
Web Programming and Design
[Robert W. Sebesta, “Programming the World Wide Web
Creating and Using Classes
JavaScript CS 4640 Programming Languages for Web Applications
JavaScript Part 2 Organizing JavaScript Code into Functions
Threads and concurrency / Safety
Presentation transcript:

CS 990: Topics in Scientific Visualization Dr. Mai Elshehaly

Assignment 1 Goal: To design a glyph/visualization that should take no more than 100x100 pixels to represent a week’s worth of data for mini challenge 1 Sample questions to detect patterns of life: What are the daily peak hours in the park? What days of the week have the most traffic? What weeks have the most traffic? What types of vehicles are most common? Do weekdays’ patterns differ from those of weekends? Does traffic tend to peak at specific locations in the park?

Sample of Submitted Answers

Sample of Submitted Answers

Sample of Submitted Answers

Data attributes: Week days Times of day Avg. number of cars in a week Weekends versus weekdays Spatial distribution of traffic Visual attributes: * 2D Heatmap inside each square Height of hexagon Width of hexagon Color/texture inside hexagon Line thickness of hexagon Suggested mapping: 2D heatmap  x-axis: weekdays, y-axis: times of day (or vice versa) Height of hexagon  avg. number of cars per week Width of hexagon  inverse of the percentage of cars per week that visit during weekends (i.e. weeks on which the majority of cars visited during weekends will have a thinner hexa to show how skewed the distribution is) Color/texture inside hexa  colored bubbles with size representing the avg. number of cars captured by each sensor during that week.

Let’s draw a glyph!

Steps Setup your project Constructor  will read data drawHexa() function for a dummy hexagon Draw rectangles around the hexagon createWeekly() creates a weekly data structure drawWeeklyHexa() function to draw a hexagon for each week drawWeeklyGlyph() function to draw the entire glyph for each week

1. Setup your project

A combination of HTML, CSS, DOM and Javascript provides an infrastructure for Web GUI development

index.html

Structure

JS Variables A JavaScript variable name must start with a letter, underscore (_), or dollar sign ($); subsequent characters can also be digits (0-9). As JavaScript is case sensitive, letters include the characters A through Z (uppercase) and the characters a through z (lowercase). New variables in JavaScript should be defined with the var keyword. If you declare a variable without assigning a value to it, its type is undefined by default. Remember that you should always declare a variable with the var keyword

Scopes You can visualize the bubbles as follows: -GLOBAL SCOPE---------------------------------------------| var g =0; | function foo(a) { -----------------------| | var b = 1; | | //code | | function bar() { ------| | | // ... |ScopeBar | ScopeFoo | } ------| | | // code | | var c = 2; | | }----------------------------------------| | foo(); //WORKS | bar(); //FAILS | ----------------------------------------------------------|

Scoping Rules When resolving a variable, JavaScript starts at the innermost scope and searches outwards. We can use functions to introduce different scopes for variables There are certain problems to this: If we must create a named function, we will pollute the global scope because we are creating too many function names We have to keep calling these functions for them to execute. This can make the code harder to read

Immediately Invoked Function Expression (IIFE) To solve the 2 problems above, we can create a function that executes itself immediately Or you can omit the function name: (function foo(){ /* code */ })(); (function(){ /* code */ })();

IIFE Omitting function name avoids polluting the global namespace but it introduces some issues: You can’t see the function name in the stack traces, debugging such code is difficult You cannot use recursion on anonymous functions Overusing anonymous IIFEs sometimes results in unreadable code

Javascript namespaces In Javascript, we use namespaces because we want to avoid collision (i.e. two variables having the same name and defined within the same namespace) Open source code is everywhere and collision is highly possible in javascript Therefore, great attention must be given to namespace creation

Util.js

mc1v2.js

OOP = Object-Oriented Programming In JS: Objects can be seen as mutable key-value-based collections. In JS: arrays, functions, and RegExp are objects In JS: numbers, strings, and Booleans are object-like constructs that are immutable but have methods.

Util.js

Prototype property Prototypes are used as a way to define properties and functions that will be applied to instances of objects. The prototype's properties eventually become properties of the instantiated objects.

mc1v2.js

Steps Setup your project Constructor  will read data drawHexa() function for a dummy hexagon Draw rectangles around the hexagon createWeekly() creates a weekly data structure drawWeeklyHexa() function to draw a hexagon for each week drawWeeklyGlyph() function to draw the entire glyph for each week

2. Constructor

The this keyword In JavaScript, the value of this is determined by the invocation context of a function and where it is called. Let's see how this behavior needs to be carefully understood:

Global context bound to this

Constructor bound to this

Object bound to this

2. Constructor

Draw a Hexagon A A x 60 A/2

Draw a Hexagon Let A = 64 (-A/2, -A*√3/2) (A/2, - A*√3/2) A A x (A, 0) 60 (-A, 0) (A, 0) A/2 (A/2, A*√3/2) (-A/2, A*√3/2)

3. drawHexa() function

4. Draw rectangles around the hexagon

Minor changes to drawHexa()

Append 1 rectangle above the hexagon

5. createWeekly() data structure

6. drawWeeklyHexa()

7. drawWeeklyGlyph()

Day/Hour Heatmap http://bl.ocks.org/tjdecke/5558084