# The World Deaths Rate in 2019

##### Concept

My initial idea was to see how COVID-19 had influenced the death rate of the whole world, however, I was not sure if this was an ethical thing to do. Therefore, I decided to visually represent what was the number of deaths in 2019 based on other illnesses. I found a great website that has public data and data visualizations available online. I thought it would be interesting to visualize the data available using circles. This way is more spontaneous and hence easier to understand. Each circle represented the cause of death. The bigger the circle the more deaths there were in 2019.

##### Approach and Code Highlights

To create this code, I was using a for loop in a setup function. I took a single row and split it into individual values that were separated by a comma.  I then assigned variables for each cause of death in a single row and I used ‘int’ to convert the value into an integer. I then calculated the sum of the deaths for every disease in a single row. And because all of this is in the for loop, this happened to every row in my data file, so I got the total number of deaths for every country in the world. After, I scaled the size of the circle according to the data. Specifically, in the data file the range of min and max values was from 0 to 500000, which would correspond to 1 to 10 size on the canvas, respectively. I placed the circle in the random x & y positions and I used the range of min and max for the radius.

After I was able to draw circles according to a country I needed to find a way to visually distinguish them. I am really proud that I was able to understand how to do it.

// Use unchar function to convert a
// single-character string to its corresponding
// integer representation
// We also use split because we have 3 letters in a
// country code and we need to extract only
// the first letter

let countryCode = unchar(split(singleRow[1], "")[0]);
print(countryCode);

// We know that the country code as represented by
// a number is going to be between 65 and 90 that
// corresponds to letters from A to Z
// We assign red values to the letters

let redValue = map(countryCode, 65, 90, 0, 255);

// Coloring the circle in a range for red value
// and fixed green,blue and alpha values

noStroke();
fill(redValue, 100, 100, 155);

I decided to use different colors to assign the colors according to some variables in the data file. In the data file, I had a country code represented as 3 letters. For instance, Kazakhstan is KAZ and Argentina is ARG. So, with the help of an unchar function, I used this country code and converted a single-character string to its corresponding integer representation. Specifically, for ease of things, I decided to split the 3 letter code into 3 values and use only the first one. To represent letters in a code I used the ASCII printable characters, where ‘A’ is 65 and ‘Z’ is 90. You can find the whole list of ASCII printable characters here. Then, I used a map function to re-map numbers from the ASCII range (65 to 90) to the color range (0 to 255). The last thing I did was to fill all the circles. I played with different Green, Blue, and Alpha values until I got visually appealing circles.

##### Future Thoughts and Reflections

I had several problems with the code, which did not allow me to see the circles. Firstly, I had some places where I forgot to put a curly brace or I put an extra one. This did not allow me to run the program and I understood how careful I should be in looking through a code. It is very helpful to write what is a curly brace for when closing it. Second, I had multiple times where I had to print the values and look if they were definer or undefined. This helped with debugging a lot. Moreover, the biggest problem was with assigning the const numbers for the radius of the circle. If the range is too big, for example from 1 to 100, what happens is that the program prints only 3 circles and the rest are not visible, probably because the smallest circles are just 1 pixel. Therefore, I had to change the range to be from 1 to 10, so that all the circles were visible. This assignment helped me to understand how to debug a problem step by step and it also taught me that the best way to do it sometimes is a trial and error method.