Files
perspective-dev--perspective/rust/perspective-viewer/test/html/plugin-resize.html
T
2026-07-13 12:25:07 +08:00

50 lines
1.8 KiB
HTML

<!doctype html>
<html>
<head>
<script type="module" src="/node_modules/@perspective-dev/viewer/dist/cdn/perspective-viewer.js"></script>
<script type="module">
await customElements.whenDefined("perspective-viewer-plugin");
const BASE = customElements.get("perspective-viewer-plugin");
class TestPluginImplementsResize extends BASE {
get_static_config() {
return {
name: "Resizing Plugin",
select_mode: "select",
config_column_names: [],
};
}
async draw(view) {
this._view = view;
console.log(await this._view.num_rows());
return await super.draw(view);
}
async update(view) {
this._view = view;
console.log(await this._view.num_rows());
return await super.update(view);
}
async resize(view) {
console.log(await this._view.num_rows());
await this._view.to_csv();
}
}
customElements.define("resize-plugin", TestPluginImplementsResize);
await customElements.whenDefined("perspective-viewer").then((viewer) => {
viewer.registerPlugin("resize-plugin");
});
</script>
<script type="module" src="/node_modules/@perspective-dev/test/load-viewer-csv.js"></script>
<link rel="stylesheet" href="../css/demo.css" />
<link rel="stylesheet" href="/node_modules/@perspective-dev/viewer/dist/css/pro.css" />
</head>
<body>
<perspective-viewer></perspective-viewer>
</body>
</html>