Skip to content

Commit

Permalink
feat: fix pickDragShape
Browse files Browse the repository at this point in the history
  • Loading branch information
darnautov committed Sep 22, 2020
1 parent eb8055f commit d1125c3
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions src/chart_types/heatmap/layout/viewmodel/viewmodel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
};

Expand Down

0 comments on commit d1125c3

Please sign in to comment.