@bokeh/bokehjs
Version:
Interactive, novel data visualization
68 lines • 1.92 kB
JavaScript
import { StyledElement, StyledElementView } from "../ui/styled_element";
import { InlineStyleSheet } from "../../core/dom";
import { BBox } from "../../core/util/bbox";
import { Place } from "../../core/enums";
import { isNumber } from "../../core/util/types";
import * as css from "../../styles/canvas_panel.css";
export class CanvasPanelView extends StyledElementView {
static __name__ = "CanvasPanelView";
_bbox = new BBox();
get bbox() {
return this._bbox;
}
position = new InlineStyleSheet("", "position");
stylesheets() {
return [...super.stylesheets(), css.default, this.position];
}
rendering_target() {
return this.parent.canvas_view.events_el;
}
render() {
super.render();
this.class_list.add(css[this.model.place]);
}
set_geometry(bbox) {
this._bbox = bbox;
this._update_position();
this.mark_finished();
}
/**
* Updates the position of the associated DOM element.
*/
_update_position() {
const { bbox, position } = this;
if (!bbox.is_valid) {
position.replace(`
:host {
display: none;
}
`);
}
}
// TODO remove this when bbox handling is unified
resolve_symbol(node) {
const target = this;
const value = target.bbox.resolve(node.symbol);
const { offset } = node;
if (isNumber(value)) {
return value + offset;
}
else {
const { x, y } = value;
return { x: x + offset, y: y + offset };
}
}
}
export class CanvasPanel extends StyledElement {
static __name__ = "CanvasPanel";
constructor(attrs) {
super(attrs);
}
static {
this.prototype.default_view = CanvasPanelView;
this.define({
place: [Place],
});
}
}
//# sourceMappingURL=canvas_panel.js.map