Make the controls on the Graph Visualiser collapsible and reorganize the controls.

This commit is contained in:
Akshay Joshi 2022-07-07 14:10:10 +05:30
parent 9cdcad7a88
commit 50c930f5fa
12 changed files with 48 additions and 31 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 90 KiB

After

Width:  |  Height:  |  Size: 108 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 28 KiB

After

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 32 KiB

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 38 KiB

After

Width:  |  Height:  |  Size: 58 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 38 KiB

After

Width:  |  Height:  |  Size: 58 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 82 KiB

After

Width:  |  Height:  |  Size: 78 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 80 KiB

After

Width:  |  Height:  |  Size: 69 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 80 KiB

After

Width:  |  Height:  |  Size: 83 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 87 KiB

After

Width:  |  Height:  |  Size: 86 KiB

View File

@ -338,6 +338,14 @@ Bar Charts, Stacked Bar Charts, and Pie Charts.
:alt: Query tool graph visualiser panel :alt: Query tool graph visualiser panel
:align: center :align: center
* Graph Type
Choose the type of the graph that you would like to generate.
.. image:: images/query_graph_type.png
:alt: Query tool graph visualiser graph type
:align: center
* X Axis * X Axis
Choose the column whose value you wish to display on X-axis from the *X Axis* Choose the column whose value you wish to display on X-axis from the *X Axis*
@ -358,14 +366,6 @@ from the drop-down menu to select all the columns.
:alt: Query tool graph visualiser yaxis :alt: Query tool graph visualiser yaxis
:align: center :align: center
* Graph Type
Choose the type of the graph that you would like to generate.
.. image:: images/query_graph_type.png
:alt: Query tool graph visualiser graph type
:align: center
* Download and Zoom button * Download and Zoom button
Zooming is performed by clicking and selecting an area over the chart with the Zooming is performed by clicking and selecting an area over the chart with the

View File

