From 6f2fc57f29a90b02dad0bc98c20ec69ef90c39ef Mon Sep 17 00:00:00 2001 From: bobzel 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/PieChart.tsx | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'src/client/views/nodes/DataVizBox/components/PieChart.tsx') diff --git a/src/client/views/nodes/DataVizBox/components/PieChart.tsx b/src/client/views/nodes/DataVizBox/components/PieChart.tsx index 79d7b3f23..a8aa51897 100644 --- a/src/client/views/nodes/DataVizBox/components/PieChart.tsx +++ b/src/client/views/nodes/DataVizBox/components/PieChart.tsx @@ -42,11 +42,11 @@ export class PieChart extends React.Component { @observable _currSelected: any | undefined = undefined; // Object of selected slice @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]); } // organized by specified number percentages/ratios if one column is selected and it contains numbers @@ -78,10 +78,11 @@ export class PieChart extends React.Component { return ax1 + ' by ' + ax0 + ' Pie Chart'; } - @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 } componentWillUnmount() { @@ -343,7 +344,7 @@ export class PieChart extends React.Component { if (each[0] == curSelectedSliceName!) selectedSliceColor = each[1]; }); - if (this._piechartData.length > 0 || !this.incomingLinks || this.incomingLinks.length == 0) { + if (this._piechartData.length > 0 || !this.parentViz) { return this.props.axes.length >= 1 ? (
-- cgit v1.2.3-70-g09d2