Карта мира: различия между версиями
Перейти к навигации
Перейти к поиску
(не показано 15 промежуточных версий этого же участника) | |||
Строка 1: | Строка 1: | ||
+ | <graph> |
||
+ | |||
+ | "version": 2, |
||
+ | "width": 1, |
||
+ | "height": 1, |
||
+ | "data": [ |
||
+ | "values": [ |
||
+ | {"a": "C", "b": 2}, {"a": "C", "b": 7}, {"a": "C", "b": 4}, |
||
+ | {"a": "D", "b": 1}, {"a": "D", "b": 2}, {"a": "D", "b": 6}, |
||
+ | {"a": "E", "b": 8}, {"a": "E", "b": 4}, {"a": "E", "b": 7} |
||
+ | ] |
||
+ | }, |
||
+ | "mark": "point", |
||
+ | "encoding": { |
||
+ | "x": {"field": "a", "type": "nominal"}, |
||
+ | "y": {"field": "b", "type": "quantitative"} |
||
+ | ] |
||
+ | </graph> |
||
<graph> |
<graph> |
||
{ |
{ |
||
+ | "version": 2, |
||
− | "$schema": "https://vega.github.io/schema/vega/v5.json", |
||
+ | "width": 1, |
||
− | "description": "Interactive map of U.S. airport connections in 2008.", |
||
− | " |
+ | "height": 1, |
− | " |
+ | "data": [ |
− | "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": [ |
||
{ |
{ |
||
− | " |
+ | "name": "highlights", |
+ | "values": [{"id":"US","v":"blue"},{"id":"AU","v":"purple"},{"id":"CN","v":"red"},{"id":"BR","v":"pink"},{"id":"DZ","v":"green"}] |
||
− | "from": "traffic", "key": "origin", |
||
− | "fields": ["iata"], "as": ["traffic"] |
||
}, |
}, |
||
{ |
{ |
||
− | " |
+ | "name": "countries", |
+ | "url": "wikiraw:///Extension:Graph/Demo/RawData:WorldMap-iso2-json", |
||
− | "expr": "datum.traffic != null" |
||
+ | "format": {"type": "topojson", "feature": "countries"}, |
||
− | }, |
||
− | + | "transform": [ |
|
− | + | { |
|
− | " |
+ | "type": "geopath", |
− | " |
+ | "value": "data", |
− | + | "scale": 80, |
|
− | + | "translate":[0,0], |
|
− | " |
+ | "projection": "equirectangular" |
− | + | }, |
|
− | + | { |
|
− | + | "type": "lookup", |
|
− | + | "keys": [ "id" ], |
|
− | + | "on": "highlights", |
|
− | + | "onKey": "id", |
|
− | " |
+ | "as": [ "zipped" ], |
− | " |
+ | "default": { |
− | " |
+ | "v": "#C0C0C0" |
− | } |
+ | } |
+ | } |
||
+ | ] |
||
} |
} |
||
− | + | ], |
|
− | + | "marks": [ |
|
− | { |
||
− | "name": "routes", |
||
− | "url": "data/flights-airport.csv", |
||
− | "format": {"type": "csv", "parse": "auto"}, |
||
− | "transform": [ |
||
{ |
{ |
||
− | "type": " |
+ | "type": "path", |
− | " |
+ | "from": { |
− | + | "data": "countries" |
|
− | + | }, |
|
− | " |
+ | "properties": { |
− | + | "enter": { |
|
− | + | "path": { |
|
+ | "field": "layout_path" |
||
− | }, |
||
− | + | } |
|
− | + | }, |
|
− | + | "update": { |
|
− | + | "fill": { |
|
+ | "field": "zipped.v" |
||
− | { |
||
− | + | } |
|
− | + | }, |
|
+ | "hover": { |
||
+ | "fill": { |
||
+ | "value": "#989898" |
||
+ | } |
||
+ | } |
||
+ | } |
||
} |
} |
||
− | + | ] |
|
+ | } |
||
− | } |
||
− | ], |
||
+ | </graph> |
||
− | "projections": [ |
||
+ | |||
+ | <graph> |
||
+ | { |
||
+ | "version": 2, |
||
+ | "width": 100, |
||
+ | "height": 100, |
||
+ | "data": [ |
||
{ |
{ |
||
− | "name": " |
+ | "name": "table", |
− | " |
+ | "values": [12,23,47,6,52,19], |
− | " |
+ | "transform": [{"type": "pie","field": "data"}] |
− | "translate": [{"signal": "translateX"}, {"signal": "translateY"}] |
||
} |
} |
||
], |
], |
||
− | |||
"scales": [ |
"scales": [ |
||
{ |
{ |
||
− | "name": " |
+ | "name": "r", |
− | "type": " |
+ | "type": "sqrt", |
− | "domain": {"data": " |
+ | "domain": {"data": "table","field": "data"}, |
− | "range": [ |
+ | "range": [20,100] |
} |
} |
||
], |
], |
||
− | |||
"marks": [ |
"marks": [ |
||
{ |
{ |
||
− | "type": " |
+ | "type": "arc", |
− | "from": {"data": " |
+ | "from": {"data": "table"}, |
− | " |
+ | "properties": { |
"enter": { |
"enter": { |
||
− | " |
+ | "x": {"field": {"group": "width"},"mult": 0.5}, |
− | " |
+ | "y": {"field": {"group": "height"},"mult": 0.5}, |
+ | "startAngle": {"field": "layout_start"}, |
||
+ | "endAngle": {"field": "layout_end"}, |
||
+ | "innerRadius": {"value": 20}, |
||
+ | "outerRadius": {"scale": "r","field": "data"}, |
||
+ | "stroke": {"value": "#fff"} |
||
}, |
}, |
||
− | "update": { |
+ | "update": {"fill": {"value": "#ccc"} }, |
− | + | "hover": {"fill": {"value": "pink"} } |
|
− | } |
||
− | } |
||
− | }, |
||
− | { |
||
− | "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", |
"type": "text", |
||
− | " |
+ | "from": {"data": "table"}, |
− | " |
+ | "properties": { |
"enter": { |
"enter": { |
||
− | "x": {" |
+ | "x": {"field": {"group": "width"},"mult": 0.5}, |
− | "y": {" |
+ | "y": {"field": {"group": "height"},"mult": 0.5}, |
− | " |
+ | "radius": {"scale": "r","field": "data","offset": 8}, |
− | " |
+ | "theta": {"field": "layout_mid"}, |
− | " |
+ | "fill": {"value": "#000"}, |
− | }, |
+ | "align": {"value": "center"}, |
− | " |
+ | "baseline": {"value": "middle"}, |
− | "text": {" |
+ | "text": {"field": "data"} |
} |
} |
||
} |
} |
Текущая версия от 17:24, 7 ноября 2022
Синтаксическая ошибка