aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/nodes/DataVizBox/components/TableBox.tsx
diff options
context:
space:
mode:
authorbobzel <zzzman@gmail.com>2023-08-17 10:00:10 -0400
committerbobzel <zzzman@gmail.com>2023-08-17 10:00:10 -0400
commit0eb9d37a9dd1a6539f331f953d5f20c761d5f940 (patch)
tree66a1796a3311a48c58e3458cb514777f4d788f5c /src/client/views/nodes/DataVizBox/components/TableBox.tsx
parentd1e31265f8707bea63e21bf9a7b1dd10ccbf2009 (diff)
fixed brushing of pinned viewports for chrome to not flash. converted pres<Property> to config_<property> and treeView<Property> to treeView_Property. fixed text toolbar to show/set text properties based on insertion point.
Diffstat (limited to 'src/client/views/nodes/DataVizBox/components/TableBox.tsx')
-rw-r--r--src/client/views/nodes/DataVizBox/components/TableBox.tsx87
1 files changed, 48 insertions, 39 deletions
diff --git a/src/client/views/nodes/DataVizBox/components/TableBox.tsx b/src/client/views/nodes/DataVizBox/components/TableBox.tsx
index f56d34fa6..5579d6d80 100644
--- a/src/client/views/nodes/DataVizBox/components/TableBox.tsx
+++ b/src/client/views/nodes/DataVizBox/components/TableBox.tsx
@@ -1,4 +1,4 @@
-import { action, computed, } from 'mobx';
+import { action, computed } from 'mobx';
import { observer } from 'mobx-react';
import * as React from 'react';
import { Doc, Field, StrListCast } from '../../../../../fields/Doc';
@@ -31,44 +31,45 @@ 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);
- return this.props.pairs?.filter(pair => this.incomingLinks[0]!.selected && StrListCast(this.incomingLinks[0].selected).includes(guids[this.props.pairs.indexOf(pair)]))
+ var guids = StrListCast(this.props.layoutDoc.dataViz_rowGuids);
+ return this.props.pairs?.filter(pair => this.incomingLinks[0]!.dataViz_selectedRows && StrListCast(this.incomingLinks[0].dataViz_selectedRows).includes(guids[this.props.pairs.indexOf(pair)]));
}
@computed get incomingLinks() {
return LinkManager.Instance.getAllRelatedLinks(this.props.rootDoc) // out of all links
.filter(link => {
- return link.link_anchor_1 == this.props.rootDoc.draggedFrom}) // get links where this chart doc is the target of the link
+ return link.link_anchor_1 == this.props.rootDoc.draggedFrom;
+ }) // 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() {
- if (!this.props.layoutDoc.rowGuids) this.props.layoutDoc.rowGuids = new List<string>();
- const guids = Cast(this.props.layoutDoc.rowGuids, listSpec("string"), null);
- if (guids.length==0) this.props.pairs.map(row => guids.push(Utils.GenerateGuid()));
- return this._tableData.length ? Array.from(Object.keys(this._tableData[0])).filter(header => header!='' && header!=undefined) : [];
+ if (!this.props.layoutDoc.dataViz_rowGuids) this.props.layoutDoc.dataViz_rowGuids = new List<string>();
+ const guids = Cast(this.props.layoutDoc.dataViz_rowGuids, listSpec('string'), null);
+ if (guids.length == 0) this.props.pairs.map(row => guids.push(Utils.GenerateGuid()));
+ 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);
- const incomingSelected = this.incomingLinks.length? StrListCast(this.incomingLinks[0].selected) : undefined;
- if (incomingSelected){
+ if (!this.props.layoutDoc.dataViz_selectedRows) this.props.layoutDoc.dataViz_selectedRows = new List<string>();
+ const selected = Cast(this.props.layoutDoc.dataViz_selectedRows, listSpec('string'), null);
+ const incomingSelected = this.incomingLinks.length ? StrListCast(this.incomingLinks[0].dataViz_selectedRows) : undefined;
+ if (incomingSelected) {
selected.map(guid => {
- if (!incomingSelected.includes(guid)) selected.splice(selected.indexOf(guid), 1)}); // filters through selected to remove guids that were removed in the incoming data
+ if (!incomingSelected.includes(guid)) selected.splice(selected.indexOf(guid), 1);
+ }); // filters through selected to remove guids that were removed in the incoming data
}
}
render() {
this.filterSelectedRowsDown();
- if (this._tableData.length>0){
+ if (this._tableData.length > 0) {
return (
- <div className="table-container" style={{height: this.props.height}}>
+ <div className="table-container" style={{ height: this.props.height }}>
<table className="table">
<thead>
<tr className="table-row">
@@ -83,7 +84,8 @@ export class TableBox extends React.Component<TableBoxProps> {
style={{
color: this.props.axes.slice().reverse().lastElement() === col ? 'darkgreen' : this.props.axes.lastElement() === col ? 'darkred' : undefined,
background: this.props.axes.slice().reverse().lastElement() === col ? '#E3fbdb' : this.props.axes.lastElement() === col ? '#Fbdbdb' : undefined,
- fontWeight: 'bolder', border: '3px solid black'
+ fontWeight: 'bolder',
+ border: '3px solid black',
}}
onPointerDown={e => {
const downX = e.clientX;
@@ -91,12 +93,13 @@ export class TableBox extends React.Component<TableBoxProps> {
setupMoveUpEvents(
{},
e,
- e => { // dragging off a column to create a brushed DataVizBox
+ 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!);
- embedding._dataVizView = DataVizView.TABLE;
- embedding._data_vizAxes = new List<string>([col, col]);
+ embedding._dataViz = DataVizView.TABLE;
+ embedding._dataViz_axes = new List<string>([col, col]);
embedding._draggedFrom = this.props.docView?.()!.rootDoc!;
embedding.annotationOn = annotationOn; //this.props.docView?.()!.rootDoc!;
embedding.histogramBarColors = Field.Copy(this.props.layoutDoc.histogramBarColors);
@@ -142,25 +145,33 @@ export class TableBox extends React.Component<TableBoxProps> {
<tbody>
{this._tableData?.map((p, i) => {
var containsData = false;
- var guid = StrListCast(this.props.layoutDoc.rowGuids)![this.props.pairs.indexOf(p)]
- this.columns.map(col => {if (p[col]!='' && p[col]!=null && p[col]!=undefined) containsData = true})
- if (containsData){
+ var guid = StrListCast(this.props.layoutDoc.dataViz_rowGuids)![this.props.pairs.indexOf(p)];
+ this.columns.map(col => {
+ if (p[col] != '' && p[col] != null && p[col] != undefined) containsData = true;
+ });
+ if (containsData) {
return (
- <tr key={i} className="table-row" onClick={action(e => {
+ <tr
+ key={i}
+ className="table-row"
+ onClick={action(e => {
// selecting a row
- const selected = Cast(this.props.layoutDoc.selected, listSpec("string"), null);
+ const selected = Cast(this.props.layoutDoc.dataViz_selectedRows, listSpec('string'), null);
if (selected.includes(guid)) selected.splice(selected.indexOf(guid), 1);
else {
- selected.push(guid)};
- })} style={{ background: StrListCast(this.props.layoutDoc.selected).includes(guid) ? 'lightgrey' : '', width: '110%' }}>
+ selected.push(guid);
+ }
+ })}
+ style={{ background: StrListCast(this.props.layoutDoc.dataViz_selectedRows).includes(guid) ? 'lightgrey' : '', width: '110%' }}>
{this.columns.map(col => {
- // each cell
- var colSelected = this.props.axes[0]==col || this.props.axes[1]==col;
- return (
- <td key={this.columns.indexOf(col)} style={{border: colSelected? '3px solid black' : '1px solid black', fontWeight: colSelected? 'bolder' : 'normal'}}>
+ // each cell
+ var colSelected = this.props.axes[0] == col || this.props.axes[1] == col;
+ return (
+ <td key={this.columns.indexOf(col)} style={{ border: colSelected ? '3px solid black' : '1px solid black', fontWeight: colSelected ? 'bolder' : 'normal' }}>
{p[col]}
</td>
- )})}
+ );
+ })}
</tr>
);
}
@@ -169,12 +180,10 @@ export class TableBox extends React.Component<TableBoxProps> {
</table>
</div>
);
- }
- 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>
- )
+ } 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>
+ );
}
}