@ -18,6 +18,8 @@ import { Box } from '@material-ui/core';
import ShowChartRoundedIcon from '@material-ui/icons/ShowChartRounded'; import ShowChartRoundedIcon from '@material-ui/icons/ShowChartRounded';
import ZoomOutMapIcon from '@material-ui/icons/ZoomOutMap'; import ZoomOutMapIcon from '@material-ui/icons/ZoomOutMap';
import SaveAltIcon from '@material-ui/icons/SaveAlt'; import SaveAltIcon from '@material-ui/icons/SaveAlt';
import ExpandLessRoundedIcon from '@material-ui/icons/ExpandLessRounded';
import ExpandMoreRoundedIcon from '@material-ui/icons/ExpandMoreRounded';
import { InputSelect } from '../../../../../../static/js/components/FormComponents'; import { InputSelect } from '../../../../../../static/js/components/FormComponents';
import { DefaultButton, PgButtonGroup, PgIconButton} from '../../../../../../static/js/components/Buttons'; import { DefaultButton, PgButtonGroup, PgIconButton} from '../../../../../../static/js/components/Buttons';
import { LineChart, BarChart, PieChart, DATA_POINT_STYLE, DATA_POINT_SIZE, import { LineChart, BarChart, PieChart, DATA_POINT_STYLE, DATA_POINT_SIZE,
@ -55,11 +57,16 @@ const useStyles = makeStyles((theme)=>({
}, },
spanLabel: { spanLabel: {
alignSelf: 'center', alignSelf: 'center',
marginRight: '4px', minWidth: '5%',
whiteSpace: 'nowrap',
}, },
selectCtrl: { selectCtrl: {
minWidth: '200px', minWidth: '200px',
}, },
axisSelectCtrl: {
minWidth: '200px',
marginTop: '2px',
},
})); }));
// This function is used to generate the appropriate graph based on the graphType. // This function is used to generate the appropriate graph based on the graphType.
@ -255,6 +262,7 @@ export function GraphVisualiser({initColumns}) {
const [loaderText, setLoaderText] = useState(''); const [loaderText, setLoaderText] = useState('');
const [columns, setColumns] = useState(initColumns); const [columns, setColumns] = useState(initColumns);
const [graphHeight, setGraphHeight] = useState(); const [graphHeight, setGraphHeight] = useState();
const [expandedState, setExpandedState] = useState(true);
// Create X axis options for drop down. // Create X axis options for drop down.
@ -390,32 +398,41 @@ export function GraphVisualiser({initColumns}) {
<Loader message={loaderText} /> <Loader message={loaderText} />
<Box className={classes.topContainer}> <Box className={classes.topContainer}>
<Box className={classes.displayFlex}> <Box className={classes.displayFlex}>
<Box className={classes.displayFlex}> <span className={classes.spanLabel} >{gettext('Graph Type')}</span>
<span className={classes.spanLabel}>{graphType != 'P' ? gettext('X Axis') : gettext('Label')}</span> <InputSelect className={classes.selectCtrl} controlProps={{allowClear: false}}
<InputSelect className={classes.selectCtrl} options={xAxisOptions} options={[
onChange={(v)=>setXAxis(v)} value={xaxis} optionsReloadBasis={optionsReload}/> {label: gettext('Line Chart'), value: 'L'},
</Box> {label: gettext('Stacked Line Chart'), value: 'SL'},
<Box className={classes.displayFlex} marginLeft="auto"> {label: gettext('Bar Chart'), value: 'B'},
<span className={classes.spanLabel} >{gettext('Graph Type')}</span> {label: gettext('Stacked Bar Chart'), value: 'SB'},
<InputSelect className={classes.selectCtrl} controlProps={{allowClear: false}} {label: gettext('Pie Chart'), value: 'P'},
options={[ ]} onChange={(v)=>{
{label: gettext('Line Chart'), value: 'L'}, setGraphType(v);
{label: gettext('Stacked Line Chart'), value: 'SL'}, if (graphType === 'P' || v === 'P') {
{label: gettext('Bar Chart'), value: 'B'}, setExpandedState(true);
{label: gettext('Stacked Bar Chart'), value: 'SB'}, }
{label: gettext('Pie Chart'), value: 'P'}, }} value={graphType} />
]} onChange={(v)=>setGraphType(v)} value={graphType} /> <DefaultButton style={{marginLeft: 'auto'}} onClick={onGenerate} startIcon={<ShowChartRoundedIcon />}
</Box>
<DefaultButton onClick={onGenerate} startIcon={<ShowChartRoundedIcon />}
disabled={ _.isEmpty(xaxis) || yaxis.length <= 0 }> disabled={ _.isEmpty(xaxis) || yaxis.length <= 0 }>
{gettext('Generate')} {gettext('Generate')}
</DefaultButton> </DefaultButton>
<PgIconButton title={expandedState ? gettext('Collapse') : gettext('Expand')}
icon={expandedState ? <ExpandLessRoundedIcon style={{height: '1.2rem'}}/> : <ExpandMoreRoundedIcon style={{height: '1.2rem'}}/>}
onClick={()=>{setExpandedState(!expandedState);}}/>
</Box> </Box>
<Box className={classes.displayFlex}> { expandedState && <>
<span className={classes.spanLabel}>{graphType != 'P' ? gettext('Y Axis') : gettext('Value')}</span> <Box className={classes.displayFlex}>
<InputSelect className={classes.selectCtrl} controlProps={{'multiple': graphType != 'P', allowSelectAll: graphType != 'P'}} <span className={classes.spanLabel}>{graphType != 'P' ? gettext('X Axis') : gettext('Label')}</span>
options={yAxisOptions} onChange={(v)=>setYAxis(v)} value={yaxis} optionsReloadBasis={optionsReload}/> <InputSelect className={classes.axisSelectCtrl} options={xAxisOptions}
</Box> onChange={(v)=>setXAxis(v)} value={xaxis} optionsReloadBasis={optionsReload}/>
</Box>
<Box className={classes.displayFlex}>
<span className={classes.spanLabel}>{graphType != 'P' ? gettext('Y Axis') : gettext('Value')}</span>
<InputSelect className={classes.axisSelectCtrl} controlProps={{'multiple': graphType != 'P', allowSelectAll: graphType != 'P'}}
options={yAxisOptions} onChange={(v)=>setYAxis(v)} value={yaxis} optionsReloadBasis={optionsReload}/>
</Box>
</>
}
</Box> </Box>
<Box display="flex" marginLeft="3px" marginTop="3px"> <Box display="flex" marginLeft="3px" marginTop="3px">
<PgButtonGroup size="small"> <PgButtonGroup size="small">