-
Notifications
You must be signed in to change notification settings - Fork 7
/
custom_bokeh_model.ts
59 lines (47 loc) · 1.38 KB
/
custom_bokeh_model.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import { HTMLBox, HTMLBoxView } from "models/layouts/html_box"
import { div } from "core/dom"
import * as p from "core/properties"
import { Slider } from "models/widgets/slider"
export class CustomView extends HTMLBoxView {
model: Custom
connect_signals(): void {
console.info("connect_signals");
super.connect_signals()
this.connect(this.model.slider.change, () => {
console.info("slider change call back");
this.render();
})
}
render(): void {
console.info("render");
super.render()
this.el.appendChild(div({
style: {
padding: '2px',
color: '#b88d8e',
backgroundColor: '#2a3153',
},
}, `${this.model.text}: ${this.model.slider.value}`))
}
}
export namespace Custom {
export type Attrs = p.AttrsOf<Props>
export type Props = HTMLBox.Props & {
slider: p.Property<Slider>
text: p.Property<string>
}
}
export interface Custom extends Custom.Attrs { }
export class Custom extends HTMLBox {
properties: Custom.Props
constructor(attrs?: Partial<Custom.Attrs>) {
super(attrs)
}
static init_Custom(): void {
this.prototype.default_view = CustomView;
this.define<Custom.Props>({
text: [p.String],
slider: [p.Instance],
})
}
}