A widget or script can use ChartChange() to add HTML to a chart, either just as decoration or to provide additional functionality. This mechanism is very flexible, but it can become complicated if you want the calling widget/script to interact with the HTML.
The HTML is added to the chart in a sandboxed iframe. It has no access to the rest of the web page, and it has no direct access to any framework features. However, the HTML can send messages to the calling widget/script, and the widget/script can send messages to the HTML. Therefore, for example, the HTML can have something like a button which sends a message to its creator, and the creator then carries out some action.
Note on common browser gotcha: if you are dynamically building HTML which contains a
<html>
<script>
var html = "<html>";
html += "<script>";
…
// MUST escape, or otherwise mangle, the closing script block.
// An alternative would be: html += "</" + "script>";
html += "<\/script>";
…