-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Adds option to rotate the pitch - Adds option to shade middle third of pitch - Adds support for interpolating heatmaps - Improved docs - Adds tests for pitch rendering - Bugfixes
- Loading branch information
1 parent
509c5fa
commit eee3203
Showing
21 changed files
with
2,248 additions
and
7,934 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>D3 soccer</title> | ||
<style type="text/css"> | ||
svg { | ||
margin: 50px; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
|
||
<div id="chart" class="light-theme"></div> | ||
|
||
<script src="https://d3js.org/d3.v5.min.js"></script> | ||
<script type="text/javascript" src="./dist/d3-soccer.js"></script> | ||
<script type="text/javascript"> | ||
var pitch_height = 500; | ||
var header_height = 120; | ||
|
||
d3.json("data/debruyne_actions_heatmap.json").then(data => { | ||
|
||
var hed = d3.header() | ||
.hed('Kevin De Bruyne') | ||
.subhed('Ball touches') | ||
.img('img/debruyne.png'); | ||
var pitch = d3.pitch() | ||
.height(pitch_height) | ||
.rotate(false); | ||
var heatmap = d3.heatmap(pitch).interpolate(true); | ||
var tooltip = d3.actionTooltip(); | ||
d3.select("#chart") | ||
.call(tooltip); | ||
|
||
var svg = d3.select("#chart") | ||
.append("svg") | ||
// .attr("class", "dark-theme") | ||
.attr("width", pitch.width() + 40) | ||
.attr("height", pitch_height + header_height + 60); | ||
|
||
svg.append("g") | ||
.attr('transform', `translate(20,${header_height + 20})`) | ||
.datum(data) | ||
.call(heatmap) | ||
|
||
d3.json("data/debruyne_actions.json").then(data => { | ||
svg.select("#above") | ||
.datum(data) | ||
.append('g') | ||
.selectAll("dot") | ||
.data(data) | ||
.enter() | ||
.append("circle") | ||
.attr("cx", function (d) { return d.start_x; } ) | ||
.attr("cy", function (d) { return d.start_y; } ) | ||
.attr("r", .5) | ||
.attr("fill", "crimson") | ||
.attr("stroke", "#white") | ||
.attr("stroke-width", .1) | ||
.on('mouseover', d => tooltip.show(d)) | ||
.on('mouseout', () => tooltip.hide()) | ||
}) | ||
|
||
svg.append('g') | ||
.attr("transform", "translate(30,30)") | ||
.call(hed); | ||
|
||
svg.append('text') | ||
.attr('x', pitch.width()) | ||
.attr('y', header_height + pitch_height + 40) | ||
.attr('text-anchor', 'end') | ||
.style("fill", "grey") | ||
.style("font-style", "italic") | ||
.style("font-size", "11px") | ||
.text("Data provided by StatsBomb"); | ||
|
||
}) | ||
|
||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.