Skip to content

Commit

Permalink
init, simple-chart
Browse files Browse the repository at this point in the history
  • Loading branch information
Danite committed Sep 5, 2017
0 parents commit a1d16f7
Show file tree
Hide file tree
Showing 6 changed files with 91 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules/
8 changes: 8 additions & 0 deletions charts/Simple-Charts/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.chart div {
font: 10px sans-serif;
background-color: steelblue;
text-align: right;
padding: 3px;
margin: 1px;
color: white;
}
41 changes: 41 additions & 0 deletions charts/Simple-Charts/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<!DOCTYPE html>
<html>

<head>
<title>Simple chart</title>
</head>

<body>
<div class="chart"></div>

<script src="https://d3js.org/d3.v4.min.js"></script>

<script>
var data = [30, 86, 168, 281, 303, 365];

d3.select(".chart")
.selectAll("div")
.data(data)
.enter()
.append("div")
.style("width", function (d) {
return d + "px";
})
.text(function (d) {
return d;
});
</script>

<style>
.chart div {
font: 10px sans-serif;
background-color: steelblue;
text-align: right;
padding: 3px;
margin: 1px;
color: white;
}
</style>
</body>

</html>
9 changes: 9 additions & 0 deletions charts/Simple-Charts/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
var data = [30, 86, 168, 281, 303, 365];

d3.select(".chart")
.selectAll("div")
.data(data)
.enter()
.append("div")
.style("width", function(d) { return d + "px"; })
.text(function(d) { return d; });
14 changes: 14 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "d3projects",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"express": "^4.15.4"
}
}
18 changes: 18 additions & 0 deletions server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
var express = require("express");
var path = require("path");

var app = express();

const dir = "charts/Simple-Charts"

app.use(express.static("Simple-Charts"));


app.get("/", (req, res) => {
res.sendFile(path.resolve(__dirname, dir, "index.html"));
})

app.listen(3000, () => {
console.log("App listening on port 3000");
console.log("App path files: " + path.resolve(__dirname, dir, "index.html"));
})

0 comments on commit a1d16f7

Please sign in to comment.