diff --git a/web/oss/src/components/pages/observability/dashboard/AnalyticsDashboard.tsx b/web/oss/src/components/pages/observability/dashboard/AnalyticsDashboard.tsx index 514f095cc..58913b797 100644 --- a/web/oss/src/components/pages/observability/dashboard/AnalyticsDashboard.tsx +++ b/web/oss/src/components/pages/observability/dashboard/AnalyticsDashboard.tsx @@ -1,7 +1,6 @@ import {useMemo, type ComponentProps} from "react" -import {ChartLine} from "@phosphor-icons/react" -import {AreaChart} from "@tremor/react" +import {ChartLineIcon} from "@phosphor-icons/react" import {Spin} from "antd" import {useAtom} from "jotai" import {createUseStyles} from "react-jss" @@ -12,6 +11,7 @@ import {JSSTheme} from "@/oss/lib/Types" import {useObservabilityDashboard} from "@/oss/state/observability" import {observabilityDashboardTimeRangeAtom} from "@/oss/state/observability/dashboard" +import CustomAreaChart from "./CustomAreaChart" import WidgetCard from "./widgetCard" const useStyles = createUseStyles((theme: JSSTheme) => ({ @@ -66,7 +66,7 @@ const useStyles = createUseStyles((theme: JSSTheme) => ({ const EmptyChart = ({className}: {className: string}) => (
- + No data
) @@ -83,22 +83,15 @@ const AnalyticsDashboard = ({layout = "grid-2"}: AnalyticsDashboardProps) => { const chartData = useMemo(() => (data?.data?.length ? data.data : []), [data]) const hasData = (data?.total_count ?? 0) > 0 - const defaultGraphProps = useMemo>( + const defaultGraphProps = useMemo>( () => ({ className: "h-[140px]", colors: ["cyan-600", "rose"], - connectNulls: true, - tickGap: 20, - curveType: "monotone", - showGridLines: true, - showLegend: false, + tickCount: 5, index: "timestamp", data: chartData, categories: [], valueFormatter: (value) => formatCompactNumber(value), - yAxisWidth: 48, - showXAxis: true, - showYAxis: true, }), [chartData], ) @@ -142,7 +135,7 @@ const AnalyticsDashboard = ({layout = "grid-2"}: AnalyticsDashboardProps) => { } > {hasData ? ( - 0 @@ -169,7 +162,7 @@ const AnalyticsDashboard = ({layout = "grid-2"}: AnalyticsDashboardProps) => { } > {hasData ? ( - `${formatCompactNumber(value)}ms`} @@ -199,7 +192,7 @@ const AnalyticsDashboard = ({layout = "grid-2"}: AnalyticsDashboardProps) => { } > {hasData ? ( - { } > {hasData ? ( - string + tickCount?: number + allowDecimals?: boolean + className?: string +} + +// Map Tremor-like color names to hex values (simplified for this specific use case) +// You might want to expand this or import from a central theme file if available +const colorMap: Record = { + "cyan-600": "#0891b2", + rose: "#e11d48", + gray: "#6b7280", +} + +const CustomAreaChart: React.FC = ({ + data, + categories, + index, + colors = ["cyan-600"], + valueFormatter = (value: number) => formatCompactNumber(value), + tickCount = 5, + allowDecimals = false, + className, +}) => { + const {token} = theme.useToken() + + return ( +
+ + + + {categories.map((category, idx) => { + const colorKey = colors[idx % colors.length] + const color = colorMap[colorKey] || colorKey + return ( + + + + + ) + })} + + + + + [valueFormatter(value), ""]} + /> + {categories.map((category, idx) => { + const colorKey = colors[idx % colors.length] + const color = colorMap[colorKey] || colorKey + return ( + + ) + })} + + +
+ ) +} + +export default CustomAreaChart