I'm having trouble getting the maximum and the minimum values out of my dataset. I think this (// Get the largest value from Json object with Javascript combined with Math.min.apply returns 0 for null) comes closest to what I need, however my data is a bit more complicated (at least from my 'beginners point of view').
my dataset concerns life expectancy for all countries from 1995 till 2016 and looks like this:
[{"country":"Abkhazia","1995":null,"1996":null,"1997":null,"1998":null,"1999":null,"2000":null,"2001":null,"2002":null,"2003":null,"2004":null,"2005":null,"2006":null,"2007":null,"2008":null,"2009":null,"2010":null}, {"country":"Afghanistan","1995":null,"1996":null,"1997":null,"1998":null,"1999":null,"2000":null,"2001":null,"2002":5.7,"2003":6.8,"2004":6.4,"2005":6.6,"2006":6.8,"2007":7.3,"2008":7.0,"2009":7.6,"2010":7.6}, {"country":"Akrotiri and Dhekelia","1995":null,"1996":null,"1997":null,"1998":null,"1999":null,"2000":null,"2001":null,"2002":null,"2003":null,"2004":null,"2005":null,"2006":null,"2007":null,"2008":null,"2009":null,"2010":null}, {"country":"Albania","1995":2.6,"1996":4.0,"1997":4.8,"1998":5.3,"1999":5.8,"2000":6.4,"2001":6.0,"2002":6.3,"2003":6.2,"2004":6.9,"2005":6.8,"2006":6.7,"2007":6.9,"2008":6.7,"2009":6.9,"2010":6.5}, etc. What I need:
The maximum value and the minimum value for the complete dataset.
For the example this would be:
min: 2.6 max: 7.6 I'm making a datamap using D3 and I want to use the values to create a range of colors.
Code I tried
As said in the introduction I think I need a combination of the two links given above, however I cannot make it work. For example, using the second link I van get the minimum value for a given country, but not the minimum of all countries.
Hope someone can help me!