{
tbl.filter(a => (a.Month == 0)).length == 0 ? tbl.unshift({ "Month": 0, "Value": 0 }) : tbl
const monthCount = tbl.length - 1;
const glblDim = {
height: height,
width: w,
margin: {
top: 20,
right: 20,
bottom: 35,
left: 50
}
}
glblDim.boundedWidth = glblDim.width - glblDim.margin.left - glblDim.margin.right;
glblDim.boundedHeight = glblDim.height - glblDim.margin.top - glblDim.margin.bottom;
const svgns = 'http://www.w3.org/2000/svg'
let svg = d3.select('#here')
.append('svg')
.attr('xmlns', svgns)
.attr("viewBox", `0 0 ${w} ${height}`);
const bound = svg.append('g')
.attr('class', 'bound')
.style('transform', `translate(${glblDim.margin.left}px, ${glblDim.margin.top}px)`)
const rangeX = d3.scaleLinear().range([0, glblDim.boundedWidth]);
var scaleX = rangeX.domain(d3.extent(tbl, d => d.Month))
const rangeY = d3.scaleLinear().range([glblDim.boundedHeight, 0]);
var scaleY = rangeY.domain(d3.extent(tbl, d => d.Value))
const interpolatorSequentialMultiHueName = [ 'd3.interpolateTurbo', 'd3.interpolateViridis', 'd3.interpolateInferno' ]
const xColorScale = d3.scaleSequential()
.domain(d3.extent(tbl, d => d.Month))
.interpolator(eval(`${interpolatorSequentialMultiHueName[1]}`))
bound.append('g')
.call(d3.axisLeft(scaleY).tickSizeOuter(0))
.attr('class', 'YAxis')
.call(d => d.select('.domain')
.attr('class', 'yAxis'))
.call(d => d.selectAll('.tick')
.attr('class', (d, i) => { return `yAxisTick${i}` }))
.call(d => d.select('.yAxisTick0')
.attr('opacity', 0.5))
bound.append('g')
.call(d3.axisBottom(scaleX).tickSizeOuter(0) )
.attr('class', 'XAxis')
.style('transform', `translateY(${glblDim.boundedHeight}px)`)
.call(d => d.select('.domain')
.attr('class', 'xAxis'))
.call(d => d.selectAll('.tick')
.attr('class', (d, i) => { return `xAxisTick${i}` }))
.call(d => d.select('.xAxisTick0')
.attr('opacity', 0))
.call(a => a.selectAll("text")
.attr("fill", d => { return xColorScale(d) })
.style("font-size", '30px')
)
.call(a => a.append('g').attr('id','Rects')
.attr('class', 'bRect')
.selectAll('rect')
.data(d3.range(0,12))
.enter()
.append('rect')
.attr('x', '0')
.attr('y', '0')
.attr('height', `${glblDim.boundedHeight}`)
.attr('width', `${scaleX(1)}`)
.attr('class', (d, i) => { return `bgRect${i}` })
.style('fill', (d, i) => { return xColorScale(i + 1) })
.style('stroke', 'black')
.style('stroke-opacity', '0.1')
.attr('transform', (d, i) => {
const attributeX = d*scaleX(1)
const attributeY = glblDim.boundedHeight * -1;
return `translate(${attributeX} ${attributeY})`
})
)
.call(a => a.selectAll("text")
.attr("fill", (d, i) => { return xColorScale(i) })
.style("font-size", '30px')
)
}