Commit 0dd4240a authored by Boxiang Sun's avatar Boxiang Sun

add iodide.output.element to display the matplotlib figure

parent 459cd18b
......@@ -434,6 +434,23 @@
}
}
function outputElement(node_type) {
var div, node;
div = document.createElement("div");
// iodide.output.element API allows user to define the node type
node = document.createElement(node_type);
div.append(node);
document.body.appendChild(div);
// div for insert in to the body
// node for return to the caller
return node;
}
// We provided window.pyodide, so matplotlib will use iodide.output.element as backend
// see: https://github.com/iodide-project/pyodide/blob/master/packages/matplotlib/src/wasm_backend.py#L108
// It is not related to addOutputHandler
window.iodide.output = {element: outputElement};
function executePyCell(line_list) {
var result, code_text = line_list.join('\n');
result = pyodide_instance.runPython(code_text);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment