yearLabels.forEach((year, yearIndex) => {
let xPosition = (barDistance * yearIndex) + graphLeft,
localHeight = 0;
const categoryLen = categoryLabels.length;
categoryLabels.forEach((category, categoryIndex) => {
let categoryItem = yearData[year][categoryIndex],
crimeHeight = categoryItem * singleCrimeHeight;
localHeight += crimeHeight;
scrawl.makeBlock({
name: `${namespace}-${year}-${category}`,
group,
width: barWidth,
height: `${crimeHeight}%`,
startX: `${xPosition}%`,
startY: `${graphBottom - localHeight}%`,
fillStyle: colorArray[categoryIndex % categoryLen],
onEnter: function () {
selectedColumn = yearIndex;
selectedRow = categoryIndex;
updateSelected();
},
});
});
});
currentDatapoint = scrawl.makeBlock({
name: `${namespace}-dataframe`,
group,
mimic: `${namespace}-${selectedColumn}-${selectedRow}`,
useMimicDimensions: true,
useMimicStart: true,
useMimicHandle: true,
lockTo: 'mimic',
lineWidth: 6,
strokeStyle: 'yellow',
method: 'draw',
});