mercredi 26 juillet 2017

can't display html produced by the altair python package

When I try to open my html file generated by python/altair it comes up with a blank page. I know my vega-lite code is valid because I have copy pasted it into the online editor and it works fine. I have also tried using chart.serve() and it comes up with a blank page as well. I have pasted the html generated by chart.to_html() below:

<!DOCTYPE html>
<head>
  <title>Vega-Lite Chart</title>
  <meta charset="utf-8">

  <script src="http://ift.tt/1kMxxfh"></script>
  <script src="http://ift.tt/2w2li4q"></script>
  <script src="http://ift.tt/2v9Qpih"></script>
  <script src="http://ift.tt/2w1VkOz" charset="utf-8"></script>

  <style media="screen">
    /* Add space between vega-embed links  */
    .vega-actions a {
      margin-right: 5px;
    }
  </style>
</head>
<body>
  <!-- Container for the visualization -->
  <div id="vis"></div>

  <script>
  var vlSpec = {
    "data": {
        "values": [
            {
                "Wins": 8,
                "a": "thing 1"
            },
            {
                "Wins": 9,
                "a": "thing 2"
            },
            {
                "Wins": 7,
                "a": "thing 3"
            },
            {
                "Wins": 9,
                "a": "thing 4"
            }
        ]
    },
    "encoding": {
        "y": {
            "type": "quantitative",
            "field": "Wins"
        },
        "x": {
            "type": "nominal",
            "field": "a"
        }
    },
    "mark": "bar"
}

  var embedSpec = {
    mode: "vega-lite",  // Instruct Vega-Embed to use the Vega-Lite compiler
    spec: vlSpec
  };

  // Embed the visualization in the container with id `vis`
  vg.embed("#vis", embedSpec, function(error, result) {
    // Callback receiving the View instance and parsed Vega spec
    // result.view is the View, which resides under the '#vis' element
  });
  </script>
</body>
</html>




Aucun commentaire:

Enregistrer un commentaire