forked from WICG/webcomponents
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtable-chart.html
65 lines (58 loc) · 2.24 KB
/
table-chart.html
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
<!DOCTYPE html>
<html>
<head>
<title>Web Components Example: Table-based Charts</title>
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Open+Sans:700|Droid+Sans+Mono|Ovo" type="text/css">
<link rel="stylesheet" href="../assets/styles/main.css" type="text/css">
<link rel="stylesheet" href="../assets/styles/prettify.css" type="text/css" />
<script src="../assets/scripts/bug-assist.js"></script>
<script src="../assets/scripts/prettify.js"></script>
<meta name="bug.blocked" content="14956">
<meta name="bug.short_desc" content="[Samples]: ">
<meta name="bug.product" content="WebAppsWG">
<meta name="bug.component" content="Component Model">
</head>
<body>
<header>
<ul>
<li><a href="../samples/index.html">Samples</a></li>
<li><a href="../explainer/index.html">Explainer</a></li>
<li><a href="../spec/shadow/index.html">Shadow DOM Spec</a></li>
<li><a href="../spec/templates/index.html">HTML Templates</a></li>
</ul>
<h2>Web Components Example</h2>
<h1>Table-based Charts</h1>
</header>
<pre class="prettyprint"><code>
<element extends="table" name="x-table-chart" constructor="TableChart">
<script>
this.lifecycle({
created: function(shadowRoot) {
this._canvas = shadowRoot.firstElementChild;
this.draw();
},
inserted: function() { this._visible = true; },
removed: function() { this._visible = false; }
});
TableChart.prototype.draw = function()
{
if (!this._visible)
return;
var type = this.chartType;
var color = this.chartColor;
var canvas = this._canvas;
// Read the table data and draw the graph on canvas.
// ...
this.dispatchEvent(new Event('draw'));
}
this.reflectAttribute('x-chart-type', 'chartType', TableChart.prototype.draw);
this.reflectAttribute('x-chart-color', 'chartColor', TableChart.prototype.draw);
this.setupEvent('draw');
</script>
<template>
<canvas></canvas>
</template>
</element>
</code></pre>
</body>
</html>