fix(charts): simplify time labels in investigation views
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { Activity, BarChart3, Database, History, LineChart, MonitorCog } from "lucide-react";
|
||||
import { AnimatePresence, MotionConfig, motion } from "motion/react";
|
||||
import { memo, type ReactNode } from "react";
|
||||
import { formatChartDisplayText, withChartDisplayTimes } from "@/shared/utils/date-time-text";
|
||||
import { StatusIcon } from "@/shared/ui/status";
|
||||
import { StandaloneInteractiveChart } from "../answer-ui/interactive-chart";
|
||||
import { normalizeSafeChartData, parseChartSpec } from "../chart-data";
|
||||
@@ -78,8 +79,12 @@ export const AgentChartView = memo(function AgentChartView({ chart, embedded = f
|
||||
});
|
||||
|
||||
function SafeChartEnvelope({ envelope, embedded = false, expanded = false }: { envelope: Extract<UIEnvelope, { kind: "chart" }>; embedded?: boolean; expanded?: boolean }) {
|
||||
const spec = parseChartSpec(envelope.spec);
|
||||
const data = normalizeSafeChartData(envelope.data, 100);
|
||||
const parsed = parseChartSpec(envelope.spec);
|
||||
const raw = normalizeSafeChartData(envelope.data, 100);
|
||||
const displayed = withChartDisplayTimes({ title: parsed.title ?? "Agent 图表", x_axis_name: parsed.xAxisName,
|
||||
x_data: raw?.xData ?? [], series: raw?.series ?? [] });
|
||||
const spec = { ...parsed, title: displayed.title, xAxisName: displayed.x_axis_name };
|
||||
const data = raw ? { ...raw, xData: displayed.x_data, series: displayed.series } : null;
|
||||
|
||||
if (!data || data.series.length === 0 || data.xData.length === 0) {
|
||||
return <FallbackText text={envelope.fallbackText ?? "图表数据未通过前端安全子集校验。"} />;
|
||||
@@ -206,7 +211,7 @@ function getEnvelopeIcon(envelope: UIEnvelope) {
|
||||
function getEnvelopeTitle(envelope: UIEnvelope) {
|
||||
if (envelope.kind === "chart") {
|
||||
const spec = parseChartSpec(envelope.spec);
|
||||
return spec.title ?? "Agent 图表";
|
||||
return formatChartDisplayText(spec.title ?? "Agent 图表");
|
||||
}
|
||||
|
||||
if (envelope.kind === "registered_component") {
|
||||
|
||||
Reference in New Issue
Block a user