Skip to content

Commit

Permalink
Merge pull request #2 from shhdgit/fix-minimap-selection
Browse files Browse the repository at this point in the history
fix: restriction of minimap brush
  • Loading branch information
YiniXu9506 authored Jun 16, 2022
2 parents 540ee26 + f72593e commit 8b20c51
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion ui/lib/components/TreeDiagram/Minimap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,34 @@ const Minimap = ({
const minimapContainerWidth = viewPort.width * minimapScale
const minimapContainerHeight = viewPort.height * minimapScale

const longSide = mainChartWidth > mainChartHeight ? 'x' : 'y'
const chartLongSideSize = Math.max(mainChartWidth, mainChartHeight)
const chartMinimapScale =
chartLongSideSize /
(longSide === 'x' ? minimapContainerWidth : minimapContainerHeight)

const drawMinimap = () => {
minimapSVG
.attr('width', minimapContainerWidth)
.attr('height', minimapContainerHeight)
.attr('viewBox', [0, 0, mainChartWidth, mainChartHeight].join(' '))
.attr(
'viewBox',
(longSide === 'x'
? [
0,
-(minimapContainerHeight * chartMinimapScale - mainChartHeight) /
2,
mainChartWidth,
minimapContainerHeight * chartMinimapScale,
]
: [
-(minimapContainerWidth * chartMinimapScale - mainChartWidth) / 2,
0,
minimapContainerWidth * chartMinimapScale,
mainChartHeight,
]
).join(' ')
)
.attr('preserveAspectRatio', 'xMidYMid meet')
.style('position', 'absolute')
.style('top', 0)
Expand Down

0 comments on commit 8b20c51

Please sign in to comment.