From 81325ec64a24a98e3677b208a56dd048669fae72 Mon Sep 17 00:00:00 2001
From: srichman333 <sarah_n_richman@brown.edu>
Date: Tue, 23 Apr 2024 23:05:24 -0400
Subject: filter one histogram bar onto child dataviz doc at a time

---
 src/client/views/nodes/DataVizBox/DataVizBox.tsx | 23 +++++++++++++++++++----
 1 file changed, 19 insertions(+), 4 deletions(-)

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

diff --git a/src/client/views/nodes/DataVizBox/DataVizBox.tsx b/src/client/views/nodes/DataVizBox/DataVizBox.tsx
index a6de64d85..f316c6e0f 100644
--- a/src/client/views/nodes/DataVizBox/DataVizBox.tsx
+++ b/src/client/views/nodes/DataVizBox/DataVizBox.tsx
@@ -347,7 +347,7 @@ export class DataVizBox extends ViewBoxAnnotatableComponent<FieldViewProps>() im
             axes: this.axes,
             titleCol: this.titleCol,
             //width: this.SidebarShown? this._props.PanelWidth()*.9/1.2: this._props.PanelWidth() * 0.9,
-            height: (this._props.PanelHeight() / scale - 32) /* height of 'change view' button */ * 0.9,
+            height: (this._props.PanelHeight() / scale - 55) /* height of 'change view' button */ * 0.8,
             width: ((this._props.PanelWidth() - this.sidebarWidth()) / scale) * 0.9,
             margin: { top: 10, right: 25, bottom: 75, left: 45 },
         };
@@ -401,11 +401,20 @@ export class DataVizBox extends ViewBoxAnnotatableComponent<FieldViewProps>() im
         GPTPopup.Instance.addDoc = this.sidebarAddDocument;
     };
 
+    // represents whether or not a data viz box created from a schema table displays live updates to the canvas
     @action
     changeLiveSchemaCheckbox = () => {
         this.layoutDoc.dataViz_schemaLive = !this.layoutDoc.dataViz_schemaLive
     }
 
+    // represents whether or not clicking on a peice of data in the visualization 
+    //      (i.e. a data point in a linechart, a bar on a histogram, or a slice of a pie chart)
+    //      filters the data onto a new data viz doc created off of this one
+    @action
+    changeFilteringCheckbox = () => {
+        this.layoutDoc.dataViz_filterSelection = !this.layoutDoc.dataViz_filterSelection
+    }
+
     specificContextMenu = (e: React.MouseEvent): void => {
         const cm = ContextMenu.Instance;
         const options = cm.findByDescription('Options...');
@@ -481,11 +490,17 @@ export class DataVizBox extends ViewBoxAnnotatableComponent<FieldViewProps>() im
                 {(this.layoutDoc && this.layoutDoc.dataViz_asSchema)?(
                     <div className={'displaySchemaLive'}>
                         <div className={'liveSchema-checkBox'} style={{ width: this._props.width }}>
-                        <Checkbox color="primary" onChange={this.changeLiveSchemaCheckbox} checked={this.layoutDoc.dataViz_schemaLive as boolean} />
-                        Display Live Updates to Canvas
+                            <Checkbox color="primary" onChange={this.changeLiveSchemaCheckbox} checked={this.layoutDoc.dataViz_schemaLive as boolean} />
+                            Display Live Updates to Canvas
+                        </div>
                     </div>
-                </div>
                 ) : null}
+                {this.layoutDoc._dataViz != DataVizView.TABLE?(
+                    <div className={'filterData-checkBox'}>
+                        <Checkbox color="primary" onChange={this.changeFilteringCheckbox} checked={this.layoutDoc.dataViz_filterSelection as boolean} />
+                        Select data to filter
+                    </div>)
+                : null }
 
                 {this.renderVizView}
 
-- 
cgit v1.2.3-70-g09d2

