aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/nodes/DataVizBox/components/TableBox.tsx
diff options
context:
space:
mode:
authorsrichman333 <sarah_n_richman@brown.edu>2023-08-08 16:15:36 -0400
committersrichman333 <sarah_n_richman@brown.edu>2023-08-08 16:15:36 -0400
commit318d56e1dff94204b100f5636e1a3288724aaffc (patch)
treeb89705e59e3fc4ed4177ddde7361de0e60fb32c5 /src/client/views/nodes/DataVizBox/components/TableBox.tsx
parent5614478b54b754665faff41c9a09b9bd0535e2f5 (diff)
comments + cleanups
Diffstat (limited to 'src/client/views/nodes/DataVizBox/components/TableBox.tsx')
-rw-r--r--src/client/views/nodes/DataVizBox/components/TableBox.tsx7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/client/views/nodes/DataVizBox/components/TableBox.tsx b/src/client/views/nodes/DataVizBox/components/TableBox.tsx
index 38dd62d8d..277ee83ec 100644
--- a/src/client/views/nodes/DataVizBox/components/TableBox.tsx
+++ b/src/client/views/nodes/DataVizBox/components/TableBox.tsx
@@ -32,6 +32,7 @@ interface TableBoxProps {
@observer
export class TableBox extends React.Component<TableBoxProps> {
+ // filters all data to just display selected data if brushed (created from an incoming link)
@computed get _tableData() {
if (this.incomingLinks.length! <= 0) return this.props.pairs;
var guids = StrListCast(this.props.layoutDoc.rowGuids);
@@ -52,6 +53,7 @@ export class TableBox extends React.Component<TableBoxProps> {
return this._tableData.length ? Array.from(Object.keys(this._tableData[0])).filter(header => header!='' && header!=undefined) : [];
}
+ // updates the 'selected' field to no longer include rows that aren't in the table
filterSelectedRowsDown() {
if (!this.props.layoutDoc.selected) this.props.layoutDoc.selected = new List<string>();
const selected = Cast(this.props.layoutDoc.selected, listSpec("string"), null);
@@ -88,7 +90,7 @@ export class TableBox extends React.Component<TableBoxProps> {
setupMoveUpEvents(
{},
e,
- e => {
+ e => { // dragging off a column to create a brushed DataVizBox
const sourceAnchorCreator = () => this.props.docView?.()!.rootDoc!;
const targetCreator = (annotationOn: Doc | undefined) => {
const embedding = Doc.MakeEmbedding(this.props.docView?.()!.rootDoc!);
@@ -144,6 +146,7 @@ export class TableBox extends React.Component<TableBoxProps> {
if (containsData){
return (
<tr key={i} className="table-row" onClick={action(e => {
+ // selecting a row
const selected = Cast(this.props.layoutDoc.selected, listSpec("string"), null);
if (selected.includes(guid)) selected.splice(selected.indexOf(guid), 1);
else {
@@ -153,6 +156,7 @@ export class TableBox extends React.Component<TableBoxProps> {
background: StrListCast(this.props.layoutDoc.selected).includes(guid) ? 'lightgrey' : '' }}>
{this.columns.map(col => (
(this.props.layoutDoc.selected)?
+ // each cell
<td key={this.columns.indexOf(col)} style={{border: '1px solid black'}}>
{p[col]}
</td>
@@ -168,6 +172,7 @@ export class TableBox extends React.Component<TableBoxProps> {
);
}
else return (
+ // when it is a brushed table and the incoming table doesn't have any rows selected
<div className='chart-container'>
Selected rows of data from the incoming DataVizBox to display.
</div>