Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add WIP map view #536

Open
wants to merge 15 commits into
base: add-map-view
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ taxonium_component/storybook-static/**
**/*.egg-info/**
**/*.pyc
**/_version.py
node_modules
6 changes: 6 additions & 0 deletions package-lock.json
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We use yarn for taxonium - I think that means we can lose this file but let me know if there's a reason it's useful, I'm no expert

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will remove! I'm used to NPM based projects, so this was just a force of habit.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

66 changes: 56 additions & 10 deletions taxonium_component/src/Deck.jsx
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We seem to have ended up with the zoom controls repeated 2x, once on the map and once on the tree. (I'd say they are better just on the tree).

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a usecase where zooming into the map would be helpful? I was assuming that users may want to zoom into part of the map to view pie charts in only certain regions (eventually), but maybe you had a different idea here. Would the map view be fully zoomed out by default if we remove the zoom functionality?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, there might be use cases where zooming would be useful - but atm the buttons on the map affect the tree so this is not achieved. I don't see a strong need for zoom buttons for the map -- as opposed to panning and scrolling -- we need them for the tree due to separate X and Y zooms.

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import React, { useState, useCallback, useRef } from "react";
import DeckGL from "@deck.gl/react";
import { View } from "@deck.gl/core";
import useLayers from "./hooks/useLayers";
import JBrowsePanel from "./components/JBrowsePanel";
import { ClipLoader } from "react-spinners";
import {
CircularProgressbarWithChildren,
Expand All @@ -19,9 +18,9 @@ import DeckSettingsModal from "./components/DeckSettingsModal";
import { TreenomeButtons } from "./components/TreenomeButtons";
import TreenomeModal from "./components/TreenomeModal";
import FirefoxWarning from "./components/FirefoxWarning";
import { JBrowseErrorBoundary } from "./components/JBrowseErrorBoundary";
import ColorSettingModal from "./components/ColorSettingModal";
import Key from "./components/Key";
import ColorSettingModal from "./components/ColorSettingModal";
import TreenomeBrowser from "./components/TreenomeBrowser";

const MemoizedKey = React.memo(Key);

Expand Down Expand Up @@ -359,12 +358,7 @@ function Deck({
}}
>
<span ref={jbrowseRef}>
<JBrowseErrorBoundary>
<JBrowsePanel
treenomeState={treenomeState}
settings={settings}
/>
</JBrowseErrorBoundary>
<TreenomeBrowser state={treenomeState} settings={settings} />
<TreenomeModal
treenomeSettingsOpen={treenomeSettingsOpen}
setTreenomeSettingsOpen={setTreenomeSettingsOpen}
Expand All @@ -384,7 +378,59 @@ function Deck({
settings={settings}
/>
</View>
<View id="main"></View>

<View id="map">
<div
id="map-div"
key={crypto.randomUUID()}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this unique key each time important? (I assume so but just checking)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Usually I err on the side of including an id so that React can more efficiently calculate rerenders. I believe this specific case was added because a warning in the console, so it seems like React was struggling to update Views.

Copy link
Owner

@theosanderson theosanderson Oct 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, the re-render thing was my concern here. My model for what will happen for the code here is that every render the key will be different and so React will not be able to see that there is a (potentially) unchanging element here. I would be happy with key="map-div-key" or similar. Again, I don't claim to be an expert and may be misunderstanding.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you're totally right here, so I just swapped out the crypto.uuid with the "map-div-key" string. Thanks!

style={{
width: "100%",
height: "100%",
borderLeftWidth: "1px",
borderColor: "black",
borderStyle: "solid",
position: "relative",
zIndex: 2,
}}
></div>
</View>

<View id="main">
<NodeHoverTip
hoverInfo={hoverInfo}
hoverDetails={hoverDetails}
colorHook={colorHook}
colorBy={colorBy}
config={config}
filterMutations={settings.filterMutations}
deckSize={deckSize}
/>
<TreenomeMutationHoverTip
hoverInfo={hoverInfo}
hoverDetails={hoverDetails}
colorHook={colorHook}
colorBy={colorBy}
config={config}
treenomeReferenceInfo={treenomeReferenceInfo}
/>
<MemoizedKey
keyStuff={keyStuff}
colorByField={colorBy.colorByField}
colorByGene={colorBy.colorByGene}
colorByPosition={colorBy.colorByPosition}
config={config}
/>
<DeckButtons
zoomReset={zoomReset}
zoomIncrement={zoomIncrement}
zoomAxis={zoomAxis}
setZoomAxis={setZoomAxis}
snapshot={snapshot}
loading={data.status === "loading"}
requestOpenSettings={() => setDeckSettingsOpen(true)}
settings={settings}
/>
</View>
</DeckGL>
</div>
);
Expand Down
27 changes: 27 additions & 0 deletions taxonium_component/src/components/SearchPanel.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,33 @@ function SearchPanel({
</button>
</span>
)}
{<br />}
{true && (
<span>
<span className="text-gray-500 text-sm">Map View:</span>
<input
name="mapEnabled"
style={{ verticalAlign: "middle" }}
type="checkbox"
className="m-3 inline-block"
checked={settings.mapViewOpen}
onChange={(e) => {
settings.setMapOpenAndToast(!settings.mapViewOpen);
}}
/>
<button
style={{ cursor: "default" }}
data-tip="Display a map with points corresponding to the location a sample was collected."
data-html={true}
>
<span
style={{ display: "inline-block", verticalAlign: "middle" }}
>
<BsQuestionCircle />
</span>
</button>
</span>
)}
</div>
<div className="py-3 space-y-2">
<div className="flex space-x-2">
Expand Down
10 changes: 10 additions & 0 deletions taxonium_component/src/components/TreenomeBrowser.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import JBrowsePanel from "./JBrowsePanel";
import { JBrowseErrorBoundary } from "./JBrowseErrorBoundary";

export default function TreenomeBrowser({ state, settings }) {
return (
<JBrowseErrorBoundary>
<JBrowsePanel treenomeState={state} settings={settings} />
</JBrowseErrorBoundary>
);
}
Loading