Ava peamenüü
Keskmine palk piirkonniti
Keskmine palk piirkonniti


<graph mode=interactive title="Keskmine palk piirkonniti">
{
  "version": 2,
  "width": 800,
  "height": 420,
  "padding": 12,
  "background": "#edf1f7",
  "signals": [
    {
      "name": "isDragging",
      "init": false,
      "streams": [
        {"type": "@handle:mousedown","expr": "true"},
        {"type": "mouseup","expr": "false"}
      ]
    },
    {
      "name": "scaledHandlePosition",
      "streams": [
        {
          "type": "mousemove[isDragging]",
          "expr": "eventX()",
          "scale": {"name": "yearsScale","invert": true}
        }
      ]
    },
    {
      "name": "currentYear",
      "init": "2017",
      "expr": "scaledHandlePosition"
    },
    {
      "name": "tooltipSignal",
      "init": {"expr": "{x: 0, y: 0, datum: {} }"}, 
      "streams": [
        {  
          "type": "@map:mouseover",    
          "expr": "{x: eventX(), y: eventY(), datum: eventItem().datum.zipped}"
        },
        {  
          "type": "@map:mouseout",
          "expr": "{x: 0, y: 0, datum: {} }"
        }
      ] 
    }
  ],
  "data": [
    {
      "name": "highlights",
      "url": "wikiraw:///Vikipeedia:Andmed/LV-average wages-2009-2017.csv",
      "format": {"type": "csv"},
      "transform": [
        {
          "type": "formula",
          "field": "v",
          "expr": "parseFloat(datum[''+currentYear])"
        }
      ]
    },
    {
      "name": "countries",
      "url": "wikiraw:///Vikipeedia:Andmed/LV-adm1-2017.json",
      "format": {"type": "topojson","feature": "collection"},
      "transform": [
        {
          "type": "geopath",
          "value": "data",
          "scale": 5800,
          "center": [20.5, 59.5],
          "translate": [0,0],
          "projection": "equirectangular"
        },
        {
          "type": "lookup",
          "keys": ["properties['LAU2_code']"],
          "on": "highlights",
          "onKey": "LAU2_code",
          "as": ["zipped"],
          "default": {"v": null, "name":"No data"}
        }
      ]
    }
  ],
  "scales": [
    {
      "name": "yearsScale",
      "type": "ordinal",
      "domain": ['2009','2010','2011','2012','2013','2014','2015','2016','2017'],
      "range": "width",
      "points": false,
    },
    {
      "name": "color",
      "type": "linear",
      "domain": {"data": "countries","field": "zipped.v"},
      "domainMin": 0,
      "zero": false,
      "range":  ["#A8EB12", "#051937"]
    }
  ],
  "marks": [
    {
      "name": "yearLabel",
      "type": "text",
      "properties": {
        "enter": {
          "x": {"value": 0},
          "y": {"value": 25},
          "fontSize": {"value": 32},
          "fontWeight": {"value": "bold"},
          "fill": {"value": "steelblue"}
        },
        "update": {"text": {"signal": "currentYear"} }
      }
    },
    {
      "name": "scrollLine",
      "type": "rule",
      "properties": {
        "enter": {
          "x": {"value": 0},
          "y": {"value": 40},
          "x2": {"value": 800},
          "stroke": {"value": "#000"},
          "strokeWidth": {"value": 2}
        }
      }
    },
    {
      "name": "handle",
      "type": "path",
      "properties": {
        "enter": {
          "y": {"value": 40},
          "path": {"value": "m-5.5,-10l0,20l11.5,-10l-11.5,-10z"},
          "stroke": {"value": "#880"},
          "strokeWidth": {"value": 2.5}
        },
        "update": {
          "x": {"scale": "yearsScale","signal": "currentYear"},
          "fill": {"value": "#fff"}
        },
        "hover": {"fill": {"value": "#f00"} }
      }
    },
    {
      "name": "map",
      "type": "path",
      "from": {"data": "countries"},
      "properties": {
        "enter": {"path": {"field": "layout_path"} },
        "update": {
          "fill": [
            {
              "test": "datum.zipped.v !== null",
              "scale": "color",
              "field": "zipped.v"
            },
            {"value": "grey"}
          ]
        },
        "hover": {"fill": {"value": "#989898"} }
      }
    },
    {
      "type": "text",
      "properties": {
        "enter": {
          "x": {"value": 800},
          "y": {"value": 10},
          "align": {"value": "right"},
          "fontSize": {"value": 17},
          "fill": {"value": "black"}
        },
        "update": {
          "text": {"template": "\u007b{tooltipSignal.datum.name}\u007d \u007b{tooltipSignal.datum.v}\u007d"}
        }
      }
    }
  ],
  "legends": [
    {
      "fill": "color",
      "title": "Keskmine palk",
      "offset": -300,
      "properties": {
        "gradient": {
          "stroke": {"value": "transparent"}
        },
        "title": {
          "fontSize": {"value": 14}
        },
        "legend": {
          "x": {"value": 0},
          "y": {"value": 360}
        }
      }
    }
  ]
}
</graph>