{
const width = 500,
height = 700,
margin = {top: 5, bottom: 5, left: 5, right: 5}
const xScale = d3.scaleLinear()
.domain([0, 252.1067])
.range([0, width])
const xScale2 = d3.scaleLinear()
.domain([0, 201.44])
.range([0, width])
const xScale3 = d3.scaleLinear()
.domain([0, 298.8993])
.range([0, width])
const xScale4 = d3.scaleLinear()
.domain([0, 220.9467])
.range([0, width])
const xScale5 = d3.scaleLinear()
.domain([0, 222.64
])
.range([0, width])
const stack = d3.stack()
.keys(['a','b','c','d', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n'])
const series = stack([sampleConfusionMatrix]);
const series2 = stack([sampleConfusionMatrix2]);
const series3 = stack([sampleConfusionMatrix3]);
const series4 = stack([sampleConfusionMatrix4]);
const series5 = stack([sampleConfusionMatrix5]);
const svg = d3.select(DOM.svg(width + margin.left + margin.right, height + margin.top + margin.bottom))
var g = svg.selectAll(".rect")
.data(series)
.enter()
.append("g")
.classed('rect', true)
g.selectAll("rect")
.data(series)
.enter().append("rect")
.attr("width", d => { console.log(d[0][1] - d[0][0]); return xScale(d[0][1] - d[0][0]) })
.attr("height", 140)
.attr("x", (d, i) => xScale(d[0][0]))
.style("fill", d => d.key == 'a' || d.key == 'b' ? 'orange' : 'steelblue')
.style("stroke","#fff")
.style("stroke-width", 5)
g.append("rect")
.data(series2)
.attr("width", d => { console.log(d[0][1] - d[0][0]); return xScale2(d[0][1] - d[0][0]) })
.attr("height", 140)
.attr("y", 140)
.attr("x", (d, i) => xScale2(d[0][0]))
.style("fill", d => d.key == 'a' || d.key == 'b' ? 'red' : 'green')
.style("stroke","#fff")
.style("stroke-width", 5)
g.append("rect")
.data(series3)
.attr("width", d => { console.log(d[0][1] - d[0][0]); return xScale3(d[0][1] - d[0][0]) })
.attr("height", 140)
.attr("y", 280)
.attr("x", (d, i) => xScale3(d[0][0]))
.style("fill", d => d.key == 'a' || d.key == 'b' ? 'purple' : 'black')
.style("stroke","#fff")
.style("stroke-width", 5)
g.append("rect")
.data(series4)
.attr("width", d => { console.log(d[0][1] - d[0][0]); return xScale4(d[0][1] - d[0][0]) })
.attr("height", 140)
.attr("y", 420)
.attr("x", (d, i) => xScale4(d[0][0]))
.style("fill", d => d.key == 'a' || d.key == 'b' ? 'red' : 'green')
.style("stroke","#fff")
.style("stroke-width", 5)
g.append("rect")
.data(series5)
.attr("width", d => { console.log(d[0][1] - d[0][0]); return xScale5(d[0][1] - d[0][0]) })
.attr("height", 140)
.attr("y", 560)
.attr("x", (d, i) => xScale5(d[0][0]))
.style("fill", d => d.key == 'a' || d.key == 'b' ? 'green' : 'blue')
.style("stroke","#fff")
.style("stroke-width", 5)
return svg.node()
}