🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.
TypeScript analyticsautogenevaluationlangchainlarge-language-modelsllama-indexllmllm-evaluationllm-observabilityllmopsmonitoringobservabilityopen-sourceopenaiplaygroundprompt-engineeringprompt-managementself-hostedycombinator
chore: refactor chart display names into single util (#7209)
Steffen Schmitz922eafd4f662
diff --git a/web/src/features/widgets/chart-library/utils.ts b/web/src/features/widgets/chart-library/utils.tsindex 61e498f228..fe48f33977 100644--- a/web/src/features/widgets/chart-library/utils.ts+++ b/web/src/features/widgets/chart-library/utils.ts@@ -60,3 +60,29 @@ export const isTimeSeriesChart = (// Used for a combination of YAxis styling workarounds as discussed in https://github.com/recharts/recharts/issues/2027#issuecomment-769674096.export const formatAxisLabel = (label: string): string =>label.length > 13 ? label.slice(0, 13).concat("…") : label;++/**+ * Maps chart types to their human-readable display names.+ */+export function getChartTypeDisplayName(+ chartType: DashboardWidgetChartType,+): string {+ switch (chartType) {+ case "LINE_TIME_SERIES":+ return "Line Chart (Time Series)";+ case "BAR_TIME_SERIES":+ return "Bar Chart (Time Series)";+ case "HORIZONTAL_BAR":+ return "Horizontal Bar Chart (Total Value)";+ case "VERTICAL_BAR":+ return "Vertical Bar Chart (Total Value)";+ case "PIE":+ return "Pie Chart (Total Value)";+ case "NUMBER":+ return "Big Number (Total Value)";+ case "HISTOGRAM":+ return "Histogram (Total Value)";+ default:+ return "Unknown Chart Type";+ }+}diff --git a/web/src/features/widgets/components/SelectWidgetDialog.tsx b/web/src/features/widgets/components/SelectWidgetDialog.tsxindex 00b897c7bd..d8f6b1cbb9 100644--- a/web/src/features/widgets/components/SelectWidgetDialog.tsx+++ b/web/src/features/widgets/components/SelectWidgetDialog.tsx@@ -20,6 +20,8 @@ import {TableCell,} from "@/src/components/ui/table";import { startCase } from "lodash";+import { getChartTypeDisplayName } from "@/src/features/widgets/chart-library/utils";+import { type DashboardWidgetChartType } from "@langfuse/shared/src/db";export type WidgetItem = {id: string;@@ -130,26 +132,9 @@ export function SelectWidgetDialog({{startCase(widget.view.toLowerCase())}</TableCell><TableCell>- {(() => {- switch (widget.chartType) {- case "LINE_TIME_SERIES":- return "Line Chart (Time Series)";- case "BAR_TIME_SERIES":- return "Bar Chart (Time Series)";- case "HORIZONTAL_BAR":- return "Horizontal Bar Chart (Total Value)";- case "VERTICAL_BAR":- return "Vertical Bar Chart (Total Value)";- case "PIE":- return "Pie Chart (Total Value)";- case "NUMBER":- return "Big Number (Total Value)";- case "HISTOGRAM":- return "Histogram (Total Value)";- default:- return widget.chartType;- }- })()}+ {getChartTypeDisplayName(+ widget.chartType as DashboardWidgetChartType,+ )}</TableCell></TableRow>))}diff --git a/web/src/features/widgets/components/WidgetTable.tsx b/web/src/features/widgets/components/WidgetTable.tsxindex 55edfd2a49..4801cffb5d 100644--- a/web/src/features/widgets/components/WidgetTable.tsx+++ b/web/src/features/widgets/components/WidgetTable.tsx@@ -22,6 +22,8 @@ import {import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import { showErrorToast } from "@/src/features/notifications/showErrorToast";import { useRouter } from "next/router";+import { getChartTypeDisplayName } from "@/src/features/widgets/chart-library/utils";+import { type DashboardWidgetChartType } from "@langfuse/shared/src/db";type WidgetTableRow = {id: string;@@ -186,26 +188,8 @@ export function DashboardWidgetTable() {id: "chartType",enableSorting: true,size: 100,- cell: (row) => {- switch (row.getValue()) {- case "LINE_TIME_SERIES":- return "Line Chart (Time Series)";- case "BAR_TIME_SERIES":- return "Bar Chart (Time Series)";- case "HORIZONTAL_BAR":- return "Horizontal Bar Chart (Total Value)";- case "VERTICAL_BAR":- return "Vertical Bar Chart (Total Value)";- case "PIE":- return "Pie Chart (Total Value)";- case "NUMBER":- return "Big Number (Total Value)";- case "HISTOGRAM":- return "Histogram (Total Value)";- default:- return "Unknown Chart Type";- }- },+ cell: (row) =>+ getChartTypeDisplayName(row.getValue() as DashboardWidgetChartType),}),columnHelper.accessor("createdAt", {header: "Created At",