 
         dc.dataCount(".dc-data-count").dimension(xfilter).group(all)
 
-        initDataTable("#dc-data-table", wards)
-        initMap("#wpLocations", wards)
+        loadDataTable("#dc-data-table", wards)
+        loadMap("#wpLocations", wards)
 
         dc.renderAll()
 

          chart.rescale())
        .yAxis().ticks(4)

    reloadTable = (datatable,dim) ->
      alldata = dim.top(Infinity)
      datatable.fnClearTable()
      datatable.fnAddData(alldata)
      datatable.fnDraw()

    initDataTable = (selector, dim) ->
      exists = $.fn.DataTable.fnIsDataTable($(selector))

      if exists
        datatable = $(selector).dataTable()
        reloadTable(datatable,dim)
      else
        cols = $scope.fields.map((x) ->
          if x.endsWith("_year")
            mData: x

          aaData: dim.top(Infinity),
          bDestroy: true,
          aoColumns: cols
      else
        datatable = $(selector).dataTable()

      reloadTable = () ->
        alldata = dim.top(Infinity)
        datatable.fnClearTable()
        datatable.fnAddData(alldata)
        datatable.fnDraw()

      dc.chartRegistry.list().forEach (chart) ->
        chart.on "filtered", () ->
          dc.events.trigger () ->
            reloadTable()

      if exists
        reloadTable()

    # controller level map object
    map = null

    loadMap = (container, dim) ->
      id = "regionalDashMap"

      if not $('#' + id).length
        e = $('<div id="' + id + '"></div>')
        $(container).append(e)

