Norric1Admin / maptemplates

Map templates
0 stars 1 forks source link

Change colour of Null values #7

Open Norric1Admin opened 5 years ago

Norric1Admin commented 5 years ago

See code below to change null values from the default (dark grey) to any colour of your choice. The example below makes them light grey / transparent (NOTE: is it worth using a different grey for areas outside the map to meet accessibility standards?).

Null values

maptemplates/indicators/###/js/script.js

Update line 140 from...

//and add properties to the geojson based on the csv file we've read in
areas.features.map(function(d, i) {

  d.properties.fill = color(rateById[d.properties.AREACD])
});

To...

//and add properties to the geojson based on the csv file we've read in
areas.features.map(function(d, i) {

    if(
        rateById[d.properties.AREACD] != null){
        d.properties.fill = color(rateById[d.properties.AREACD])
    } else {
        d.properties.fill = "#eee"
    }

  });

Update line 435 from...

function updateLayers() {

  //update properties to the geojson based on the csv file we've read in
  areas.features.map(function(d, i) {

    d.properties.fill = color(rateById[d.properties.AREACD])
  });

To...

function updateLayers() {

  //update properties to the geojson based on the csv file we've read in
  areas.features.map(function(d, i) {

    if(
        rateById[d.properties.AREACD] != null){
        d.properties.fill = color(rateById[d.properties.AREACD])
    } else {
        d.properties.fill = "#ccc"
        d.properties.opacity = "0.5"
    }

  });