refactor(experiment_5):重构实验 5 数据格式和图表展示
- 移除 iris.csv 和 marketing.sql 文件 - 新增 sales_manager.csv 和 sales_month.csv 文件 - 添加 sales_manager.js 文件,实现销售数据的图表展示
This commit is contained in:
36
experiment_5/task4/js/test.html
Normal file
36
experiment_5/task4/js/test.html
Normal file
@@ -0,0 +1,36 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Title</title>
|
||||
|
||||
<script src="d3.min.js"></script>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<script>
|
||||
d3.csv("../data/sales_month.csv", function (error, data) {
|
||||
console.log(data);
|
||||
var month = [];
|
||||
var sales = [];
|
||||
var profit = [];
|
||||
for (i = 0; i < data.length; i++){
|
||||
month.push(data[i].month);
|
||||
sales.push(Math.round(data[i].sales / 100) / 100);
|
||||
profit.push(Math.round(data[i].profit / 100) / 100);
|
||||
}
|
||||
console.log("---month---")
|
||||
console.log(month)
|
||||
console.log("---sales---")
|
||||
console.log(sales)
|
||||
console.log("---profit---")
|
||||
console.log(profit)
|
||||
})
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user