Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -355,10 +355,6 @@ const DeckMulti = (props: DeckMultiProps) => {
handleFeatureClick(info, sliceFeatureInfoColumnNames),
);

if (!newLayer) {
return null;
}

const payloadData = payload?.data || [];
const geometryType = getGeometryType(payloadData[0]?.geojson);
let transformPropsGeojsonLayer =
Expand Down Expand Up @@ -483,13 +479,15 @@ const DeckMulti = (props: DeckMultiProps) => {
maxZoom: zoomSlider[1],
};

const newLayerStates = layerStatesGenerator(
newLayer,
newLayerStateOptions,
);
// When the layer has no renderable data, return an entry with
// empty layerStates so the legend can show it as "loaded but
// empty" instead of spinning forever.
const newLayerStates = newLayer
? layerStatesGenerator(newLayer, newLayerStateOptions)
: [];

if (!newLayerStates.length) {
return null;
legendEntry.empty = true;
}

const layerFeatures: JsonObject[] =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,13 @@ const CategoryRow = styled.div`
gap: 8px;
`;

const NoDataLabel = styled.div`
font-size: 11px;
color: gray;
margin-bottom: 6px;
margin-left: -20px;
`;

const MetricBlock = styled.div`
margin: 6px 0;
`;
Expand All @@ -176,20 +183,22 @@ const Bounds = styled.div(
`,
);

const VisibilityCheckbox = styled.input`
const VisibilityCheckbox = styled.input<{ $empty?: boolean }>`
width: 14px;
height: 14px;
cursor: pointer;
margin: 0 !important;
flex-shrink: 0;
${({ $empty }) => $empty && 'accent-color: gray;'}
`;

// Checkbox that supports indeterminate state (shows minus sign when some but not all are selected)
const IndeterminateCheckbox: React.FC<{
checked: boolean;
indeterminate: boolean;
onChange: (e: React.ChangeEvent<HTMLInputElement>) => void;
}> = ({ checked, indeterminate, onChange }) => {
$empty?: boolean;
}> = ({ checked, indeterminate, onChange, $empty }) => {
const ref = useRef<HTMLInputElement>(null);

useEffect(() => {
Expand All @@ -204,6 +213,7 @@ const IndeterminateCheckbox: React.FC<{
type="checkbox"
checked={checked}
onChange={onChange}
$empty={$empty}
/>
);
};
Expand Down Expand Up @@ -249,17 +259,20 @@ const LegendEntryContent: React.FC<{

return (
<div>
{/* SIMPLE - show icon and slice name (skip when sizeEntry with a range handles the display) */}
{legendEntry.empty && <NoDataLabel>Visible but Empty</NoDataLabel>}
{/* SIMPLE - show icon and slice name (skip when sizeEntry handles the display) */}
{legendEntry.type === 'simple' &&
legendEntry.simpleStyle &&
(!legendEntry.sizeEntry ||
legendEntry.sizeEntry.startSize === legendEntry.sizeEntry.endSize) && (
legendEntry.sizeEntry.startSize ===
legendEntry.sizeEntry.endSize) && (
<CategoryRow>
{showEntryCheckbox && (
<VisibilityCheckbox
type="checkbox"
checked={isVisible}
onChange={onToggleVisibility}
$empty={legendEntry.empty}
/>
)}
<Swatch
Expand Down Expand Up @@ -313,6 +326,7 @@ const LegendEntryContent: React.FC<{
type="checkbox"
checked={item.enabled}
onChange={() => onToggleCategory(sliceId, item.label)}
$empty={legendEntry.empty}
/>
)}
<span>{item.label}</span>
Expand All @@ -338,6 +352,7 @@ const LegendEntryContent: React.FC<{
type="checkbox"
checked={isEnabled}
onChange={() => onToggleCategory(sliceId, cat.label)}
$empty={legendEntry.empty}
/>
)}
<Swatch
Expand Down Expand Up @@ -380,6 +395,7 @@ const LegendEntryContent: React.FC<{
type="checkbox"
checked={isVisible}
onChange={onToggleVisibility}
$empty={legendEntry.empty}
/>
<Swatch
fill={fill}
Expand Down Expand Up @@ -511,6 +527,8 @@ export const MultiLegend: React.FC<MultiLegendProps> = ({
someVisibleSomeNot || (isVisible && hasPartialCategories);

const allLoading = entries.every(e => e.legendEntry.loading);
const allEmpty =
!allLoading && entries.every(e => e.legendEntry.empty);

return (
<Group key={displayTitle}>
Expand All @@ -523,6 +541,7 @@ export const MultiLegend: React.FC<MultiLegendProps> = ({
<IndeterminateCheckbox
checked={isVisible}
indeterminate={isIndeterminate}
$empty={allEmpty}
onChange={e => {
e.stopPropagation();
setOptimisticVisibility(prev => ({
Expand Down
1 change: 1 addition & 0 deletions superset-frontend/plugins/geoset-map-chart/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ export type LegendEntry = {
isCombinedMetricSize?: boolean;
initialCollapsed?: boolean; // Whether this legend entry starts collapsed
loading?: boolean; // True for stub entries whose layer data is still loading
empty?: boolean; // True when layer loaded successfully but returned no data
};

export type LegendGroup = {
Expand Down
Loading
Loading