             # only keep the renderlet once
             dc.renderlet null
 
-          setupCharts $scope.region
+          # ensure we have the population data
+          populationData.then (data) ->
+            popData = data
+            setupCharts $scope.region
 
     # what value to use for year 0
     YEAR_ZERO=1950

      statusPerManagement: { sizeX: 6, sizeY: 4, row: 21, col: 0, title: "Functionality by Management" }
      statusPerExtraction: { sizeX: 6, sizeY: 4, row: 21, col: 6, title: "Functionality by Extraction" }

    modalSpinner = null
    $scope.openSpinner = () ->
      modalSpinner = $modal.open

        res

      reduceCostStatus = (group) ->
        isFunc = (x) -> x.status_group == "functional"
        res = group.reduce(\
          ((p, v) ->
            ++p.count
            p.total += v.amount_tsh
            p.pop_served_fun += if isFunc(v) then v.population else 0
            p.numFun += if isFunc(v) then 1 else 0
            p.avgCost = p.total / p.count
            p.percFun = p.numFun / p.count * 100
            p),
          ((p, v) ->
            --p.count
            p.total -= v.amount_tsh
            p.pop_served_fun -= if isFunc(v) then v.population else 0
            p.numFun -= if isFunc(v) then 1 else 0
            p.avgCost = (p.count) ? p.total / p.count * 1 : 0
            p.percFun = (p.count) ? p.numFun / p.count * 100 : 0
            p),
          (() ->
            count: 0, total: 0, pop_served_fun: 0, pop: 0, popReach: 0, percFun: 0, numFun: 0, avgCost: 0))

        res.all().forEach((d) ->
          # Lookup the population of the ward
          pop = popData.lookup(null,null,d.key)
          if pop > 0
            d.value.pop = pop
            d.value.popReach = d.value.pop_served_fun / d.value.pop * 100)

        res

      reduceAvg = (group, fieldAcc) ->
