Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
10 changes: 9 additions & 1 deletion src/components/PopoverCard/index.tsx

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Image

Updated rendering for the feature values at the bottom of this popover

Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ export interface PopoverCardProps {
xValue?: string;
yLabel?: string;
yValue?: string;
lineLabel?: string;
lineValue?: string;
}

const PopoverCard: React.FC<PopoverCardProps> = (props) => {
Expand Down Expand Up @@ -46,7 +48,7 @@ const PopoverCard: React.FC<PopoverCardProps> = (props) => {
return (
<Card className={styles.container} cover={cover} variant="borderless">
<Meta description={props.description} title={props.title} />
{(props.xValue || props.yValue) && (
{(props.xValue || props.yValue || props.lineValue !== undefined) && (
<div className={styles.axisValues}>
{props.xValue && (
<div className={styles.axisRow}>
Expand All @@ -60,6 +62,12 @@ const PopoverCard: React.FC<PopoverCardProps> = (props) => {
<span className={styles.axisValue}>{props.yValue}</span>
</div>
)}
{props.lineValue && (
<div className={styles.axisRow}>
<span className={styles.axisLabel}>{props.lineLabel}</span>
<span className={styles.axisValue}>{props.lineValue}</span>
</div>
)}
</div>
)}
</Card>
Expand Down
13 changes: 12 additions & 1 deletion src/containers/MainPlotContainer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ import {
getXAxisRange,
getYAxisRange,
getAnnotations,
getConnectByFeatureDisplayName,
getFormattedHoveredConnectByFeatureValue,
} from "./selectors";
import { getFeatureDefTooltip } from "../../state/selection/selectors";
import { formatThumbnailSrc } from "../../state/util";
Expand All @@ -66,11 +68,13 @@ interface PropsFromState {
hoveredPointData: SelectedPointData | null;
hoveredXValue: string;
hoveredYValue: string;
hoveredConnectByFeatureValue: string;
mousePosition: MousePosition;
plotDataArray: any;
thumbnailRoot: string;
xDisplayName: string;
yDisplayName: string;
connectByFeatureDisplayName: string;
xDropDownValue: string;
yDropDownValue: string;
yDropDownOptions: MeasuredFeatureDef[];
Expand Down Expand Up @@ -203,7 +207,8 @@ class MainPlotContainer extends React.Component<MainPlotContainerProps, MainPlot
srcPath: point.customdata.srcPath,
xValue: point.x,
yValue: point.y,
});
connectByFeatureValue: point.customdata.connectByFeature,
} satisfies SelectedPointData);
this.loadThumbnailForZarr(point.id, point.customdata.srcPath);
} else {
changeHoveredPoint(null);
Expand Down Expand Up @@ -251,6 +256,8 @@ class MainPlotContainer extends React.Component<MainPlotContainerProps, MainPlot
yDisplayName,
hoveredXValue,
hoveredYValue,
connectByFeatureDisplayName,
hoveredConnectByFeatureValue,
} = this.props;
let thumbnailSrc: string | undefined = formatThumbnailSrc(
thumbnailRoot,
Expand All @@ -273,6 +280,8 @@ class MainPlotContainer extends React.Component<MainPlotContainerProps, MainPlot
xValue={hoveredXValue}
yLabel={yDisplayName}
yValue={hoveredYValue}
lineLabel={connectByFeatureDisplayName}
lineValue={hoveredConnectByFeatureValue}
/>
)
);
Expand Down Expand Up @@ -383,6 +392,8 @@ function mapStateToProps(state: State): PropsFromState {
thumbnailRoot: selectionStateBranch.selectors.getThumbnailRoot(state),
xDisplayName: getXDisplayName(state),
yDisplayName: getYDisplayName(state),
connectByFeatureDisplayName: getConnectByFeatureDisplayName(state),
hoveredConnectByFeatureValue: getFormattedHoveredConnectByFeatureValue(state),
xDropDownOptions: getXDisplayOptions(state),
xDropDownValue: selectionStateBranch.selectors.getPlotByOnX(state),
xTickConversion: getXTickConversion(state),
Expand Down
66 changes: 50 additions & 16 deletions src/containers/MainPlotContainer/selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import {
getShowConnectLines,
getFilteredConnectByCategoryValues,
getLineMovingAverageWindow,
getConnectByFeature,
} from "../../state/selection/selectors";
import { MainPlotSettings, SelectedPointData, TickConversion } from "../../state/selection/types";
import {
Expand Down Expand Up @@ -103,16 +104,24 @@ export const handleNullValues = (
};

export const getPlotlyCustomData = createSelector(
[getFilteredCellData],
(filteredCellData: DataForPlot): PlotlyCustomData[] => {
[getFilteredCellData, getShowConnectLines, getConnectByFeature],
(
filteredCellData: DataForPlot,
showConnectByLines: boolean,
connectByFeature: string

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

What are the potential values of connectByFeature? It's not immediately obvious to me. Is it an enum in practice or something else?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It's the string key of any feature in the currently-loaded dataset!

): PlotlyCustomData[] => {
const thumbnailPaths = filteredCellData.labels.thumbnailPaths;
const srcPaths = filteredCellData.labels.sourcePaths;
const indices = filteredCellData.indices;
const connectByFeatureValues = showConnectByLines
? filteredCellData.values[connectByFeature]
: undefined;
return map(indices, (cellIndex, i) => {
return {
index: cellIndex,
thumbnailPath: thumbnailPaths[i],
srcPath: srcPaths?.[i],
connectByFeature: connectByFeatureValues?.[i],
};
Comment thread
ShrimpCryptid marked this conversation as resolved.
});
}
Expand Down Expand Up @@ -549,26 +558,30 @@ const makeNumberAxis = (): TickConversion => {
};
};

const getFeatureTickConversion = (
featureKey: string,
featureDefs: MeasuredFeatureDef[]
): TickConversion => {
const feature = find(featureDefs, { key: featureKey });
if (feature && feature.discrete) {
return makeNumberToTextConversion(feature.options);
}
return makeNumberAxis();
};
Comment on lines +561 to +570

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Moved repeated logic out of getXTickConversion and getYTickConversion.


export const getXTickConversion = createSelector(
[getPlotByOnX, getMeasuredFeaturesDefs],
(plotByOnX, measuredFeaturesDefs: MeasuredFeatureDef[]): TickConversion => {
const feature = findFeature(measuredFeaturesDefs, plotByOnX);
if (feature && feature.discrete) {
return makeNumberToTextConversion(feature.options);
}
return makeNumberAxis();
}
getFeatureTickConversion
);

export const getYTickConversion = createSelector(
[getPlotByOnY, getMeasuredFeaturesDefs],
(plotByOnY, measuredFeaturesDefs: MeasuredFeatureDef[]): TickConversion => {
const feature = find(measuredFeaturesDefs, { key: plotByOnY });
if (feature && feature.discrete) {
return makeNumberToTextConversion(feature.options);
}
return makeNumberAxis();
}
getFeatureTickConversion
);

export const getConnectByFeatureTickConversion = createSelector(
[getConnectByFeature, getMeasuredFeaturesDefs],
getFeatureTickConversion
);

export const getDataForOverlayCard = createSelector(
Expand Down Expand Up @@ -630,6 +643,14 @@ export const getYDisplayName = createSelector(
}
);

export const getConnectByFeatureDisplayName = createSelector(
[getConnectByFeature, getMeasuredFeaturesDefs],
(connectByFeature, featureDefs): string => {
const feature = findFeature(featureDefs, connectByFeature);
return feature?.displayName ?? connectByFeature;
}
);

function formatAxisValue(
value: number | string | undefined,
isCategorical: boolean,
Expand Down Expand Up @@ -666,3 +687,16 @@ export const getFormattedHoveredYValue = createSelector(
);
}
);

export const getFormattedHoveredConnectByFeatureValue = createSelector(
[
getHoveredPointData,
getCategoricalFeatureKeys,
getConnectByFeature,
getConnectByFeatureTickConversion,
],
(hoveredPointData, categoricalFeatures, connectByKey, tickConversion): string => {
const value = hoveredPointData?.connectByFeatureValue ?? undefined;
return formatAxisValue(value, includes(categoricalFeatures, connectByKey), tickConversion);
}
);
1 change: 1 addition & 0 deletions src/state/selection/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ export interface SelectedPointData {
groupBy?: string;
xValue?: number | string;
yValue?: number | string;
connectByFeatureValue?: number | string | null;
}

export interface ChangeHoveredPointAction {
Expand Down
2 changes: 2 additions & 0 deletions src/state/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ export interface SelectedGroupDatum {
export interface PlotlyCustomData {
thumbnailPath: string;
index: number;
srcPath?: string;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added srcPath, since it was being defined in getPlotlyCustomData() in MainPlotContainers/selectors.ts.

connectByFeatureValue?: number | null;
}

export enum DataType {
Expand Down
Loading