From 9dbd9efeb0080418fcb44c5c78511fffa09ad229 Mon Sep 17 00:00:00 2001
From: srichman333 <sarah_n_richman@brown.edu>
Date: Sun, 13 Aug 2023 17:37:02 -0400
Subject: just one histogram bar bug fix + message displayed when graphs have
 no incoming data rows selected

---
 .../views/nodes/DataVizBox/components/PieChart.tsx | 62 ++++++++++++----------
 1 file changed, 35 insertions(+), 27 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 03c9efdd1..0c54d0a4e 100644
--- a/src/client/views/nodes/DataVizBox/components/PieChart.tsx
+++ b/src/client/views/nodes/DataVizBox/components/PieChart.tsx
@@ -337,36 +337,44 @@ export class PieChart extends React.Component<PieChartProps> {
         var sliceColors = StrListCast(this.props.layoutDoc.pieSliceColors).map(each => each.split('::'));
         sliceColors.map(each => {if (each[0]==curSelectedSliceName!) selectedSliceColor = each[1]});
 
-        return (
-            this.props.axes.length >= 1 ? (
-            <div className="chart-container">
-                <div className="graph-title"> 
-                    <EditableText
-                        val={StrCast(this.props.layoutDoc[titleAccessor])}
-                        setVal={undoable (action(val => this.props.layoutDoc[titleAccessor] = val as string), "Change Graph Title")}
-                        color={"black"}
-                        size={Size.LARGE}
-                        fillWidth
-                    />
-                </div>
-                <div ref={this._piechartRef} />
-                {selected != 'none' ? 
-                    <div className={'selected-data'}>
-                        Selected: {selected}
-                        &nbsp; &nbsp;
-                        <ColorPicker
-                            tooltip={'Change Slice Color'} 
-                            type={Type.SEC} 
-                            icon={<FaFillDrip/>}
-                            selectedColor={selectedSliceColor? selectedSliceColor : this.curSliceSelected.attr("fill")}
-                            setSelectedColor={undoable (color => this.changeSelectedColor(color), "Change Selected Slice Color")}
-                            size={Size.XSMALL}
+        if (this._piechartData.length>0){
+            return (
+                this.props.axes.length >= 1 ? (
+                <div className="chart-container">
+                    <div className="graph-title"> 
+                        <EditableText
+                            val={StrCast(this.props.layoutDoc[titleAccessor])}
+                            setVal={undoable (action(val => this.props.layoutDoc[titleAccessor] = val as string), "Change Graph Title")}
+                            color={"black"}
+                            size={Size.LARGE}
+                            fillWidth
                         />
                     </div>
-                : null}
+                    <div ref={this._piechartRef} />
+                    {selected != 'none' ? 
+                        <div className={'selected-data'}>
+                            Selected: {selected}
+                            &nbsp; &nbsp;
+                            <ColorPicker
+                                tooltip={'Change Slice Color'} 
+                                type={Type.SEC} 
+                                icon={<FaFillDrip/>}
+                                selectedColor={selectedSliceColor? selectedSliceColor : this.curSliceSelected.attr("fill")}
+                                setSelectedColor={undoable (color => this.changeSelectedColor(color), "Change Selected Slice Color")}
+                                size={Size.XSMALL}
+                            />
+                        </div>
+                    : null}
+                </div>
+                ) : <span className="chart-container"> {'first use table view to select a column to graph'}</span>
+            );
+        }
+        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>
-            ) : <span className="chart-container"> {'first use table view to select a column to graph'}</span>
-        );
+        )
     }
 
 }
\ No newline at end of file
-- 
cgit v1.2.3-70-g09d2

