mattijn
1/5/2020 - 10:18 PM

map 2 print 4 bday

map 2 print 4 bday

{
  "$schema": "https://vega.github.io/schema/vega/v5.json",
  "width": 600,
  "height": 300,
  "autosize": "fit-x",

  "signals": [
    {
      "name": "projection", "value": "equalEarth"
    },
    {
      "name": "scale", "value": 110
    },
    {
      "name": "rotate0", "value": 0
    },
    {
      "name": "rotate1", "value": 0
    },
    {
      "name": "rotate2", "value": 0
    },
    {
      "name": "opacity", "value": 0.5
    },
    {
      "name": "levels", "value": 5
    },
    {
      "name": "stop", "value": 3000
    },
    {
      "name": "step",
      "update": "stop / levels"
    }
  ],

  "data": [
    {
      "name": "precipitation",
      "url": "data/annual-precip.json"
    },
    {
      "name": "contours",
      "source": "precipitation",
      "transform": [
        {
          "type": "isocontour",
          "thresholds": {"signal": "sequence(step, stop, step)"},
          "smooth":false
        }
      ]
    },
    {
      "name": "world",
      "url": "data/world-110m.json",
      "format": {"type": "topojson", "feature": "countries"}
    },
    {
      "name": "graticule",
      "transform": [
        { "type": "graticule" }
      ]
    },
    {
      "name": "sphere",
      "values": [{"type": "Sphere"}]
    }    
  ],

  "projections": [
    {
      "name": "projection",
      "type": {"signal": "projection"},
      "scale": {"signal": "scale"},
      "rotate": {"signal": "[rotate0, rotate1, rotate2]"},
      "translate": {"signal": "[width/2, height/2]"}
    }
  ],

  "scales": [
    {
      "name": "color",
      "type": "quantize",
      "domain": {"signal": "[0, stop]"},
      "range": ["#A3CC89", "#6CC4EB", "#43569B", "#864A92"]
      
    }
  ],

  "marks": [  
    {
      "type": "shape",
      "clip": true,
      "from": {"data": "world"},
      "encode": {
        "update": {
          "fill": {"value": "#AD8C6A"},
          "fillOpacity": {"value": 0.6}
        }
      },
      "transform": [
        {
          "type": "geoshape",
          "projection": "projection"
        }
      ]
    },
    {
      "type": "shape",
      "clip": true,
      "from": { "data": "contours"},
      "encode": {
        "update": {
          "fill": {"scale": "color", "field": "contour.value"},
          "fillOpacity": {"value": 1}
        }
      },
      "transform": [
        {
          "type": "geoshape",
          "field": "datum.contour",
          "projection": "projection"
        }
      ]
    },
    {
      "type": "shape",
      "clip": true,
      "from": {"data": "world"},
      "encode": {
        "update": {
          "strokeWidth": {"value": 0.1},
          "stroke": {"value": "blue"}
        }
      },
      "transform": [
        {
          "type": "geoshape",
          "projection": "projection"
        }
      ]
    },
    {
      "type": "shape",
      "from": {"data": "sphere"},
      "encode": {
        "enter": {
          "strokeWidth": {"value": 1},
          "stroke": {"value": "red"}
        }
      },
      "transform": [
        { "type": "geoshape", "projection": "projection" }
      ]
    }         
  ],

  "legends": [
    {
      "title": "Annual Precipitation (mm)",
      "fill": "color",
      "gradientOpacity": 1,
      "orient": "bottom",
      "offset": 5,
      "type": "gradient",
      "gradientLength": 300,
      "gradientThickness": 12,
      "titlePadding": 10,
      "titleOrient": "left",
      "titleAnchor": "end",
      "direction": "horizontal"
    }
  ],

  "config": {
    "legend": {"layout": {"anchor": "middle"}}
  }
}