0% found this document useful (0 votes)
52 views

Iris Dataset

This document loads iris data from a CSV file, converts the numeric fields to numbers, and renders the data to the page within preformatted HTML tags using the D3 JavaScript library. A function is defined to parse the CSV data and convert string values to numbers. Another function renders the JSON representation of the data to the page. On page load, the CSV data is loaded, parsed using the type function, and rendered to the page using the render function.

Uploaded by

aarthi dev
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
52 views

Iris Dataset

This document loads iris data from a CSV file, converts the numeric fields to numbers, and renders the data to the page within preformatted HTML tags using the D3 JavaScript library. A function is defined to parse the CSV data and convert string values to numbers. Another function renders the JSON representation of the data to the page. On page load, the CSV data is loaded, parsed using the type function, and rendered to the page using the render function.

Uploaded by

aarthi dev
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

<!

DOCTYPE html>
<head>
<meta charset="utf-8">
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.9/d3.min.js"></script>
</head>

<body>
<script>

function render(data){
d3.select("body")
.append("pre")
.text(JSON.stringify(data, null, 2));
}

function type(d){
d.sepal_length = +d.sepal_length;
d.sepal_width = +d.sepal_width;
d.petal_length = +d.petal_length;
d.petal_width = +d.petal_width;
return d;
}

d3.csv("iris.csv", type, render);

</script>
</body>

You might also like