Skip to content

Instantly share code, notes, and snippets.

@li01012
Last active May 7, 2017 02:47
Show Gist options
  • Save li01012/7881236f9e2a69c9084749e149b59446 to your computer and use it in GitHub Desktop.
Save li01012/7881236f9e2a69c9084749e149b59446 to your computer and use it in GitHub Desktop.
may6th1.2
license: mit
<!DOCTYPE html>
<meta charset="utf-8">
<title>class-02 demo</title>
<style>
.line {
fill: none;
stroke: black;
stroke-width: 1px;
}
rect {
fill: none;
stroke: black;
stroke-width: 1px;
}
path{
fill: none;
stroke: black;
}
</style>
<script src="https://d3js.org/d3.v4.min.js"></script>
<script src="https://d3js.org/topojson.v2.min.js"></script>
<body>
<script>
var width = 960;
var height = 500;
var data = null; // global variable
// Set the map projection centered on Texas
var projection = d3.geoMercator()
.scale(2000)
.center([-98.90, 31.96]);
var path = d3.geoPath()
.pointRadius(5)
.projection(projection);
//projection.fitSize([width, height], object);
var svg = d3.select("body").append("svg")
.attr("width", width)
.attr("height", height);
var layer1 = svg.append("g");
var layer2 = svg.append("g");
var url = "https://raw.githubusercontent.com/TNRIS/tx.geojson/master/counties/tx_counties.geojson";
var TEX = "https://raw.githubusercontent.com/li01012/classes/master/Project/Final_Texas_Data.csv";
// Read and plot the state & county boundaries
d3.json(url, plotState);
d3.csv(TEX, function(err, csv){
if (err) throw err;
console.log(csv[0])
});
function plotState(error, tx) {
if (error) console.log(error);
var all = tx.features;
layer1.selectAll("path")
.data(all)
.enter().append ("path")
.attr("d", path);
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment