After creation, you can send messages from the widget/script to the HTML using
Framework.ChartChange({
mode: "active", // or "all", or "single" plus a .chartId value
command: "send-html-message",
msg: "some update for the HTML"
});
The HTML can listen for the messages using standard window
var html = "<html>";
html += "<script>";
html += "window.addEventListener('message', event => {";
// event.data contains the message from the widget. For example:
html += "document.body.innerText = event.data;";
html += "});"
// See note above about escaping the closing script block in dynamically constructed HTML
html += "<\/script>";