chart = {
const svg = d3.create("svg")
.attr("viewBox", [0, 0, width, height]);
const splitBarCount = data[0];
const groups = svg.append("g")
.attr("fill", color)
.selectAll("g")
.data(data)
.join("g")
.attr("transform", (d, i) => "translate(0," + yAxis(d) + ")")
.attr('class', 'split-bar-group')
.each(function (d, idx) {
const bars = d3.select(this)
.selectAll('rect')
.data(d => d)
.join("rect")
.attr('class', 'split-bar-group-rect')
.attr("x", (d, i) => xAxis(i))
.attr("height", yAxis.bandwidth())
.attr("fill", (d, i) => colors[i])
.attr("width", (d,i) => nestedScales[i](d));
bars.append("text")
.text( function (d) { return d })
.attr("x", (d, i) => xAxis(i + 1) - 10)
.attr("font-family", "sans-serif")
.attr("font-size", "20px")
.attr("fill", "red");
})
.append("g")
.call(d3.axisLeft(yAxisLabels))
return svg.node();
}