Guest User

Untitled

a guest
Nov 17th, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.59 KB | None | 0 0
  1. {
  2. "$schema": "https://vega.github.io/schema/vega/v3.0.json",
  3. "width": 277,
  4. "height": 200,
  5. "padding": 32,
  6. "data": [
  7. {
  8. "name": "table",
  9. "values": [
  10. {
  11. "category": "1",
  12. "label": "1",
  13. "amount": 28
  14. },
  15. {
  16. "category": "2",
  17. "label": "",
  18. "amount": 55
  19. },
  20. {
  21. "category": "3",
  22. "label": "",
  23. "amount": 43
  24. },
  25. {
  26. "category": "4",
  27. "label": "4",
  28. "amount": 91
  29. }
  30. ]
  31. }
  32. ],
  33. "signals": [
  34. {
  35. "name": "tooltip",
  36. "value": {},
  37. "on": [
  38. {
  39. "events": "rect:mouseover",
  40. "update": "datum"
  41. },
  42. {
  43. "events": "rect:mouseout",
  44. "update": "{}"
  45. }
  46. ]
  47. }
  48. ],
  49. "scales": [
  50. {
  51. "name": "xscale",
  52. "type": "band",
  53. "domain": {
  54. "data": "table",
  55. "field": "category"
  56. },
  57. "range": "width",
  58. "paddingInner": 0.15,
  59. "paddingOuter": 0.30,
  60. "round": true
  61. },
  62. {
  63. "name": "xlabels",
  64. "type": "ordinal",
  65. "domain": {
  66. "data": "table",
  67. "field": "category"
  68. },
  69. "range": {
  70. "data": "table",
  71. "field": "label"
  72. }
  73. },
  74. {
  75. "name": "yscale",
  76. "domain": {
  77. "data": "table",
  78. "field": "amount"
  79. },
  80. "nice": true,
  81. "range": "height"
  82. }
  83. ],
  84. "axes": [
  85. {
  86. "orient": "bottom",
  87. "scale": "xscale",
  88. "labelPadding": 10,
  89. "ticks": false,
  90. "encode": {
  91. "labels": {
  92. "update": {
  93. "text": {
  94. "data": "table",
  95. "field": "label"
  96. },
  97. "font": {"value": "Lato"},
  98. "fontSize": {"value": 14},
  99. "fontWeight": {"value": "bold"}
  100. }
  101. },
  102. "domain": {
  103. "update": {
  104. "stroke": {
  105. "value": "#071323"
  106. },
  107. "strokeWidth": {
  108. "value": 1
  109. }
  110. }
  111. }
  112. }
  113. },
  114. {
  115. "orient": "left",
  116. "labels": false,
  117. "ticks": false,
  118. "domain": false,
  119. "scale": "yscale"
  120. }
  121. ],
  122. "marks": [
  123. {
  124. "type": "rect",
  125. "from": {
  126. "data": "table"
  127. },
  128. "encode": {
  129. "enter": {
  130. "x": {
  131. "scale": "xscale",
  132. "field": "category"
  133. },
  134. "width": {
  135. "scale": "xscale",
  136. "band": 1
  137. },
  138. "y": {
  139. "scale": "yscale",
  140. "field": "amount"
  141. },
  142. "y2": {
  143. "scale": "yscale",
  144. "value": 0
  145. }
  146. },
  147. "update": {
  148. "fill": {
  149. "value": "#51c878"
  150. }
  151. }
  152. }
  153. },
  154. {
  155. "type": "text",
  156. "encode": {
  157. "enter": {
  158. "align": {
  159. "value": "center"
  160. },
  161. "baseline": {
  162. "value": "bottom"
  163. },
  164. "fill": {
  165. "value": "#333"
  166. }
  167. },
  168. "update": {
  169. "x": {
  170. "scale": "xscale",
  171. "signal": "tooltip.category",
  172. "band": 0.5
  173. },
  174. "y": {
  175. "scale": "yscale",
  176. "signal": "tooltip.amount",
  177. "offset": -2
  178. },
  179. "text": {
  180. "signal": "tooltip.amount"
  181. },
  182. "fillOpacity": [
  183. {
  184. "test": "datum === tooltip",
  185. "value": 0
  186. },
  187. {
  188. "value": 1
  189. }
  190. ]
  191. }
  192. }
  193. }
  194. ]
  195. }
Add Comment
Please, Sign In to add comment