Карта мира: различия между версиями

Материал из wiki.energogroup.org
Перейти к навигации Перейти к поиску
 
(не показаны 43 промежуточные версии 2 участников)
Строка 1: Строка 1:
<graph mode=interactive>
+
<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>
 
{
 
{
"version": 2,
+
"version": 2,
"width": 500,
+
"width": 1,
"height": 260,
+
"height": 1,
"padding": 12,
+
"data": [
"background": "#edf1f7",
 
"data": [
 
{
 
"name": "countryNames",
 
"url": "wikidatasparql:///?query=PREFIX%20wikibase%3A%20%3Chttp%3A%2F%2Fwikiba.se%2Fontology%23%3E%0APREFIX%20wd%3A%20%3Chttp%3A%2F%2Fwww.wikidata.org%2Fentity%2F%3E%20%0APREFIX%20wdt%3A%20%3Chttp%3A%2F%2Fwww.wikidata.org%2Fprop%2Fdirect%2F%3E%0A%0ASELECT%20%3Fid%20%3Fvalue%20WHERE%20%7B%0A%20%20%20%7B%20SELECT%20DISTINCT%20%3Fid%20%20WHERE%20%7B%0A%20%20%20%20%20%3Fplace%20wdt%3AP17%20%3Fid%20.%0A%20%20%20%7D%20%7D%0A%20%20%20%3Fid%20wdt%3AP299%20%3Fcode%20.%0A%20%20%20SERVICE%20wikibase%3Alabel%20%7B%0A%20%20%20%20%20bd%3AserviceParam%20wikibase%3Alanguage%20%22en%2Cen%22%20.%0A%20%20%20%20%20%3Fid%20rdfs%3Alabel%20%3Fvalue%0A%20%20%20%7D%0A%7D%0A",
 
"format": { "type": "json" }
 
},
 
{
 
"name": "countryPopulation",
 
"url": "wikidatasparql:///?query=PREFIX%20wikibase%3A%20%3Chttp%3A%2F%2Fwikiba.se%2Fontology%23%3E%0APREFIX%20wd%3A%20%3Chttp%3A%2F%2Fwww.wikidata.org%2Fentity%2F%3E%20%0APREFIX%20wdt%3A%20%3Chttp%3A%2F%2Fwww.wikidata.org%2Fprop%2Fdirect%2F%3E%0A%0ASELECT%20%3Fid%20%3Fvalue%20WHERE%20%7B%0A%20%20%20%7B%20SELECT%20DISTINCT%20%3Fid%20%20WHERE%20%7B%0A%20%20%20%20%20%3Fplace%20wdt%3AP17%20%3Fid%20.%0A%20%20%20%7D%20%7D%0A%20%20%20%3Fid%20wdt%3AP299%20%3Fcode%20.%0A%20%20%20%3Fid%20wdt%3AP1082%20%3Fvalue%20.%0A%7D%0A",
 
"format": { "type": "json" }
 
},
 
{
 
"name": "museumCounts",
 
"url":"wikidatasparql:///?query=PREFIX%20wikibase%3A%20%3Chttp%3A%2F%2Fwikiba.se%2Fontology%23%3E%0APREFIX%20wd%3A%20%3Chttp%3A%2F%2Fwww.wikidata.org%2Fentity%2F%3E%20%0APREFIX%20wdt%3A%20%3Chttp%3A%2F%2Fwww.wikidata.org%2Fprop%2Fdirect%2F%3E%0A%0ASELECT%20DISTINCT%20%3Fid%20(count(*)%20as%20%3Fvalue)%20WHERE%20%7B%0A%20%20%20%3Fplace%20wdt%3AP31%2Fwdt%3AP279*%20wd%3AQ33506%20.%0A%20%20%20%3Fplace%20wdt%3AP17%20%3Fid%20.%0A%7D%0A%0AGROUP%20BY%20%3Fid",
 
"format": { "type": "json" }
 
},
 
{
 
"name": "map",
 
"url": "wikiraw:///Extension:Graph/Demo/RawData:WorldMap-json",
 
"format": {"type": "topojson","feature": "countries"},
 
"transform": [
 
 
{
 
{
"type": "geopath",
+
"name": "highlights",
  +
"values": [{"id":"US","v":"blue"},{"id":"AU","v":"purple"},{"id":"CN","v":"red"},{"id":"BR","v":"pink"},{"id":"DZ","v":"green"}]
"value": "data",
 
"scale": 80,
 
"center": [-180,125],
 
"translate": [0,0],
 
"projection": "equirectangular"
 
 
},
 
},
 
{
 
{
"type": "lookup",
+
"name": "countries",
"keys": ["id"],
+
"url": "wikiraw:///Extension:Graph/Demo/RawData:WorldMap-iso2-json",
"on": "countryNames",
+
"format": {"type": "topojson", "feature": "countries"},
"onKey": "id",
+
"transform": [
"as": ["name"],
+
{
"default": {"value": {"value": "???"} }
+
"type": "geopath",
},
+
"value": "data",
{ "type": "formula", "field": "name", "expr": "datum.name.value" },
+
"scale": 80,
  +
"translate":[0,0],
  +
"projection": "equirectangular"
  +
},
  +
{
  +
"type": "lookup",
  +
"keys": [ "id" ],
  +
"on": "highlights",
  +
"onKey": "id",
  +
"as": [ "zipped" ],
  +
"default": {
  +
"v": "#C0C0C0"
  +
}
  +
}
  +
]
  +
}
  +
],
  +
"marks": [
 
{
 
{
"type": "lookup",
+
"type": "path",
"keys": ["id"],
+
"from": {
"on": "countryPopulation",
+
"data": "countries"
"onKey": "id",
+
},
"as": ["population"],
+
"properties": {
"default": {"value": {"value": 0} }
+
"enter": {
},
+
"path": {
{ "type": "formula", "field": "population", "expr": "datum.population.value" },
+
"field": "layout_path"
{
+
}
"type": "lookup",
+
},
"keys": ["id"],
+
"update": {
"on": "museumCounts",
+
"fill": {
"onKey": "id",
+
"field": "zipped.v"
"as": ["museums"],
+
}
"default": {"value": {"value": 0} }
+
},
},
+
"hover": {
{ "type": "formula", "field": "museums", "expr": "datum.museums.value" },
+
"fill": {
  +
"value": "#989898"
{
 
"type": "formula",
+
}
"field": "rate",
+
}
  +
}
"expr": "datum.population > 0 && datum.museums > 0 ? (datum.museums / datum.population) : 0.000000001"
 
 
}
 
}
]
+
]
  +
}
}
 
  +
],
 
  +
</graph>
"signals": [
 
  +
  +
<graph>
  +
{
  +
"version": 2,
  +
"width": 100,
  +
"height": 100,
  +
"data": [
 
{
 
{
"name": "tooltipSignal",
+
"name": "table",
  +
"values": [12,23,47,6,52,19],
"init": {"expr": "{x: 0, y: 0, datum: {name:'', population:'', museums:''} }"},
 
"streams": [
+
"transform": [{"type": "pie","field": "data"}]
{
 
"type": "@map:mouseover",
 
"expr": "{x: eventX(), y: eventY(), datum: eventItem().datum}"
 
},
 
{
 
"type": "@map:mouseout",
 
"expr": "{x: 0, y: 0, datum: {name:'', population:'', museums:''} }"
 
}
 
]
 
 
}
 
}
 
],
 
],
 
"scales": [
 
"scales": [
 
{
 
{
"name": "color",
+
"name": "r",
"type": "log",
+
"type": "sqrt",
"domain": {"data": "map","field": "rate"},
+
"domain": {"data": "table","field": "data"},
"zero": false,
+
"range": [20,100]
"range": ["#FFEDBC", "#f83600"]
 
 
}
 
}
 
],
 
],
 
"marks": [
 
"marks": [
 
{
 
{
"type": "text",
+
"type": "arc",
  +
"from": {"data": "table"},
 
"properties": {
 
"properties": {
 
"enter": {
 
"enter": {
"text": {"value": "Museums"},
+
"x": {"field": {"group": "width"},"mult": 0.5},
"x": {"value": 0},
+
"y": {"field": {"group": "height"},"mult": 0.5},
"y": {"value": 25},
+
"startAngle": {"field": "layout_start"},
"fontSize": {"value": 32},
+
"endAngle": {"field": "layout_end"},
"fontWeight": {"value": "bold"},
+
"innerRadius": {"value": 20},
"fill": {"value": "steelblue"}
+
"outerRadius": {"scale": "r","field": "data"},
}
+
"stroke": {"value": "#fff"}
}
 
},
 
{
 
"name": "map",
 
"type": "path",
 
"from": {"data": "map"},
 
"properties": {
 
"enter": {"path": {"field": "layout_path"} },
 
"update": {
 
"fill": [
 
{
 
"test": "datum.rate !== null",
 
"scale": "color",
 
"field": "rate"
 
},
 
{"value": "grey"}
 
]
 
 
},
 
},
"hover": {"fill": {"value": "#989898"} }
+
"update": {"fill": {"value": "#ccc"} },
  +
"hover": {"fill": {"value": "pink"} }
 
}
 
}
 
},
 
},
 
{
 
{
 
"type": "text",
 
"type": "text",
  +
"from": {"data": "table"},
 
"properties": {
 
"properties": {
 
"enter": {
 
"enter": {
"x": {"value": 500},
+
"x": {"field": {"group": "width"},"mult": 0.5},
"y": {"value": 10},
+
"y": {"field": {"group": "height"},"mult": 0.5},
"align": {"value": "right"},
+
"radius": {"scale": "r","field": "data","offset": 8},
"fontSize": {"value": 17},
+
"theta": {"field": "layout_mid"},
"fill": {"value": "black"}
+
"fill": {"value": "#000"},
},
+
"align": {"value": "center"},
"update": {
+
"baseline": {"value": "middle"},
"text": {"template": "\u007b{tooltipSignal.datum.name}\u007d \u007b{tooltipSignal.datum.museums}\u007d"}
+
"text": {"field": "data"}
}
 
}
 
}
 
],
 
"legends": [
 
{
 
"fill": "color",
 
"title": "Per Capita",
 
"offset": -300,
 
"properties": {
 
"labels": {
 
"text": {"value": ""}
 
},
 
"gradient": {
 
"stroke": {"value": "transparent"}
 
},
 
"title": {
 
"fontSize": {"value": 14}
 
},
 
"legend": {
 
"x": {"value": 0},
 
"y": {"value": 180}
 
 
}
 
}
 
}
 
}

Текущая версия от 17:24, 7 ноября 2022

Синтаксическая ошибка