From d1125c3de7e12bc981b90a2b8bf90b96fcf2da15 Mon Sep 17 00:00:00 2001 From: Dmitrii Arnautov Date: Tue, 22 Sep 2020 11:43:28 +0200 Subject: [PATCH] feat: fix pickDragShape --- .../heatmap/layout/viewmodel/viewmodel.ts | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/src/chart_types/heatmap/layout/viewmodel/viewmodel.ts b/src/chart_types/heatmap/layout/viewmodel/viewmodel.ts index 8b8a5166fc..d3c8300e1b 100644 --- a/src/chart_types/heatmap/layout/viewmodel/viewmodel.ts +++ b/src/chart_types/heatmap/layout/viewmodel/viewmodel.ts @@ -272,24 +272,23 @@ export function shapeViewModel( * @param end */ const pickDragShape: PickDragShapeFunction = ([start, end]) => { - const startX = Math.min(start.x, end.x); + const startX = Math.min(start.x, end.x) - chartDimensions.left; const startY = Math.min(start.y, end.y); - const endX = Math.max(start.x, end.x); + const endX = Math.max(start.x, end.x) - chartDimensions.left; const endY = Math.max(start.y, end.y); - const [startPoint] = pickQuads(startX, startY); - const [endPoint] = pickQuads(endX, endY); + const startXValue = Math.floor(startX / cellWidth) * cellWidth; + const startYValue = Math.floor(startY / cellHeight) * cellHeight; - if (startPoint === undefined || endPoint === undefined) { - return; - } + const endXValue = Math.floor(endX / cellWidth) * cellWidth; + const endYValue = Math.floor(endY / cellHeight) * cellHeight; return { - x: startPoint.x + maxTextWidth, - y: startPoint.y, - width: Math.abs(endPoint.x - startPoint.x) + cellWidth, - height: Math.abs(endPoint.y - startPoint.y) + cellHeight, + x: startXValue + chartDimensions.left, + y: startYValue, + width: Math.abs(endXValue - startXValue) + cellWidth, + height: Math.abs(endYValue - startYValue) + cellHeight, }; };