Skip to content

Commit

Permalink
The selection range does not exceed the view for xy-charts
Browse files Browse the repository at this point in the history
 add conditions at the ends so that the selection range remains in the view

Contributes towards fixing eclipse-cdt-cloud#420

Signed-off-by: Ibrahim Fradj <ibrahim.fradj@ericsson.com>
  • Loading branch information
IbrahimFradj authored and bhufmann committed Aug 25, 2021
1 parent 18ca4a5 commit f271709
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,11 @@ export class XYOutputComponent extends AbstractTreeOutputComponent<AbstractOutpu
if (this.mouseIsDown && this.props.unitController.selectionRange) {
const xStartPos = this.props.unitController.selectionRange.start;
const scale = this.props.viewRange.getEnd() - this.props.viewRange.getstart();
let end = xStartPos + ((event.screenX - this.posPixelSelect) / this.lineChartRef.current.chartInstance.width) * scale;
end = Math.min(Math.max(end, 0), this.props.unitController.absoluteRange);
this.props.unitController.selectionRange = {
start: xStartPos,
end: xStartPos + ((event.screenX - this.posPixelSelect) / this.lineChartRef.current.chartInstance.width) * scale
end: end
};
}
};
Expand Down

0 comments on commit f271709

Please sign in to comment.