{
const margin = { top: 30, right: 30, bottom: 30, left: 100 };
const height = 800;
const innerWidth = width - margin.left - margin.right;
const innerHeight = height - margin.top - margin.bottom;
const x = d3
.scaleBand()
.range([0, innerWidth])
.domain(dataset.varitySorted)
.padding(0.15);
const y = d3
.scaleBand()
.range([innerHeight, 0])
.domain(dataset.siteSorted)
.padding(0.15);
const colorScaleRelY_ = d3
.scaleLinear()
.range(["white", "#006600"])
.domain([-2, dataset.yieldRelYextent[1]]);
const colorScaleRelY = d3
.scaleSequential(d3.interpolateRdYlGn)
.domain([0, dataset.yieldRelYextent[1]]);
let svg = d3.create("svg").attr("width", width).attr("height", height);
svg
.append("g")
.attr(
"transform",
"translate(" + margin.left + "," + (height - margin.bottom) + ")"
)
.call(d3.axisBottom(x));
svg
.append("g")
.attr("transform", "translate(" + margin.left + "," + margin.top + ")")
.call(d3.axisLeft(y));
let rsvg = svg
.append("g")
.attr("transform", "translate(" + margin.left + "," + margin.top + ")");
rsvg
.selectAll("g.m")
.data(dataset.valuesAggregated)
.join("g")
.attr("class", "m")
.each(function (d) {
let rel = d.y1 - d.y2;
let relval = 1 / (1 + Math.exp(-rel));
let angle = relval * 200 - 100;
d3.select(this)
.call(cob(d.y1, d.y2, x.bandwidth() / 2, 6, 100))
.attr(
"transform",
`translate(${x(d.variety)} ${y(d.site)}) rotate(${angle} ${
x.bandwidth() / 2
} 0)`
);
});
return svg.node();
}