The Open Standard for Generative UI
"use client";
import { defineComponent } from "@openuidev/react-lang";
import React from "react";
import { z } from "zod/v4";
import { LineChartCondensed as LineChartCondensedComponent } from "../../components/Charts";
import { buildChartData, hasAllProps } from "../helpers";
import { SeriesSchema } from "./Series";
export const LineChartCondensedSchema = z.object({
labels: z.array(z.string()),
series: z.array(SeriesSchema),
variant: z.enum(["linear", "natural", "step"]).optional(),
xLabel: z.string().optional(),
yLabel: z.string().optional(),
height: z.number().optional(),
});
export const LineChartCondensed = defineComponent({
name: "LineChart",
props: LineChartCondensedSchema,
description: "Lines over categories; use for trends and continuous data over time",
component: ({ props }) => {
if (!hasAllProps(props as Record<string, unknown>, "labels", "series")) return null;
const data = buildChartData(props.labels, props.series);
if (!data.length) return null;
return React.createElement(LineChartCondensedComponent, {
data,
categoryKey: "category",
variant: props.variant as "linear" | "natural" | "step" | undefined,
xAxisLabel: props.xLabel,
yAxisLabel: props.yLabel,
height: props.height as number | undefined,
isAnimationActive: false,
});
},
});