-
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
37bacfa
commit 1ffa03b
Showing
138 changed files
with
447,991 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,226 @@ | ||
{ | ||
"$schema": "https://vega.github.io/schema/vega/v4.json", | ||
"width": 900, | ||
"height": 560, | ||
"padding": {"top": 25, "left": 0, "right": 0, "bottom": 0}, | ||
"autosize": "none", | ||
|
||
"signals": [ | ||
{ | ||
"name": "scale", "value": 1200, | ||
"bind": {"input": "range", "min": 500, "max": 3000} | ||
}, | ||
{ | ||
"name": "translateX", "value": 450, | ||
"bind": {"input": "range", "min": -500, "max": 1200} | ||
}, | ||
{ | ||
"name": "translateY", "value": 260, | ||
"bind": {"input": "range", "min": -300, "max": 700} | ||
}, | ||
{ | ||
"name": "shape", "value": "line", | ||
"bind": {"input": "radio", "options": ["line", "curve"]} | ||
}, | ||
{ | ||
"name": "hover", | ||
"value": null, | ||
"on": [ | ||
{"events": "@cell:mouseover", "update": "datum"}, | ||
{"events": "@cell:mouseout", "update": "null"} | ||
] | ||
}, | ||
{ | ||
"name": "title", | ||
"value": "U.S. Airports, 2008", | ||
"update": "hover ? hover.name + ' (' + hover.iata + ')' : 'U.S. Airports, 2008'" | ||
}, | ||
{ | ||
"name": "cell_stroke", | ||
"value": null, | ||
"on": [ | ||
{"events": "dblclick", "update": "cell_stroke ? null : 'brown'"}, | ||
{"events": "mousedown!", "update": "cell_stroke"} | ||
] | ||
} | ||
], | ||
|
||
"data": [ | ||
{ | ||
"name": "states", | ||
"url": "data/us-10m.json", | ||
"format": {"type": "topojson", "feature": "states"}, | ||
"transform": [ | ||
{ | ||
"type": "geopath", | ||
"projection": "projection" | ||
} | ||
] | ||
}, | ||
{ | ||
"name": "traffic", | ||
"url": "data/flights-airport.csv", | ||
"format": {"type": "csv", "parse": "auto"}, | ||
"transform": [ | ||
{ | ||
"type": "aggregate", | ||
"groupby": ["origin"], | ||
"fields": ["count"], "ops": ["sum"], "as": ["flights"] | ||
} | ||
] | ||
}, | ||
{ | ||
"name": "airports", | ||
"url": "data/airports.csv", | ||
"format": {"type": "csv","parse": "auto" | ||
}, | ||
"transform": [ | ||
{ | ||
"type": "lookup", | ||
"from": "traffic", "key": "origin", | ||
"fields": ["iata"], "as": ["traffic"] | ||
}, | ||
{ | ||
"type": "filter", | ||
"expr": "datum.traffic != null" | ||
}, | ||
{ | ||
"type": "geopoint", | ||
"projection": "projection", | ||
"fields": ["longitude", "latitude"] | ||
}, | ||
{ | ||
"type": "filter", | ||
"expr": "datum.x != null && datum.y != null" | ||
}, | ||
{ | ||
"type": "voronoi", "x": "x", "y": "y" | ||
}, | ||
{ | ||
"type": "collect", "sort": { | ||
"field": "traffic.flights", | ||
"order": "descending" | ||
} | ||
} | ||
] | ||
}, | ||
{ | ||
"name": "routes", | ||
"url": "data/flights-airport.csv", | ||
"format": {"type": "csv", "parse": "auto"}, | ||
"transform": [ | ||
{ | ||
"type": "filter", | ||
"expr": "hover && hover.iata == datum.origin" | ||
}, | ||
{ | ||
"type": "lookup", | ||
"from": "airports", "key": "iata", | ||
"fields": ["origin", "destination"], "as": ["source", "target"] | ||
}, | ||
{ | ||
"type": "filter", | ||
"expr": "datum.source && datum.target" | ||
}, | ||
{ | ||
"type": "linkpath", | ||
"shape": {"signal": "shape"} | ||
} | ||
] | ||
} | ||
], | ||
|
||
"projections": [ | ||
{ | ||
"name": "projection", | ||
"type": "albersUsa", | ||
"scale": {"signal": "scale"}, | ||
"translate": [{"signal": "translateX"}, {"signal": "translateY"}] | ||
} | ||
], | ||
|
||
"scales": [ | ||
{ | ||
"name": "size", | ||
"type": "linear", | ||
"domain": {"data": "traffic", "field": "flights"}, | ||
"range": [16, 1000] | ||
} | ||
], | ||
|
||
"marks": [ | ||
{ | ||
"type": "path", | ||
"from": {"data": "states"}, | ||
"encode": { | ||
"enter": { | ||
"fill": {"value": "#dedede"}, | ||
"stroke": {"value": "white"} | ||
}, | ||
"update": { | ||
"path": {"field": "path"} | ||
} | ||
} | ||
}, | ||
{ | ||
"type": "symbol", | ||
"from": {"data": "airports"}, | ||
"encode": { | ||
"enter": { | ||
"size": {"scale": "size", "field": "traffic.flights"}, | ||
"fill": {"value": "steelblue"}, | ||
"fillOpacity": {"value": 0.8}, | ||
"stroke": {"value": "white"}, | ||
"strokeWidth": {"value": 1.5} | ||
}, | ||
"update": { | ||
"x": {"field": "x"}, | ||
"y": {"field": "y"} | ||
} | ||
} | ||
}, | ||
{ | ||
"type": "path", | ||
"name": "cell", | ||
"from": {"data": "airports"}, | ||
"encode": { | ||
"enter": { | ||
"fill": {"value": "transparent"}, | ||
"strokeWidth": {"value": 0.35} | ||
}, | ||
"update": { | ||
"path": {"field": "path"}, | ||
"stroke": {"signal": "cell_stroke"} | ||
} | ||
} | ||
}, | ||
{ | ||
"type": "path", | ||
"interactive": false, | ||
"from": {"data": "routes"}, | ||
"encode": { | ||
"enter": { | ||
"path": {"field": "path"}, | ||
"stroke": {"value": "black"}, | ||
"strokeOpacity": {"value": 0.35} | ||
} | ||
} | ||
}, | ||
{ | ||
"type": "text", | ||
"interactive": false, | ||
"encode": { | ||
"enter": { | ||
"x": {"value": 895}, | ||
"y": {"value": 0}, | ||
"fill": {"value": "black"}, | ||
"fontSize": {"value": 20}, | ||
"align": {"value": "right"} | ||
}, | ||
"update": { | ||
"text": {"signal": "title"} | ||
} | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
{ | ||
"$schema": "https://vega.github.io/schema/vega/v4.json", | ||
"width": 800, | ||
"padding": 5, | ||
|
||
"config": { | ||
"title": {"fontSize": 14} | ||
}, | ||
|
||
"title": { | ||
"text": "Seattle Annual Temperatures", | ||
"anchor": "start", "offset": 4 | ||
}, | ||
|
||
"signals": [ | ||
{"name": "rangeStep", "value": 25}, | ||
{"name": "height", "update": "rangeStep * 24"} | ||
], | ||
|
||
"data": [ | ||
{ | ||
"name": "temperature", | ||
"url": "data/seattle-temps.csv", | ||
"format": {"type": "csv", "parse": {"temp": "number", "date": "date"}}, | ||
"transform": [ | ||
{"type": "formula", "as": "hour", "expr": "hours(datum.date)"}, | ||
{ "type": "formula", "as": "date", | ||
"expr": "datetime(year(datum.date), month(datum.date), date(datum.date))"} | ||
] | ||
} | ||
], | ||
|
||
"scales": [ | ||
{ | ||
"name": "row", | ||
"type": "band", | ||
"domain": [ | ||
6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, | ||
0, 1, 2, 3, 4, 5 | ||
], | ||
"range": {"step": {"signal": "rangeStep"}} | ||
}, | ||
{ | ||
"name": "x", | ||
"type": "time", | ||
"domain": {"data": "temperature", "field": "date"}, | ||
"range": "width" | ||
}, | ||
{ | ||
"name": "y", | ||
"type": "linear", "zero": false, | ||
"domain": {"data": "temperature", "field": "temp"}, | ||
"range": [{"signal": "rangeStep"}, 1] | ||
} | ||
], | ||
|
||
"axes": [ | ||
{"orient": "bottom", "scale": "x", "domain": false, "title": "Month", "format": "%b"}, | ||
{ | ||
"orient": "left", "scale": "row", "domain": false, "title": "Hour", | ||
"tickSize": 0, | ||
"encode": { | ||
"labels": { | ||
"update": { | ||
"text": {"signal": "datum.value === 0 ? 'Midnight' : datum.value === 12 ? 'Noon' : datum.value < 12 ? datum.value + ':00 am' : (datum.value - 12) + ':00 pm'"} | ||
} | ||
} | ||
} | ||
} | ||
], | ||
|
||
"marks": [ | ||
{ | ||
"type": "group", | ||
"from": { | ||
"facet": { | ||
"name": "hour", | ||
"data": "temperature", | ||
"groupby": "hour" | ||
} | ||
}, | ||
"encode": { | ||
"enter": { | ||
"x": {"value": 0}, | ||
"y": {"scale": "row", "field": "hour"}, | ||
"width": {"signal": "width"}, | ||
"height": {"signal": "rangeStep"} | ||
} | ||
}, | ||
"marks": [ | ||
{ | ||
"type": "area", | ||
"from": {"data": "hour"}, | ||
"encode": { | ||
"enter": { | ||
"x": {"scale": "x", "field": "date"}, | ||
"y": {"scale": "y", "field": "temp"}, | ||
"y2": {"signal": "rangeStep"} | ||
} | ||
} | ||
} | ||
] | ||
} | ||
] | ||
} |
Oops, something went wrong.