chartMatrix = {
const svg = d3.create('svg').attr("viewBox", [0, 0, layout.width, layout.height]);
const g = svg.append('g').attr('id', 'global-group')
.attr('transform', `translate(${layout.margin.left},${layout.margin.top})`);
const colorSourceGroups= g.selectAll('.color-by-source-group')
.data(colorArray_Scale_bySource_bySerise)
.join('g')
.attr('class','color-by-source-group')
.attr('transform', (d,i)=>{
let verticalNum = 0
for (let index = 0; index < i; ++index) {
verticalNum += Math.ceil(lengthMirrorArray[index]/horizontalNumber)
}
let height = verticalNum * (frameHeight + groupGutter) + verticalNum * innerGutter
return `translate(0,${height})`
})
const colorSeriseGroups = colorSourceGroups.selectAll('.color-by-serise-group')
.data(d=>d[1])
.join('g')
.attr('class','color-by-serise-group')
.attr('transform', (d,i)=>{
let x = Math.ceil(i%horizontalNumber)*(layout.frameWidth+innerGutter),
y = Math.floor(i/horizontalNumber)*(frameHeight+innerGutter)
return `translate(${x},${y})`
})
.call(g=>{
g.append('rect')
.attr('class', 'frame')
.attr('fill', 'none')
.attr('stroke', 'rgba(0,0,0,.5)')
.attr('width',layout.frameWidth)
.attr('height',frameHeight)
})
const colorDots = colorSeriseGroups
.append('g')
.selectAll('circle')
.data(d=>d[1])
.join('circle')
.attr("r", r)
.attr("fill", d => d['Hex'])
.attr('cx', d =>scaleX(chroma_okhcl(d['Hex'])[xFeild]))
.attr('cy', d =>scaleY(chroma_okhcl(d['Hex'])[yFeild]))
// // .selectAll('circle')
// // .join('circle')
// // .attr("r", r)
// // .attr("fill", d => d['Hex'])
// // .attr('cx', d =>{
// // console.log(d)
// // // return scaleChromaX(chroma_okhcl(d['Hex'])['chroma']
// // })
// // .attr('cy', d =>scaleLightnessY(chroma_okhcl(d['Hex'])['lightness']))
// })
colorSeriseGroups.append('g')
.attr('transform',`translate(0,${frameHeight})`)
.attr('class', 'x-axis')
.call(xAxis)
.call(g=>{
g.select('.domain')
.remove()
})
.call(g=>{
g.selectAll('.tick line')
.clone()
.attr('y2', -frameHeight)
.attr('opacity', .1)
})
colorSeriseGroups.append('g')
.attr('class', 'y-axis')
.call(yAxis)
.call(g=>{
g.select('.domain')
.remove()
})
.call(g=>{
g.selectAll('.tick line')
.clone()
.attr('x2', layout.frameWidth)
.attr('opacity', .1)
})
colorSourceGroups.append('g')
.append('text')
.text(d=>d[0])
.style("font", "12px sans-serif")
.style("font-weight", '500')
.style("text-anchor","middle")
.attr('transform',(d,i)=>{
let verticalNum = Math.ceil(d[1].length/horizontalNumber),
height = verticalNum * (frameHeight + innerGutter) - innerGutter
return `translate(-50,${height/2}) rotate(-90)`
})
g.append('g')
.append('text')
.text(`↑${yFeild.charAt(0).toUpperCase() + yFeild.slice(1)}`)
.style("font", "12px sans-serif")
.style("font-weight", '500')
.attr('transform', 'translate(-8, -20)')
g.append('g')
.append('text')
.text(`${xFeild.charAt(0).toUpperCase() + xFeild.slice(1)} →`)
.style("font", "12px sans-serif")
.style("font-weight", '500')
.attr('transform', `translate(-8, ${frameHeight + 40})`)
return svg.node()
}