Skip to content

Commit 9eb06bb

Browse files
author
weinStag
committed
feat: integrate resizable chart panel in DataBrowser
- Add ResizableBox for chart panel - Fixed positioning to prevent UI collapse - Toggle functionality for chart visibility - Proper state management for panel width
1 parent ea8b48c commit 9eb06bb

File tree

3 files changed

+88
-3
lines changed

3 files changed

+88
-3
lines changed

src/dashboard/Data/Browser/BrowserToolbar.react.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ const BrowserToolbar = ({
8282
classwiseCloudFunctions,
8383
appId,
8484
appName,
85+
86+
toggleChartPanel,
87+
isChartPanelVisible,
8588
}) => {
8689
const selectionLength = Object.keys(selection).length;
8790
const isPendingEditCloneRows = editCloneRows && editCloneRows.length > 0;
@@ -280,6 +283,8 @@ const BrowserToolbar = ({
280283
classwiseCloudFunctions={classwiseCloudFunctions}
281284
appId={appId}
282285
appName={appName}
286+
toggleChartPanel={toggleChartPanel}
287+
isChartPanelVisible={isChartPanelVisible}
283288
>
284289
{onAddRow && (
285290
<a className={classes.join(' ')} onClick={onClick}>

src/dashboard/Data/Browser/DataBrowser.react.js

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { ResizableBox } from 'react-resizable';
1515
import styles from './Databrowser.scss';
1616

1717
import AggregationPanel from '../../../components/AggregationPanel/AggregationPanel';
18+
import ChartVisualization from '../../../components/ChartVisualization/ChartVisualization.react';
1819

1920
/**
2021
* DataBrowser renders the browser toolbar and data table
@@ -49,6 +50,8 @@ export default class DataBrowser extends React.Component {
4950
isResizing: false,
5051
maxWidth: window.innerWidth - 300,
5152
showAggregatedData: true,
53+
isChartPanelVisible: false,
54+
chartPanelWidth: 400,
5255
};
5356

5457
this.handleResizeDiv = this.handleResizeDiv.bind(this);
@@ -67,6 +70,7 @@ export default class DataBrowser extends React.Component {
6770
this.setSelectedObjectId = this.setSelectedObjectId.bind(this);
6871
this.setContextMenu = this.setContextMenu.bind(this);
6972
this.handleCellClick = this.handleCellClick.bind(this);
73+
this.toggleChartPanelVisibility = this.toggleChartPanelVisibility.bind(this);
7074
this.saveOrderTimeout = null;
7175
}
7276

@@ -210,6 +214,12 @@ export default class DataBrowser extends React.Component {
210214
}
211215
}
212216

217+
toggleChartPanelVisibility() {
218+
this.setState(prevState => ({
219+
isChartPanelVisible: !prevState.isChartPanelVisible
220+
}));
221+
}
222+
213223
getAllClassesSchema(schema) {
214224
const allClasses = Object.keys(schema.data.get('classes').toObject());
215225
const schemaSimplifiedData = {};
@@ -610,9 +620,7 @@ export default class DataBrowser extends React.Component {
610620
firstSelectedCell: clickedCellKey,
611621
});
612622
}
613-
}
614-
615-
render() {
623+
} render() {
616624
const {
617625
className,
618626
count,
@@ -682,6 +690,31 @@ export default class DataBrowser extends React.Component {
682690
</div>
683691
</ResizableBox>
684692
)}
693+
{this.state.isChartPanelVisible && this.state.selectedData.length > 1 && (
694+
<ResizableBox
695+
width={this.state.chartPanelWidth}
696+
height={Infinity}
697+
minConstraints={[400, Infinity]}
698+
maxConstraints={[800, Infinity]}
699+
onResizeStart={() => this.setState({ isResizing: true })}
700+
onResizeStop={(event, { size }) => this.setState({
701+
isResizing: false,
702+
chartPanelWidth: size.width
703+
})}
704+
onResize={(event, { size }) => this.setState({ chartPanelWidth: size.width })}
705+
resizeHandles={['w']}
706+
className={styles.chartPanel}
707+
>
708+
<div className={styles.chartPanelContainer}>
709+
<ChartVisualization
710+
selectedData={this.state.selectedData}
711+
selectedCells={this.state.selectedCells}
712+
data={this.props.data}
713+
order={this.state.order}
714+
/>
715+
</div>
716+
</ResizableBox>
717+
)}
685718
</div>
686719

687720
<BrowserToolbar
@@ -711,6 +744,8 @@ export default class DataBrowser extends React.Component {
711744
allClassesSchema={this.state.allClassesSchema}
712745
togglePanel={this.togglePanelVisibility}
713746
isPanelVisible={this.state.isPanelVisible}
747+
toggleChartPanel={this.toggleChartPanelVisibility}
748+
isChartPanelVisible={this.state.isChartPanelVisible}
714749
appId={this.props.app.applicationId}
715750
appName={this.props.appName}
716751
{...other}

src/dashboard/Data/Browser/Databrowser.scss

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,51 @@
1818
}
1919
}
2020

21+
.chartPanel {
22+
position: fixed !important;
23+
top: 262px;
24+
right: 0%;
25+
bottom: 40px;
26+
width: 700px !important;
27+
max-height: 620px !important;
28+
height: auto !important;
29+
background: white;
30+
box-shadow: -2px 0 10px rgba(0, 0, 0, 0.1);
31+
z-index: 1000;
32+
33+
// Garantir que não seja colapsado
34+
flex-shrink: 0 !important;
35+
flex-grow: 0 !important;
36+
min-width: 400px !important;
37+
max-width: 800px !important;
38+
}
39+
40+
.chartPanelContainer {
41+
width: 100%;
42+
height: 100%;
43+
padding: 20px;
44+
display: flex;
45+
flex-direction: column;
46+
overflow: auto;
47+
}
48+
49+
.chartPanelContainerCustom {
50+
position: fixed;
51+
width: 600px;
52+
height: auto;
53+
min-height: 400px;
54+
background: white;
55+
box-shadow: -2px 0 10px rgba(0, 0, 0, 0.1);
56+
z-index: 1000;
57+
padding: 20px;
58+
display: flex;
59+
flex-direction: column;
60+
61+
// Garantir que não seja colapsado
62+
flex-shrink: 0;
63+
flex-grow: 0;
64+
}
65+
2166
.aggregationPanelContainer{
2267
height: 100%;
2368
overflow: auto;

0 commit comments

Comments
 (0)