Mercurial > code > home > repos > streamed-graph
changeset 27:e0f5da648199
fix getter, startup expanded state, better display before 1st data (but that one might not work)
author | drewp@bigasterisk.com |
---|---|
date | Fri, 13 Dec 2019 23:53:56 -0800 |
parents | 7fe46400f04b |
children | c751380b70c5 |
files | src/streamed-graph.ts |
diffstat | 1 files changed, 13 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/src/streamed-graph.ts Fri Dec 13 23:52:43 2019 -0800 +++ b/src/streamed-graph.ts Fri Dec 13 23:53:56 2019 -0800 @@ -10,7 +10,7 @@ import { GraphView } from './graph_view'; import { StreamedGraphClient } from './streamed_graph_client'; -interface VersionedGraph { version: number, store: N3Store|undefined }; +interface VersionedGraph { version: number, store: N3Store | undefined }; @customElement('streamed-graph') class StreamedGraph extends PolymerElement { @@ -23,8 +23,8 @@ @property({ type: Boolean }) expanded: boolean = false; - // @computed('expanded') - expandAction(): string { + @computed('expanded') + get expandAction() { return this.expanded ? '-' : '+'; } @@ -52,6 +52,9 @@ this.graphView = (this.shadowRoot as ShadowRoot).getElementById("graphView") as Element; this._onUrl(this.url); // todo: watch for changes and rebuild + if (this.expanded) { + this.redrawGraph(); + } } toggleExpand(ev: Event) { @@ -92,7 +95,12 @@ _redrawLater() { if (!this.graphViewDirty) return; - render(new GraphView(this.url, (this.graph as VersionedGraph).store as N3Store).makeTemplate(), this.graphView); - this.graphViewDirty = false; + + if ((this.graph as VersionedGraph).store && this.graph.store) { + render(new GraphView(this.url, this.graph.store).makeTemplate(), this.graphView); + this.graphViewDirty = false; + } else { + render(html`<span>waiting for data...</span>`, this.graphView); + } } } \ No newline at end of file