Though you can make charts with it
Though you can make maps with it
Though you can use it with them
S1 | S2 | S3 |
---|---|---|
18 | 25 | 19 |
1 | 5 | 17 |
21 | 22 | 14 |
18 | 25 | 19 |
HTML
CSS
SVG
Javascript
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<h1>My First Heading</h1>
<p>My first paragraph.</p>
</body>
</html>
<html>
<html>
<body>
<body>
<head>
<head>
<h1>
<p>
<!DOCTYPE html>
<meta charset="utf-8">
<style>
body {
background: steelblue;
}
p {
font: italic bold 40px Georgia, serif;
color: white;
}
</style>
<body>
<h1>My First Heading</h1>
<p>My first paragraph.</p>
</body>
<svg width="100" height="100">
<circle
cx="50" cy="50" r="40"
stroke="green" stroke-width="4"
fill="yellow" />
</svg>
<svg width="160" height="110">
<rect width="150" height="100"
style="fill: rgb(0,0,255);
stroke-width:3;
stroke: rgb(0,0,0)" />
</svg>
<svg height="210" width="200">
<polygon points="100,10 150,190 60,210"
style="fill: lime;
stroke: purple;
stroke-width: 1" />
</svg>
<svg height="210" width="200">
<polygon points="100,10 40,198 190,78 10,78 160,198"
style="fill: lime;
stroke: purple;
stroke-width:5;
fill-rule: nonzero;" />
</svg>
// -- global variables --
// an integer stored as number
a = 0;
// a string
b = "1";
// an array
c = [1, 2, "3", [4]];
// a boolean
f = false;
// redefining f as a float stored as a number
f = 34.56;
// -- "local" variables --
var name="Alex";
var age=34;
Variables
// an integer stored as number
a = 0;
// a string
b = "0";
a == b
// return ture
a === b
// return false
== &Â ===
// adding, substracting, multiplying, dividing
var sum = 1 + 3;
sum += 1;
sum++;
sum--;
var division = sum/13;
// modulo
var mod = division % 2;
// typeof operator
typeof(division); // returns string number
// String concatenation
var compoundString = "two " + "words";
Operations
// The familiar if
if (1 == parseFloat("1")) {
console.log("First if");
} else if (2 == parseFloat("3")) {
console.log("Else if");
} else {
console.log("else");
}
// for loops
var output = "";
for (i = 0; i < 10; ++i) {
output += i + ", ";
}
console.log("For loop: " + output);
Control &Â Loop Â
function someFunction(v) {
if (v < 10) {
return v;
} else {
return v*v;
}
}
someFunction(5)
// return 5
someFunction(10)
//return 100
Function
// here's what a functor is
function functor(x) {
return function() {
return x;
};
}
Functor
var passed = 3;
var addTo = function () {
var inner = 2;
return passed + inner;
};
console.dir(addTo());
var passed = 4;
console.dir(addTo());
Closure
var addTo = function (passed) {
var add = function(inner){
return passed + inner
};
return add;
};
var addTree = new addto(3);
var addFour = new addto(4);
console.log(addThree(1));
console.log(addFour(1));
#foo // <any id="foo">
foo // <foo>
.foo // <any class="foo">
[foo=bar] // <any foo="bar">
foo bar // <foo><bar></foo>
foo.bar // <foo class="bar">
foo#bar // <foo id="bar">
CSS provides a handy way to refer to specific elements. ​
foo, bar {
font-family: "Menlo", monospace;
font-size: 48px;
}
document.querySelector("node")
document.querySelectorAll("node")
A selection is an array of elements pulled from the current document.
d3.select(selector)
d3.select(node)
d3.selectAll(selector)
d3.selectAll(nodes)
Â
#foo
foo
.foo
[foo=bar]
foo bar
foo.bar
foo#bar
// select all <circle> elements
var circle = d3.selectAll("circle");
// set some attributes and styles
circle.attr("cx", 20);
circle.attr("cy", 12);
circle.attr("r", 24);
circle.style("fill", "red");
<svg height="120" width="120">
<circle/>
</svg>
<svg height="120" width="120">
<circle />
</svg>
<svg height="120" width="120">
<circle />
</svg>
// select the <body> element
var body = d3.select("body");
// add an <h1> element
var h1 = body.append("h1");
h1.text("Hello!");
<body>
</body>
// select the <body> element
var body = d3.select("body");
// add an <h1> element
var h1 = body.style("background", "steelblue")
.append("h1");
h1.text("Hello!")
.style("color", "white");
<body>
</body>
<body>
<section></section>
<section></section>
<section></section>
</body>
// select the <body> element
var body = d3.selectAll("section");
// add an <h1> element
var h1 = body.style("background", "steelblue")
.append("h1");
h1.text("Hello!")
.style("color", "white");
// A bar chart, perhaps?
var data = [3, 8, 12, 7, 17];
// A scatterplot, perhaps?
var data = [
{x: 10.0, y: 9.14},
{x: 8.0, y: 8.14},
{x: 13.0, y: 8.74},
{x: 9.0, y: 8.77},
{x: 11.0, y: 9.26}
];
svg.selectAll("circle")
.data(data)
.enter().append("circle")
.attr("cx", x)
.attr("cy", y)
.attr("r", 2.5);
var circle = svg.selectAll("circle")
.data(data);
var circle = svg.selectAll("circle")
.data(data);
circle.enter().append("circle");
var circle = svg.selectAll("circle")
.data(data);
circle.enter().append("circle")
.attr("cx", x)
.attr("cy", y)
.attr("r", 2.5);
var graph = {
"nodes":[
{
"name":"1",
"rating":90,
"id":2951},
{
"name":"2",
"rating":80,
"id":654654
},
...
],
"links":[
{
"source":6,
"target":5,
"label":"publishedOn"
},
{
"source":8,
"target":5,
"label":"publishedOn"},
...
]
}
var matrix = [
[1144, 71, 35, 14, 11, 2, 39],
[92, 672, 5, 44, 31, 18, 51],
[246, 58, 144, 19, 11, 43, 56],
[56, 99, 2, 220, 20, 9, 24],
[23, 68, 2, 24, 255, 34, 56],
[0, 0, 0, 0, 0, 206, 0],
[152, 87, 10, 20, 24, 21, 1456],
];
Developed by Jason DaviesÂ
1. Place the word at some starting point: usually near the middle, or somewhere on a central horizontal line.​
3. If the word intersects with any previously-placed words, move it one step along an increasing spiral. Repeat until no intersections are found.
THANK YOU FOR LISTENING
Â
The slides are made by reveal.js and slides.com