lightview 1.6.5-b → 1.7.2-b

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,8 +1,8 @@
1
- # lightview v1.6.5b (BETA)
1
+ # lightview v1.7.2b (BETA)
2
2
 
3
3
  Small, simple, powerful web UI and micro front end creation ...
4
4
 
5
- Great ideas from Svelte, React, Vue and Riot combined into one small tool: < 7K (minified/gzipped).
5
+ Great ideas from Svelte, React, Vue and Riot combined into one small tool: < 7.5K (minified/gzipped).
6
6
 
7
7
  See the docs and examples at [https://lightview.dev](https://lightview.dev).
8
8
 
@@ -36,7 +36,7 @@ Meanwhile, here is what you get:
36
36
 
37
37
  1) SPA, and MPA friendly ... somewhat SEO friendly and short steps away from fully SEO friendly.
38
38
 
39
- 1) A [component library](https://lightview.dev/components) including charts and gauges.
39
+ 1) A [component library](https://lightview.dev/components) including charts and gauges that work in Markdown files.
40
40
 
41
41
  1) Lots of live [editable examples](https://lightview.dev/#examples).
42
42
 
@@ -0,0 +1,15 @@
1
+ <html>
2
+ <head>
3
+ <meta charset="UTF-8">
4
+ <title>Lightview:Chart</title>
5
+ </head>
6
+ <body>
7
+ <div id="target"></div>
8
+ <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
9
+ <script src="https://unpkg.com/json5@^2.0.0/dist/index.min.js"></script>
10
+ <script type="lightview/module">
11
+ const {chart} = await import("/components/components.js");
12
+ chart(self);
13
+ </script>
14
+ </body>
15
+ </html>
@@ -0,0 +1,32 @@
1
+ <!DOCTYPE html>
2
+ <head>
3
+ <title>Lightview:Chart:Example</title>
4
+ <link href="./chart.html" rel="module">
5
+ <script src="../../lightview.js"></script>
6
+ </head>
7
+ <body>
8
+ <l-chart id="myPieChart" type="PieChart" style="height:500px;" title="How Much Pizza I Ate Last Night">
9
+ {
10
+ options: { },
11
+ columns: [
12
+ {label: "Topping", type: "string"},
13
+ {label: "Slices", type: "number"}
14
+ ],
15
+ rows: [
16
+ ["Mushrooms", 3],
17
+ ["Onions", 1],
18
+ ["Olives", 1],
19
+ ["Zucchini", 1],
20
+ ["Pepperoni", 2]
21
+ ]
22
+ }
23
+ </l-chart>
24
+ <script>
25
+ const el = document.getElementById("myChart");
26
+ el.addEventListener("mounted",() => {
27
+ chart = el.chart;
28
+ chart.addRow(["Anchovies",1]);
29
+ });
30
+ </script>
31
+ </body>
32
+ </html>
@@ -8,6 +8,10 @@
8
8
  <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
9
9
  <script src="https://unpkg.com/json5@^2.0.0/dist/index.min.js"></script>
10
10
  <script type="lightview/module">
11
+ let table = JSON5.parse(self.firstChild.textContent.trim()),
12
+ chart,
13
+ datatable,
14
+ options = {};
11
15
  const target = self.getElementById("target"),
12
16
  resizeObserver = new ResizeObserver(entries => {
13
17
  for (let entry of entries) {
@@ -20,10 +24,19 @@
20
24
  }
21
25
  }
22
26
  chart.draw(datatable, options);
23
- });
24
- let chart,
25
- datatable,
26
- options = {};
27
+ }),
28
+ callback = (textNode, oldValue, newValue) => {
29
+ datatable = new google.visualization.DataTable();
30
+ try {
31
+ table = table || JSON5.parse(newValue.trim());
32
+ datatable = google.visualization.arrayToDataTable(table);
33
+ chart.draw(datatable, options);
34
+ table = null;
35
+ } catch (e) {
36
+ target.innerText = e + newValue;
37
+ }
38
+ };
39
+ self.firstChild.innerText = "Loading ...";
27
40
  self.variables({type: "string", title: "string", style: "string"}, {observed});
28
41
  if(style) target.setAttribute("style",style);
29
42
  self.addRow = (row) => {
@@ -40,21 +53,8 @@
40
53
  Object.assign(options,newOptions);
41
54
  };
