Skip to content

Commit

Permalink
Restore loading bar when opening a dotplot track and other small fixes (
Browse files Browse the repository at this point in the history
#3569)

* Fix loading message not displaying after dotplot refactors

* Release ctrlKey mode on mouse up

* Avoid a crash in the renderer when passed empty region set

* Bump lock
  • Loading branch information
cmdcolin committed Mar 8, 2023
1 parent 3037b59 commit ce05d01
Show file tree
Hide file tree
Showing 15 changed files with 483 additions and 482 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,21 @@ function DotplotDisplay(props: {
children?: React.ReactNode
}) {
const { model, children } = props
const { offsetX = 0, offsetY = 0, bpPerPxX, bpPerPxY } = model.data || {}
const { offsetX = 0, offsetY = 0 } = model.data || {}
const view = getContainingView(model) as DotplotViewModel
const same =
view.vview.bpPerPx === bpPerPxY && view.hview.bpPerPx === bpPerPxX

const top = view.vview.offsetPx - offsetY
const left = -(view.hview.offsetPx - offsetX)
return (
<div style={{ position: 'relative' }}>
{same ? (
<model.ReactComponent2
{...props}
style={{
position: 'absolute',
top,
left,
}}
/>
) : null}
<model.ReactComponent2
{...props}
style={{
position: 'absolute',
top,
left,
}}
/>
{children}
</div>
)
Expand Down
7 changes: 7 additions & 0 deletions plugins/dotplot-view/src/DotplotDisplay/stateModelFactory.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@ export function stateModelFactory(configSchema: AnyConfigurationSchemaType) {
})),
)
.views(self => ({
get shouldDisplay() {
const view = getContainingView(self)
return (
view.vview.bpPerPx === self.data.bpPerPxY &&
view.hview.bpPerPx === self.data.bpPerPxX
)
},
/**
* #getter
*/
Expand Down
4 changes: 2 additions & 2 deletions plugins/dotplot-view/src/DotplotRenderer/DotplotRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -319,8 +319,8 @@ export default class DotplotRenderer extends ComparativeRenderer {
...ret,
height,
width,
offsetX: views[0].dynamicBlocks.blocks[0].offsetPx,
offsetY: views[1].dynamicBlocks.blocks[0].offsetPx,
offsetX: views[0].dynamicBlocks.blocks[0]?.offsetPx || 0,
offsetY: views[1].dynamicBlocks.blocks[0]?.offsetPx || 0,
bpPerPxX: views[0].bpPerPx,
bpPerPxY: views[1].bpPerPx,
}
Expand Down
4 changes: 2 additions & 2 deletions plugins/dotplot-view/src/DotplotView/1dview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,14 @@ const Dotplot1DView = Base1DView.extend(self => {
* #getter
*/
get maxOffset() {
return self.displayedRegionsTotalPx - self.width * 0.95
return self.displayedRegionsTotalPx - self.width * 0.2
},

/**
* #getter
*/
get minOffset() {
return -self.width * 0.05
return -self.width * 0.8
},
},
actions: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ const DotplotViewInternal = observer(function ({
let cleanup = () => {}

function globalMouseUp(event: MouseEvent) {
setCtrlKeyWasUsed(false)
if (Math.abs(xdistance) > 3 && Math.abs(ydistance) > 3 && validSelect) {
setMouseUpClient([event.clientX, event.clientY])
} else {
Expand Down
32 changes: 8 additions & 24 deletions plugins/dotplot-view/src/DotplotView/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,30 +111,6 @@ export default function stateModelFactory(pm: PluginManager) {
* #property
*/
vview: types.optional(DotplotVView, {}),
/**
* #property
*/
cursorMode: types.optional(
types.string,
() => localStorageGetItem('dotplot-cursorMode') || 'crosshair',
),

/**
* #property
*/
wheelMode: types.optional(
types.string,
() => localStorageGetItem('dotplot-wheelMode') || 'zoom',
),

/**
* #property
*/
showPanButtons: types.optional(types.boolean, () =>
Boolean(
JSON.parse(localStorageGetItem('dotplot-showPanbuttons') || 'true'),
),
),

/**
* #property
Expand All @@ -155,6 +131,14 @@ export default function stateModelFactory(pm: PluginManager) {
.volatile(() => ({
volatileWidth: undefined as number | undefined,
volatileError: undefined as unknown,

// these are 'personal preferences', stored in volatile and
// loaded/written to localStorage
cursorMode: localStorageGetItem('dotplot-cursorMode') || 'crosshair',
showPanButtons: Boolean(
JSON.parse(localStorageGetItem('dotplot-showPanbuttons') || 'true'),
),
wheelMode: localStorageGetItem('dotplot-wheelMode') || 'zoom',
borderX: 100,
borderY: 100,
}))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ export async function renderToSvg(
<VerticalAxisRaw model={model} />
<g transform={`translate(${borderX} 0)`}>
<GridRaw model={model} />

<defs>
<clipPath id="clip-ruler">
<rect x={0} y={0} width={viewWidth} height={viewHeight} />
Expand Down
16 changes: 10 additions & 6 deletions plugins/dotplot-view/src/ServerSideRenderedBlockContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,17 @@ function BlockError({ error }: { error: unknown }) {
)
}

const ServerSideRenderedBlockContent = observer(function ({
export default observer(function ({
model,
style,
}: {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
model: any
model: {
error?: unknown
message?: string
filled?: boolean
shouldDisplay?: boolean
reactElement?: React.ReactElement
}
style: CSSProperties
}) {
if (model.error) {
Expand All @@ -74,9 +79,8 @@ const ServerSideRenderedBlockContent = observer(function ({
return <BlockMessage messageText={model.message} />
} else if (!model.filled) {
return <LoadingMessage />
} else {
} else if (model.shouldDisplay) {
return <div style={style}>{model.reactElement}</div>
}
return null
})

export default ServerSideRenderedBlockContent
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export default function SVGTrackLabel({
const theme = useTheme()
const fill = theme.palette.text.primary
const xoff = trackLabels === 'overlay' ? 5 : 0
const yoff = trackLabels === 'offset' ? 5 : 0
return trackLabels !== 'none' ? (
<g>
{trackLabels === 'left' ? (
Expand All @@ -33,6 +34,7 @@ export default function SVGTrackLabel({
) : (
<text
x={x + xoff}
y={yoff}
fill={fill}
fontSize={fontSize}
dominantBaseline="hanging"
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Loading

0 comments on commit ce05d01

Please sign in to comment.