🪢 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
fix(dashboards): represent small numbers in scientific notation (#7506)
Steffen Schmitzd65bdaa7611b
diff --git a/web/src/features/widgets/chart-library/HistogramChart.tsx b/web/src/features/widgets/chart-library/HistogramChart.tsxindex 155956fb7d..2f567945c1 100644--- a/web/src/features/widgets/chart-library/HistogramChart.tsx+++ b/web/src/features/widgets/chart-library/HistogramChart.tsx@@ -2,7 +2,7 @@ import React from "react";import { type DataPoint } from "@/src/features/widgets/chart-library/chart-props";import { BarChart, Bar, XAxis, YAxis, ResponsiveContainer } from "recharts";import { ChartContainer, ChartTooltip } from "@/src/components/ui/chart";-import { compactNumberFormatter } from "@/src/utils/numbers";+import { compactSmallNumberFormatter } from "@/src/utils/numbers";interface HistogramDataPoint {binLabel: string;@@ -22,7 +22,7 @@ const HistogramChart = ({ data }: { data: DataPoint[] }) => {// ClickHouse histogram format: [(lower, upper, height), ...]return (firstDataPoint.metric as [number, number, number][]).map(([lower, upper, height]) => ({- binLabel: `[${compactNumberFormatter(lower)}, ${compactNumberFormatter(upper)}]`,+ binLabel: `[${compactSmallNumberFormatter(lower)}, ${compactSmallNumberFormatter(upper)}]`,count: height,lower,upper,diff --git a/web/src/utils/numbers.ts b/web/src/utils/numbers.tsindex d2a5763cdc..cf0522b917 100644--- a/web/src/utils/numbers.ts+++ b/web/src/utils/numbers.ts@@ -11,6 +11,29 @@ export const compactNumberFormatter = (}).format(number ?? 0);};+/**+ * Specialized formatter for very small numbers (10^-3 to 10^-15 range)+ * Uses scientific notation for compact representation with ~3 significant digits+ */+export const compactSmallNumberFormatter = (+ number?: number | bigint,+ significantDigits: number = 3,+) => {+ const num = Number(number ?? 0);++ if (num === 0) return "0";++ const absNum = Math.abs(num);++ // For numbers >= 1e-3, use standard compact formatting+ if (absNum >= 1e-3) {+ return compactNumberFormatter(num, significantDigits);+ }++ // For very small numbers, use scientific notation+ return num.toExponential(significantDigits - 1);+};+export const numberFormatter = (number?: number | bigint,fractionDigits?: number,