@jbrowse/plugin-dotplot-view 2.6.1 → 2.6.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (190) hide show
  1. package/dist/ComparativeRenderer/index.js +0 -1
  2. package/dist/DotplotDisplay/components/DotplotDisplay.js +0 -1
  3. package/dist/DotplotDisplay/index.js +0 -1
  4. package/dist/DotplotDisplay/renderDotplotBlock.js +0 -1
  5. package/dist/DotplotDisplay/stateModelFactory.js +0 -1
  6. package/dist/DotplotReadVsRef/DotplotReadVsRef.js +0 -1
  7. package/dist/DotplotReadVsRef/index.js +0 -1
  8. package/dist/DotplotRenderer/ComparativeRenderRpc.js +0 -1
  9. package/dist/DotplotRenderer/DotplotRenderer.js +0 -1
  10. package/dist/DotplotRenderer/components/DotplotRendering.js +0 -1
  11. package/dist/DotplotRenderer/configSchema.js +0 -1
  12. package/dist/DotplotRenderer/index.js +0 -1
  13. package/dist/DotplotView/1dview.js +0 -1
  14. package/dist/DotplotView/blockTypes.js +0 -1
  15. package/dist/DotplotView/components/Axes.js +0 -1
  16. package/dist/DotplotView/components/CursorIcon.js +0 -1
  17. package/dist/DotplotView/components/DotplotTooltip.js +0 -1
  18. package/dist/DotplotView/components/DotplotView.js +0 -1
  19. package/dist/DotplotView/components/DotplotWarnings.js +0 -1
  20. package/dist/DotplotView/components/ExportSvgDialog.js +0 -1
  21. package/dist/DotplotView/components/Grid.js +0 -1
  22. package/dist/DotplotView/components/Header.js +0 -1
  23. package/dist/DotplotView/components/ImportCustomTrack.js +0 -1
  24. package/dist/DotplotView/components/ImportForm.js +0 -1
  25. package/dist/DotplotView/components/ImportSyntenyTrackSelector.js +0 -1
  26. package/dist/DotplotView/components/PanButtons.js +0 -1
  27. package/dist/DotplotView/components/WarningDialog.js +0 -1
  28. package/dist/DotplotView/components/util.js +0 -1
  29. package/dist/DotplotView/index.js +0 -1
  30. package/dist/DotplotView/model.d.ts +64 -40
  31. package/dist/DotplotView/model.js +11 -4
  32. package/dist/DotplotView/svgcomponents/SVGBackground.js +2 -2
  33. package/dist/DotplotView/svgcomponents/SVGDotplotView.js +0 -1
  34. package/dist/LaunchDotplotView.js +0 -1
  35. package/dist/ServerSideRenderedBlockContent.js +0 -1
  36. package/dist/ServerSideSyntenyRendering.js +0 -1
  37. package/dist/index.js +0 -1
  38. package/dist/util.js +0 -1
  39. package/esm/ComparativeRenderer/index.js +0 -1
  40. package/esm/DotplotDisplay/components/DotplotDisplay.js +0 -1
  41. package/esm/DotplotDisplay/index.js +0 -1
  42. package/esm/DotplotDisplay/renderDotplotBlock.js +0 -1
  43. package/esm/DotplotDisplay/stateModelFactory.js +0 -1
  44. package/esm/DotplotReadVsRef/DotplotReadVsRef.js +0 -1
  45. package/esm/DotplotReadVsRef/index.js +0 -1
  46. package/esm/DotplotRenderer/ComparativeRenderRpc.js +0 -1
  47. package/esm/DotplotRenderer/DotplotRenderer.js +0 -1
  48. package/esm/DotplotRenderer/components/DotplotRendering.js +0 -1
  49. package/esm/DotplotRenderer/configSchema.js +0 -1
  50. package/esm/DotplotRenderer/index.js +0 -1
  51. package/esm/DotplotView/1dview.js +0 -1
  52. package/esm/DotplotView/blockTypes.js +0 -1
  53. package/esm/DotplotView/components/Axes.js +0 -1
  54. package/esm/DotplotView/components/CursorIcon.js +0 -1
  55. package/esm/DotplotView/components/DotplotTooltip.js +0 -1
  56. package/esm/DotplotView/components/DotplotView.js +0 -1
  57. package/esm/DotplotView/components/DotplotWarnings.js +0 -1
  58. package/esm/DotplotView/components/ExportSvgDialog.js +0 -1
  59. package/esm/DotplotView/components/Grid.js +0 -1
  60. package/esm/DotplotView/components/Header.js +0 -1
  61. package/esm/DotplotView/components/ImportCustomTrack.js +0 -1
  62. package/esm/DotplotView/components/ImportForm.js +0 -1
  63. package/esm/DotplotView/components/ImportSyntenyTrackSelector.js +0 -1
  64. package/esm/DotplotView/components/PanButtons.js +0 -1
  65. package/esm/DotplotView/components/WarningDialog.js +0 -1
  66. package/esm/DotplotView/components/util.js +0 -1
  67. package/esm/DotplotView/index.js +0 -1
  68. package/esm/DotplotView/model.d.ts +64 -40
  69. package/esm/DotplotView/model.js +11 -4
  70. package/esm/DotplotView/svgcomponents/SVGBackground.js +2 -2
  71. package/esm/DotplotView/svgcomponents/SVGDotplotView.js +0 -1
  72. package/esm/LaunchDotplotView.js +0 -1
  73. package/esm/ServerSideRenderedBlockContent.js +0 -1
  74. package/esm/ServerSideSyntenyRendering.js +0 -1
  75. package/esm/index.js +0 -1
  76. package/esm/util.js +0 -1
  77. package/package.json +4 -4
  78. package/dist/ComparativeRenderer/index.js.map +0 -1
  79. package/dist/DotplotDisplay/components/DotplotDisplay.js.map +0 -1
  80. package/dist/DotplotDisplay/index.js.map +0 -1
  81. package/dist/DotplotDisplay/renderDotplotBlock.js.map +0 -1
  82. package/dist/DotplotDisplay/stateModelFactory.js.map +0 -1
  83. package/dist/DotplotReadVsRef/DotplotReadVsRef.js.map +0 -1
  84. package/dist/DotplotReadVsRef/index.js.map +0 -1
  85. package/dist/DotplotRenderer/ComparativeRenderRpc.js.map +0 -1
  86. package/dist/DotplotRenderer/DotplotRenderer.js.map +0 -1
  87. package/dist/DotplotRenderer/components/DotplotRendering.js.map +0 -1
  88. package/dist/DotplotRenderer/configSchema.js.map +0 -1
  89. package/dist/DotplotRenderer/index.js.map +0 -1
  90. package/dist/DotplotView/1dview.js.map +0 -1
  91. package/dist/DotplotView/blockTypes.js.map +0 -1
  92. package/dist/DotplotView/components/Axes.js.map +0 -1
  93. package/dist/DotplotView/components/CursorIcon.js.map +0 -1
  94. package/dist/DotplotView/components/DotplotTooltip.js.map +0 -1
  95. package/dist/DotplotView/components/DotplotView.js.map +0 -1
  96. package/dist/DotplotView/components/DotplotWarnings.js.map +0 -1
  97. package/dist/DotplotView/components/ExportSvgDialog.js.map +0 -1
  98. package/dist/DotplotView/components/Grid.js.map +0 -1
  99. package/dist/DotplotView/components/Header.js.map +0 -1
  100. package/dist/DotplotView/components/ImportCustomTrack.js.map +0 -1
  101. package/dist/DotplotView/components/ImportForm.js.map +0 -1
  102. package/dist/DotplotView/components/ImportSyntenyTrackSelector.js.map +0 -1
  103. package/dist/DotplotView/components/PanButtons.js.map +0 -1
  104. package/dist/DotplotView/components/WarningDialog.js.map +0 -1
  105. package/dist/DotplotView/components/util.js.map +0 -1
  106. package/dist/DotplotView/index.js.map +0 -1
  107. package/dist/DotplotView/model.js.map +0 -1
  108. package/dist/DotplotView/svgcomponents/SVGBackground.js.map +0 -1
  109. package/dist/DotplotView/svgcomponents/SVGDotplotView.js.map +0 -1
  110. package/dist/LaunchDotplotView.js.map +0 -1
  111. package/dist/ServerSideRenderedBlockContent.js.map +0 -1
  112. package/dist/ServerSideSyntenyRendering.js.map +0 -1
  113. package/dist/index.js.map +0 -1
  114. package/dist/util.js.map +0 -1
  115. package/esm/ComparativeRenderer/index.js.map +0 -1
  116. package/esm/DotplotDisplay/components/DotplotDisplay.js.map +0 -1
  117. package/esm/DotplotDisplay/index.js.map +0 -1
  118. package/esm/DotplotDisplay/renderDotplotBlock.js.map +0 -1
  119. package/esm/DotplotDisplay/stateModelFactory.js.map +0 -1
  120. package/esm/DotplotReadVsRef/DotplotReadVsRef.js.map +0 -1
  121. package/esm/DotplotReadVsRef/index.js.map +0 -1
  122. package/esm/DotplotRenderer/ComparativeRenderRpc.js.map +0 -1
  123. package/esm/DotplotRenderer/DotplotRenderer.js.map +0 -1
  124. package/esm/DotplotRenderer/components/DotplotRendering.js.map +0 -1
  125. package/esm/DotplotRenderer/configSchema.js.map +0 -1
  126. package/esm/DotplotRenderer/index.js.map +0 -1
  127. package/esm/DotplotView/1dview.js.map +0 -1
  128. package/esm/DotplotView/blockTypes.js.map +0 -1
  129. package/esm/DotplotView/components/Axes.js.map +0 -1
  130. package/esm/DotplotView/components/CursorIcon.js.map +0 -1
  131. package/esm/DotplotView/components/DotplotTooltip.js.map +0 -1
  132. package/esm/DotplotView/components/DotplotView.js.map +0 -1
  133. package/esm/DotplotView/components/DotplotWarnings.js.map +0 -1
  134. package/esm/DotplotView/components/ExportSvgDialog.js.map +0 -1
  135. package/esm/DotplotView/components/Grid.js.map +0 -1
  136. package/esm/DotplotView/components/Header.js.map +0 -1
  137. package/esm/DotplotView/components/ImportCustomTrack.js.map +0 -1
  138. package/esm/DotplotView/components/ImportForm.js.map +0 -1
  139. package/esm/DotplotView/components/ImportSyntenyTrackSelector.js.map +0 -1
  140. package/esm/DotplotView/components/PanButtons.js.map +0 -1
  141. package/esm/DotplotView/components/WarningDialog.js.map +0 -1
  142. package/esm/DotplotView/components/util.js.map +0 -1
  143. package/esm/DotplotView/index.js.map +0 -1
  144. package/esm/DotplotView/model.js.map +0 -1
  145. package/esm/DotplotView/svgcomponents/SVGBackground.js.map +0 -1
  146. package/esm/DotplotView/svgcomponents/SVGDotplotView.js.map +0 -1
  147. package/esm/LaunchDotplotView.js.map +0 -1
  148. package/esm/ServerSideRenderedBlockContent.js.map +0 -1
  149. package/esm/ServerSideSyntenyRendering.js.map +0 -1
  150. package/esm/index.js.map +0 -1
  151. package/esm/util.js.map +0 -1
  152. package/src/ComparativeRenderer/index.ts +0 -87
  153. package/src/DotplotDisplay/components/DotplotDisplay.tsx +0 -34
  154. package/src/DotplotDisplay/index.ts +0 -48
  155. package/src/DotplotDisplay/renderDotplotBlock.ts +0 -60
  156. package/src/DotplotDisplay/stateModelFactory.tsx +0 -196
  157. package/src/DotplotReadVsRef/DotplotReadVsRef.ts +0 -115
  158. package/src/DotplotReadVsRef/index.ts +0 -50
  159. package/src/DotplotRenderer/ComparativeRenderRpc.ts +0 -87
  160. package/src/DotplotRenderer/DotplotRenderer.ts +0 -328
  161. package/src/DotplotRenderer/__image_snapshots__/linear-synteny-renderer-test-ts-test-rendering-a-simple-synteny-from-fake-data-1-snap.png +0 -0
  162. package/src/DotplotRenderer/components/DotplotRendering.tsx +0 -12
  163. package/src/DotplotRenderer/configSchema.ts +0 -92
  164. package/src/DotplotRenderer/index.ts +0 -16
  165. package/src/DotplotView/1dview.ts +0 -98
  166. package/src/DotplotView/blockTypes.ts +0 -140
  167. package/src/DotplotView/components/Axes.tsx +0 -246
  168. package/src/DotplotView/components/CursorIcon.tsx +0 -24
  169. package/src/DotplotView/components/DotplotTooltip.tsx +0 -163
  170. package/src/DotplotView/components/DotplotView.tsx +0 -348
  171. package/src/DotplotView/components/DotplotWarnings.tsx +0 -26
  172. package/src/DotplotView/components/ExportSvgDialog.tsx +0 -129
  173. package/src/DotplotView/components/Grid.tsx +0 -112
  174. package/src/DotplotView/components/Header.tsx +0 -182
  175. package/src/DotplotView/components/ImportCustomTrack.tsx +0 -262
  176. package/src/DotplotView/components/ImportForm.tsx +0 -209
  177. package/src/DotplotView/components/ImportSyntenyTrackSelector.tsx +0 -90
  178. package/src/DotplotView/components/PanButtons.tsx +0 -93
  179. package/src/DotplotView/components/WarningDialog.tsx +0 -74
  180. package/src/DotplotView/components/util.ts +0 -118
  181. package/src/DotplotView/index.ts +0 -16
  182. package/src/DotplotView/model.test.ts +0 -17
  183. package/src/DotplotView/model.ts +0 -719
  184. package/src/DotplotView/svgcomponents/SVGBackground.tsx +0 -21
  185. package/src/DotplotView/svgcomponents/SVGDotplotView.tsx +0 -68
  186. package/src/LaunchDotplotView.ts +0 -63
  187. package/src/ServerSideRenderedBlockContent.tsx +0 -86
  188. package/src/ServerSideSyntenyRendering.tsx +0 -54
  189. package/src/index.ts +0 -41
  190. package/src/util.ts +0 -14
