in clns-acuity-vahub/vahub/src/main/webapp/src/app/common/trellising/grid/plot/plottypes/AbstractPlotComponent.ts [169:353]
selection: function (event): boolean {
const selectedPoints = [];
const selectionRectangle = {
xMin: event.xAxis[0].min || 0,
xMax: event.xAxis[0].max || 0,
yMin: event.yAxis[0].min || 0,
yMax: event.yAxis[0].max || 0,
categories: undefined
};
const chartSelection: IChartSelection = that.selection ? that.selection.find((subSelection: IChartSelection) => {
const trellising = subSelection.get('trellising', null);
return trellising && isEqual(trellising.toJS(), that.trellising);
}) : null;
const jEvent = event;
let xCategories: string[];
let newRanges: any;
let selection: any[];
if (that.isCategorical
|| that.tabId === TabId.LAB_BOXPLOT
|| that.tabId === TabId.LAB_SHIFTPLOT
|| that.tabId === TabId.CARDIAC_BOXPLOT
|| that.tabId === TabId.PK_RESULT_OVERALL_RESPONSE
|| that.tabId === TabId.DOSE_PROPORTIONALITY_BOX_PLOT
|| that.tabId === TabId.RENAL_LABS_BOXPLOT
|| that.tabId === TabId.VITALS_BOXPLOT
|| that.tabId === TabId.LUNG_FUNCTION_BOXPLOT
|| that.tabId === TabId.EXACERBATIONS_COUNTS) {
if (that.tabId === TabId.RENAL_CKD_BARCHART
|| that.tabId === TabId.LAB_BOXPLOT
|| that.tabId === TabId.LAB_SHIFTPLOT
|| that.tabId === TabId.CARDIAC_BOXPLOT
|| that.tabId === TabId.PK_RESULT_OVERALL_RESPONSE
|| that.tabId === TabId.DOSE_PROPORTIONALITY_BOX_PLOT) {
xCategories = that.getCategories(event);
} else {
const alteredXSelection = SelectionService.alterCategoricalSelectionX(
selectionRectangle.xMin,
selectionRectangle.xMax
);
selectionRectangle.xMin = alteredXSelection.xMin;
selectionRectangle.xMax = alteredXSelection.xMax;
}
}
if (that.tabId === TabId.RENAL_LABS_BOXPLOT
|| that.tabId === TabId.VITALS_BOXPLOT
|| that.tabId === TabId.LUNG_FUNCTION_BOXPLOT
|| that.tabId === TabId.EXACERBATIONS_COUNTS) {
xCategories = that.getCategories({
xAxis: [
{
axis: event.xAxis[0].axis,
min: selectionRectangle.xMin,
max: selectionRectangle.xMax
}
]
});
}
// noinspection JSPotentiallyInvalidUsageOfClassThis
this.series.forEach((series) => {
series.points.forEach((point) => {
if (that.pointInSelectionRectangle(point, selectionRectangle)) {
selectedPoints.push({
category: point.category,
series: point.series.name === 'All' ? null : point.series.name
});
}
});
});
// Appending selection
if (event.originalEvent.ctrlKey) {
newRanges = chartSelection && chartSelection.get('range') ? chartSelection.get('range').toJS() : [];
const previousPoints = chartSelection && chartSelection.get('bars') ? chartSelection.get('bars').toJS() : [];
if (that.tabId === TabId.RENAL_CKD_BARCHART
|| that.tabId === TabId.LAB_BOXPLOT
|| that.tabId === TabId.SINGLE_SUBJECT_LAB_LINEPLOT
|| that.tabId === TabId.LAB_SHIFTPLOT
|| that.tabId === TabId.LAB_LINEPLOT
|| that.tabId === TabId.PK_RESULT_OVERALL_RESPONSE
|| that.tabId === TabId.DOSE_PROPORTIONALITY_BOX_PLOT
|| that.tabId === TabId.RENAL_LABS_BOXPLOT
|| that.tabId === TabId.VITALS_BOXPLOT
|| that.tabId === TabId.LUNG_FUNCTION_BOXPLOT
|| that.tabId === TabId.CARDIAC_BOXPLOT
|| that.tabId === TabId.EXACERBATIONS_COUNTS) {
let categories;
if (that.tabId === TabId.LAB_LINEPLOT || that.tabId === TabId.SINGLE_SUBJECT_LAB_LINEPLOT) {
categories = selectedPoints;
} else {
categories = xCategories;
}
newRanges.push({
categories,
xMin: selectionRectangle.xMin,
xMax: selectionRectangle.xMax,
yMin: selectionRectangle.yMin,
yMax: selectionRectangle.yMax
});
} else {
newRanges.push(selectionRectangle);
}
const selectionInPlot = fromJS({
series: that.series,
trellising: that.trellising,
range: newRanges,
bars: unionWith(previousPoints, selectedPoints, isEqual)
});
if (that.selection && that.selection.size > 0) {
selection = [];
that.selection
.filter((selectionItem) => {
const trellising = selectionItem.get('trellising', null);
return !(trellising && isEqual(trellising.toJS(), that.trellising));
})
.forEach(subSelection => selection.push(subSelection.toMap()));
selection.push(selectionInPlot);
} else {
selection = [selectionInPlot];
}
} else {
if (that.tabId === TabId.RENAL_CKD_BARCHART
|| that.tabId === TabId.LAB_BOXPLOT
|| that.tabId === TabId.SINGLE_SUBJECT_LAB_LINEPLOT
|| that.tabId === TabId.LAB_SHIFTPLOT
|| that.tabId === TabId.LAB_LINEPLOT
|| that.tabId === TabId.PK_RESULT_OVERALL_RESPONSE
|| that.tabId === TabId.DOSE_PROPORTIONALITY_BOX_PLOT
|| that.tabId === TabId.RENAL_LABS_BOXPLOT
|| that.tabId === TabId.LUNG_FUNCTION_BOXPLOT
|| that.tabId === TabId.CARDIAC_BOXPLOT
|| that.tabId === TabId.EXACERBATIONS_COUNTS
|| that.tabId === TabId.SINGLE_SUBJECT_RENAL_LINEPLOT
|| that.tabId === TabId.VITALS_BOXPLOT) {
let categories;
if (that.tabId === TabId.LAB_LINEPLOT || that.tabId === TabId.SINGLE_SUBJECT_LAB_LINEPLOT) {
categories = selectedPoints;
} else {
categories = xCategories;
}
newRanges = [{
categories,
xMin: selectionRectangle.xMin,
xMax: selectionRectangle.xMax,
yMin: selectionRectangle.yMin,
yMax: selectionRectangle.yMax
}];
} else {
newRanges = [selectionRectangle];
}
selection = [fromJS({
series: that.series,
trellising: that.trellising,
range: newRanges,
bars: selectedPoints
})];
}
if (!NEW_APPROACH_TAB_LIST.contains(that.tabId) ||
that.hasSelection(selection)) {
that.trellisingMiddleware.updateSelection(List<IChartSelection>(selection));
if (!jEvent.target.mouseDownX || !jEvent.target.mouseDownY) {
that.displayMarkingDialogue.emit({
x: jEvent.originalEvent.offsetX,
y: jEvent.originalEvent.offsetY
});
} else if (jEvent.target.mouseDownX - jEvent.originalEvent.offsetX < 0) {
that.displayMarkingDialogue.emit({
x: jEvent.originalEvent.offsetX,
y: jEvent.target.mouseDownY
});
} else {
that.displayMarkingDialogue.emit({x: jEvent.target.mouseDownX, y: jEvent.target.mouseDownY});
}
}
return false;
},