Advertisement
Guest User

Untitled

a guest
Jul 26th, 2017
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.60 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <head>
  3. <title>Vega-Lite Chart</title>
  4. <meta charset="utf-8">
  5.  
  6. <script src="https://d3js.org/d3.v3.min.js"></script>
  7. <script src="https://vega.github.io/vega/vega.js"></script>
  8. <script src="https://vega.github.io/vega-lite/vega-lite.js"></script>
  9. <script src="https://vega.github.io/vega-editor/vendor/vega-embed.js" charset="utf-8"></script>
  10.  
  11. <style media="screen">
  12. /* Add space between vega-embed links */
  13. .vega-actions a {
  14. margin-right: 5px;
  15. }
  16. </style>
  17. </head>
  18. <body>
  19. <!-- Container for the visualization -->
  20. <div id="vis"></div>
  21.  
  22. <script>
  23. var vlSpec = {
  24. "data": {
  25. "values": [
  26. {
  27. "Wins": 8,
  28. "a": "thing 1"
  29. },
  30. {
  31. "Wins": 9,
  32. "a": "thing 2"
  33. },
  34. {
  35. "Wins": 7,
  36. "a": "thing 3"
  37. },
  38. {
  39. "Wins": 9,
  40. "a": "thing 4"
  41. }
  42. ]
  43. },
  44. "encoding": {
  45. "y": {
  46. "type": "quantitative",
  47. "field": "Wins"
  48. },
  49. "x": {
  50. "type": "nominal",
  51. "field": "a"
  52. }
  53. },
  54. "mark": "bar"
  55. }
  56.  
  57. var embedSpec = {
  58. mode: "vega-lite", // Instruct Vega-Embed to use the Vega-Lite compiler
  59. spec: vlSpec
  60. };
  61.  
  62. // Embed the visualization in the container with id `vis`
  63. vg.embed("#vis", embedSpec, function(error, result) {
  64. // Callback receiving the View instance and parsed Vega spec
  65. // result.view is the View, which resides under the '#vis' element
  66. });
  67. </script>
  68. </body>
  69. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement