-
Rennen, Brumm, Brumm!
-
- Eingerückt wird mit 2 Leerzeichen pro Einrückungsebene.
- Charset ist UTF-8.
- TODO
-
-
-
-
Hier erscheint gleich ein Diagramm.
-
-
Hier erscheint gleich ein Test-Diagramm.
-
-
-
diff --git a/js/diagrams.js b/js/diagrams.js
index 803b47d..0d1aa48 100644
--- a/js/diagrams.js
+++ b/js/diagrams.js
@@ -2,6 +2,8 @@
// https://bl.ocks.org/mbostock/3884955
function createLineGraph(containerId, raceData){
+ var linePointSize = 4;
+
console.log(raceData);
var height = 1000;
@@ -10,7 +12,7 @@ function createLineGraph(containerId, raceData){
var amountClickedLines = 0;
// set the dimensions and margins of the graph
- var margin = {top: 20, right: 20, bottom: 30, left: 50},
+ var margin = {top: 50, right: 100, bottom: 50, left: 100},
width = width - margin.left - margin.right,
height = height - margin.top - margin.bottom;
@@ -42,13 +44,10 @@ function createLineGraph(containerId, raceData){
// Adds all lines
enhancedLapData.forEach((driverLapData, driverIndex) => {
- //console.log(driverLapData);
+ console.log(driverLapData);
svg.append("path")
.data([driverLapData.laps])
.attr("class", "line")
- .attr("data-line", driverLapData.driver.driverId)// custom data to Specify the line
- .attr("data-highlightable", 1)
- .attr("data-highlighted", 0)
.attr("stroke", getColorValue(driverIndex, enhancedLapData.length) )
.attr("d", lineDataDefinition);
@@ -56,15 +55,11 @@ function createLineGraph(containerId, raceData){
svg.selectAll(".linepoint")
.data(driverLapData.laps)
.enter().append("circle") // Uses the enter().append() method
- .attr("class", "dot linedot") // Assign a class for styling
- .attr("data-line", driverLapData.driver.driverId)
- .attr("data-highlightable", 0)
- .attr("data-highlighted", 0)
+ .attr("class", "dot") // Assign a class for styling
.attr("fill", getColorValue(driverIndex, enhancedLapData.length))
.attr("cx", function(d, i) {return x(d.lap) })
.attr("cy", function(d, i) { return y(d.position) })
.attr("r", linePointSize)
- .on("click", handleClickOnPoint)
.on("mouseover", handleMouseOverLinePoint)
.on("mouseout", handleMouseOutLinePoint)
.style("opacity", 0);
@@ -75,15 +70,11 @@ function createLineGraph(containerId, raceData){
svg.selectAll(".pitstoppoint")
.data([singleLap])
.enter().append("circle") // Uses the enter().append() method
- .attr("class", "dot pitstopdot") // Assign a class for styling
- .attr("data-line", driverLapData.driver.driverId)
- .attr("data-highlightable", 1)
- .attr("data-highlighted", 0)
+ .attr("class", "dot") // Assign a class for styling
.attr("fill", getColorValue(driverIndex, enhancedLapData.length))
.attr("cx", function(d, i) {return x(d.lap) })
.attr("cy", function(d, i) { return y(d.position) })
.attr("r", linePointSize * 1.2)
- .on("click", handleClickOnPoint)
.on("mouseover", handleMouseOverLinePoint)
.on("mouseout", handleMouseOutLinePoint);
}
@@ -103,35 +94,6 @@ function createLineGraph(containerId, raceData){
.call(d3.axisRight(y))
.attr("transform", "translate( " + (width) + ", 0 )");
- function handleClickOnPoint(d,i){
- console.log(this);
- //select elements that are highlightable but are not highlighted
- d3.selectAll("[data-highlightable='" + 1 +"'][data-highlighted='" + 0 +"']")
- .style("opacity", 0.3);
-
- // if clicked on already highlighted line, remove highlight
- if(this.getAttribute("data-highlighted") == 1){
- d3.selectAll("[data-line='" + d.driverId +"'][data-highlightable='" + 1 +"']")
- .attr("data-highlighted", 0)
- .style("opacity", 0.3);
- }else{
- //select elements that belong to line and are highlightable
- d3.selectAll("[data-line='" + d.driverId +"'][data-highlightable='" + 1 +"']")
- .attr("data-highlighted", 1)
- .style("opacity", 1);
- }
-
- // if no element highlighted, then everything normal again
- var highlightedElements = d3.selectAll("[data-highlightable='" + 1 +"'][data-highlighted='" + 1 +"']");
- console.log(highlightedElements);
- if(highlightedElements.size() == 0){
- //select elements that are highlightable but are not highlighted
- d3.selectAll("[data-highlightable='" + 1 +"'][data-highlighted='" + 0 +"']")
- .style("opacity", 1);
- }
-
- }
-
function handleMouseOverLinePoint(d, i) {
// Add interactivity
// Use D3 to select element, change color and size
diff --git a/js/main.js b/js/main.js
index 0696f96..09a159e 100644
--- a/js/main.js
+++ b/js/main.js
@@ -7,8 +7,8 @@
preprocessor.load(function(data) {
// Some sample code for a year selector - TODO: Improve a lot and move somewhere else
var yearSelector = $("#seasonByYearSelector");
- var seasons = preprocessor.getResults().seasons;
- for(var year in seasons) yearSelector.append("