function ScatterChart({
data,
element,
width = 600,
height = 150,
x,
y,
points,
highlightValue,
formatNumber = ".0s",
mainColor = { color: "#708090", stroke: "#121212", opacity: 0.3 },
highlightColor = { color: "#708090", stroke: "#121212", opacity: 0.8 }
}) {
const data_filtered = data.filter((d) => d);
const X = d3.map(data_filtered, (d) => d[x]);
const Y = d3.map(data_filtered, (d) => d[y]);
const xDomain = [0, d3.max(X)];
const yDomain = new d3.InternSet(Y);
const xRange = [0, width];
const yRange = [0, height];
const xScale = d3.scaleLinear(xDomain, xRange);
const yScale = d3.scaleBand(yDomain, yRange);
const xAxis = d3.axisBottom(xScale).ticks(width /80 )
.tickFormat(localized[language].format(".1s"));
const yAxis = d3.axisLeft(yScale).tickSizeOuter(0);
element.append("g").attr("transform", `translate(0,${height})`).call(xAxis);
const yAxisObject = element
.append("g")
.attr("transform", `translate(0,0)`)
.call(yAxis);
yAxisObject
.selectAll(".tick")
.attr("stroke-opacity", 0.3)
.attr("stroke-dasharray", "2,2")
.selectAll("line")
.attr("x2", width)
.attr("x1", -5);
yAxisObject.select(".domain").attr("stroke-opacity", 0);
yAxisObject.selectAll("text")
.attr("font-size", 13)
.each(function(d, i) { mapText(d3.select(this)) });
const circles = element
.append("g")
.selectAll("circle")
.data(data_filtered.filter(d => d[points] !== highlightValue))
.join("circle")
.attr("fill", (d) => d[points] === highlightValue ? highlightColor.color : mainColor.color)
.attr("stroke", (d) => d[points] == highlightValue ? highlightColor.stroke : mainColor.stroke)
.attr("stroke-width", 1)
.attr("r", 6)
.attr("cx", (d) => xScale(d[x]))
.attr("cy", (d) => yScale(d[y]) + yScale.bandwidth() / 2)
.attr("opacity", (d) => d[points] === highlightValue ? highlightColor.opacity : mainColor.opacity)
const images = element
.append("g")
.selectAll("image")
.data(data_filtered.filter(d => d[points] === highlightValue))
.join("image")
.attr("xlink:href", "https://cdn.pixabay.com/photo/2021/10/18/19/56/fire-6721968_960_720.png")
.attr("width", 25)
.attr("anchor", 'middle')
.attr("x", (d) => xScale(d[x]) - 25/2)
.attr("y", -5)
const labels = element
.append("g")
.selectAll("text")
.data(data_filtered.filter((d) => d[points] === highlightValue))
.join("text")
.attr("font-family", "sans-serif")
.attr("font-size", 12)
.attr("font-weight", 'bold')
.attr("text-anchor", "middle")
.attr("fill", highlightColor.color)
.attr("x", (d) => xScale(d[x]))
.attr("y", (d) => yScale(d[y]) + yScale.bandwidth() / 2 + 20)
.text((d) => localized[language].format(',')(d[x]))
const labels2 = element
.append("g")
.selectAll("text")
.data(data_filtered.filter((d) => d[points] === highlightValue))
.join("text")
.attr("font-family", "sans-serif")
.attr("font-size", 12)
.attr("text-anchor", "start")
.attr("font-weight", 'bold')
.attr("fill", highlightColor.color)
.attr("opacity", 0.7)
.attr("x", (d) => xScale(d[x]) + 10)
.attr("y", (d) => yScale(d[y]) + yScale.bandwidth() / 2 - 20)
.text((d) => localized[language].format('.1%')(d[x] / area_total[d.bioma]) + " " + texts[language].label1)
}