Skip to content

Commit 54002e4

Browse files
authored
Merge pull request #105 from Caltech-IPAC/DM-5763_deciopts
DM-5763: XYPlot decimation options
2 parents bff9b02 + 6902b01 commit 54002e4

File tree

6 files changed

+226
-98
lines changed

6 files changed

+226
-98
lines changed

src/firefly/js/ui/SuggestBoxInputField.jsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,8 @@ class SuggestBoxInputFieldView extends Component {
109109
this.state = {
110110
isOpen: false,
111111
displayValue: props.value,
112-
valid: true,
113-
message: '',
112+
valid: get(props, 'valid', true),
113+
message: get(props.message, ''),
114114
inputWidth: undefined,
115115
suggestions: [],
116116
mouseTrigger: false
@@ -123,6 +123,12 @@ class SuggestBoxInputFieldView extends Component {
123123
this.updateSuggestions = debounce(this.updateSuggestions.bind(this), 200);
124124
}
125125

126+
componentWillReceiveProps(nextProps) {
127+
const {valid, message, value} = nextProps;
128+
if (valid !== this.state.valid || message !== this.state.message || value !== this.state.displayValue) {
129+
this.setState({valid, message, displayValue: value});
130+
}
131+
}
126132

127133
onValueChange(ev) {
128134
var displayValue = get(ev, 'target.value');
@@ -230,7 +236,7 @@ class SuggestBoxInputFieldView extends Component {
230236
/>
231237
</div>
232238

233-
{isOpen && <div className={'SuggestBoxPopup'} style={{left: leftOffset, minWidth: minWidth}} onMouseLeave={() => this.setState({highlightedIdx : undefined})}>
239+
{isOpen && <div className={'SuggestBoxPopup'} style={{left: leftOffset, minWidth}} onMouseLeave={() => this.setState({highlightedIdx : undefined})}>
234240
<SuggestBox
235241
suggestions={suggestions}
236242
highlightedIdx={highlightedIdx}

src/firefly/js/visualize/ChartsTableViewPanel.jsx

Lines changed: 38 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ import {PopupPanel} from '../ui/PopupPanel.jsx';
3434
import DialogRootContainer from '../ui/DialogRootContainer.jsx';
3535
import {dispatchShowDialog, dispatchHideDialog, isDialogVisible} from '../core/ComponentCntlr.js';
3636

37+
import {showInfoPopup} from '../ui/PopupUtil.jsx';
38+
3739
import OUTLINE_EXPAND from 'html/images/icons-2014/24x24_ExpandArrowsWhiteOutline.png';
3840
import SETTINGS from 'html/images/icons-2014/24x24_GearsNEW.png';
3941
import ZOOM_IN from 'html/images/icons-2014/24x24_ZoomIn.png';
@@ -322,23 +324,28 @@ class ChartsPanel extends React.Component {
322324

323325
addSelection() {
324326
if (this.state.chartType === SCATTER) {
325-
const {tblId, tableModel} = this.props;
326-
const selection = get(this.props, 'tblPlotData.xyPlotParams.selection');
327-
const rows = get(this.props, 'tblPlotData.xyPlotData.rows');
328-
if (tableModel && rows && selection) {
329-
const {xMin, xMax, yMin, yMax} = selection;
330-
const selectInfoCls = SelectInfo.newInstance({rowCount: tableModel.totalRows});
331-
// add all rows which fall into selection
332-
const xIdx = 0, yIdx = 1;
333-
rows.forEach((arow, index) => {
334-
const x = Number(arow[xIdx]);
335-
const y = Number(arow[yIdx]);
336-
if (x>=xMin && x<=xMax && y>=yMin && y<=yMax) {
337-
selectInfoCls.setRowSelect(index, true);
338-
}
339-
});
340-
const selectInfo = selectInfoCls.data;
341-
TablesCntlr.dispatchTableSelect(tblId, selectInfo);
327+
if (get(this.props, 'tblPlotData.xyPlotData.decimateKey')) {
328+
showInfoPopup('Your data set is too large to select. You must filter it down first.',
329+
`Can't Select`); // eslint-disable-line quotes
330+
} else {
331+
const {tblId, tableModel} = this.props;
332+
const selection = get(this.props, 'tblPlotData.xyPlotParams.selection');
333+
const rows = get(this.props, 'tblPlotData.xyPlotData.rows');
334+
if (tableModel && rows && selection) {
335+
const {xMin, xMax, yMin, yMax} = selection;
336+
const selectInfoCls = SelectInfo.newInstance({rowCount: tableModel.totalRows});
337+
// add all rows which fall into selection
338+
const xIdx = 0, yIdx = 1, rowIdx = 2;
339+
rows.forEach((arow) => {
340+
const x = Number(arow[xIdx]);
341+
const y = Number(arow[yIdx]);
342+
if (x >= xMin && x <= xMax && y >= yMin && y <= yMax) {
343+
selectInfoCls.setRowSelect(Number(arow[rowIdx]), true);
344+
}
345+
});
346+
const selectInfo = selectInfoCls.data;
347+
TablesCntlr.dispatchTableSelect(tblId, selectInfo);
348+
}
342349
}
343350
}
344351
}
@@ -389,15 +396,19 @@ class ChartsPanel extends React.Component {
389396

390397
selectionNotEmpty(selection) {
391398
const rows = get(this.props, 'tblPlotData.xyPlotData.rows');
392-
if (rows && selection) {
393-
const {xMin, xMax, yMin, yMax} = selection;
394-
const xIdx = 0, yIdx = 1;
395-
const aPt = rows.find((arow) => {
396-
const x = Number(arow[xIdx]);
397-
const y = Number(arow[yIdx]);
398-
return (x >= xMin && x <= xMax && y >= yMin && y <= yMax);
399-
});
400-
return Boolean(aPt);
399+
if (rows) {
400+
if (selection) {
401+
const {xMin, xMax, yMin, yMax} = selection;
402+
const xIdx = 0, yIdx = 1;
403+
const aPt = rows.find((arow) => {
404+
const x = Number(arow[xIdx]);
405+
const y = Number(arow[yIdx]);
406+
return (x >= xMin && x <= xMax && y >= yMin && y <= yMax);
407+
});
408+
return Boolean(aPt);
409+
} else {
410+
return true; // empty selection replacing non-empty
411+
}
401412
} else {
402413
return false;
403414
}
@@ -413,7 +424,7 @@ class ChartsPanel extends React.Component {
413424
src={ZOOM_IN}
414425
onClick={() => this.addZoom()}
415426
/>
416-
{!get(this.props, 'tblPlotData.xyPlotData.decimateKey') && <img style={selectionBtnStyle}
427+
{<img style={selectionBtnStyle}
417428
title='Select enclosed points'
418429
src={SELECT_ROWS}
419430
onClick={() => this.addSelection()}

0 commit comments

Comments
 (0)