havenRegionData = {
let margin = {
top:110,
right: 40,
bottom: 60,
left: 95
}
let spacing = 5
let barScale = d3.scaleLinear()
.domain([0, 1])
.range([0,963-margin.left])
let textSize = d3.scaleLinear()
.domain([10, 3])
.range([26,48])
let textY = d3.scaleLinear()
.domain([3, 10])
.range([57,42])
let svg = d3.create('svg').style("background-color", 'white').attr("preserveAspectRatio", "none")
.attr("viewBox", "0 0 963 460")
svg.append("text")
.attr("class", "signature")
.attr("text-anchor", "left")
.attr("y", 2)
.attr("x", 0)
.attr("dy", ".75em")
.attr('style', "font-size: 14px; font-family: 'Bebas Neue';")
.text("Author: Sam Rosenberg");
svg.append("image")
.attr("xlink:href", "https://greblytics.com/wp-content/uploads/2021/03/cropped-Grebnesor-Analytics-SK_JRD-01.png")
.attr("x", 853)
.attr("y", 0)
.attr("width", 100)
.attr("height", 50);
var text2 = svg.append("svg:text").attr("class", "title")
.attr("text-anchor", "middle")
.attr("y", 53)
.attr("x", 963/2)
.attr('style', "font-size: 45px; font-family: 'Bebas Neue';").attr("fill", valred);
;
text2.append("svg:tspan").style("fill", "black").text("Recent Gun Choices: ");
text2.append("svg:tspan").style("fill", valblue).text('Phantom');
text2.append("svg:tspan").style("fill", "black").text(" or ");
text2.append("svg:tspan").style("fill", valred).text('Vandal');
var text3 = svg.append("svg:text").attr("class", "title")
.attr("text-anchor", "middle")
.attr("y", 60).attr("dy", "1em")
.attr("x", 963/2)
.attr('style', "font-size: 20px; font-family: 'Bebas Neue';").attr("fill", 'black').text("Percentages are of guns used across all rounds.");
var text4 = svg.append("svg:text").attr("class", "title")
.attr("text-anchor", "middle")
.attr("y", 60).attr("dy", "1em")
.attr("x", 963/2)
.attr('style', "font-size: 20px; font-family: 'Bebas Neue';").attr("fill", 'black');
text4.append("svg:tspan").attr("dy", "2em").style("fill", "black").text("While only the phantom and vandal are listed, people played rounds with other guns.");
//vandal back
svg.selectAll("vandal")
.data(regionGunData)
.join('rect')
.attr("x", margin.left)
.attr("y", function(d, i) {return margin.top + 55*i+spacing*i})
.attr("width", function(d, i) {return barScale(1)})
.attr("height", 50)
.attr("fill", valred);
//adding phantom
svg.selectAll("phantom")
.data(regionGunData)
.join('rect')
.attr("x", margin.left)
.attr("y", function(d, i) {return margin.top + 55*i+spacing*i})
.attr("width", function(d, i) {return barScale(d.find(g => g.Weapon === "Phantom")["Pick Percentage"]/(Number(d.find(g => g.Weapon === "Vandal")["Pick Percentage"]) + Number(d.find(g => g.Weapon === "Phantom")["Pick Percentage"])))})
.attr("height", 50)
.attr("fill", valblue);
svg.selectAll("percentphan")
.data(regionGunData)
.join('text')
.attr("x", d => barScale(d.find(g => g.Weapon === "Phantom")["Pick Percentage"]/(Number(d.find(g => g.Weapon === "Vandal")["Pick Percentage"]) + Number(d.find(g => g.Weapon === "Phantom")["Pick Percentage"])))/2 + margin.left)
.attr("y", function(d, i) {return margin.top + 55*i+45+spacing*i-1}).attr("fill", 'black').call(addWebFont, 'Bebas Neue', 'https://fonts.gstatic.com/s/bebasneue/v2/JTUSjIg69CK48gW7PXoo9WlhyyTh89Y.woff2').attr('style', "font-size: "+50+"px; font-family: 'Bebas Neue';").attr("text-anchor", "middle").attr("fill", 'white')
.text(d =>((d.find(g => g.Weapon === "Phantom")["Pick Percentage"]/(Number(d.find(g => g.Weapon === "Vandal")["Pick Percentage"]) + Number(d.find(g => g.Weapon === "Phantom")["Pick Percentage"])))*100).toFixed(0)+"%");
svg.selectAll("percentvan")
.data(regionGunData)
.join('text')
.attr("x", d => barScale(d.find(g => g.Weapon === "Phantom")["Pick Percentage"]/(Number(d.find(g => g.Weapon === "Vandal")["Pick Percentage"]) + Number(d.find(g => g.Weapon === "Phantom")["Pick Percentage"])))+ + margin.left + barScale(d.find(g => g.Weapon === "Vandal")["Pick Percentage"]/(Number(d.find(g => g.Weapon === "Vandal")["Pick Percentage"]) + Number(d.find(g => g.Weapon === "Phantom")["Pick Percentage"])))/2)
.attr("y", function(d, i) {return margin.top + 55*i+45+spacing*i-2}).attr("fill", 'black').call(addWebFont, 'Bebas Neue', 'https://fonts.gstatic.com/s/bebasneue/v2/JTUSjIg69CK48gW7PXoo9WlhyyTh89Y.woff2').attr('style', "font-size: "+50+"px; font-family: 'Bebas Neue';").attr("text-anchor", "middle").attr("fill", 'white')
.text(d =>((d.find(g => g.Weapon === "Vandal")["Pick Percentage"]/(Number(d.find(g => g.Weapon === "Vandal")["Pick Percentage"]) + Number(d.find(g => g.Weapon === "Phantom")["Pick Percentage"])))*100).toFixed(0)+"%");
svg.selectAll("regions")
.data(regionGunData)
.join('text')
.attr("x", margin.left-3)
.attr("y", function(d, i) {return margin.top + 55*i+textY(d.find(g => g.Weapon === "Phantom")["region"].length)+spacing*i})
.text(d => d.find(g => g.Weapon === "Phantom")["region"])
.attr("fill", 'black').call(addWebFont, 'Bebas Neue', 'https://fonts.gstatic.com/s/bebasneue/v2/JTUSjIg69CK48gW7PXoo9WlhyyTh89Y.woff2').attr('style', d => "font-size: "+textSize(d.find(g => g.Weapon === "Phantom")["region"].length)+"px; font-family: 'Bebas Neue';").attr("text-anchor", "end").attr("alignment-baseline", "ideographic");
//https://media.valorant-api.com/weapons/ee8e8d15-496b-07ac-e5f6-8fae5d4c7b1a/displayicon.png
//"https://media.valorant-api.com/weapons/9c82e19d-4575-0200-1a81-3eacf00cf872/displayicon.png"
svg.append("image")
.attr("xlink:href", "https://media.valorant-api.com/weapons/ee8e8d15-496b-07ac-e5f6-8fae5d4c7b1a/displayicon.png")
.attr("x", 0)
.attr("y", 30)
.attr("width", 150)
.attr("height", margin.top);
svg.append("image")
.attr("xlink:href", "https://media.valorant-api.com/weapons/9c82e19d-4575-0200-1a81-3eacf00cf872/displayicon.png")
.attr("x", 963-150)
.attr("y",30)
.attr("width", 150)
.attr("height", margin.top);
return svg.node();
}