Advertisement
Guest User

Untitled

a guest
Feb 9th, 2016
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.03 KB | None | 0 0
  1. {
  2. "legends": [
  3. {
  4. "fill": "color",
  5. "title": "Legend",
  6. "offset": 0,
  7. "properties": {
  8. "symbols": {
  9. "fillOpacity": {"value": 0.5},
  10. "stroke": {"value": "transparent"}
  11. }
  12. }
  13. }
  14. ],
  15. "width": 400,
  16. "height": 200,
  17. "axes": [
  18. {"type": "x","scale": "x","grid": true,"title": "rpm"},
  19. {
  20. "type": "y",
  21. "scale": "y",
  22. "grid": true,
  23. "title": "torque"
  24. }
  25. ],
  26. "data": [
  27. {
  28. "metadata": {
  29. "names": ["rpm","torque","horsepower","EngineType"],
  30. "types": ["linear","linear","ordinal","ordinal"]
  31. },
  32. "values": [
  33. {
  34. "rpm": 0,
  35. "torque": 10,
  36. "horsepower": 1,
  37. "EngineType": "Rotary"
  38. },
  39. {
  40. "rpm": 0,
  41. "torque": 20,
  42. "horsepower": 5,
  43. "EngineType": "Piston"
  44. },
  45. {
  46. "rpm": 2,
  47. "torque": 12,
  48. "horsepower": 12,
  49. "EngineType": "Piston"
  50. },
  51. {
  52. "rpm": 2,
  53. "torque": 15,
  54. "horsepower": 15,
  55. "EngineType": "Rotary"
  56. }
  57. ],
  58. "name": "table"
  59. }
  60. ],
  61. "scales": [
  62. {
  63. "name": "x",
  64. "type": "linear",
  65. "range": "width",
  66. "zero": false,
  67. "domain": {"data": "table","field": "rpm"}
  68. },
  69. {
  70. "name": "y",
  71. "type": "linear",
  72. "range": "height",
  73. "zero": false,
  74. "domain": {"data": "table","field": "torque"}
  75. },
  76. {
  77. "name": "color",
  78. "type": "ordinal",
  79. "domain": {"data": "table","field": "EngineType"},
  80. "range": "category10"
  81. }
  82. ],
  83. "padding": {"top": 50,"left": 60,"bottom": 40,"right": 150},
  84. "marks": [
  85. {
  86. "type": "group",
  87. "from": {
  88. "data": "table",
  89. "transform": [{"type": "facet","groupby": ["EngineType"]}]
  90. },
  91. "marks": [
  92. {
  93. "type": "line",
  94. "properties": {
  95. "update": {
  96. "x": {"scale": "x","field": "rpm"},
  97. "y": {"scale": "y","field": "torque"},
  98. "stroke": {"scale": "color","field": "EngineType"},
  99. "strokeWidth": {"value": 2},
  100. "strokeOpacity": {"value": 1}
  101. },
  102. "hover": {"strokeOpacity": {"value": 0.5}}
  103. }
  104. }
  105. ]
  106. },
  107. {
  108. "type": "symbol",
  109. "from": {"data": "table"},
  110. "properties": {
  111. "update": {
  112. "x": {"scale": "x","field": "rpm"},
  113. "y": {"scale": "y","field": "torque"},
  114. "fill": {"scale": "color","field": "EngineType"},
  115. "size": {"value": 200},
  116. "fillOpacity": {"value": 1}
  117. }
  118. }
  119. },
  120. {
  121. "type": "group",
  122. "from": {
  123. "data": "table",
  124. "transform": [
  125. {
  126. "type": "filter",
  127. "test": "datum.rpm == hover.rpm"
  128. }
  129. ]
  130. },
  131. "properties": {
  132. "update": {
  133. "x": {"scale": "x","signal": "hover.rpm","offset": 0},
  134. "y": {
  135. "scale": "y",
  136. "signal": "hover.torque",
  137. "offset": -30
  138. },
  139. "width": {"value": 120},
  140. "height": {"value": 35},
  141. "fill": {"value": "#e5f2ff"}
  142. }
  143. },
  144. "marks": [
  145. {
  146. "type": "text",
  147. "properties": {
  148. "update": {
  149. "x": {"value": 6},
  150. "y": {"value": 14},
  151. "text": {"template": "X \n (rpm) \t {{hover.rpm}}"},
  152. "fill": {"value": "black"}
  153. }
  154. }
  155. },
  156. {
  157. "type": "text",
  158. "properties": {
  159. "update": {
  160. "x": {"value": 6},
  161. "y": {"value": 29},
  162. "text": {
  163. "template": "Y \t (torque) \t {{hover.torque}}"
  164. },
  165. "fill": {"value": "black"}
  166. }
  167. }
  168. }
  169. ]
  170. }
  171. ],
  172. "signals": [
  173. {
  174. "name": "hover",
  175. "init": {},
  176. "streams": [
  177. {"type": "symbol:mouseover","expr": "datum"},
  178. {"type": "symbol:mouseout","expr": "{}"}
  179. ]
  180. }
  181. ]
  182. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement