Skip to content

Instantly share code, notes, and snippets.

@lqb2

lqb2/index.html Secret

Last active August 29, 2015 13:56
Show Gist options
  • Save lqb2/9139366 to your computer and use it in GitHub Desktop.
Save lqb2/9139366 to your computer and use it in GitHub Desktop.
Working on Tosci Coffee Viz
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF8">
</head>
<body>
<script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script>
<script src="tosci.js" charset="utf-8"></script>
</body>
</html>
//var dataset = [];
var dataset = d3.csv("5feb2014.csv", function(d) {
var dateTimeJoiner = d3.time.format("%x %X") // combines date and time into a Date object
var dateTime = dateTimeJoiner.parse(d["Date"] + " " + d["Time"]) // grabs the date and time
var gross_sales_conversion = +d["Gross Sales"].substr(1) //strips the $ sign
var total_sales = gross_sales_conversion * 1.07 //add tax
return {
date: dateTime,
category: d.Category,
item: d.Item,
quantity: +d.Quantity,
pricepoint: d["Price Point Name"],
gross_sales: gross_sales_conversion,
total_sale: +d3.format(".2f")(total_sales), // rounds to 2 decimal places
device_name: d["Device Name"]
};
}, function(error, rows) {
console.log(rows);
/*for (var item in rows) {
console.log(item);
};*/
// document.write(rows.length);
});
/*for (var item in dataset) {
alert(dataset[item]);
}
*/
@bengolder
Copy link

rows.forEach(function(row, i, arr){
    console.log("date for item", i, row.date);
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment