forked from barrycorcoran/barrycorcoran.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
87 lines (78 loc) · 2.09 KB
/
main.js
File metadata and controls
87 lines (78 loc) · 2.09 KB
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
var getScriptPromisify = (src) => {
return new Promise((resolve) => {
$.getScript(src, resolve);
});
};
(function () {
const prepared = document.createElement("template");
prepared.innerHTML = `
<style>
</style>
<div id="root" style="width: 100%; height: 100%;">
</div>
`;
class SamplePiePrepared extends HTMLElement {
constructor() {
super();
this._shadowRoot = this.attachShadow({ mode: "open" });
this._shadowRoot.appendChild(prepared.content.cloneNode(true));
this._root = this._shadowRoot.getElementById("root");
this._props = {};
this.render();
}
onCustomWidgetResize(width, height) {
this.render();
}
async render() {
await getScriptPromisify(
"https://cdn.bootcdn.net/ajax/libs/echarts/5.0.0/echarts.min.js"
);
const chart = echarts.init(this._root);
const option = {
tooltip: {
trigger: "item",
},
legend: {
top: "5%",
left: "center",
},
series: [
{
name: "Access From",
type: "pie",
radius: ["40%", "70%"],
avoidLabelOverlap: false,
itemStyle: {
borderRadius: 10,
borderColor: "#fff",
borderWidth: 2,
},
label: {
show: false,
position: "center",
},
emphasis: {
label: {
show: true,
fontSize: "40",
fontWeight: "bold",
},
},
labelLine: {
show: false,
},
data: [
{ value: 1048, name: "Search Engine" },
{ value: 735, name: "Direct" },
{ value: 580, name: "Email" },
{ value: 484, name: "Union Ads" },
{ value: 300, name: "Video Ads" },
],
},
],
};
chart.setOption(option);
}
}
customElements.define("github-sap-demo-sample-chart", SamplePiePrepared);
})();