From 6f2fc57f29a90b02dad0bc98c20ec69ef90c39ef Mon Sep 17 00:00:00 2001
From: bobzel <zzzman@gmail.com>
Date: Fri, 25 Aug 2023 11:58:14 -0400
Subject: simplification of vizBoxes to use parentViz instead of going through
 links

---
 src/client/views/nodes/DataVizBox/components/TableBox.tsx | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

(limited to 'src/client/views/nodes/DataVizBox/components/TableBox.tsx')

diff --git a/src/client/views/nodes/DataVizBox/components/TableBox.tsx b/src/client/views/nodes/DataVizBox/components/TableBox.tsx
index e90b541ae..7bca08c15 100644
--- a/src/client/views/nodes/DataVizBox/components/TableBox.tsx
+++ b/src/client/views/nodes/DataVizBox/components/TableBox.tsx
@@ -41,17 +41,18 @@ export class TableBox extends React.Component<TableBoxProps> {
         this._inputChangedDisposer?.();
     }
     @computed get _tableDataIds() {
-        return !this.incomingLinks.length ? this.props.records.map((rec, i) => i) : NumListCast(this.incomingLinks[0].dataViz_selectedRows);
+        return !this.parentViz ? this.props.records.map((rec, i) => i) : NumListCast(this.parentViz.dataViz_selectedRows);
     }
     // returns all the data records that will be rendered by only returning those records that have been selected by the parent visualization (or all records if there is no parent)
     @computed get _tableData() {
-        return !this.incomingLinks.length ? this.props.records : this._tableDataIds.map(rowId => this.props.records[rowId]);
+        return !this.parentViz ? this.props.records : this._tableDataIds.map(rowId => this.props.records[rowId]);
     }
 
-    @computed get incomingLinks() {
-        return LinkManager.Instance.getAllRelatedLinks(this.props.rootDoc) // out of all links
-            .filter(link => link.link_anchor_1 == this.props.rootDoc.dataViz_parentViz) // get links where this chart doc is the target of the link
-            .map(link => DocCast(link.link_anchor_1)); // then return the source of the link
+    @computed get parentViz() {
+        return DocCast(this.props.rootDoc.dataViz_parentViz);
+        // return LinkManager.Instance.getAllRelatedLinks(this.props.rootDoc) // out of all links
+        //     .filter(link => link.link_anchor_1 == this.props.rootDoc.dataViz_parentViz) // get links where this chart doc is the target of the link
+        //     .map(link => DocCast(link.link_anchor_1)); // then return the source of the link
     }
 
     @computed get columns() {
@@ -105,7 +106,7 @@ export class TableBox extends React.Component<TableBoxProps> {
                                                         const embedding = Doc.MakeEmbedding(this.props.docView?.()!.rootDoc!);
                                                         embedding._dataViz = DataVizView.TABLE;
                                                         embedding._dataViz_axes = new List<string>([col, col]);
-                                                        embedding._dataViz_parentViz = this.props.docView?.()!.rootDoc!;
+                                                        embedding._dataViz_parentViz = this.props.rootDoc;
                                                         embedding.annotationOn = annotationOn; //this.props.docView?.()!.rootDoc!;
                                                         embedding.histogramBarColors = Field.Copy(this.props.layoutDoc.histogramBarColors);
                                                         embedding.defaultHistogramColor = this.props.layoutDoc.defaultHistogramColor;
-- 
cgit v1.2.3-70-g09d2

