function appendIntersectionObjects(isAwayFromOrigin = false) {
if (isAwayFromOrigin) {
d3.select('circle.staticIntersection').raise();
d3.selectAll("text.staticIntersection").remove();
const tempX = d3.select("circle.staticIntersection").attr("cx")
const tempY = d3.select("circle.staticIntersection").attr("cy")
svg.append('text')
.classed("staticIntersection", true)
.attr('x', tempX )
.attr('y', tempY)
.style('fill', 'gray')
.style('text-shadow', textShadow)
.style("font-size", 14)
.text("Old equilibrium");
}
svg.selectAll("circle.intersection").remove();
svg.selectAll("line.hDrop").remove();
svg.selectAll("line.vDrop").remove();
svg.selectAll('text.vDropLabel').remove();
svg.selectAll('text.hDropLabel').remove();
intersectionPoints.map( pair => {
const point = intersectLines(getLineByLabel(pair.labels[0]), getLineByLabel(pair.labels[1]));
if (point.x >= xAxisScale.domain[0] && point.x <= xAxisScale.domain[1] &&
point.y >= yAxisScale.domain[0] && point.y <= yAxisScale.domain[1])
{
if (pair.drawVerticalDropline) {
svg.append("line")
.classed('vDrop', true)
.style('stroke-width', dropLines.width)
.style('stroke-dasharray', dropLines.dashCSS)
.style('stroke', 'black')
.attr("x1", xScale(point.x)).attr("y1", height - margin.bottom)
.attr("x2", xScale(point.x)).attr("y2", yScale(point.y));
}
if(pair.drawHorizontalDropline) {
svg.append("line")
.classed('hDrop', true)
.style('stroke-width', dropLines.width)
.style('stroke-dasharray', dropLines.dashCSS)
.style('stroke', 'black')
.attr("x1", xScale(xAxisScale.domain[0])).attr("y1", yScale(point.y))
.attr("x2", xScale(point.x)).attr("y2", yScale(point.y))
}
svg.append("circle")
.classed("intersection", true)
.attr('cx', xScale(point.x))
.attr('cy', yScale(point.y))
.attr('r','5px')
.style("stroke", () => {
return (pair.isPrimary) ? 'none' : '#5A5A5A'
})
.style("stroke-width", "2px")
.style('fill', () => {
return (pair.isPrimary) ? 'black' : 'none'
})
d3.selectAll('text.vDropLabel').remove();
d3.selectAll('text.hDropLabel').remove();
svg.append('text')
.classed("vDropLabel", true)
.attr('x', xScale(point.x) + pair.verticalLabelOffset[0])
.attr('y', height - margin.bottom + pair.verticalLabelOffset[1])
.style('fill', pair.verticalLabelColor)
.style('text-shadow', textShadow)
.style("font-size", 18)
.style("font-weight", 'bold')
.text(() => `${d3.format(pair.verticalLabelFormat)(point.x/100)}`)
svg.append('text')
.classed("hDropLabel", true)
.attr('x', xScale(xAxisScale.domain[0]) + pair.horizontalLabelOffset[0])
.attr('y', yScale(point.y) + pair.horizontalLabelOffset[1])
.style('fill', pair.horizontalLabelColor)
.style('text-shadow', textShadow)
.style("font-size", 18)
.style("font-weight", 'bold')
.text(() => `${d3.format(pair.horizontalLabelFormat)(point.y/100)}`)
}
})
}