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
12 changes: 6 additions & 6 deletions app/src/app/(dashboard)/[id]/edit/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -341,19 +341,19 @@ export default function DashboardEditorPage({
{
shortcut: "Cmd+E",
handler: () => {
router.push("/" + id);
// Route through unsaved-changes guard (same as the Back button)
if (requestNavigation("/" + id)) router.push("/" + id);
},
},
{
shortcut: "Cmd+N",
shortcut: "Cmd+Shift+N",
handler: openAddWidget,
disabled: editorOpen,
},
{
shortcut: "Escape",
handler: () => {
if (editorOpen) setEditorOpen(false);
},
handler: () => setEditorOpen(false),
disabled: !editorOpen,
},
]);

Expand Down Expand Up @@ -468,7 +468,7 @@ export default function DashboardEditorPage({
variant="outline"
size="sm"
onClick={openAddWidget}
title="Add widget (Cmd+N)"
title="Add widget (Cmd+Shift+N)"
>
<Plus className="mr-2 h-4 w-4" />
Add Widget
Expand Down
16 changes: 16 additions & 0 deletions app/src/components/card-container.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,7 @@ export function CardContainer({
);
}
let mappedData: unknown;
let transformError: string | null = null;
try {
mappedData = (chartConfig.transformWithMapping ?? chartConfig.transform)(
previewData,
Expand All @@ -314,6 +315,7 @@ export function CardContainer({
err,
);
mappedData = previewData;
transformError = "Data transform failed — showing raw data";
}
// Skip transforms for graph charts — their data shape is incompatible with tabular transforms
let transformedData: unknown = mappedData;
Expand All @@ -327,11 +329,17 @@ export function CardContainer({
} catch (err) {
console.error("Data transform failed:", err);
transformedData = mappedData;
transformError = "Data transform failed — showing raw data";
}
}
const availableColumns = extractColumnNames(previewData);
return (
<div className="h-full w-full flex flex-col">
{transformError && (
<div className="px-3 py-1 bg-amber-50 dark:bg-amber-950/30 border-b border-amber-200 dark:border-amber-800 text-amber-700 dark:text-amber-400 text-xs">
{transformError}
</div>
)}
<div className="flex-1 min-h-0">
<ChartRenderer
type={chartConfig.type}
Expand Down Expand Up @@ -602,6 +610,7 @@ export function CardContainer({
}

let mappedData: unknown;
let liveTransformError: string | null = null;
try {
mappedData = (chartConfig.transformWithMapping ?? chartConfig.transform)(
rawData,
Expand All @@ -610,6 +619,7 @@ export function CardContainer({
} catch (err) {
console.error("Chart transform failed for " + widget.chartType + ":", err);
mappedData = rawData;
liveTransformError = "Data transform failed — showing raw data";
}
let transformedData: unknown = mappedData;
if (dataTransforms.length) {
Expand All @@ -622,12 +632,18 @@ export function CardContainer({
} catch (err) {
console.error("Data transform failed:", err);
transformedData = mappedData;
liveTransformError = "Data transform failed — showing raw data";
}
}
const availableColumns = extractColumnNames(rawData);

return (
<div className="h-full w-full flex flex-col">
{liveTransformError && (
<div className="px-3 py-1 bg-amber-50 dark:bg-amber-950/30 border-b border-amber-200 dark:border-amber-800 text-amber-700 dark:text-amber-400 text-xs">
{liveTransformError}
</div>
)}
{widgetQuery.data?.truncated && (
<div className="px-3 py-1.5 text-xs text-muted-foreground bg-muted/50 border-b flex items-center gap-1.5">
<span>&#9888;</span>
Expand Down
4 changes: 3 additions & 1 deletion app/src/plugins/choropleth/transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ export function transformToChoroplethData(data: unknown): unknown {
keys.find(
(k) =>
k !== nameKey && /^(value|count|total|population|gdp|amount)$/i.test(k),
) ?? keys[1];
) ??
keys.find((k) => k !== nameKey) ??
keys[1];

return records
.map((row) => ({
Expand Down
27 changes: 20 additions & 7 deletions component/src/charts/choropleth-chart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,27 @@ function ChoroplethChart({
useEffect(() => {
if (mapRegistered || registering.current) return;
registering.current = true;
let cancelled = false;

import("./world.geo.json").then((module) => {
const geoJSON = module.default ?? module;
if (!echarts.getMap("world")) {
echarts.registerMap("world", geoJSON as never);
}
setMapRegistered(true);
});
import("./world.geo.json")
.then((module) => {
if (cancelled) return;
const geoJSON = module.default ?? module;
if (!echarts.getMap("world")) {
echarts.registerMap("world", geoJSON as never);
}
setMapRegistered(true);
})
.catch((err) => {
if (!cancelled) {
console.error("Failed to load world map GeoJSON:", err);
registering.current = false; // allow retry on re-mount
}
});

return () => {
cancelled = true;
};
}, [mapRegistered]);

const options = useMemo((): EChartsOption | undefined => {
Expand Down
2 changes: 1 addition & 1 deletion docs/src/content/docs/guides/keyboard-shortcuts.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ description: Speed up your workflow with keyboard shortcuts.
|----------|--------|
| `Cmd/Ctrl + S` | Save dashboard |
| `Cmd/Ctrl + E` | Switch to view mode |
| `Cmd/Ctrl + N` | Open "Add Widget" dialog |
| `Cmd/Ctrl + Shift + N` | Open "Add Widget" dialog |
| `Escape` | Close the current modal or dialog |

### View Mode
Expand Down
Loading