Data Visualization
“Data visualization is both an art and a science”
Presenter:Chi-Hsuan, Huang @ Netdb.NCKU
“Data visualization is both an art and a science”
Presenter:Chi-Hsuan, Huang @ Netdb.NCKU
A primary goal of data visualization is to communicate information clearly and efficiently to users.
Effective visualization also helps
users in analyzing and reasoning about data.
and makes complex data more
accessible, understandable and usable.
Turn data into information, and information into insight.
--Carly Fiorina, Former CEO of HP
After creating visualizations,
should be notice that does it convey the data
honestly?
<html>
<head>
</head>
<body>
Hello, world!
</body>
</html>
<style>
body {
background-color: black;
}
</style>
<script>
// Array
var arr = [1, 2, 3, 4, 5];
// Object
var obj = {
key: 'value'
};
// Also have if control, for loop...
for (var i = 0; i < 10; ++i) {}
// Print
console.log(arr);
</script>
var svg = d3.select("body").append("svg");
d3.selectAll("circle")
.attr("cx", 20)
.attr("cy", 12)
.attr("r", 24)
.style("fill", "red");
var data = [1, 1, 2, 3, 5, 8];
var circle = svg.selectAll("circle")
data([32, 57, 293], function(d) { return d; });
circle.enter().append("circle");
var data = [
{name: "Alice", x: 10.0, y: 9.14},
{name: "Bob", x: 8.0, y: 8.14},
{name: "Carol", x: 13.0, y: 8.74},
{name: "Dave", x: 9.0, y: 8.77},
{name: "Edith", x: 11.0, y: 9.26}
];
function key(d) { return d.name; }
var circle = svg.selectAll("circle")
.data(data, key)
.attr("cx", x)
.attr("cy", y)
.attr("r", 2.5);
d3.csv("stocks.csv", function(stocks) {
// your code
});
var x = d3.scale.linear()
.domain([12, 24])
.range([0, 720]);
var yAxis = d3.svg.axis()
.scale(y)
.orient("left");
svg.on("click", function(){
path
.transition()
.duration(2000)
.ease("linear")
.attr("stroke-dashoffset", totalLength);
})
function draw() {
var canvas = document.getElementById("canvas");
if (canvas.getContext) {
var ctx = canvas.getContext("2d");
ctx.fillStyle = "rgb(200,0,0)";
ctx.fillRect (10, 10, 55, 50);
ctx.fillStyle = "rgba(0, 0, 200, 0.5)";
ctx.fillRect (30, 30, 55, 50);
}
}
var map = L.map('map').setView([51.505, -0.09], 13);
L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
attribution: '© OpenStreetMap contributors'
}).addTo(map);
L.marker([51.5, -0.09]).addTo(map)
.bindPopup('A pretty CSS3 popup.
Easily customizable.')
.openPopup();