I am using plotly to make multiple graphs and django framework to present the graph to user. I am storing all the graphs in list, example: all_graphs=[graph1, graph2] I need to show only one graph at a time according to value selected in dropdown in HTML.
I am using javascript and jinja2 element for the same. Below is my javascript code: `
function graphshow(s){
var id=Number(s[s.selectedIndex].id);
var graph1 = {{ all_graphs.0 | safe}};
Plotly.plot('id_of_div_to_show_graph', graph1, {});
}
` The above code works perfectly but when i replace 0 in line 2 with 'id' which is the index value of graph to be shown the code doesn't work. The value stored in 'id' is correct i've already checked.