42
55
  self.init = () => {
43
- const node = self.firstChild,
44
- callback = (textNode, oldValue, newValue) => {
45
- datatable = new google.visualization.DataTable();
46
- try {
47
- const table = JSON5.parse(newValue.trim());
48
- datatable = google.visualization.arrayToDataTable(table);
49
- chart.draw(datatable, options);
50
- } catch (e) {
51
- target.innerText = e + newValue;
52
- }
53
- };
54
56
  if(!options.title && title) options.title = title;
55
57
  chart = new google.visualization[type](target);
56
- node.characterDataMutationCallback = callback;
57
- callback(node, node.textContent, node.textContent);
58
58
  addEventListener("change",({target,value}) => {
59
59
  if (target === "type") {
60
60
  chart = new google.visualization[type](target);
@@ -65,8 +65,12 @@
65
65
  }
66
66
  chart.draw(datatable, options);
67
67
  });
68
+ const node = self.firstChild;
69
+ callback(node, node.textContent, node.textContent);
70
+ // Will be used by the Lightview global observer
71
+ node.characterDataMutationCallback = callback;
72
+ // resized charts if window resizes
68
73
  resizeObserver.observe(target);
69
- self.removeAttribute("hidden");
70
74
  };
71
75
  self.addEventListener("connected", ({target}) => {
72
76
  google.charts.load("current", {"packages": ["corechart","gauge"]});
@@ -0,0 +1,93 @@
1
+ const chart = (self,{packages = ["corechart"],options={},columns=[],rows=[],type,rowTransform}={}) => {
2
+ options = {...options};
3
+ columns = [...columns];
4
+ let chart,
5
+ datatable;
6
+ const chartProxy = (chart) => {
7
+ const extras = {
8
+ setOption(name,value) {
9
+ options[name] = value;
10
+ chart.draw(datatable, options);
11
+ },
12
+ setOptions(newOptions) {
13
+ options = {...newOptions};
14
+ chart.draw(datatable, options);
15
+ }
16
+ };
17
+ return new Proxy(chart,{
18
+ get(target,property) {
19
+ let value = extras[property];
20
+ if(value!==undefined) return value;
21
+ value = target[property];
22
+ if(value!==undefined) return Reflect.get(target,property);
23
+ value = datatable[property];
24
+ if(typeof(value)==="function") {
25
+ if(["add","insert","remove","set"].some((prefix) => property.startsWith(prefix))) {
26
+ return (...args) => { value.call(datatable,...args); chart.draw(datatable,options); };
27
+ };
28
+ return value.bind(datatable);
29
+ };
30
+ }
31
+ });
32
+ };
33
+ const target = self.getElementById("target"),
34
+ resizeObserver = new ResizeObserver(entries => {
35
+ for (let entry of entries) {
36
+ if(entry.contentBoxSize) {
37
+ // Firefox implements `contentBoxSize` as a single content rect, rather than an array
38
+ const contentBoxSize = Array.isArray(entry.contentBoxSize) ? entry.contentBoxSize[0] : entry.contentBoxSize;
39
+ options.width = contentBoxSize.inlineSize;
40
+ } else {
41
+ options.width = entry.contentRect.width;
42
+ }
43
+ }
44
+ chart.draw(datatable, options);
45
+ }),
46
+ callback = (textNode, oldValue, newValue) => {
47
+ datatable = new google.visualization.DataTable();
48
+ try {
49
+ const config = JSON5.parse(newValue.trim());
50
+ if(config.options) options=config.options;
51
+ if(config.columns) columns=config.columns;
52
+ if(config.rows) rows=config.rows;
53
+ columns.forEach((column) => {
54
+ datatable.addColumn(column);
55
+ });
56
+ if(rowTransform) rows = rows.map((row) => rowTransform(row));
57
+ datatable.addRows(rows);
58
+ chart.draw(datatable, options);
59
+ } catch (e) {
60
+ target.innerText = e + newValue;
61
+ }
62
+ };
63
+ self.firstChild.innerText = "Loading ...";
64
+ self.variables({type: "string", title: "string", style: "string"}, {observed:true});
65
+ if(self.hasAttribute("style")) target.setAttribute("style",self.getAttribute("style"));
66
+ self.init = () => {
67
+ if(!options.title && self.hasAttribute("title")) options.title = self.getAttribute("title");
68
+ self.chart = chart = chartProxy(new google.visualization[type||self.getAttribute("type")](target));
69
+ addEventListener("change",({target,value}) => {
70
+ if (target === "type") {
71
+ chart = new google.visualization[type](target);
72
+ } else if (target === "title") {
73
+ options.title = value;
74
+ } else if(target === "style") {
75
+ target.setAttribute("style",value);
76
+ }
77
+ chart.draw(datatable, options);
78
+ });
79
+ const node = self.firstChild;
80
+ callback(node, node.textContent, node.textContent);
81
+ // Will be used by the Lightview global observer
82
+ node.characterDataMutationCallback = callback;
83
+ // resized charts if window resizes
84
+ resizeObserver.observe(target);
85
+ self.dispatchEvent(new Event("mounted"));
86
+ };
87
+ self.addEventListener("connected", ({target}) => {
88
+ google.charts.load("current", {"packages":packages});
89
+ google.charts.setOnLoadCallback(self.init);
90
+ });
91
+ }
92
+
93
+ export {chart};
@@ -0,0 +1,27 @@
1
+ <!DOCTYPE html>
2
+ <head>
3
+ <title>Lightview:Chart:Example</title>
4
+ <link href="./gantt.html" rel="module">
5
+ <script src="../../lightview.js"></script>
6
+ </head>
7
+ <body>
8
+ <l-gantt id="myChart" style="height:500px;" title="Research Project">
9
+ {
10
+ options: { },
11
+ rows: [
12
+ ['Research', 'Find sources',"2015-01-01", "2015-01-05", null, 100, null],
13
+ ['Write', 'Write paper',null,"2015-01-09", "3d", 25, 'Research,Outline'],
14
+ ['Cite', 'Create bibliography',null, "2015-01-07","1d" , 20, 'Research'],
15
+ ['Complete', 'Hand in paper', null, "2015-01-10", "1d" , 0, 'Cite,Write'],
16
+ ['Outline', 'Outline paper', null, "2015-01-06", "1d" , 100, 'Research']
17
+ ]
18
+ }
19
+ </l-gantt>
20
+ <script>
21
+ const el = document.getElementById("myChart");
22
+ el.addEventListener("mounted",() => {
23
+ chart = el.chart;
24
+ });
25
+ </script>
26
+ </body>
27
+ </html>
@@ -0,0 +1,34 @@
1
+ <html>
2
+ <head>
3
+ <title>Lightview:Gantt</title>
4
+ </head>
5
+ <body>
6
+ <div id="target"></div>
7
+ <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
8
+ <script src="https://unpkg.com/json5@^2.0.0/dist/index.min.js"></script>
9
+ <script type="lightview/module">
10
+ const {chart} = await import("/components/components.js"),
11
+ {duration} = await import("/types.js");
12
+ chart(self,{
13
+ packages:["gantt"],
14
+ columns:[
15
+ {label:"Task ID",type:"string"},
16
+ {label:"Task Name",type:"string"},
17
+ {label:"Start Date",type:"date"},
18
+ {label:"End Date",type:"date"},
19
+ {label:"Duration",type:"number"},
20
+ {label:"% Complete",type:"number"},
21
+ {label:"Dependencies",type:"string"}
22
+ ],
23
+ type:"Gantt",
24
+ rowTransform(row) {
25
+ return row.map((item,index) => {
26
+ if(item && (index===2 || index===3)) return new Date(item);
27
+ if(item && index===4) return duration.parse(item);
28
+ return item;
29
+ })
30
+ }
31
+ });
32
+ </script>
33
+ </body>
34
+ </html>
@@ -0,0 +1,28 @@
1
+ <!DOCTYPE html>
2
+ <head>
3
+ <title>Lightview:Gauge:Example</title>
4
+ <link href="./gauge.html" rel="module">
5
+ <script src="../../lightview.js"></script>
6
+ </head>
7
+ <body>
8
+ <l-gauge id="myChart" style="height:500px;" title="Server" hidden l-unhide>
9
+ {
10
+ options: {
11
+
12
+ },
13
+ rows: [
14
+ ['Memory', 80],
15
+ ['CPU', 55],
16
+ ['Network', 68]
17
+ ]
18
+ }
19
+ </l-gauge>
20
+ <script>
21
+ const el = document.getElementById("myChart");
22
+ el.addEventListener("mounted",() => {
23
+ chart = el.chart;
24
+ chart.addRow(["Storage",10]);
25
+ });
26
+ </script>
27
+ </body>
28
+ </html>
@@ -0,0 +1,19 @@
1
+ <html>
2
+ <head>
3
+ <meta charset="UTF-8">
4
+ <title>Lightview:Gauge</title>
5
+ </head>
6
+ <body>
7
+ <div id="target"></div>
8
+ <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
9
+ <script src="https://unpkg.com/json5@^2.0.0/dist/index.min.js"></script>
10
+ <script type="lightview/module">
11
+ const {chart} = await import("/components/components.js");
12
+ chart(self,{
13
+ packages:["corechart","gauge"],
14
+ columns:[{label:"Label",type:"string"},{label:"Value",type:"number"}],
15
+ type:"Gauge"
16
+ });
17
+ </script>
18
+ </body>
19
+ </html>
@@ -0,0 +1,81 @@
1
+ <html>
2
+ <head>
3
+ <meta charset="UTF-8">
4
+ <title>Lightview:Timeline</title>
5
+ </head>
6
+ <body hidden>
7
+ <div id="target"></div>
8
+ <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
9
+ <script src="https://unpkg.com/json5@^2.0.0/dist/index.min.js"></script>
10
+ <script type="lightview/module">
11
+ debugger;
12
+ let table = JSON5.parse(self.firstChild.textContent.trim()),
13
+ chart,
14
+ datatable,
15
+ options = {};
16
+ const target = self.getElementById("target"),
17
+ resizeObserver = new ResizeObserver(entries => {
18
+ for (let entry of entries) {
19
+ if(entry.contentBoxSize) {
20
+ // Firefox implements `contentBoxSize` as a single content rect, rather than an array
21
+ const contentBoxSize = Array.isArray(entry.contentBoxSize) ? entry.contentBoxSize[0] : entry.contentBoxSize;
22
+ options.width = contentBoxSize.inlineSize;
23
+ } else {
24
+ options.width = entry.contentRect.width;
25
+ }
26
+ }
27
+ chart.draw(datatable, options);
28
+ }),
29
+ callback = (textNode, oldValue, newValue) => {
30
+ datatable = new google.visualization.DataTable();
31
+ try {
32
+ table = table || JSON5.parse(newValue.trim());
33
+ datatable = google.visualization.arrayToDataTable(table);
34
+ chart.draw(datatable, options);
35
+ table = null;
36
+ } catch (e) {
37
+ target.innerText = e + newValue;
38
+ }
39
+ };
40
+ self.firstChild.innerText = "Loading ...";
41
+ self.variables({type: "string", title: "string", style: "string"}, {observed});
42
+ if(style) target.setAttribute("style",style);
43
+ self.addRow = (row) => {
44
+ datatable.addRows([row]);
45
+ chart.draw(datatable, options);
46
+ };
47
+ self.setValue = (row,col,value) => {
48
+ if(datatable) {
49
+ datatable.setValue(row,col,value);
50
+ chart.draw(datatable, options);
51
+ }
52
+ };
53
+ self.setOptions = (newOptions) => {
54
+ Object.assign(options,newOptions);
55
+ };
56
+ self.init = () => {
57
+ if(!options.title && title) options.title = title;
58
+ chart = new google.visualization.Timeline(target);
59
+ addEventListener("change",({target,value}) => {
60
+ if(target === "title") {
61
+ options.title = value;
62
+ } else if(target === "style") {
63
+ target.setAttribute("style",value);
64
+ }
65
+ chart.draw(datatable, options);
66
+ });
67
+
68
+ const node = self.firstChild;
69
+ callback(node, node.textContent, node.textContent);
70
+ // Will be used by the Lightview global observer
71
+ node.characterDataMutationCallback = callback;
72
+ // resized charts if window resizes
73
+ resizeObserver.observe(target);
74
+ };
75
+ self.addEventListener("connected", ({target}) => {
76
+ google.charts.load("current", {"packages": ["timeline"]});
77
+ google.charts.setOnLoadCallback(self.init);
78
+ });
79
+ </script>
80
+ </body>
81
+ </html>
@@ -5,7 +5,7 @@
5
5
 
6
6
  <body>
7
7
  <p>
8
- <button l-on:click="bump">Click count:${count}</button>
8
+ <button l-on:click="${bump}">Click count:${count}</button>
9
9
  </p>
10
10
 
11
11
  <script type="lightview/module">
@@ -12,24 +12,38 @@
12
12
  The component below is loaded from an alternate domain and running in a child iframe.
13
13
  The logging console is below the component in this frame.
14
14
  </p>
15
- <iframe id="myframe" src="https://lightview.dev/foreignform.html?id=myframe"></iframe>
15
+ <p>New Order:<span id="orderclip"></span></p>
16
+ <iframe id="myframe"
17
+ class="l-remote" style="border-width:2px;border-style:dashed;"
18
+ src="https://lightview.dev/examples/foreignform.html?id=myframe"></iframe>
16
19
  <div id="console" style="max-height:250px;scroll:auto"></div>
17
20
  <script>
18
- const mutationCallback = (mutationsList) => {
19
- const console = document.getElementById("console");
20
- for (const {target,attributeName,oldValue} of mutationsList) {
21
- const line = document.createElement("div"),
22
- event = {attributeName,oldValue,value:target.getAttribute(attributeName)};
23
- line.innerText = JSON.stringify(event);
24
- console.appendChild(line);
25
- }
26
- };
27
- const observer = new MutationObserver(mutationCallback),
28
- iframe = document.getElementById("myframe");
29
- observer.observe(iframe, { attributes:true, attributeOldValue: true });
21
+ const iframe = document.getElementById("myframe");
30
22
  iframe.addEventListener("DOMContentLoaded",(event) => {
23
+ // modify the line below, or remove this event listener
24
+ // based on the needs of your application
31
25
  console.log(event);
32
26
  });
27
+ iframe.addEventListener("message",({detail}) => {
28
+ // modify the lines below, or remove this event listener
29
+ // based on the needs of your application
30
+ const orderclip = document.getElementById("orderclip");
31
+ orderclip.innerText = JSON.stringify(detail);
32
+ });
33
+
34
+ iframe.addEventListener("attribute.changed",(event) => {
35
+ const {target,detail} = event,
36
+ {attributeName,value,oldValue} = detail;
37
+ event.stopImmediatePropagation();
38
+ if(target.getAttribute(attributeName)!==oldValue) {
39
+ // modify the lines below, or remove this event listener
40
+ // based on the needs of your application
41
+ const console = document.getElementById("console"),
42
+ line = document.createElement("div");
43
+ line.innerText = JSON.stringify(detail);
44
+ console.appendChild(line);
45
+ }
46
+ });
33
47
  </script>
34
48
  </body>
35
49
 
@@ -27,7 +27,9 @@
27
27
  <option>tomato</option>
28
28
  <option>cheese</option>
29
29
  </select>
30
+ <br><button l-on:click="${placeOrder}">Place Order</button>
30
31
  </p>
32
+ Expose: <input type="checkbox" value="${checked}">
31
33
  <p l-if="${checked}">
32
34
  Now you've done it. You've exposed me.
33
35
  </p>
@@ -45,24 +47,43 @@
45
47
  </p>
46
48
  </div>
47
49
  <script type="lightview/module">
50
+ const orders = [];
51
+ self.variables({
52
+ checked: "boolean"
53
+ }, {
54
+ reactive
55
+ });
48
56
  self.variables({
49
57
  color: "string",
50
- checked: "boolean",
51
58
  hamburger: Array
52
59
  }, {
53
- reactive
60
+ reactive, exported
61
+ });
62
+ self.addEventListener("connected",() => {
63
+ color = "green";
64
+ checked = true;
65
+ hamburger = ["lettuce"];
54
66
  });
55
- color = "green";
56
- checked = true;
57
- hamburger = ["lettuce"];
67
+ self.placeOrder = () => {
68
+ orders.push(hamburger);
69
+ message = {hamburger};
70
+ };
58
71
  // demo instrumentation
59
72
  const variableValues = () => {
60
73
  const el = self.getElementById("variables");
61
74
  while (el.lastElementChild) el.lastElementChild.remove();
62
75
  self.getVariableNames().forEach((name) => {
63
- const line = document.createElement("div");
64
- line.innerText = `${name} = ${JSON.stringify(self.getVariableValue(name))}`;
65
- el.appendChild(line);
76
+ const line = document.createElement("div");
77
+ line.innerText = `${name} = ${JSON.stringify(self.getVariableValue(name))}`;
78
+ el.appendChild(line);
79
+ });
80
+ const line = document.createElement("div");
81
+ line.innerText = "Previous Orders";
82
+ el.appendChild(line);
83
+ orders.forEach((order) => {
84
+ const line = document.createElement("div");
85
+ line.innerText = JSON.stringify(order);
86
+ el.appendChild(line);
66
87
  });
67
88
  };
68
89
  variableValues();
@@ -38,7 +38,7 @@
38
38
  addEventListener("change", () => {
39
39
  variableValues()
40
40
  });
41
- addEventListener("connected",() => {
41
+ self.addEventListener("connected",() => {
42
42
  color = "yellow";
43
43
  checked = true;
44
44
  hamburger = ["cheese"];
@@ -6,7 +6,7 @@
6
6
  </head>
7
7
  <body>
8
8
  <p>
9
- <button l-on:click="bump">Click count:${count}</button>
9
+ <button l-on:click="${bump}">Click count:${count}</button>
10
10
  </p>
11
11
  <div style="margin:20px">
12
12
  <p>
@@ -24,9 +24,6 @@
24
24
  <p>
25
25
  ${function(){return \${test}})()}
26
26
  </p>
27
- <p>
28
- ${window.alert("ok")}
29
- </p>
30
27
  </div>
31
28
 
32
29
  <script type="lightview/module">
@@ -15,11 +15,12 @@
15
15
  </head>
16
16
  <body>
17
17
  <!--
18
- layout the dashboad using the chart component r-chart
18
+ layout the dashboard using the chart component r-chart
19
19
  -->
20
20
  <div style="width:100%;text-align:center">
21
21
  <!--
22
22
  set the initial value 0 for all components in a relaxed JSON5 configuration data block
23
+ add the attributes hidden and l-unhide to eliminate flicker and display of Loading ....
23
24
  -->
24
25
  <r-chart id="dashboard" style="display:inline-block" type="Gauge" title="Server Status">
25
26
  [
@@ -6,7 +6,6 @@
6
6
  <body>
7
7
  ${value}
8
8
  <script type="lightview/module">
9
- debugger;
10
9
  self.variables({value:"string"},{imported});
11
10
  </script>
12
11
  </body>
@@ -0,0 +1,32 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+
4
+ <head>
5
+ <title>Form</title>
6
+ <script src="../lightview.js?as=x-body"></script>
7
+ </head>
8
+
9
+ <body>
10
+ <form value="${hamburger}" style="margin:20px;padding:5px;border:1px;border-style:solid;">
11
+ <div>Hamburger options:</div>
12
+ <select value="${hamburger.options}" multiple>
13
+ <option value="lettuce">lettuce</option>
14
+ <option value="tomato">tomato</option>
15
+ <option>cheese</option>
16
+ </select>
17
+ <p id="variables">
18
+
19
+ </p>
20
+ </form>
21
+ <script type="lightview/module">
22
+ self.addEventListener("connected",() => {
23
+ hamburger.options = ["cheese"];
24
+ observe(() => {
25
+ const el = self.getElementById("variables");
26
+ el.innerText = JSON.stringify(hamburger);
27
+ });
28
+ });
29
+ </script>
30
+ </body>
31
+
32
+ </html>
@@ -1 +1 @@
1
- {"name":"joe","age":30}
1
+ {"name":"joe","age":40}
@@ -0,0 +1,21 @@
1
+ <!DOCTYPE html>
2
+ <head>
3
+ <title>Chart</title>
4
+ <link href="../components/timeline.html" rel="module">
5
+ <script src="../lightview.js"></script>
6
+ </head>
7
+ <body>
8
+ <l-timeline id="myPieChart" style="max-width:750px" type="PieChart" title="How Much Pizza I Ate Last Night">
9
+ // Chart will resize automatically to a max-width of 750px and repaint on type and title changes.
10
+ // The component DOM element also exposes a method `el.addRow(row:array)` to dynamically add data
11
+ // And, `el.init()` will re-render from the initial data and current attributes.
12
+ [
13
+ [{ type: 'string', id: 'Position' },{ type: 'string', id: 'Name' },{ type: 'date', id: 'Start' },{ type: 'date', id: 'End' }],
14
+ [ '1', 'George Washington', '1789-03-30','1797-02-04'] // Date(1789, 3, 30), Date(1797, 2, 4)
15
+ //[ '2', 'John Adams', Date(1797, 2, 4), Date(1801, 2, 4) ],
16
+ //[ '3', 'Thomas Jefferson', Date(1801, 2, 4), Date(1809, 2, 4) ]]);
17
+ ]
18
+ </l-timeline>
19
+
20
+ </body>
21
+ </html>