Mercurial > code > home > repos > streamed-graph
diff src/streamed-graph.ts @ 8:6fefd287aff9
closer- element now holds a changing graph, but can't draw it yet
author | drewp@bigasterisk.com |
---|---|
date | Thu, 05 Dec 2019 01:32:13 -0800 |
parents | a5bc13dcce41 |
children | 26d3e4860adc |
line wrap: on
line diff
--- a/src/streamed-graph.ts Wed Dec 04 23:44:29 2019 -0800 +++ b/src/streamed-graph.ts Thu Dec 05 01:32:13 2019 -0800 @@ -6,21 +6,18 @@ import { PolymerElement, html } from '@polymer/polymer'; import { customElement, property, computed } from '@polymer/decorators'; import { render } from 'lit-html'; -// import { graphView } from '/rdf/browse/graphView.js'; - - +import { graphView } from './graph_view'; +import { Store, DataFactory } from "n3" import { StreamedGraphClient } from './streamed_graph_client'; -console.log(StreamedGraphClient); - @customElement('streamed-graph') class StreamedGraph extends PolymerElement { @property({ type: String }) url: string = ''; @property({ type: Object }) - graph: Object; + graph: {version: number, graph: Store}; @property({ type: Boolean }) expanded: Boolean = false; @@ -45,13 +42,15 @@ StreamedGraph <a href="{{url}}">[source]</a>: {{status}} </div> - <div id="graphView">graph here - </div>`; + <div id="graphView"></div>`; } ready() { super.ready(); + this.graph = {version: -1, graph: null}; this.graphView = this.shadowRoot.getElementById("graphView"); + + this._onUrl(this.url); // todo: watch for changes and rebuild } toggleExpand(ev) { @@ -70,17 +69,18 @@ } _onUrl(url) { - // if (this.sg) { this.sg.close(); } - // this.sg = new StreamedGraphClient( - // url, - // this.onGraphChanged.bind(this), - // this.set.bind(this, 'status'), - // [],//window.NS, - // []); + if (this.sg) { this.sg.close(); } + this.sg = new StreamedGraphClient( + url, + this.onGraphChanged.bind(this), + this.set.bind(this, 'status'), + [],//window.NS, + [] + ); } onGraphChanged() { - //this.graph = { version: this.graph.version + 1, graph: this.sg }; + this.graph = { version: this.graph.version + 1, graph: this.sg.store }; if (this.expanded) { this.redrawGraph(); } @@ -88,7 +88,7 @@ _redrawLater() { if (!this.graphViewDirty) return; - //render(graphView(this.graph.graph), this.graphView); + render(graphView(this.graph.graph), this.graphView); this.graphViewDirty = false; }