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

Материал из wiki.energogroup.org
Перейти к навигации Перейти к поиску
Строка 1: Строка 1:
<graph>
 
 
{
 
{
"version": 2,
+
"version": 2,
"width": 600,
+
"width": 1,
"height": 600,
+
"height": 1,
"padding": 5,
+
"data": [
 
{
"signals": [
 
{ "name": "rotation", "init": 0,
+
"name": "highlights",
  +
"values": [{"id":"US","v":"blue"},{"id":"AU","v":"purple"},{"id":"CN","v":"red"},{"id":"BR","v":"pink"},{"id":"DZ","v":"green"}]
"streams": [{
 
"type": "click",
+
},
"expr": "rotation + 6.14/180"
+
{
 
"name": "countries",
}]
 
  +
"url": "wikiraw:///Extension:Graph/Demo/RawData:WorldMap-iso2-json",
}
 
 
"format": {"type": "topojson", "feature": "countries"},
],
 
"data": [
+
"transform": [
{
+
{
"name": "tree",
+
"type": "geopath",
"url": "wikiraw:///Extension:Graph/data/flare-json",
+
"value": "data",
"format": {"type": "treejson"},
+
"scale": 80,
"transform": [
+
"translate":[0,0],
  +
"projection": "equirectangular"
{ "type": "hierarchy", "sort": "name", "size": [6.28, 300], "orient": "radial", "output": {"x": "angle1", "y": "radius"} },
 
 
},
{ "type": "formula", "field": "angle", "expr": "(datum.angle1 + rotation) % (2*PI)" },
 
 
{
{ "type": "formula", "field": "sign", "expr": "datum.angle > 3.14 ? 1 : -1" },
 
 
"type": "lookup",
{ "type": "formula", "field": "degrees", "expr": "!datum.radius ? 0 : (datum.angle + datum.sign*1.57) * 180/PI" },
 
{ "type": "formula", "field": "yy", "expr": "300 + datum.radius * cos(datum.angle)" },
+
"keys": [ "id" ],
{ "type": "formula", "field": "xx", "expr": "300 + datum.radius * -sin(datum.angle)" },
+
"on": "highlights",
 
"onKey": "id",
{ "type": "formula", "field": "align", "expr": "!datum.radius ? 'center' : datum.sign < 0 ? 'left' : 'right'" }
 
  +
"as": [ "zipped" ],
]
 
 
"default": {
}
 
  +
"v": "#C0C0C0"
],
 
  +
}
"marks": [
 
{
+
}
"type": "path",
+
]
"from": {
 
"data": "tree",
 
"transform": [
 
{"type": "filter", "test": "datum.parent"},
 
{
 
"type": "linkpath",
 
"sourceX": "parent.xx", "sourceY": "parent.yy",
 
"targetX": "xx", "targetY": "yy",
 
"shape": "line"
 
}
 
]
 
},
 
"properties": {
 
"update": {
 
"path": {"field": "layout_path"},
 
"stroke": {"value": "#ddd"}
 
 
}
 
}
}
+
],
},
+
"marks": [
{
+
{
"type": "text",
+
"type": "path",
"from": {"data": "tree"},
+
"from": {
"properties": {
+
"data": "countries"
"update": {
+
},
"x": {"field": "xx"},
+
"properties": {
"y": {"field": "yy"},
+
"enter": {
"font": {"value": "Helvetica Neue"},
+
"path": {
"fontSize": {"value": 10},
+
"field": "layout_path"
"align": {"field": "align"},
+
}
"baseline": {"value": "middle"},
+
},
"fill": {"value": "#000"},
+
"update": {
"text": {"field": "name"},
+
"fill": {
"angle": {"field": "degrees"}
+
"field": "zipped.v"
  +
}
  +
},
 
"hover": {
  +
"fill": {
 
"value": "#989898"
  +
}
  +
}
 
}
 
}
 
}
}
+
]
}
 
]
 
 
}
 
}
</graph>
 

Версия от 12:35, 3 ноября 2022

{

   "version": 2,
   "width": 1,
   "height": 1,
   "data": [
       {
           "name": "highlights",
           "values": [{"id":"US","v":"blue"},{"id":"AU","v":"purple"},{"id":"CN","v":"red"},{"id":"BR","v":"pink"},{"id":"DZ","v":"green"}]
       },
       {
           "name": "countries",
           "url": "wikiraw:///Extension:Graph/Demo/RawData:WorldMap-iso2-json",
           "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": [
       {
           "type": "path",
           "from": {
               "data": "countries"
           },
           "properties": {
               "enter": {
                   "path": {
                       "field": "layout_path"
                   }
               },
               "update": {
                   "fill": {
                       "field": "zipped.v"
                   }
               },
               "hover": {
                   "fill": {
                       "value": "#989898"
                   }
               }
           }
       }
   ]

}