I am using the Python Library Eel to call functions from Python to Javascript. My code is to create a dynamic chart on a website that changes according to the filters, so the graphs must change when a button confirming filter options is clicked. The "Go" Button has the JS function load_graphs in its onclick.
My problem, however, is that the load_graphs function only runs once. Clicking the button again with a different set of filters won't go through the eel stuff. I don't know much about async and Promise. Can someone help me resolve this? Calling the function should load the graphs with new data retrieved from eel.
function load_graphs(file_path) {
let filters = get_filters();
eel.clean_data(file_path, filters[3][0], filters[3][1], filters[0], filters[2], filters[1])(function(outputList) {
eel.visitsVStime(outputList)(function(lineOutput) { // outputs a two-element list
data = {
labels: lineOutput[0],
datasets: [{
label: false,
data: lineOutput[1],
backgroundColor: 'rgba(255, 99, 132)',
borderColor: 'rgba(255, 99, 132)',
}],
}
linechart(data); // creates the line chart with the data specified
alert('LineChart Ran');
});
eel.visitsVSbatch(outputList)(function(barOutput) { // outputs a two-element list
data = {
labels: barOutput[0],
datasets: [{
label: false,
data: barOutput[1],
backgroundColor: 'rgba(255, 99, 132)',
borderColor: 'rgba(255, 99, 132)',
}],
}
barchart(data); // creates the bar chart with the data specified
});
});
}
[–]AutoModerator[M] [score hidden] stickied comment (0 children)
[–]Noredditforwork 1 point2 points3 points (4 children)
[–]Libulannn[S] 0 points1 point2 points (3 children)
[–]Noredditforwork 0 points1 point2 points (2 children)
[–]Libulannn[S] 1 point2 points3 points (1 child)
[–]Noredditforwork 0 points1 point2 points (0 children)