If data has been available for every month over the past 3 years, I need it to be displayed in a specific format. You can refer to this example fiddle for reference: https://jsfiddle.net/bthorn/ncqn0jwy/
However, there are times when certain months may not have any data, and in such cases, those months should not be shown in the final output.
In an attempt to manipulate the data, I created another fiddle where I tried looping through the data. Here's the link to that fiddle: https://jsfiddle.net/bthorn/2zkhk3dt/1/
The initial step was to loop over the years to extract distinct year values:
for (var y in data) {
if (typeof(uniqueYears[data[y].year]) === "undefined") {
distinctYears.push(data[y].year);
year = data[y].year;
if (year === "" || year === null) {
year = "";
}
strResult += "<th style='text-align:left;'><h2>" + year + "</h2></th>";
//console.log(year);
uniqueYears[data[y].year] = 0;
}
}
Subsequently, I attempted to loop over the months while considering the year value. However, this approach did not yield the desired output which necessitated further exploration of how to integrate my data into the year/month fiddle.
I even tried implementing a function to iterate through all data outputs corresponding to the year/month combination but only ended up with August 2015 being displayed consistently despite extensive debugging efforts.
Update
The first fiddle is meant to display data for 4 months in 2015 from a folder, leaving the rest as blank placeholders.
https://i.sstatic.net/qxVpg.png
Update 2:
A visual representation of the result obtained from combining the data with the year/month loops reveals inconsistencies within the output.
https://i.sstatic.net/KwoB3.png
Update 3
In the third fiddle, a function was created to cross-check and validate the data against the expected year/month combinations. However, the returned result only matches August 2015.