D3 leverage?

core tochnology
css, html, javascript, svg

data driven documents

Arrays(d3-array)

var data = [
	{name: "Alice", value: 2},
	{name: "Bob", value: 3},
	{name: "Carol", value: 1},
	{name: "Dwayne", value: 5},
];

d3: html, css, javascript, svg

5+7;
12
function say_hello(){
    return "Hello World!";
}
undefined
say_hello
function say_hello(){
    return "Hello World!";
}
say_hello();
"Hello World!"

Visualization Spectrum

HTML5 Canvas:https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API
WebGL:https://www.khronos.org/webgl/
SVG(Scalable Vector Graphics):https://developer.mozilla.org/en-US/docs/Web/SVG
D3.js:https://d3js.org/
NVD3:http://nvd3.org/
Dimple.js:http://dimplejs.org/
Rickshaw:http://code.shutterstock.com/rickshaw/
Chartio:https://chartio.com/
RAW:http://rawgraphs.io/

Predefined chart
python/ruby, c/c++, assembly

VizWiz

Data visualization
http://www.vizwiz.com/

Data Science Process
-Computer Science, Statistic and Data mining, Graphic Design, Infovis and HCI
-acquire, parse, filter, mine, represent, refine, interact

D3.js
https://d3js.org/

Rental Variables
size, color hue, orientation, shape, color saturation, texture

Display
position x, y, size, color

more accurate <-> less accurate

https://www.targetprocess.com/articles/visual-encoding/

– WebGL, Canvas, SVG
efficient, performant
flexible
low level
hard to develop with

Genome

Blood Vessel, skin cell, Red Blood Cell

Trait: any distinguishing feature of an individual
1.Physical vs Behavioral
2.Visible vs Hidden
3.Innate vs Learned

situs inversus: a condition where the organs are arranged in a mirror image of the normal positioning.

Deoxynucleotides: the building blocks of DNA
Adenine, Thymin, Guanine, Cytosine

Table views

Delegate Pattern
Controller, Protocol, View

we use the most to customize the textfield.
textField(_:shouldChangeCharactersInRange: replacementString:)

An array of structs

struct Album {
	let name:String
	let image:UIImage
	let count:Int
}

An array of dictionaries

let albums = [
	["name": "Camera Roll", "imageName": "img1", "count": 5],
	["name": "Recently Deleted", "imageName": "img2", "count": 0],
]

Generating a meme object

func save(){
	let meme = Meme(topText: topTextField.text!, bottomText: bottomTextField.text!, originalImage: imageView.image!, memedImage: memedImage)
}

func generateMemedImage() -> UIImage {
	UIGraphicsBeginImageContext(self.view.frame.size)
	view.drawHierarchy(in: self.view.frame, afterScreenUpdates: true)
	let memedImage:UIImage = UIGrphicsGetImageFromCurrentImageContext()!
	UIGraphicsEndImageContext()

	return memedImage
} 

What about the camera?

@IBAction func pickAnImageFromAlbum(_ sender: Any){
	let imagePicker = UIImagePickerController()
	imagePicker.delegate = self
	present(imagePicker, animated: true, completion: nil)
}

@IBAction func pickAnImageFromCamera(_ sender: Any){

	let imagePicker = UIImagePickerController()
	imagePicker.delegate = self
	present(imagePicker, animated: true, completion: nil)
}

@IBAction func pickAnImageFromAlbum(_ sender: Any){
	let imagePicker = UIImagePickerController()
	imagePicker.delegate = self
	imagePicker.sourceType = .photoLibrary
	present(imagePicker, animated: true, completion: nil)
}

cameraButton.isEnabled = UIImagePickerController.isSourceTypeAvailable(.camera)
let memeTextAttributes:[String:Any] = [
	NSStrokeColorAttributeName:
	NSForegroundColorAttributeName:
	NSFontAttributeName: UIFont(name: "HelveticaNeue-CondenseBlack", size: 40)!,
	NSStrokeWidthAttributeName:
]
override func viewWillAppear(_ animated: Bool){
	super.viewWillAppear(animated)
	subscribeTokeyboardNotifications()
}

override func viewWillDisappear(_ animated: Bool){
	super.viewWillDisappear(animated)
	unsubscribeFromKeyboardNotifications()
}

func subscribeToKeyboardNotifications(){
	NotificationCenter.default.addObserver(self, selector: #selector(keboardWillShow(_:)), name: .UIKey)
}

func keyboardWillShow(_ notification:Notification){
	view.frame.origin.y -= getKeyboardHeight(notification)
}

func getKeyboardHeight(_ notification:Notification) -> CGFloat{
	let userInfo = notification.userInfo
	let keyboardSize = userInfo![UIKeyboardFrameEndUserInfoKey] as! NSValue
	return keyboardSize.cgRectValue.height
}

Preparing the incoming ViewController

Code: No segue
Code & Segue: Segue is created in Storyboard, action is invoked in code
Seque: No code. set up completely in Storyboard

CurrentVC -> prepareForSeque -> NextVC

override func prepare(for seque: UIStoryboardSegue, sender: Any?)

	if segue.identifier == "rollDice"{
		let controller = segue.destination as! DiceViewController

		controller.firstValue = randomDiceValue()
		controller.secondValue = randomDiceValue()
	}
self.textField1.delegate = emojiDelegate
self.textField2.delegate = colorizerDelegate
self.textField3.delegate = self
@IBAction func pickAnImage(_ sender: Any){

	let imagePicker = UIImagePickerController()
	imagePicker.delegate = self
	present(imagePicker, animated: true, completion: nil)
}

RollViewController

import UIKit

class RollViewController: UIViewController {

	func randomDiceValue() -> Int {
		let randomValue = 1 + arc4random() % 6

		return Int(randomValue)
	}

	@IBAction func rollTheDice(){

		var controller:DiceViewController
		controller = self.storyboard?.instantiateViewControllerWithIdentifier("DiceViewController") as!
		DiceViewController

		controller.firstValue = self.randomDiceValue()
		controller.secondValue = self.randomDiceValue()

		self.presentViewController(controller, animated: true, completion: nil)
	}
}

Presenting the Dice View

import UIKit

class RollViewController: UIViewController {

	func randomDiceValue() -> Int {

		let randomValue = 1 + arc4random() % 6

		return Int(randomDiceValue) 
	}

	@IBAction func rollTheDice(){
		
	}
}
@IBAction func rollTheDice(){

	let controller: DiceViewController
	controller = storyboard?.instantiateViewController(withIdentifier: "DiceViewController") as! DiceViewController

	controller.firstValue = randomDiceValue()
	controller.secondValue = randomDiceValue()

	present(controller, animated: true, completion: nil)
}