@@ -1,246 +0,0 @@
1
- import React from 'react'
2
- import { makeStyles } from 'tss-react/mui'
3
- import { observer } from 'mobx-react'
4
- import { getSnapshot } from 'mobx-state-tree'
5
- import { getTickDisplayStr } from '@jbrowse/core/util'
6
- import { bpToPx } from '@jbrowse/core/util/Base1DUtils'
7
- import { useTheme } from '@mui/material'
8
-
9
- // locals
10
- import { getBlockLabelKeysToHide } from './util'
11
- import { DotplotViewModel } from '../model'
12
-
13
- const useStyles = makeStyles()(() => ({
14
- vtext: {
15
- gridColumn: '1/2',
16
- gridRow: '1/2',
17
- pointerEvents: 'none',
18
- userSelect: 'none',
19
- },
20
- htext: {
21
- gridColumn: '2/2',
22
- gridRow: '2/2',
23
- pointerEvents: 'none',
24
- userSelect: 'none',
25
- },
26
- }))
27
-
28
- export const HorizontalAxis = observer(function ({
29
- model,
30
- }: {
31
- model: DotplotViewModel
32
- }) {
33
- const { viewWidth, borderY } = model
34
- const { classes } = useStyles()
35
- return (
36
- <svg width={viewWidth} height={borderY} className={classes.htext}>
37
- <HorizontalAxisRaw model={model} />
38
- </svg>
39
- )
40
- })
41
-
42
- export const HorizontalAxisRaw = observer(function ({
43
- model,
44
- }: {
45
- model: DotplotViewModel
46
- }) {
47
- const { viewWidth, borderX, borderY, hview, htextRotation, hticks } = model
48
- const { offsetPx, width, dynamicBlocks, bpPerPx } = hview
49
- const dblocks = dynamicBlocks.contentBlocks
50
- const hide = getBlockLabelKeysToHide(dblocks, viewWidth, offsetPx)
51
- const theme = useTheme()
52
- const hviewSnap = {
53
- ...getSnapshot(hview),
54
- width,
55
- staticBlocks: hview.staticBlocks,
56
- }
57
-
58
- return (
59
- <>
60
- {dblocks
61
- .filter(region => !hide.has(region.key))
62
- .map(region => {
63
- const x = region.offsetPx
64
- const y = 0
65
- const xoff = Math.floor(x - hview.offsetPx)
66
-
67
- return (
68
- <text
69
- transform={`rotate(${htextRotation},${xoff},${y})`}
70
- key={JSON.stringify(region)}
71
- x={xoff}
72
- y={y + 1}
73
- fill={theme.palette.text.primary}
74
- fontSize={11}
75
- dominantBaseline="hanging"
76
- textAnchor="end"
77
- >
78
- {region.refName}
79
- </text>
80
- )
81
- })}
82
- {hticks.map(tick => {
83
- const x =
84
- (bpToPx({
85
- refName: tick.refName,
86
- coord: tick.base,
87
- self: hviewSnap,
88
- })?.offsetPx || 0) - offsetPx
89
- return (
90
- <line
91
- key={`line-${JSON.stringify(tick)}`}
92
- x1={x}
93
- x2={x}
94
- y1={0}
95
- y2={tick.type === 'major' ? 6 : 4}
96
- strokeWidth={1}
97
- stroke={theme.palette.divider}
98
- />
99
- )
100
- })}
101
- {hticks
102
- .filter(tick => tick.type === 'major')
103
- .map(tick => {
104
- const x =
105
- (bpToPx({
106
- refName: tick.refName,
107
- coord: tick.base,
108
- self: hviewSnap,
109
- })?.offsetPx || 0) - offsetPx
110
- const y = 0
111
- return x > 10 ? (
112
- <text
113
- x={x - 7}
114
- y={y}
115
- transform={`rotate(${htextRotation},${x},${y})`}
116
- key={`text-${JSON.stringify(tick)}`}
117
- fill={theme.palette.text.primary}
118
- fontSize={11}
119
- dominantBaseline="middle"
120
- textAnchor="end"
121
- >
122
- {getTickDisplayStr(tick.base + 1, bpPerPx)}
123
- </text>
124
- ) : null
125
- })}
126
- <text
127
- y={borderY - 12}
128
- x={(viewWidth - borderX) / 2}
129
- fill={theme.palette.text.primary}
130
- textAnchor="middle"
131
- fontSize={11}
132
- dominantBaseline="hanging"
133
- >
134
- {hview.assemblyNames.join(',')}
135
- </text>
136
- </>
137
- )
138
- })
139
-
140
- export const VerticalAxis = observer(function ({
141
- model,
142
- }: {
143
- model: DotplotViewModel
144
- }) {
145
- const { borderX, viewHeight } = model
146
- const { classes } = useStyles()
147
- return (
148
- <svg className={classes.vtext} width={borderX} height={viewHeight}>
149
- <VerticalAxisRaw model={model} />
150
- </svg>
151
- )
152
- })
153
-
154
- export const VerticalAxisRaw = observer(function ({
155
- model,
156
- }: {
157
- model: DotplotViewModel
158
- }) {
159
- const { viewHeight, borderX, borderY, vview, vtextRotation, vticks } = model
160
- const { offsetPx, width, dynamicBlocks, bpPerPx } = vview
161
- const dblocks = dynamicBlocks.contentBlocks
162
- const hide = getBlockLabelKeysToHide(dblocks, viewHeight, offsetPx)
163
- const theme = useTheme()
164
- const vviewSnap = {
165
- ...getSnapshot(vview),
166
- width,
167
- staticBlocks: vview.staticBlocks,
168
- }
169
- return (
170
- <>
171
- {dblocks
172
- .filter(region => !hide.has(region.key))
173
- .map(region => {
174
- const y = region.offsetPx
175
- const x = borderX
176
- const yoff = Math.floor(viewHeight - y + offsetPx)
177
-
178
- return (
179
- <text
180
- transform={`rotate(${vtextRotation},${x},${y})`}
181
- key={JSON.stringify(region)}
182
- x={x}
183
- y={yoff}
184
- fill={theme.palette.text.primary}
185
- fontSize={11}
186
- textAnchor="end"
187
- >
188
- {region.refName}
189
- </text>
190
- )
191
- })}
192
- {vticks.map(tick => {
193
- const y =
194
- (bpToPx({
195
- refName: tick.refName,
196
- coord: tick.base,
197
- self: vviewSnap,
198
- })?.offsetPx || 0) - offsetPx
199
- return (
200
- <line
201
- key={`line-${JSON.stringify(tick)}`}
202
- y1={viewHeight - y}
203
- y2={viewHeight - y}
204
- x1={borderX}
205
- x2={borderX - (tick.type === 'major' ? 6 : 4)}
206
- strokeWidth={1}
207
- stroke={theme.palette.divider}
208
- />
209
- )
210
- })}
211
- {vticks
212
- .filter(tick => tick.type === 'major')
213
- .map(tick => {
214
- const y =
215
- (bpToPx({
216
- refName: tick.refName,
217
- coord: tick.base,
218
- self: vviewSnap,
219
- })?.offsetPx || 0) - offsetPx
220
- return y > 10 ? (
221
- <text
222
- y={viewHeight - y - 3}
223
- x={borderX - 7}
224
- key={`text-${JSON.stringify(tick)}`}
225
- textAnchor="end"
226
- fill={theme.palette.text.primary}
227
- dominantBaseline="hanging"
228
- fontSize={11}
229
- >
230
- {getTickDisplayStr(tick.base + 1, bpPerPx)}
231
- </text>
232
- ) : null
233
- })}
234
- <text
235
- y={(viewHeight - borderY) / 2}
236
- x={12}
237
- fill={theme.palette.text.primary}
238
- transform={`rotate(-90,12,${(viewHeight - borderY) / 2})`}
239
- textAnchor="middle"
240
- fontSize={11}
241
- >
242
- {vview.assemblyNames.join(',')}
243
- </text>
244
- </>
245
- )
246
- })
@@ -1,24 +0,0 @@
1
- import SvgIcon, { SvgIconProps } from '@mui/material/SvgIcon'
2
- import React from 'react'
3
-
4
- export function CursorMove(props: SvgIconProps) {
5
- return (
6
- <SvgIcon {...props}>
7
- <path
8
- fill="currentColor"
9
- d="M13,6V11H18V7.75L22.25,12L18,16.25V13H13V18H16.25L12,22.25L7.75,18H11V13H6V16.25L1.75,12L6,7.75V11H11V6H7.75L12,1.75L16.25,6H13Z"
10
- />
11
- </SvgIcon>
12
- )
13
- }
14
-
15
- export function CursorMouse(props: SvgIconProps) {
16
- return (
17
- <SvgIcon {...props}>
18
- <path
19
- fill="currentColor"
20
- d="M10.07,14.27C10.57,14.03 11.16,14.25 11.4,14.75L13.7,19.74L15.5,18.89L13.19,13.91C12.95,13.41 13.17,12.81 13.67,12.58L13.95,12.5L16.25,12.05L8,5.12V15.9L9.82,14.43L10.07,14.27M13.64,21.97C13.14,22.21 12.54,22 12.31,21.5L10.13,16.76L7.62,18.78C7.45,18.92 7.24,19 7,19A1,1 0 0,1 6,18V3A1,1 0 0,1 7,2C7.24,2 7.47,2.09 7.64,2.23L7.65,2.22L19.14,11.86C19.57,12.22 19.62,12.85 19.27,13.27C19.12,13.45 18.91,13.57 18.7,13.61L15.54,14.23L17.74,18.96C18,19.46 17.76,20.05 17.26,20.28L13.64,21.97Z"
21
- />
22
- </SvgIcon>
23
- )
24
- }
@@ -1,163 +0,0 @@
1
- import React, { useMemo, useRef, useState } from 'react'
2
- import { observer } from 'mobx-react'
3
- import { makeStyles } from 'tss-react/mui'
4
-
5
- // locals
6
- import { DotplotViewModel } from '../model'
7
- import { locstr } from './util'
8
- import { Portal, alpha } from '@mui/material'
9
- import { usePopper } from 'react-popper'
10
-
11
- export function round(value: number) {
12
- return Math.round(value * 1e5) / 1e5
13
- }
14
- const useStyles = makeStyles()(theme => ({
15
- // these styles come from
16
- // https://github.com/mui-org/material-ui/blob/master/packages/material-ui/src/Tooltip/Tooltip.js
17
- tooltip: {
18
- position: 'absolute',
19
- pointerEvents: 'none',
20
- backgroundColor: alpha(theme.palette.grey[700], 0.9),
21
- borderRadius: theme.shape.borderRadius,
22
- color: theme.palette.common.white,
23
- fontFamily: theme.typography.fontFamily,
24
- padding: '4px 8px',
25
- fontSize: theme.typography.pxToRem(12),
26
- lineHeight: `${round(14 / 10)}em`,
27
- maxWidth: 300,
28
- wordWrap: 'break-word',
29
- },
30
- }))
31
-
32
- type Coord = [number, number] | undefined
33
- const blank = { left: 0, top: 0, width: 0, height: 0 }
34
-
35
- export const TooltipWhereMouseovered = observer(function ({
36
- model,
37
- mouserect,
38
- mouserectClient,
39
- xdistance,
40
- ydistance,
41
- }: {
42
- model: DotplotViewModel
43
- mouserect: Coord
44
- mouserectClient: Coord
45
- xdistance: number
46
- ydistance: number
47
- }) {
48
- const { classes } = useStyles()
49
- const { hview, vview, viewHeight } = model
50
- const [anchorEl, setAnchorEl] = useState<HTMLDivElement | null>(null)
51
- const ref = useRef<HTMLDivElement>(null)
52
- const rect = ref.current?.getBoundingClientRect() || blank
53
- const offset = 6
54
- const w = rect.height + offset * 2
55
-
56
- // must be memoized a la https://github.com/popperjs/react-popper/issues/391
57
- const virtElement = useMemo(
58
- () => ({
59
- getBoundingClientRect: () => {
60
- const x = offset + (mouserectClient?.[0] || 0) - (xdistance < 0 ? w : 0)
61
- const y = offset + (mouserectClient?.[1] || 0) - (ydistance < 0 ? w : 0)
62
- return {
63
- top: y,
64
- left: x,
65
- bottom: y,
66
- right: x,
67
- width: 0,
68
- height: 0,
69
- x,
70
- y,
71
- toJSON() {},
72
- }
73
- },
74
- }),
75
- [mouserectClient, xdistance, ydistance, w],
76
- )
77
- const { styles, attributes } = usePopper(virtElement, anchorEl, {
78
- placement: xdistance < 0 ? 'left' : 'right',
79
- })
80
- return (
81
- <>
82
- {mouserect ? (
83
- <Portal>
84
- <div
85
- ref={setAnchorEl}
86
- className={classes.tooltip}
87
- // zIndex needed to go over widget drawer
88
- style={{ ...styles.popper, zIndex: 100000 }}
89
- {...attributes.popper}
90
- >
91
- {`x - ${locstr(mouserect[0], hview)}`}
92
- <br />
93
- {`y - ${locstr(viewHeight - mouserect[1], vview)}`}
94
- <br />
95
- </div>
96
- </Portal>
97
- ) : null}
98
- </>
99
- )
100
- })
101
-
102
- export const TooltipWhereClicked = observer(function ({
103
- model,
104
- mousedown,
105
- mousedownClient,
106
- xdistance,
107
- ydistance,
108
- }: {
109
- model: DotplotViewModel
110
- mousedown: Coord
111
- mousedownClient: Coord
112
- xdistance: number
113
- ydistance: number
114
- }) {
115
- const { classes } = useStyles()
116
- const { hview, vview, viewHeight } = model
117
- const [anchorEl, setAnchorEl] = useState<HTMLDivElement | null>(null)
118
-
119
- // must be memoized a la https://github.com/popperjs/react-popper/issues/391
120
- const virtElement = useMemo(
121
- () => ({
122
- getBoundingClientRect: () => {
123
- const x = (mousedownClient?.[0] || 0) - (xdistance < 0 ? 0 : 0)
124
- const y = (mousedownClient?.[1] || 0) - (ydistance < 0 ? 0 : 0)
125
- return {
126
- top: y,
127
- left: x,
128
- bottom: y,
129
- right: x,
130
- width: 0,
131
- height: 0,
132
- x,
133
- y,
134
- toJSON() {},
135
- }
136
- },
137
- }),
138
- [mousedownClient, xdistance, ydistance],
139
- )
140
- const { styles, attributes } = usePopper(virtElement, anchorEl, {
141
- placement: xdistance < 0 ? 'right' : 'left',
142
- })
143
- return (
144
- <>
145
- {mousedown && Math.abs(xdistance) > 3 && Math.abs(ydistance) > 3 ? (
146
- <Portal>
147
- <div
148
- ref={setAnchorEl}
149
- className={classes.tooltip}
150
- // zIndex needed to go over widget drawer
151
- style={{ ...styles.popper, zIndex: 100000 }}
152
- {...attributes.popper}
153
- >
154
- {`x - ${locstr(mousedown[0], hview)}`}
155
- <br />
156
- {`y - ${locstr(viewHeight - mousedown[1], vview)}`}
157
- <br />
158
- </div>
159
- </Portal>
160
- ) : null}
161
- </>
162
- )
163
- })