Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

fix: improve widget loading states for small dashboards (#12769)

Max Deichmann3e911e9aafd5
diff --git a/.gitignore b/.gitignore
index 1bb03f7081..a962acb3ea 100644
--- a/.gitignore
+++ b/.gitignore
@@ -73,6 +73,7 @@ node_modules
web/test-results/*
.playwright-mcp/*
+.codex-artifacts/
# local config files
*.local.*
diff --git a/web/src/__tests__/chart-loading-state.clienttest.tsx b/web/src/__tests__/chart-loading-state.clienttest.tsx
index cab65237c6..f6b666de0e 100644
--- a/web/src/__tests__/chart-loading-state.clienttest.tsx
+++ b/web/src/__tests__/chart-loading-state.clienttest.tsx
@@ -87,4 +87,33 @@ describe("ChartLoadingState", () => {
expect(screen.getByText(customHint)).toBeInTheDocument();
expect(screen.queryByText(SLOW_QUERY_HINT_TEXT)).not.toBeInTheDocument();
});
+
+ test("renders query progress details when progress is provided", () => {
+ render(
+ <ChartLoadingState
+ isLoading={true}
+ progress={{
+ read_rows: 1_779_300_000,
+ total_rows_to_read: 2_924_500_000,
+ elapsed_ns: 0,
+ read_bytes: 0,
+ percent: 0.6084,
+ }}
+ />,
+ );
+
+ expect(screen.getByRole("progressbar")).toBeInTheDocument();
+ expect(screen.getByText("Reading 1.8B / ~2.9B rows")).toBeInTheDocument();
+ });
+
+ test("supports tight layout without rendering the default preview chrome", () => {
+ const { container } = render(
+ <ChartLoadingState isLoading={true} layout="tight" />,
+ );
+
+ expect(
+ screen.getByRole("status", { name: "Loading chart data" }),
+ ).toBeInTheDocument();
+ expect(container.querySelector(".space-y-3")).not.toBeInTheDocument();
+ });
});
diff --git a/web/src/__tests__/query-status-footer.clienttest.tsx b/web/src/__tests__/query-status-footer.clienttest.tsx
new file mode 100644
index 0000000000..783aa1783f
--- /dev/null
+++ b/web/src/__tests__/query-status-footer.clienttest.tsx
@@ -0,0 +1,72 @@
+import React from "react";
+import { act, render, screen } from "@testing-library/react";
+import "@testing-library/jest-dom";
+import { QueryStatusFooter } from "@/src/features/widgets/chart-library/QueryStatusFooter";
+
+describe("QueryStatusFooter", () => {
+ beforeEach(() => {
+ jest.useFakeTimers();
+ });
+
+ afterEach(() => {
+ jest.useRealTimers();
+ });
+
+ test("shows running text and row progress immediately", () => {
+ render(
+ <QueryStatusFooter
+ isLoading={true}
+ progress={{
+ read_rows: 1_779_300_000,
+ total_rows_to_read: 2_924_500_000,
+ elapsed_ns: 0,
+ read_bytes: 0,
+ percent: 0.6084,
+ }}
+ />,
+ );
+
+ expect(screen.getByText("Running query...")).toBeInTheDocument();
+ expect(screen.getByText("Reading 1.8B / ~2.9B rows")).toBeInTheDocument();
+ expect(
+ screen.queryByText("Try reducing the time range or adding more filters."),
+ ).not.toBeInTheDocument();
+ });
+
+ test("shows short recommendation copy for tight widgets after delay", () => {
+ render(
+ <QueryStatusFooter
+ isLoading={true}
+ layout="tight"
+ hintDelayMs={900}
+ progress={{
+ read_rows: 1_736_400_000,
+ total_rows_to_read: 2_924_600_000,
+ elapsed_ns: 0,
+ read_bytes: 0,
+ percent: 0.5937,
+ }}
+ />,
+ );
+
+ act(() => {
+ jest.advanceTimersByTime(900);
+ });
+
+ expect(
+ screen.getByText("Add filters or reduce range."),
+ ).toBeInTheDocument();
+ });
+
+ test("shows an indeterminate progress placeholder before query progress arrives", () => {
+ render(<QueryStatusFooter isLoading={true} />);
+
+ const progressbar = screen.getByRole("progressbar", {
+ name: "Query progress",
+ });
+
+ expect(progressbar).toBeInTheDocument();
+ expect(progressbar).not.toHaveAttribute("aria-valuenow");
+ expect(screen.getByText("Reading query progress...")).toBeInTheDocument();
+ });
+});
diff --git a/web/src/features/widgets/chart-library/ChartLoadingState.tsx b/web/src/features/widgets/chart-library/ChartLoadingState.tsx
index 44fb5ead1c..55623a72ac 100644
--- a/web/src/features/widgets/chart-library/ChartLoadingState.tsx
+++ b/web/src/features/widgets/chart-library/ChartLoadingState.tsx
@@ -2,6 +2,9 @@ import { useEffect, useState } from "react";
import { Loader2 } from "lucide-react";
import { cn } from "@/src/utils/tailwind";
import { SLOW_QUERY_HINT_TEXT } from "@langfuse/shared";
+import { Skeleton } from "@/src/components/ui/skeleton";
+import { type QueryProgress } from "@/src/hooks/useSSEDashboardQuery";
+import { QueryProgressBar } from "@/src/features/widgets/chart-library/QueryProgressBar";
const DEFAULT_HINT_DELAY_MS = 2000;
@@ -15,8 +18,27 @@ type ChartLoadingStateProps = {
hintDelayMs?: number;
showSpinner?: boolean;
showHintImmediately?: boolean;
+ progress?: QueryProgress | null;
+ layout?: "default" | "compact" | "tight";
};
+function ChartLoadingPreview() {
+ return (
+ <div aria-hidden="true" className="space-y-3">
+ <div className="flex items-end gap-2">
+ <Skeleton className="h-12 flex-1 rounded-xl" />
+ <Skeleton className="h-[4.5rem] flex-1 rounded-xl" />
+ <Skeleton className="h-8 flex-1 rounded-xl" />
+ <Skeleton className="h-14 flex-1 rounded-xl" />
+ </div>
+ <div className="flex gap-2">
+ <Skeleton className="h-2 flex-1 rounded-full" />
+ <Skeleton className="h-2 w-[4.5rem] rounded-full" />
+ </div>
+ </div>
+ );
+}
+
export function ChartLoadingState({
isLoading,
className,
@@ -27,6 +49,8 @@ export function ChartLoadingState({
hintDelayMs = DEFAULT_HINT_DELAY_MS,
showSpinner = true,
showHintImmediately = false,
+ progress,
+ layout = "default",
}: ChartLoadingStateProps) {
const [showHint, setShowHint] = useState(false);
@@ -50,6 +74,9 @@ export function ChartLoadingState({
}
const shouldShowHint = showHintImmediately || showHint;
+ const isCompact = layout !== "default";
+ const isTight = layout === "tight";
+ const statusTitle = showSpinner ? "Loading widget" : "Query needs attention";
return (
<div
@@ -57,27 +84,79 @@ export function ChartLoadingState({
aria-live="polite"
aria-label={spinnerLabel}
className={cn(
- "text-muted-foreground flex flex-col items-center justify-center gap-2",
+ "text-muted-foreground flex h-full min-h-0 w-full flex-col overflow-hidden",
className,
)}
>
- <div className="flex h-4 w-4 items-center justify-center">
- {showSpinner ? (
- <Loader2 className={cn("h-4 w-4 animate-spin", spinnerClassName)} />
- ) : (
- <span className="h-4 w-4" aria-hidden="true" />
- )}
+ <div className="m-auto w-full max-w-sm px-4 py-4">
+ <div className={cn("flex flex-col", isCompact ? "gap-3" : "gap-5")}>
+ {!isCompact ? <ChartLoadingPreview /> : null}
+
+ <div
+ className={cn(
+ "flex",
+ isCompact
+ ? "items-start gap-3 text-left"
+ : "flex-col items-center gap-3 text-center",
+ )}
+ >
+ <div
+ className={cn(
+ "bg-background/80 border-border/60 flex shrink-0 items-center justify-center rounded-full border shadow-xs",
+ isCompact ? "h-9 w-9" : "h-10 w-10",
+ )}
+ >
+ {showSpinner ? (
+ <Loader2
+ className={cn(
+ isCompact ? "h-4 w-4" : "h-5 w-5",
+ "animate-spin",
+ spinnerClassName,
+ )}
+ />
+ ) : (
+ <span
+ className={cn(
+ "bg-muted-foreground/60 block rounded-full",
+ "h-2.5 w-2.5",
+ )}
+ aria-hidden="true"
+ />
+ )}
+ </div>
+
+ <div className={cn("space-y-1", isCompact ? "min-w-0 flex-1" : "")}>
+ <p
+ className={cn(
+ "text-foreground font-medium",
+ isTight ? "text-xs" : "text-sm",
+ )}
+ >
+ {statusTitle}
+ </p>
+ {shouldShowHint ? (
+ <p
+ className={cn(
+ "animate-in fade-in-0 text-muted-foreground duration-300",
+ isTight
+ ? "line-clamp-3 text-[11px] leading-4"
+ : isCompact
+ ? "line-clamp-4 text-xs leading-4"
+ : "line-clamp-3 text-xs leading-5",
+ hintClassName,
+ )}
+ >
+ {hintText}
+ </p>
+ ) : null}
+ </div>
+ </div>
+
+ {progress ? (
+ <QueryProgressBar progress={progress} layout={layout} />
+ ) : null}
+ </div>
</div>
- {shouldShowHint ? (
- <p
- className={cn(
- "animate-in fade-in-0 max-w-xs text-center text-xs duration-300",
- hintClassName,
- )}
- >
- {hintText}
- </p>
- ) : null}
</div>
);
}
diff --git a/web/src/features/widgets/chart-library/PivotTable.tsx b/web/src/features/widgets/chart-library/PivotTable.tsx
index 56dea7785f..a31672c302 100644
--- a/web/src/features/widgets/chart-library/PivotTable.tsx
+++ b/web/src/features/widgets/chart-library/PivotTable.tsx
@@ -44,7 +44,6 @@ import { type ChartProps } from "@/src/features/widgets/chart-library/chart-prop
import { numberFormatter } from "@/src/utils/numbers";
import { formatMetricName } from "@/src/features/widgets/utils";
import { type OrderByState } from "@langfuse/shared";
-import { ChartLoadingState } from "@/src/features/widgets/chart-library/ChartLoadingState";
/**
* Props interface for the PivotTable component
@@ -356,6 +355,10 @@ export const PivotTable: React.FC<PivotTableProps> = ({
// Handle empty data state
if (!data || data.length === 0) {
+ if (isLoading) {
+ return <div className="h-full" aria-hidden="true" />;
+ }
+
return (
<div className="flex h-full items-center justify-center">
<div className="text-center">
@@ -367,6 +370,10 @@ export const PivotTable: React.FC<PivotTableProps> = ({
// Handle transformation errors
if (pivotTableRows.length === 0) {
+ if (isLoading) {
+ return <div className="h-full" aria-hidden="true" />;
+ }
+
return (
<div className="flex h-full items-center justify-center">
<div className="text-center">
@@ -379,14 +386,7 @@ export const PivotTable: React.FC<PivotTableProps> = ({
}
return (
- <div className="relative h-full overflow-auto px-5 pb-2">
- {isLoading && (
- <ChartLoadingState
- isLoading={isLoading}
- className="bg-background/80 absolute inset-0 z-10 backdrop-blur-xs"
- hintClassName="max-w-sm px-4"
- />
- )}
+ <div className="h-full overflow-auto px-5 pb-2">
<Table>
<TableHeader className="sticky top-0 z-10">
<TableRow>
diff --git a/web/src/features/widgets/chart-library/QueryProgressBar.tsx b/web/src/features/widgets/chart-library/QueryProgressBar.tsx
index 34a8c3df5b..de59da2752 100644
--- a/web/src/features/widgets/chart-library/QueryProgressBar.tsx
+++ b/web/src/features/widgets/chart-library/QueryProgressBar.tsx
@@ -2,31 +2,60 @@ import { type QueryProgress } from "@/src/hooks/useSSEDashboardQuery";
import { cn } from "@/src/utils/tailwind";
function formatRows(n: number): string {
+ if (n >= 1_000_000_000) return `${(n / 1_000_000_000).toFixed(1)}B`;
if (n >= 1_000_000) return `${(n / 1_000_000).toFixed(1)}M`;
if (n >= 1_000) return `${(n / 1_000).toFixed(0)}K`;
return String(n);
}
+type QueryProgressBarProps = {
+ progress?: QueryProgress | null;
+ className?: string;
+ layout?: "default" | "compact" | "tight";
+};
+
export function QueryProgressBar({
progress,
className,
-}: {
- progress: QueryProgress;
- className?: string;
-}) {
- const percent = Math.min(progress.percent * 100, 100);
+ layout = "default",
+}: QueryProgressBarProps) {
+ const hasProgress = progress != null;
+ const percent = hasProgress ? Math.min(progress.percent * 100, 100) : 0;
+ const compactLayout = layout !== "default";
return (
- <div className={cn("flex flex-col items-center gap-1.5", className)}>
- <div className="bg-muted h-1.5 w-32 overflow-hidden rounded-full">
- <div
- className="bg-primary/60 h-full rounded-full transition-all duration-500 ease-out"
- style={{ width: `${percent}%` }}
- />
+ <div className={cn("w-full min-w-0", className)}>
+ <div
+ role="progressbar"
+ aria-label="Query progress"
+ aria-valuemin={0}
+ aria-valuemax={100}
+ aria-valuenow={hasProgress ? Math.round(percent) : undefined}
+ className={cn(
+ "bg-muted/80 overflow-hidden rounded-full",
+ compactLayout ? "h-1.5" : "h-2",
+ )}
+ >
+ {hasProgress ? (
+ <div
+ className="bg-primary/60 h-full rounded-full transition-all duration-500 ease-out"
+ style={{ width: `${percent}%` }}
+ />
+ ) : (
+ <div className="bg-primary/50 h-full w-1/3 animate-pulse rounded-full" />
+ )}
</div>
- <p className="text-muted-foreground text-xs">
- Reading {formatRows(progress.read_rows)} / ~
- {formatRows(progress.total_rows_to_read)} rows
+ <p
+ className={cn(
+ "text-muted-foreground mt-2 tabular-nums",
+ compactLayout ? "text-[11px] leading-4" : "text-xs",
+ )}
+ >
+ {hasProgress
+ ? `Reading ${formatRows(progress.read_rows)} / ~${formatRows(
+ progress.total_rows_to_read,
+ )} rows`
+ : "Reading query progress..."}
</p>
</div>
);
diff --git a/web/src/features/widgets/chart-library/QueryStatusFooter.tsx b/web/src/features/widgets/chart-library/QueryStatusFooter.tsx
new file mode 100644
index 0000000000..450a4384bd
--- /dev/null
+++ b/web/src/features/widgets/chart-library/QueryStatusFooter.tsx
@@ -0,0 +1,86 @@
+import { useEffect, useState } from "react";
+import { type QueryProgress } from "@/src/hooks/useSSEDashboardQuery";
+import { cn } from "@/src/utils/tailwind";
+import { QueryProgressBar } from "@/src/features/widgets/chart-library/QueryProgressBar";
+
+const DEFAULT_HINT_DELAY_MS = 3000;
+const DEFAULT_RECOMMENDATION_TEXT =
+ "Try reducing the time range or adding more filters.";
+const COMPACT_RECOMMENDATION_TEXT = "Add filters or reduce range.";
+
+type QueryStatusFooterProps = {
+ isLoading: boolean;
+ progress?: QueryProgress | null;
+ className?: string;
+ hintDelayMs?: number;
+ layout?: "default" | "compact" | "tight";
+ hintText?: string;
+};
+
+export function QueryStatusFooter({
+ isLoading,
+ progress,
+ className,
+ hintDelayMs = DEFAULT_HINT_DELAY_MS,
+ layout = "default",
+ hintText,
+}: QueryStatusFooterProps) {
+ const [showHint, setShowHint] = useState(false);
+
+ useEffect(() => {
+ if (!isLoading) {
+ setShowHint(false);
+ return;
+ }
+
+ const timeoutId = window.setTimeout(() => {
+ setShowHint(true);
+ }, hintDelayMs);
+
+ return () => {
+ window.clearTimeout(timeoutId);
+ };
+ }, [hintDelayMs, isLoading]);
+
+ if (!isLoading) {
+ return null;
+ }
+
+ const isTight = layout === "tight";
+ const isCompact = layout !== "default";
+ const recommendationText =
+ hintText ??
+ (isCompact ? COMPACT_RECOMMENDATION_TEXT : DEFAULT_RECOMMENDATION_TEXT);
+
+ return (
+ <div
+ role="status"
+ aria-live="polite"
+ className={cn(
+ "border-border/50 border-t px-4 py-3",
+ isTight ? "space-y-1.5" : "space-y-2",
+ className,
+ )}
+ >
+ <p
+ className={cn(
+ "text-foreground/90 font-medium",
+ isCompact ? "text-xs" : "text-sm",
+ )}
+ >
+ Running query...
+ </p>
+
+ <QueryProgressBar progress={progress} layout={layout} />
+
+ <p
+ className={cn(
+ "text-muted-foreground min-h-[1rem]",
+ isCompact ? "text-[11px] leading-4" : "text-xs leading-5",
+ )}
+ >
+ {showHint ? recommendationText : <span aria-hidden="true">&nbsp;</span>}
+ </p>
+ </div>
+ );
+}
diff --git a/web/src/features/widgets/components/DashboardWidget.tsx b/web/src/features/widgets/components/DashboardWidget.tsx
index dfc25cc0f8..680028dec4 100644
--- a/web/src/features/widgets/components/DashboardWidget.tsx
+++ b/web/src/features/widgets/components/DashboardWidget.tsx
@@ -25,11 +25,11 @@ import {
shouldUseWidgetSSE,
} from "@/src/features/widgets/utils";
import { ChartLoadingState } from "@/src/features/widgets/chart-library/ChartLoadingState";
+import { QueryStatusFooter } from "@/src/features/widgets/chart-library/QueryStatusFooter";
import { getChartLoadingStateProps } from "@/src/features/widgets/chart-library/chartLoadingStateUtils";
import { useV4Beta } from "@/src/features/events/hooks/useV4Beta";
import { type ViewVersion } from "@/src/features/query";
import { useScheduledDashboardExecuteQuery } from "@/src/hooks/useDashboardQueryScheduler";
-import { QueryProgressBar } from "@/src/features/widgets/chart-library/QueryProgressBar";
import {
validateQuery,
toQueryChartConfig,
@@ -205,6 +205,14 @@ export function DashboardWidget({
isError: queryResult.isError,
errorMessage: queryResult.error,
});
+ const loadingStateLayout =
+ placement.y_size <= 2
+ ? "tight"
+ : placement.x_size <= 4
+ ? "compact"
+ : "default";
+ const showQueryErrorState =
+ chartLoadingState.isLoading && !queryResult.isPending;
const transformedData = useMemo(() => {
if (!widget.data || !queryResult.data) {
@@ -371,60 +379,68 @@ export function DashboardWidget({
>
{widget.data.description}
</div>
- <div className="relative min-h-0 flex-1">
+ <div className="flex min-h-0 flex-1 flex-col">
{!queryValidation.valid ? (
- <ChartLoadingState
- isLoading={true}
- showSpinner={false}
- showHintImmediately={true}
- hintText={queryValidation.reason}
- className="bg-background/80 absolute inset-0 z-20 backdrop-blur-xs"
- hintClassName="max-w-sm px-4"
- />
- ) : (
- <>
- <Chart
- chartType={widget.data.chartType}
- data={transformedData}
- rowLimit={
- widget.data.chartConfig.type === "LINE_TIME_SERIES" ||
- widget.data.chartConfig.type === "BAR_TIME_SERIES" ||
- widget.data.chartConfig.type === "AREA_TIME_SERIES"
- ? 100
- : (widget.data.chartConfig.row_limit ?? 100)
- }
- chartConfig={{
- ...widget.data.chartConfig,
- // For PIVOT_TABLE, enhance chartConfig with dimensions and metric field names
- ...(widget.data.chartType === "PIVOT_TABLE" && {
- dimensions: widget.data.dimensions.map((dim) => dim.field),
- metrics: widget.data.metrics.map(
- (metric) => `${metric.agg}_${metric.measure}`,
- ),
- }),
- }}
- sortState={
- widget.data.chartType === "PIVOT_TABLE" ? sortState : undefined
- }
- onSortChange={
- widget.data.chartType === "PIVOT_TABLE" ? updateSort : undefined
- }
- isLoading={queryResult.isPending}
- />
+ <div className="relative min-h-0 flex-1">
<ChartLoadingState
- isLoading={chartLoadingState.isLoading}
- showSpinner={chartLoadingState.showSpinner}
- showHintImmediately={chartLoadingState.showHintImmediately}
- hintText={chartLoadingState.hintText}
+ isLoading={true}
+ showSpinner={false}
+ showHintImmediately={true}
+ hintText={queryValidation.reason}
+ layout={loadingStateLayout}
className="bg-background/80 absolute inset-0 z-20 backdrop-blur-xs"
hintClassName="max-w-sm px-4"
/>
- {queryResult.progress && queryResult.isPending ? (
- <QueryProgressBar
- progress={queryResult.progress}
- className="absolute inset-x-0 bottom-4 z-30"
+ </div>
+ ) : (
+ <>
+ <div className="relative min-h-0 flex-1">
+ <Chart
+ chartType={widget.data.chartType}
+ data={transformedData}
+ rowLimit={
+ widget.data.chartConfig.type === "LINE_TIME_SERIES" ||
+ widget.data.chartConfig.type === "BAR_TIME_SERIES" ||
+ widget.data.chartConfig.type === "AREA_TIME_SERIES"
+ ? 100
+ : (widget.data.chartConfig.row_limit ?? 100)
+ }
+ chartConfig={{
+ ...widget.data.chartConfig,
+ // For PIVOT_TABLE, enhance chartConfig with dimensions and metric field names
+ ...(widget.data.chartType === "PIVOT_TABLE" && {
+ dimensions: widget.data.dimensions.map((dim) => dim.field),
+ metrics: widget.data.metrics.map(
+ (metric) => `${metric.agg}_${metric.measure}`,
+ ),
+ }),
+ }}
+ sortState={
+ widget.data.chartType === "PIVOT_TABLE"
+ ? sortState
+ : undefined
+ }
+ onSortChange={
+ widget.data.chartType === "PIVOT_TABLE"
+ ? updateSort
+ : undefined
+ }
+ isLoading={queryResult.isPending}
+ />
+ <ChartLoadingState
+ isLoading={showQueryErrorState}
+ showSpinner={chartLoadingState.showSpinner}
+ showHintImmediately={chartLoadingState.showHintImmediately}
+ hintText={chartLoadingState.hintText}
+ className="bg-background/80 absolute inset-0 z-20 backdrop-blur-xs"
+ hintClassName="max-w-sm px-4"
/>
- ) : null}
+ </div>
+ <QueryStatusFooter
+ isLoading={queryResult.isPending}
+ progress={queryResult.progress}
+ layout={loadingStateLayout}
+ />
</>
)}
</div>
diff --git a/web/src/features/widgets/components/WidgetForm.tsx b/web/src/features/widgets/components/WidgetForm.tsx
index b1fe4af9ba..c129046582 100644
--- a/web/src/features/widgets/components/WidgetForm.tsx
+++ b/web/src/features/widgets/components/WidgetForm.tsx
@@ -75,6 +75,7 @@ import {
MAX_PIVOT_TABLE_METRICS,
} from "@/src/features/widgets/utils/pivot-table-utils";
import { ChartLoadingState } from "@/src/features/widgets/chart-library/ChartLoadingState";
+import { QueryStatusFooter } from "@/src/features/widgets/chart-library/QueryStatusFooter";
import { getChartLoadingStateProps } from "@/src/features/widgets/chart-library/chartLoadingStateUtils";
type ChartType = {
@@ -1901,52 +1902,60 @@ export function WidgetForm({
</Alert>
</div>
</CardContent>
- ) : queryResult.data ? (
- <div className="relative min-h-0 flex-1">
- <Chart
- chartType={selectedChartType as DashboardWidgetChartType}
- data={transformedData}
- rowLimit={rowLimit}
- chartConfig={
- selectedChartType === "PIVOT_TABLE"
- ? {
- type: selectedChartType as DashboardWidgetChartType,
- dimensions: pivotDimensions,
- row_limit: rowLimit,
- metrics: selectedMetrics.map((metric) => metric.id), // Pass metric field names
- defaultSort:
- defaultSortColumn && defaultSortColumn !== "none"
- ? {
- column: defaultSortColumn,
- order: defaultSortOrder,
- }
- : undefined,
- }
- : selectedChartType === "HISTOGRAM"
+ ) : queryResult.data || chartLoadingState.isLoading ? (
+ <div className="flex min-h-0 flex-1 flex-col">
+ <div className="relative min-h-0 flex-1">
+ <Chart
+ chartType={selectedChartType as DashboardWidgetChartType}
+ data={transformedData}
+ rowLimit={rowLimit}
+ chartConfig={
+ selectedChartType === "PIVOT_TABLE"
? {
type: selectedChartType as DashboardWidgetChartType,
- bins: histogramBins,
- }
- : {
- type: selectedChartType as DashboardWidgetChartType,
+ dimensions: pivotDimensions,
row_limit: rowLimit,
+ metrics: selectedMetrics.map((metric) => metric.id), // Pass metric field names
+ defaultSort:
+ defaultSortColumn && defaultSortColumn !== "none"
+ ? {
+ column: defaultSortColumn,
+ order: defaultSortOrder,
+ }
+ : undefined,
}
- }
- sortState={
- selectedChartType === "PIVOT_TABLE"
- ? previewSortState
- : undefined
- }
- onSortChange={undefined}
+ : selectedChartType === "HISTOGRAM"
+ ? {
+ type: selectedChartType as DashboardWidgetChartType,
+ bins: histogramBins,
+ }
+ : {
+ type: selectedChartType as DashboardWidgetChartType,
+ row_limit: rowLimit,
+ }
+ }
+ sortState={
+ selectedChartType === "PIVOT_TABLE"
+ ? previewSortState
+ : undefined
+ }
+ onSortChange={undefined}
+ isLoading={queryResult.isPending}
+ />
+ <ChartLoadingState
+ isLoading={
+ chartLoadingState.isLoading && !queryResult.isPending
+ }
+ showSpinner={chartLoadingState.showSpinner}
+ showHintImmediately={chartLoadingState.showHintImmediately}
+ hintText={chartLoadingState.hintText}
+ className="bg-background/80 absolute inset-0 z-20 backdrop-blur-xs"
+ hintClassName="max-w-sm px-4"
+ />
+ </div>
+ <QueryStatusFooter
isLoading={queryResult.isPending}
- />
- <ChartLoadingState
- isLoading={chartLoadingState.isLoading}
- showSpinner={chartLoadingState.showSpinner}
- showHintImmediately={chartLoadingState.showHintImmediately}
- hintText={chartLoadingState.hintText}
- className="bg-background/80 absolute inset-0 z-20 backdrop-blur-xs"
- hintClassName="max-w-sm px-4"
+ progress={null}
/>
</div>
) : (
@@ -1958,6 +1967,7 @@ export function WidgetForm({
showSpinner={chartLoadingState.showSpinner}
showHintImmediately={chartLoadingState.showHintImmediately}
hintText={chartLoadingState.hintText}
+ progress={null}
hintClassName="max-w-sm px-4"
/>
) : (