diff options
-rw-r--r-- | python/fatcat_web/graphics.py | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/python/fatcat_web/graphics.py b/python/fatcat_web/graphics.py index 56852627..5493d175 100644 --- a/python/fatcat_web/graphics.py +++ b/python/fatcat_web/graphics.py @@ -9,13 +9,14 @@ def ia_coverage_histogram(rows): raw_years = [int(r[0]) for r in rows] years = dict() - for y in range(min(raw_years), max(raw_years)+1): - years[int(y)] = dict(year=int(y), available=0, missing=0) - for r in rows: - if r[1]: - years[int(r[0])]['available'] = r[2] - else: - years[int(r[0])]['missing'] = r[2] + if raw_years: + for y in range(min(raw_years), max(raw_years)+1): + years[int(y)] = dict(year=int(y), available=0, missing=0) + for r in rows: + if r[1]: + years[int(r[0])]['available'] = r[2] + else: + years[int(r[0])]['missing'] = r[2] years = sorted(years.values(), key=lambda x: x['year']) |