-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathviz_widget.js
56 lines (40 loc) · 1.48 KB
/
viz_widget.js
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
class DotGraphElement extends HTMLElement {
constructor() {
super();
this.attachShadow({mode: 'open'});
this.content_div = document.createElement('div');
this.shadowRoot.appendChild(this.content_div);
this.slot_ele = document.createElement('slot');
this.shadowRoot.appendChild(this.slot_ele);
this.dot_text = "";
}
connectedCallback(){
let layout = this.hasAttribute('layout') ? this.getAttribute('layout') : "fdp";
let style = this.hasAttribute('style') ? this.getAttribute('style') : "";
this.content_div.style = style;
let that = this;
this.slot_ele.addEventListener('slotchange', e => {
let graphviz_text = that.innerText;
this.dot_text = graphviz_text;
this.content_div.innerHTML = Viz(this.dot_text, {engine:layout});
this.slot_ele.style.display = "none";
this.content_div.children[0].setAttribute("width", this.content_div.style.width);
this.content_div.children[0].setAttribute("height", this.content_div.style.height);
});
}
disconnectedCallback() {
}
attributeChangedCallback(name, oldValue, newValue) {
//this.displayVal.innerText = this.value;
}
get layout(){
}
set layout(x){
}
get value(){
//dot code
}
set value(x){
}
}
customElements.define('dot-graph', DotGraphElement);