/*Loading data from CSV file and editing the properties to province codes. Unary operator plus is used to save the data as numbers (originally imported as string)*/
varrowHeight=thisCanvasHeight/14//we have 14 regions
//initialize starting position for the rows
varyPosition=0
//iterate over different regions - i.e., columns of the data; skip date column and whole Czech Republic
for (varkeyindata[0]){
if (key!='date'&&key!='Czech_Republic'){
//append region label
heatMap.append("text")
.attr("x",labelWidth)
.attr("y",yPosition+rowHeight)
.attr("class","subline")
.attr("text-anchor","end")//text alignment anchor - end means that the 'x' postion attribute will specify the position of the text end (value can be start/middle/end)
.style('fill','white')
.style("font-size",rowHeight)
.text(key.replace(/_/g,""))//specify the text, the replace fuction with regex expression '/_/g' is used to find all underscores in the string and replace them with space character
//iterate over the values for the region
for (letindex=0;index<data.length;index++){
//skip zero values (missing data for Prague)
if (data[index][key]!=0){
//append rectagle representing the value to heatmap
heatMap.append('rect')
.attr("x",labelWidth+index*barWidth)
.attr("y",yPosition)
.attr("width",barWidth)
.attr("height",rowHeight)
.attr("fill",myColorScale(data[index][key]))
}
}
//after each region, increase yPosition of the heatmap row