I am trying to use the mpld3-flask example (https://github.com/nipunreddevil/mpld3-flask) as a template to achieve a certain behavior. What I would like, is to add links on the header bar to different plots, rather than having a radio button query form.
Right now, the example code above, in templates/index.html, makes a container and then populates it with a plot when the user submits a query by clicking the "View Plot" button. That happens in this code, as far as I can tell, in index.html:
$("#query").click(function() {
$("#loading-div-background").show();
$("#container").hide();
var plot_type = $('input:radio[name=plot_type]:checked').val();
var qu = {"plot_type":plot_type}
$.ajax({
type: "POST",
async:true,
contentType: "application/json; charset=utf-8",
url: "/query",
data: JSON.stringify(qu),
success: function (data) {
var graph = $("#container");
graph.html(data);
$("#loading-div-background").hide();
$("#container").show();
},
dataType: "html"
});
});
What I would like instead is to add to the header bar that currently has "Home" in it, and bring up each example plot in a different page. I would route to a different link, and then populate the template html code with the data for the plot, without requiring a user query.
I am a bit of a novice with html and essentially know nothing about JavaScript at this point. My sense here is that there is some relatively easy way to use flask + jinja2 to do this, but I haven't been able to figure it out.
I am having some trouble with the sort of unclear namespaces that result from combining all of these languages. I am usually very strict with namespaces in my own python programming (i.e. I never, ever use 'from ____ import *') so this is driving me a little crazy.