Created
August 8, 2022 19:12
-
-
Save jgoodie/e89dd6fb61c561d9739b3318f5935973 to your computer and use it in GitHub Desktop.
simple js file to read iris data and format the numbers
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// set the dimensions and margins of the graph | |
const margin = {top: 10, right: 30, bottom: 40, left: 70}, | |
width = 800 - margin.left - margin.right, | |
height = 600 - margin.top - margin.bottom; | |
// append the svg object to the body of the page | |
const svg = d3.select("body") | |
.append("svg") | |
.attr("width", width + margin.left + margin.right) | |
.attr("height", height + margin.top + margin.bottom) | |
.append("g") | |
.attr("transform", `translate(${margin.left},${margin.top})`); | |
d3.csv("data/iris.csv").then( function(data) { | |
// clean/fix the data | |
data.forEach(function(d) { | |
d.sepal_width = +Number(d.sepal_width); | |
d.sepal_length = +Number(d.sepal_length); | |
d.petal_width = +Number(d.petal_width); | |
d.petal_length = +Number(d.petal_length); | |
}); | |
console.log(data) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment