vega horizontal bar charts -


the vega documentation/tutorials suggest setting horizontal bar chart easy, can't figure out life of me. how go changing vertical bar chart, such http://vega.github.io/vega-editor/index.html?spec=bar, horizontal one?

like this

{   "width": 200,   "height": 210,   "padding": "auto",   "data": [     {       "name": "raw",       "values": [         {"x": "a","y": 28},         {"x": "b","y": 55},         {"x": "c","y": 43},         {"x": "d","y": 91},         {"x": "e","y": 81},         {"x": "f","y": 53},         {"x": "g","y": 19},         {"x": "h","y": 87},         {"x": "i","y": 52}       ],       "format": {"parse": {"y": "number"}},       "transform": [{"type": "filter","test": "(d.data.y!==null)"}]     }   ],   "scales": [],   "marks": [     {       "_name": "cell",       "type": "group",       "properties": {         "enter": {"width": {"value": 200},"height": {"value": 210}}       },       "scales": [         {           "name": "x",           "type": "linear",           "domain": {"data": "raw","field": "data.y"},           "range": [0,200],           "zero": true,           "reverse": false,           "round": true,           "nice": true         },         {           "name": "y",           "type": "ordinal",           "domain": {"data": "raw","field": "data.x"},           "sort": true,           "range": [0,210],           "bandwidth": 21,           "round": true,           "nice": true,           "points": true,           "padding": 1         }       ],       "axes": [         {           "type": "x",           "scale": "x",           "properties": {             "grid": {               "stroke": {"value": "#000000"},               "opacity": {"value": 0.08}             }           },           "layer": "back",           "format": "",           "ticks": 5,           "titleoffset": 38,           "grid": true,           "title": "y"         },         {           "type": "y",           "scale": "y",           "properties": {             "labels": {"text": {"template": "{{data | truncate:25}}"}},             "grid": {               "stroke": {"value": "#000000"},               "opacity": {"value": 0.08}             }           },           "layer": "back",           "titleoffset": 28,           "grid": true,           "title": "x"         }       ],       "marks": [         {           "type": "rect",           "from": {"data": "raw"},           "properties": {             "enter": {               "x": {"scale": "x","field": "data.y"},               "x2": {"value": 0},               "yc": {"scale": "y","field": "data.x"},               "height": {"value": 21,"offset": -1},               "fill": {"value": "#4682b4"}             },             "update": {               "x": {"scale": "x","field": "data.y"},               "x2": {"value": 0},               "yc": {"scale": "y","field": "data.x"},               "height": {"value": 21,"offset": -1},               "fill": {"value": "#4682b4"}             }           }         }       ],       "legends": []     }   ] } 

i generated chart from

{   "data": {     "values": [       {"x":"a", "y":28}, {"x":"b", "y":55}, {"x":"c", "y":43},       {"x":"d", "y":91}, {"x":"e", "y":81}, {"x":"f", "y":53},       {"x":"g", "y":19}, {"x":"h", "y":87}, {"x":"i", "y":52}     ]   },   "marktype": "bar",   "encoding": {     "y": {"type": "o","name": "x"},     "x": {"type": "q","name": "y"}   } } 

with vega-lite (https://vega.github.io/vega-lite/).


Comments

Popular posts from this blog

searchKeyword not working in AngularJS filter -

sequelize.js - Sequelize: sort by enum cases -

user interface - how to replace an ongoing process of image capture from another process call over the same ImageLabel in python's GUI TKinter -