protected handleDblclickEvent()

in clns-acuity-vahub/vahub/src/main/webapp/src/app/common/trellising/grid/plot/plottypes/AbstractPlotComponent.ts [468:562]


    protected handleDblclickEvent(event: ChartMouseEvent): boolean {
        const { series, xAxis, yAxis } = this.chart;
        const newSelection = SelectionService.getAllSelection(series, false, xAxis[0].isCategorical, yAxis[0].isCategorical);
        const newRange = newSelection.range;

        if (this.chart instanceof ScatterChart) {
           this.chart.setSelectedZone(newRange);
        }
        if (this.chart instanceof ShiftChart || this.chart instanceof BoxPlot) {
            const rangeForColoringSelectedZone = newRange;

            if  (newRange.xMin === newRange.xMax) {
                rangeForColoringSelectedZone.xMin = rangeForColoringSelectedZone.xMin - 1;
                rangeForColoringSelectedZone.xMax = rangeForColoringSelectedZone.xMax + 1;
            }
            this.chart.setSelectedZone(rangeForColoringSelectedZone);
        }

        let newSelectedBars = newSelection.selectedBars;

        if (isEqual(this.currentSelection, [newRange])) {
            this.trellisingDispatcher.clearSelections();
        } else {
            if (this.isCategorical
                || this.tabId === TabId.RENAL_CKD_BARCHART
                || this.tabId === TabId.SINGLE_SUBJECT_LAB_LINEPLOT
                || this.tabId === TabId.LAB_BOXPLOT
                || this.tabId === TabId.LAB_LINEPLOT
                || this.tabId === TabId.LAB_SHIFTPLOT
                || this.tabId === TabId.SINGLE_SUBJECT_VITALS_LINEPLOT
                || this.tabId === TabId.SINGLE_SUBJECT_CARDIAC_LINEPLOT
                || this.tabId === TabId.VITALS_BOXPLOT
                || this.tabId === TabId.CARDIAC_BOXPLOT
                || this.tabId === TabId.DOSE_PROPORTIONALITY_BOX_PLOT
                || this.tabId === TabId.RENAL_LABS_BOXPLOT
                || this.tabId === TabId.LUNG_FUNCTION_BOXPLOT
                || this.tabId === TabId.EXACERBATIONS_COUNTS
                || this.tabId === TabId.SINGLE_SUBJECT_LUNG_LINEPLOT
                || this.tabId === TabId.SINGLE_SUBJECT_RENAL_LINEPLOT) {
                if (this.tabId === TabId.RENAL_CKD_BARCHART) {
                    newRange.categories = _.chain(this.chart.series)
                        .flatMap('chart')
                        .flatMap('xAxis')
                        .flatMap('categories')
                        .uniq()
                        .value();
                } else if (this.tabId === TabId.LAB_BOXPLOT
                    || this.tabId === TabId.LAB_SHIFTPLOT
                    || this.tabId === TabId.SINGLE_SUBJECT_VITALS_LINEPLOT
                    || this.tabId === TabId.SINGLE_SUBJECT_CARDIAC_LINEPLOT
                    || this.tabId === TabId.VITALS_BOXPLOT
                    || this.tabId === TabId.CARDIAC_BOXPLOT
                    || this.tabId === TabId.PK_RESULT_OVERALL_RESPONSE
                    || this.tabId === TabId.DOSE_PROPORTIONALITY_BOX_PLOT
                    || this.tabId === TabId.RENAL_LABS_BOXPLOT
                    || this.tabId === TabId.LUNG_FUNCTION_BOXPLOT
                    || this.tabId === TabId.EXACERBATIONS_COUNTS
                    || this.tabId === TabId.SINGLE_SUBJECT_LUNG_LINEPLOT
                    || this.tabId === TabId.SINGLE_SUBJECT_RENAL_LINEPLOT) {
                    // None of the tabs should have bars in selection
                    newRange.categories = newSelection.selectedBars.map(bar => bar.category);
                    newSelectedBars = [];
                } else {
                    const alteredXSelection = SelectionService.alterCategoricalSelectionX(newRange.xMin, newRange.xMax);
                    newRange.xMin = alteredXSelection.xMin;
                    newRange.xMax = alteredXSelection.xMax;
                }
            }

            const selectionInPlot = fromJS({
                series: this.series,
                trellising: this.trellising,
                range: [newRange],
                bars: newSelectedBars
            });

            let selection: any[];
            if (event.ctrlKey && this.selection && this.selection.size > 0) {
                selection = [];
                this.selection.forEach(subSelection => {
                    const trellising = subSelection.get('trellising') ? subSelection.get('trellising').toJS() : null;
                    if (!isEqual(trellising, this.trellising)) {
                        selection.push(subSelection.toMap());
                    }
                });
                selection.push(selectionInPlot);
            } else {
                selection = [selectionInPlot];
            }
            this.trellisingMiddleware.updateSelection(List<IChartSelection>(selection));
            this.displayMarkingDialogue.emit({x: event.layerX, y: event.layerY});
            return false;
        }
        return;
    }