Skip to content

Commit

Permalink
bumb d3 to v5
Browse files Browse the repository at this point in the history
  • Loading branch information
lsquaredleland committed Jul 18, 2018
1 parent 199ffa2 commit ca01c20
Showing 1 changed file with 41 additions and 52 deletions.
93 changes: 41 additions & 52 deletions UI/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,72 +19,61 @@

</style>
<body>
<script src="https://d3js.org/d3.v3.min.js"></script>
<script src="https://d3js.org/d3.v5.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/lodash.min.js"></script>
<script>

var margin = {top: 20, right: 20, bottom: 30, left: 40},
width = 1400 - margin.left - margin.right,
height = 500 - margin.top - margin.bottom;

var x = d3.scale.linear()
var x = d3.scaleLinear()
.range([0, width]);

var y = d3.scale.linear()
var y = d3.scaleLinear()
.range([height / 3, 0]);

var color = d3.scale.category10();
var xAxis = d3.axisBottom(x);

var xAxis = d3.svg.axis()
.scale(x)
.orient("bottom");

var yAxis = d3.svg.axis()
.scale(y)
.orient("left");
var yAxis = d3.axisLeft(y);

const generateGraph = (svg, data, x, y, height) => {
d3.tsv("data.csv", function(error, _data) {
if (error) throw error;

data.forEach(function(d) {
d.saleValue = +d.saleValue;
d.blockHeight = +d.blockHeight;
});

svg.append("g")
.attr("class", "x axis")
.attr("transform", "translate(0," + height + ")")
.call(xAxis)
.append("text")
.attr("class", "label")
.attr("x", width)
.attr("y", -6)
.style("text-anchor", "end")
.text("Execution Block Height");

svg.append("g")
.attr("class", "y axis")
.call(yAxis)
.append("text")
.attr("class", "label")
.attr("transform", "rotate(-90)")
.attr("y", 6)
.attr("dy", ".71em")
.style("text-anchor", "end")
.text("Initial Auction Price")

svg.selectAll(".bars_")
.data(data)
.enter().append("rect")
.attr("class", "bars_")
.attr("x", (d) => x(d.blockHeight))
.attr("y", (d) => y(d.saleValue))
.attr("width", 0.5)
.attr("height", (d) => height - y(d.saleValue))
.style("fill", (d) => color(d.species));

});
data.forEach(function(d) {
d.saleValue = +d.saleValue;
d.blockHeight = +d.blockHeight;
});

svg.append("g")
.attr("class", "x axis")
.attr("transform", "translate(0," + height + ")")
.call(xAxis)
.append("text")
.attr("class", "label")
.attr("x", width)
.attr("y", -6)
.style("text-anchor", "end")
.text("Execution Block Height");

svg.append("g")
.attr("class", "y axis")
.call(yAxis)
.append("text")
.attr("class", "label")
.attr("transform", "rotate(-90)")
.attr("y", 6)
.attr("dy", ".71em")
.style("text-anchor", "end")
.text("Initial Auction Price")

svg.selectAll(".bars_")
.data(data)
.enter().append("rect")
.attr("class", "bars_")
.attr("x", (d) => x(d.blockHeight))
.attr("y", (d) => y(d.saleValue))
.attr("width", 0.5)
.attr("height", (d) => height - y(d.saleValue))
.style("fill", (d) => "salmon");
}

const generateData = (count) => {
Expand Down

0 comments on commit ca01c20

Please sign in to comment.