The Open Standard for Generative UI
Enhance Charts components by adding condensed charts (#215)
Ankit Das9480363e32c9
diff --git a/js/packages/react-ui/src/components/Charts/AreaChartCondensed/AreaChartCondensed.tsx b/js/packages/react-ui/src/components/Charts/AreaChartCondensed/AreaChartCondensed.tsxnew file mode 100644index 000000000..109634f61--- /dev/null+++ b/js/packages/react-ui/src/components/Charts/AreaChartCondensed/AreaChartCondensed.tsx@@ -0,0 +1,228 @@+import clsx from "clsx";+import React, { useMemo, useRef, useState } from "react";+import { Area, AreaChart as RechartsAreaChart, XAxis, YAxis } from "recharts";+import { useId } from "../../../polyfills";+import { AreaChartData, AreaChartVariant } from "../AreaChart/types";+import { ChartConfig, ChartContainer, ChartTooltip } from "../Charts";+import { X_AXIS_PADDING } from "../constants";+import { SideBarChartData, SideBarTooltipProvider } from "../context/SideBarTooltipContext";+import {+ useAutoAngleCalculation,+ useMaxLabelWidth,+ useTransformedKeys,+ useYAxisLabelWidth,+} from "../hooks";+import {+ ActiveDot,+ cartesianGrid,+ CondensedXAxisTick,+ CondensedXAxisTickVariant,+ CustomTooltipContent,+ YAxisTick,+} from "../shared";+import { LabelTooltipProvider } from "../shared/LabelTooltip/LabelTooltip";+import { get2dChartConfig, getDataKeys } from "../utils/dataUtils";+import { PaletteName, useChartPalette } from "../utils/PalletUtils";++export interface AreaChartCondensedProps<T extends AreaChartData> {+ data: T;+ categoryKey: keyof T[number];+ theme?: PaletteName;+ customPalette?: string[];+ variant?: AreaChartVariant;+ tickVariant?: CondensedXAxisTickVariant;+ grid?: boolean;+ icons?: Partial<Record<keyof T[number], React.ComponentType>>;+ isAnimationActive?: boolean;+ showYAxis?: boolean;+ className?: string;+ height?: number;+ width?: number;+}++const CHART_HEIGHT = 200;+const CHART_CONTAINER_BOTTOM_MARGIN = 10;++const AreaChartCondensedComponent = <T extends AreaChartData>({+ data,+ categoryKey,+ theme = "ocean",+ customPalette,+ variant = "natural",+ tickVariant = "singleLine",+ grid = true,+ icons = {},+ isAnimationActive = false,+ showYAxis = true,+ className,+ height = CHART_HEIGHT,+ width,+}: AreaChartCondensedProps<T>) => {+ const dataKeys = useMemo(() => {+ return getDataKeys(data, categoryKey as string);+ }, [data, categoryKey]);++ const { yAxisWidth, setLabelWidth } = useYAxisLabelWidth(data, dataKeys);++ const maxLabelWidth = useMaxLabelWidth(data, categoryKey as string);++ const { angle: calculatedAngle, height: xAxisHeight } = useAutoAngleCalculation(+ maxLabelWidth,+ yAxisWidth,+ tickVariant === "angled",+ showYAxis,+ );++ const effectiveHeight = useMemo(() => {+ if (tickVariant === "angled") {+ return xAxisHeight + height;+ }+ return height;+ }, [height, xAxisHeight]);++ const transformedKeys = useTransformedKeys(dataKeys);++ const colors = useChartPalette({+ chartThemeName: theme,+ customPalette,+ themePaletteName: "areaChartPalette",+ dataLength: dataKeys.length,+ });++ const chartConfig: ChartConfig = useMemo(() => {+ return get2dChartConfig(dataKeys, colors, transformedKeys, undefined, icons);+ }, [dataKeys, icons, colors, transformedKeys]);++ const id = useId();+ const gradientID = useMemo(() => `area-chart-condensed-gradient-${id}`, [id]);++ const chartMargin = useMemo(+ () => ({+ top: 10,+ right: 10,+ bottom: CHART_CONTAINER_BOTTOM_MARGIN,+ left: showYAxis ? 10 : 0,+ }),+ [showYAxis],+ );++ const containerRef = useRef<HTMLDivElement>(null);+ const [isSideBarTooltipOpen, setIsSideBarTooltipOpen] = useState(false);+ const [sideBarTooltipData, setSideBarTooltipData] = useState<SideBarChartData>({+ title: "",+ values: [],+ });++ return (+ <LabelTooltipProvider>+ <SideBarTooltipProvider+ isSideBarTooltipOpen={isSideBarTooltipOpen}+ setIsSideBarTooltipOpen={setIsSideBarTooltipOpen}+ data={sideBarTooltipData}+ setData={setSideBarTooltipData}+ >+ <div+ ref={containerRef}+ className={clsx("crayon-area-chart-condensed", className)}+ style={{+ width: width ? `${width}px` : "100%",+ height: `${effectiveHeight}px`,+ }}+ >+ <ChartContainer+ config={chartConfig}+ style={{ width: "100%", height: "100%" }}+ rechartsProps={{+ width: "100%",+ height: "100%",+ }}+ >+ <RechartsAreaChart+ accessibilityLayer+ key={`area-chart-condensed-${id}`}+ data={data}+ margin={chartMargin}+ >+ {grid && cartesianGrid()}++ <XAxis+ dataKey={categoryKey as string}+ tickLine={false}+ axisLine={false}+ textAnchor={tickVariant === "angled" ? "end" : "middle"}+ interval="preserveStartEnd"+ minTickGap={5}+ height={xAxisHeight}+ tick={<CondensedXAxisTick />}+ angle={calculatedAngle}+ orientation="bottom"+ padding={{+ left: X_AXIS_PADDING,+ right: X_AXIS_PADDING,+ }}+ />++ {showYAxis && (+ <YAxis+ tickLine={false}+ axisLine={false}+ tick={<YAxisTick setLabelWidth={setLabelWidth} />}+ width={yAxisWidth}+ />+ )}++ <ChartTooltip+ content={<CustomTooltipContent parentRef={containerRef} />}+ offset={10}+ />++ {dataKeys.map((key) => {+ const transformedKey = transformedKeys[key];+ const color = `var(--color-${transformedKey})`;+ return (+ <defs key={`gradient-${transformedKey}`}>+ <linearGradient+ id={`${gradientID}-${transformedKey}`}+ x1="0"+ y1="0"+ x2="0"+ y2="1"+ >+ <stop offset="5%" stopColor={color} stopOpacity={0.6} />+ <stop offset="95%" stopColor={color} stopOpacity={0} />+ </linearGradient>+ </defs>+ );+ })}++ {dataKeys.map((key) => {+ const transformedKey = transformedKeys[key];+ const color = `var(--color-${transformedKey})`;+ return (+ <Area+ key={`area-${key}`}+ dataKey={key}+ type={variant}+ stroke={color}+ fill={`url(#${gradientID}-${transformedKey})`}+ fillOpacity={1}+ stackId="a"+ activeDot={<ActiveDot key={`active-dot-${key}-${id}`} />}+ dot={false}+ isAnimationActive={isAnimationActive}+ // strokeWidth={2}+ />+ );+ })}+ </RechartsAreaChart>+ </ChartContainer>+ </div>+ </SideBarTooltipProvider>+ </LabelTooltipProvider>+ );+};++// Added React.memo for performance optimization to avoid unnecessary re-renders+export const AreaChartCondensed = React.memo(+ AreaChartCondensedComponent,+) as typeof AreaChartCondensedComponent;diff --git a/js/packages/react-ui/src/components/Charts/AreaChartCondensed/areaChartCondensed.scss b/js/packages/react-ui/src/components/Charts/AreaChartCondensed/areaChartCondensed.scssnew file mode 100644index 000000000..325231cf3--- /dev/null+++ b/js/packages/react-ui/src/components/Charts/AreaChartCondensed/areaChartCondensed.scss@@ -0,0 +1,7 @@+@use "../../../cssUtils" as cssUtils;++.crayon-area-chart-condensed {+ display: flex;+ flex-direction: column;+ position: relative;+}diff --git a/js/packages/react-ui/src/components/Charts/AreaChartCondensed/dependencies.ts b/js/packages/react-ui/src/components/Charts/AreaChartCondensed/dependencies.tsnew file mode 100644index 000000000..9168685c2--- /dev/null+++ b/js/packages/react-ui/src/components/Charts/AreaChartCondensed/dependencies.ts@@ -0,0 +1,2 @@+const dependencies = ["AreaChartCondensed"];+export default dependencies;diff --git a/js/packages/react-ui/src/components/Charts/AreaChartCondensed/index.ts b/js/packages/react-ui/src/components/Charts/AreaChartCondensed/index.tsnew file mode 100644index 000000000..d2c029164--- /dev/null+++ b/js/packages/react-ui/src/components/Charts/AreaChartCondensed/index.ts@@ -0,0 +1,2 @@+export * from "../AreaChart/types";+export * from "./AreaChartCondensed";diff --git a/js/packages/react-ui/src/components/Charts/AreaChartCondensed/stories/areaChartCondensed.stories.tsx b/js/packages/react-ui/src/components/Charts/AreaChartCondensed/stories/areaChartCondensed.stories.tsxnew file mode 100644index 000000000..1b7eede05--- /dev/null+++ b/js/packages/react-ui/src/components/Charts/AreaChartCondensed/stories/areaChartCondensed.stories.tsx@@ -0,0 +1,1291 @@+import type { Meta, StoryObj } from "@storybook/react";+import { Calendar, Globe, Laptop, Monitor, Smartphone, TabletSmartphone } from "lucide-react";+import { Card } from "../../../Card";+import { AreaChartCondensed, AreaChartCondensedProps } from "../AreaChartCondensed";++// Test Data Generators+const generateLargeDataset = (points: number) => {+ return Array.from({ length: points }, (_, i) => ({+ date: `Day ${i + 1}`,+ value1: Math.floor(Math.random() * 1000) + 100,+ value2: Math.floor(Math.random() * 800) + 50,+ value3: Math.floor(Math.random() * 600) + 30,+ }));+};++const generateTimeSeriesData = (days: number) => {+ const startDate = new Date("2024-01-01");+ return Array.from({ length: days }, (_, i) => {+ const date = new Date(startDate);+ date.setDate(date.getDate() + i);+ return {+ date: date.toISOString().split("T")[0],+ sales: Math.floor(Math.random() * 5000) + 1000,+ orders: Math.floor(Math.random() * 200) + 50,+ };+ });+};++// Test Data Variations+const testData = {+ // Edge Cases+ empty: [],+ singlePoint: [{ month: "Jan", value: 100 }],+ twoPoints: [+ { month: "Jan", value: 100 },+ { month: "Feb", value: 200 },+ ],++ // Small Datasets+ threePoints: [+ { month: "Jan", value: 100 },+ { month: "Feb", value: 150 },+ { month: "Mar", value: 120 },+ ],+ fivePoints: [+ { month: "Jan", desktop: 150, mobile: 90 },+ { month: "Feb", desktop: 280, mobile: 180 },+ { month: "Mar", desktop: 220, mobile: 140 },+ { month: "Apr", desktop: 180, mobile: 160 },+ { month: "May", desktop: 250, mobile: 120 },+ ],++ // Medium Datasets+ twelvePoints: [+ { month: "Jan", desktop: 150, mobile: 90, tablet: 120 },+ { month: "Feb", desktop: 280, mobile: 180, tablet: 140 },+ { month: "Mar", desktop: 220, mobile: 140, tablet: 160 },+ { month: "Apr", desktop: 180, mobile: 160, tablet: 180 },+ { month: "May", desktop: 250, mobile: 120, tablet: 140 },+ { month: "Jun", desktop: 300, mobile: 180, tablet: 160 },+ { month: "Jul", desktop: 320, mobile: 200, tablet: 180 },+ { month: "Aug", desktop: 290, mobile: 170, tablet: 150 },+ { month: "Sep", desktop: 310, mobile: 190, tablet: 170 },+ { month: "Oct", desktop: 280, mobile: 160, tablet: 140 },+ { month: "Nov", desktop: 350, mobile: 210, tablet: 190 },+ { month: "Dec", desktop: 400, mobile: 250, tablet: 220 },+ ],++ // Large Datasets+ large50: generateLargeDataset(50),+ large100: generateLargeDataset(100),+ large500: generateLargeDataset(500),++ // Special Value Cases+ allZeros: [+ { month: "Jan", value: 0 },+ { month: "Feb", value: 0 },+ { month: "Mar", value: 0 },+ { month: "Apr", value: 0 },+ ],+ withZeros: [+ { month: "Jan", desktop: 100, mobile: 0 },+ { month: "Feb", desktop: 0, mobile: 50 },+ { month: "Mar", desktop: 150, mobile: 0 },+ { month: "Apr", desktop: 0, mobile: 100 },+ ],+ negativeValues: [+ { month: "Jan", profit: -50, loss: -30 },+ { month: "Feb", profit: 100, loss: -20 },+ { month: "Mar", profit: -30, loss: -40 },+ { month: "Apr", profit: 150, loss: -10 },+ ],+ mixedValues: [+ { month: "Jan", value1: -100, value2: 200 },+ { month: "Feb", value1: 150, value2: -50 },+ { month: "Mar", value1: -75, value2: 300 },+ { month: "Apr", value1: 200, value2: -100 },+ ],++ // Extreme Values+ veryLarge: [+ { month: "Jan", value: 1000000, secondary: 500000 },+ { month: "Feb", value: 1500000, secondary: 750000 },+ { month: "Mar", value: 1200000, secondary: 600000 },+ ],+ verySmall: [+ { month: "Jan", value: 0.001, secondary: 0.002 },+ { month: "Feb", value: 0.003, secondary: 0.0015 },+ { month: "Mar", value: 0.002, secondary: 0.0025 },+ ],+ wideRange: [+ { month: "Jan", small: 1, large: 1000000 },+ { month: "Feb", small: 2, large: 1500000 },+ { month: "Mar", small: 1.5, large: 1200000 },+ ],++ // Pattern Tests+ linear: Array.from({ length: 10 }, (_, i) => ({+ x: `P${i + 1}`,+ y: i * 10,+ })),+ exponential: Array.from({ length: 10 }, (_, i) => ({+ x: `P${i + 1}`,+ y: Math.pow(2, i),+ })),+ sinusoidal: Array.from({ length: 20 }, (_, i) => ({+ x: `P${i + 1}`,+ y: Math.sin(i / 3) * 100 + 150,+ })),+ constant: Array.from({ length: 8 }, (_, i) => ({+ x: `P${i + 1}`,+ y: 100,+ })),+ volatile: Array.from({ length: 15 }, (_, i) => ({+ x: `P${i + 1}`,+ spike: i % 3 === 0 ? 500 : 50,+ normal: 100 + Math.random() * 20,+ })),++ // Real-world Scenarios+ dailySales: generateTimeSeriesData(30),+ quarterlySales: [+ { quarter: "Q1 2023", revenue: 12000, profit: 4000, costs: 8000 },+ { quarter: "Q2 2023", revenue: 15000, profit: 5500, costs: 9500 },+ { quarter: "Q3 2023", revenue: 18000, profit: 7000, costs: 11000 },+ { quarter: "Q4 2023", revenue: 20000, profit: 7000, costs: 13000 },+ { quarter: "Q1 2024", revenue: 22000, profit: 8000, costs: 14000 },+ ],+ weeklyTraffic: [+ { day: "Mon", visits: 2200, conversions: 180, bounces: 800 },+ { day: "Tue", visits: 2500, conversions: 220, bounces: 900 },+ { day: "Wed", visits: 2300, conversions: 190, bounces: 850 },+ { day: "Thu", visits: 2800, conversions: 250, bounces: 1000 },+ { day: "Fri", visits: 3200, conversions: 280, bounces: 1100 },+ { day: "Sat", visits: 1800, conversions: 120, bounces: 600 },+ { day: "Sun", visits: 1500, conversions: 100, bounces: 500 },+ ],+};++const icons = {+ desktop: Monitor,+ mobile: TabletSmartphone,+ tablet: Calendar,+ revenue: Globe,+ profit: Smartphone,+ visits: Monitor,+ conversions: Laptop,+ value: Monitor,+ value1: Monitor,+ value2: TabletSmartphone,+ value3: Calendar,+ small: Smartphone,+ large: Globe,+ sales: Globe,+ orders: Laptop,+ bounces: Calendar,+ costs: Smartphone,+} as const;++/**+ * # AreaChartCondensed Test Suite+ *+ * This file contains comprehensive test cases for the AreaChartCondensed component,+ * covering edge cases, data variations, and stress testing scenarios.+ *+ * ## Test Categories+ *+ * ### 1. Edge Cases+ * - Empty data+ * - Single data point+ * - Two data points (minimum for area)+ *+ * ### 2. Data Size Variations+ * - Small datasets (3-5 points)+ * - Medium datasets (10-20 points)+ * - Large datasets (50-500 points)+ *+ * ### 3. Value Ranges+ * - Zero values+ * - Negative values+ * - Mixed positive/negative+ * - Very large numbers (millions)+ * - Very small decimals+ * - Wide value ranges+ *+ * ### 4. Data Patterns+ * - Linear progression+ * - Exponential growth+ * - Sinusoidal waves+ * - Constant values+ * - Volatile/spike patterns+ *+ * ### 5. Real-world Scenarios+ * - Time series data+ * - Financial data+ * - Traffic analytics+ */+const meta: Meta<AreaChartCondensedProps<any>> = {+ title: "Components/Charts/AreaChartCondensed",+ component: AreaChartCondensed,+ parameters: {+ layout: "centered",+ docs: {+ description: {+ component: `+## Test Suite Overview++This comprehensive test suite validates the AreaChartCondensed component across various scenarios:++### Test Coverage Areas++1. **Edge Cases**: Empty data, single point, minimal data+2. **Data Size**: Small (3-5), Medium (10-20), Large (50-500+) datasets+3. **Value Ranges**: Zeros, negatives, extremes (millions to decimals)+4. **Data Patterns**: Linear, exponential, sinusoidal, constant, volatile+5. **Real-world**: Time series, financial, analytics data++### How to Use This Test Suite++Each story represents a specific test case. Use these to:+- Verify component behavior with different data types+- Check rendering performance with large datasets+- Validate handling of edge cases+- Ensure visual consistency across variations++\`\`\`tsx+// Example: Testing with large dataset+<AreaChartCondensed+ data={testData.large100}+ categoryKey="date"+ theme="ocean"+ height={200}+/>+\`\`\`+`,+ },+ },+ },+ tags: ["dev", "autodocs"],+ argTypes: {+ data: {+ description: "Array of data objects for the chart. Same format as AreaChart.",+ control: false,+ table: {+ type: { summary: "Array<Record<string, string | number>>" },+ category: "📊 Data Configuration",+ },+ },+ categoryKey: {+ description: "The key in your data object for the X-axis category.",+ control: false,+ table: {+ type: { summary: "string" },+ category: "📊 Data Configuration",+ },+ },+ theme: {+ description: "Color palette for the chart. Ignored when customPalette is provided.",+ control: "select",+ options: ["ocean", "orchid", "emerald", "sunset", "spectrum", "vivid"],+ table: {+ defaultValue: { summary: "ocean" },+ category: "🎨 Visual Styling",+ },+ },+ customPalette: {+ description: "Custom color array. Overrides theme when provided.",+ control: "object",+ table: {+ type: { summary: "string[]" },+ category: "🎨 Visual Styling",+ },+ },+ variant: {+ description: "Area interpolation method.",+ control: "radio",+ options: ["linear", "natural", "step"],+ table: {+ defaultValue: { summary: "natural" },+ category: "🎨 Visual Styling",+ },+ },+ tickVariant: {+ description:+ "X-axis tick label style. Choose between singleLine (horizontal) or angled (-45°).",+ control: "radio",+ options: ["singleLine", "angled"],+ table: {+ defaultValue: { summary: "singleLine" },+ category: "🎨 Visual Styling",+ },+ },+ grid: {+ description: "Show or hide grid lines.",+ control: "boolean",+ table: {+ defaultValue: { summary: "true" },+ category: "📱 Display Options",+ },+ },+ showYAxis: {+ description: "Show or hide Y-axis.",+ control: "boolean",+ table: {+ defaultValue: { summary: "true" },+ category: "📱 Display Options",+ },+ },+ isAnimationActive: {+ description: "Enable loading animation.",+ control: "boolean",+ table: {+ defaultValue: { summary: "false" },+ category: "🎬 Animation",+ },+ },+ height: {+ description: "Chart height in pixels.",+ control: "number",+ table: {+ defaultValue: { summary: "200" },+ type: { summary: "number" },+ category: "Layout & Sizing",+ },+ },+ width: {+ description: "Chart width in pixels. Defaults to 100% of container.",+ control: "number",+ table: {+ type: { summary: "number" },+ category: "Layout & Sizing",+ },+ },+ className: {+ description: "Custom CSS class for the container.",+ control: "text",+ table: {+ type: { summary: "string" },+ category: "Layout & Sizing",+ },+ },+ },+} satisfies Meta<typeof AreaChartCondensed>;++export default meta;+type Story = StoryObj<typeof meta>;++// ============================================================================+// EDGE CASES - Testing component behavior with minimal/unusual data+// ============================================================================++/**+ * ## TEST: Empty Data+ *+ * **Purpose**: Verify component handles empty array gracefully+ * **Expected**: Should render without errors, show empty state or message+ */+export const EdgeCase_EmptyData: Story = {+ args: {+ data: testData.empty as any,+ categoryKey: "month" as any,+ theme: "ocean",+ height: 200,+ },+ render: (args: any) => (+ <Card style={{ width: "500px", padding: "16px" }}>+ <div style={{ marginBottom: "8px", fontSize: "12px", color: "#666" }}>+ <strong>Test:</strong> Empty dataset | <strong>Data points:</strong> 0+ </div>+ <AreaChartCondensed {...args} />+ </Card>+ ),+};++/**+ * ## TEST: Single Data Point+ *+ * **Purpose**: Verify rendering with only one data point+ * **Expected**: Should render single point, may not show area+ */+export const EdgeCase_SinglePoint: Story = {+ args: {+ data: testData.singlePoint as any,+ categoryKey: "month" as any,+ theme: "ocean",+ height: 200,+ },+ render: (args: any) => (+ <Card style={{ width: "500px", padding: "16px" }}>+ <div style={{ marginBottom: "8px", fontSize: "12px", color: "#666" }}>+ <strong>Test:</strong> Single point | <strong>Data points:</strong> 1+ </div>+ <AreaChartCondensed {...args} />+ </Card>+ ),+};++/**+ * ## TEST: Two Data Points+ *+ * **Purpose**: Minimum data to show an area (edge case)+ * **Expected**: Should show basic area between two points+ */+export const EdgeCase_TwoPoints: Story = {+ args: {+ data: testData.twoPoints as any,+ categoryKey: "month" as any,+ theme: "emerald",+ height: 200,+ },+ render: (args: any) => (+ <Card style={{ width: "500px", padding: "16px" }}>+ <div style={{ marginBottom: "8px", fontSize: "12px", color: "#666" }}>+ <strong>Test:</strong> Two points (minimum area) | <strong>Data points:</strong> 2+ </div>+ <AreaChartCondensed {...args} />+ </Card>+ ),+};++// ============================================================================+// DATA SIZE TESTS - Testing performance with different dataset sizes+// ============================================================================++/**+ * ## TEST: Small Dataset (3 points)+ *+ * **Purpose**: Verify rendering with minimal but valid data+ * **Expected**: Clean rendering, good spacing+ */+export const DataSize_Small3Points: Story = {+ args: {+ data: testData.threePoints as any,+ categoryKey: "month" as any,+ theme: "ocean",+ height: 200,+ },+ render: (args: any) => (+ <Card style={{ width: "400px", padding: "16px" }}>+ <div style={{ marginBottom: "8px", fontSize: "12px", color: "#666" }}>+ <strong>Test:</strong> Small dataset | <strong>Data points:</strong> 3+ </div>+ <AreaChartCondensed {...args} />+ </Card>+ ),+};++/**+ * ## TEST: Small Dataset (5 points, multiple series)+ *+ * **Purpose**: Test small data with multiple data series+ * **Expected**: All series visible, good color differentiation+ */+export const DataSize_Small5Points: Story = {+ args: {+ data: testData.fivePoints as any,+ categoryKey: "month" as any,+ theme: "sunset",+ icons,+ height: 200,+ },+ render: (args: any) => (+ <Card style={{ width: "450px", padding: "16px" }}>+ <div style={{ marginBottom: "8px", fontSize: "12px", color: "#666" }}>+ <strong>Test:</strong> Small dataset, 2 series | <strong>Data points:</strong> 5+ </div>+ <AreaChartCondensed {...args} />+ </Card>+ ),+};++/**+ * ## TEST: Medium Dataset (12 points, 3 series)+ *+ * **Purpose**: Standard use case with monthly data+ * **Expected**: Clean rendering, all points visible+ */+export const DataSize_Medium12Points: Story = {+ args: {+ data: testData.twelvePoints as any,+ categoryKey: "month" as any,+ theme: "orchid",+ icons,+ height: 200,+ },+ render: (args: any) => (+ <Card style={{ width: "600px", padding: "16px" }}>+ <div style={{ marginBottom: "8px", fontSize: "12px", color: "#666" }}>+ <strong>Test:</strong> Medium dataset, 3 series | <strong>Data points:</strong> 12+ </div>+ <AreaChartCondensed {...args} />+ </Card>+ ),+};++/**+ * ## TEST: Large Dataset (50 points)+ *+ * **Purpose**: Test performance with larger dataset+ * **Expected**: Should handle smoothly, may need scrolling or compression+ */+export const DataSize_Large50Points: Story = {+ args: {+ data: testData.large50 as any,+ categoryKey: "date" as any,+ theme: "emerald",+ height: 250,+ },+ render: (args: any) => (+ <Card style={{ width: "700px", padding: "16px" }}>+ <div style={{ marginBottom: "8px", fontSize: "12px", color: "#666" }}>+ <strong>Test:</strong> Large dataset, 3 series | <strong>Data points:</strong> 50+ </div>+ <AreaChartCondensed {...args} />+ </Card>+ ),+};++/**+ * ## TEST: Large Dataset (100 points)+ *+ * **Purpose**: Stress test rendering performance+ * **Expected**: Chart should remain responsive+ */+export const DataSize_Large100Points: Story = {+ args: {+ data: testData.large100 as any,+ categoryKey: "date" as any,+ theme: "vivid",+ height: 250,+ },+ render: (args: any) => (+ <Card style={{ width: "800px", padding: "16px" }}>+ <div style={{ marginBottom: "8px", fontSize: "12px", color: "#666" }}>+ <strong>Test:</strong> Large dataset, 3 series | <strong>Data points:</strong> 100+ </div>+ <AreaChartCondensed {...args} />+ </Card>+ ),+};++/**+ * ## TEST: Very Large Dataset (500 points)+ *+ * **Purpose**: Maximum stress test for performance+ * **Expected**: Should handle without crashing, check render time+ */+export const DataSize_VeryLarge500Points: Story = {+ args: {+ data: testData.large500 as any,+ categoryKey: "date" as any,+ theme: "spectrum",+ height: 300,+ showYAxis: true,+ },+ render: (args: any) => (+ <Card style={{ width: "1000px", padding: "16px" }}>+ <div style={{ marginBottom: "8px", fontSize: "12px", color: "#666" }}>+ <strong>⚠️ Stress Test:</strong> Very large dataset | <strong>Data points:</strong> 500+ </div>+ <AreaChartCondensed {...args} />+ </Card>+ ),+};++// ============================================================================+// VALUE RANGE TESTS - Testing different value types and ranges+// ============================================================================++/**+ * ## TEST: All Zero Values+ *+ * **Purpose**: Verify behavior when all values are zero+ * **Expected**: Should show flat line at zero+ */+export const ValueRange_AllZeros: Story = {+ args: {+ data: testData.allZeros as any,+ categoryKey: "month" as any,+ theme: "ocean",+ height: 200,+ },+ render: (args: any) => (+ <Card style={{ width: "400px", padding: "16px" }}>+ <div style={{ marginBottom: "8px", fontSize: "12px", color: "#666" }}>+ <strong>Test:</strong> All zero values+ </div>+ <AreaChartCondensed {...args} />+ </Card>+ ),+};++/**+ * ## TEST: Mixed Zeros in Series+ *+ * **Purpose**: Test handling of zero values mixed with non-zero+ * **Expected**: Should handle gaps/zeros gracefully+ */+export const ValueRange_WithZeros: Story = {+ args: {+ data: testData.withZeros as any,+ categoryKey: "month" as any,+ theme: "emerald",+ icons,+ height: 200,+ },+ render: (args: any) => (+ <Card style={{ width: "450px", padding: "16px" }}>+ <div style={{ marginBottom: "8px", fontSize: "12px", color: "#666" }}>+ <strong>Test:</strong> Zeros mixed with values+ </div>+ <AreaChartCondensed {...args} />+ </Card>+ ),+};++/**+ * ## TEST: Negative Values+ *+ * **Purpose**: Verify handling of negative numbers+ * **Expected**: Should display below zero line correctly+ */+export const ValueRange_Negative: Story = {+ args: {+ data: testData.negativeValues as any,+ categoryKey: "month" as any,+ theme: "sunset",+ height: 200,+ },+ render: (args: any) => (+ <Card style={{ width: "450px", padding: "16px" }}>+ <div style={{ marginBottom: "8px", fontSize: "12px", color: "#666" }}>+ <strong>Test:</strong> Negative values+ </div>+ <AreaChartCondensed {...args} />+ </Card>+ ),+};++/**+ * ## TEST: Mixed Positive/Negative+ *+ * **Purpose**: Test combination of positive and negative values+ * **Expected**: Should show crossing zero line+ */+export const ValueRange_Mixed: Story = {+ args: {+ data: testData.mixedValues as any,+ categoryKey: "month" as any,+ theme: "orchid",+ height: 200,+ },+ render: (args: any) => (+ <Card style={{ width: "450px", padding: "16px" }}>+ <div style={{ marginBottom: "8px", fontSize: "12px", color: "#666" }}>+ <strong>Test:</strong> Mixed positive/negative values+ </div>+ <AreaChartCondensed {...args} />+ </Card>+ ),+};++/**+ * ## TEST: Very Large Numbers (Millions)+ *+ * **Purpose**: Test formatting and display of large numbers+ * **Expected**: Should format with appropriate abbreviations (K, M, B)+ */+export const ValueRange_VeryLarge: Story = {+ args: {+ data: testData.veryLarge as any,+ categoryKey: "month" as any,+ theme: "vivid",+ height: 200,+ },+ render: (args: any) => (+ <Card style={{ width: "450px", padding: "16px" }}>+ <div style={{ marginBottom: "8px", fontSize: "12px", color: "#666" }}>+ <strong>Test:</strong> Very large numbers (millions)+ </div>+ <AreaChartCondensed {...args} />+ </Card>+ ),+};++/**+ * ## TEST: Very Small Decimals+ *+ * **Purpose**: Test precision handling for small decimal values+ * **Expected**: Should display appropriate decimal precision+ */+export const ValueRange_VerySmall: Story = {+ args: {+ data: testData.verySmall as any,+ categoryKey: "month" as any,+ theme: "emerald",+ height: 200,+ },+ render: (args: any) => (+ <Card style={{ width: "450px", padding: "16px" }}>+ <div style={{ marginBottom: "8px", fontSize: "12px", color: "#666" }}>+ <strong>Test:</strong> Very small decimal values+ </div>+ <AreaChartCondensed {...args} />+ </Card>+ ),+};++/**+ * ## TEST: Wide Value Range+ *+ * **Purpose**: Test scaling when series have vastly different magnitudes+ * **Expected**: Should scale appropriately or show warning+ */+export const ValueRange_WideRange: Story = {+ args: {+ data: testData.wideRange as any,+ categoryKey: "month" as any,+ theme: "spectrum",+ height: 200,+ },+ render: (args: any) => (+ <Card style={{ width: "500px", padding: "16px" }}>+ <div style={{ marginBottom: "8px", fontSize: "12px", color: "#666" }}>+ <strong>Test:</strong> Wide range (1 to 1,000,000)+ </div>+ <AreaChartCondensed {...args} />+ </Card>+ ),+};++// ============================================================================+// PATTERN TESTS - Testing different data patterns and shapes+// ============================================================================++/**+ * ## TEST: Linear Progression+ *+ * **Purpose**: Verify rendering of linear increasing data+ * **Expected**: Clean straight line progression+ */+export const Pattern_Linear: Story = {+ args: {+ data: testData.linear as any,+ categoryKey: "x" as any,+ theme: "ocean",+ variant: "linear",+ height: 200,+ },+ render: (args: any) => (+ <Card style={{ width: "500px", padding: "16px" }}>+ <div style={{ marginBottom: "8px", fontSize: "12px", color: "#666" }}>+ <strong>Test:</strong> Linear progression pattern+ </div>+ <AreaChartCondensed {...args} />+ </Card>+ ),+};++/**+ * ## TEST: Exponential Growth+ *+ * **Purpose**: Test rendering of exponentially increasing values+ * **Expected**: Should handle steep curve and wide Y-axis range+ */+export const Pattern_Exponential: Story = {+ args: {+ data: testData.exponential as any,+ categoryKey: "x" as any,+ theme: "emerald",+ variant: "natural",+ height: 200,+ },+ render: (args: any) => (+ <Card style={{ width: "500px", padding: "16px" }}>+ <div style={{ marginBottom: "8px", fontSize: "12px", color: "#666" }}>+ <strong>Test:</strong> Exponential growth pattern+ </div>+ <AreaChartCondensed {...args} />+ </Card>+ ),+};++/**+ * ## TEST: Sinusoidal Wave+ *+ * **Purpose**: Test smooth curves with wave pattern+ * **Expected**: Natural variant should show smooth sine wave+ */+export const Pattern_Sinusoidal: Story = {+ args: {+ data: testData.sinusoidal as any,+ categoryKey: "x" as any,+ theme: "orchid",+ variant: "natural",+ height: 200,+ },+ render: (args: any) => (+ <Card style={{ width: "600px", padding: "16px" }}>+ <div style={{ marginBottom: "8px", fontSize: "12px", color: "#666" }}>+ <strong>Test:</strong> Sinusoidal wave pattern+ </div>+ <AreaChartCondensed {...args} />+ </Card>+ ),+};++/**+ * ## TEST: Constant Values+ *+ * **Purpose**: Test behavior with no variation in data+ * **Expected**: Flat horizontal line+ */+export const Pattern_Constant: Story = {+ args: {+ data: testData.constant as any,+ categoryKey: "x" as any,+ theme: "sunset",+ height: 200,+ },+ render: (args: any) => (+ <Card style={{ width: "450px", padding: "16px" }}>+ <div style={{ marginBottom: "8px", fontSize: "12px", color: "#666" }}>+ <strong>Test:</strong> Constant value pattern+ </div>+ <AreaChartCondensed {...args} />+ </Card>+ ),+};++/**+ * ## TEST: Volatile/Spike Pattern+ *+ * **Purpose**: Test rendering of data with extreme spikes+ * **Expected**: Should handle spikes without distortion+ */+export const Pattern_Volatile: Story = {+ args: {+ data: testData.volatile as any,+ categoryKey: "x" as any,+ theme: "vivid",+ height: 200,+ },+ render: (args: any) => (+ <Card style={{ width: "550px", padding: "16px" }}>+ <div style={{ marginBottom: "8px", fontSize: "12px", color: "#666" }}>+ <strong>Test:</strong> Volatile pattern with spikes+ </div>+ <AreaChartCondensed {...args} />+ </Card>+ ),+};++// ============================================================================+// REAL-WORLD SCENARIO TESTS - Practical use cases+// ============================================================================++/**+ * ## TEST: Daily Time Series (30 days)+ *+ * **Purpose**: Test typical time-series sales data+ * **Expected**: Clean rendering of date-based data+ */+export const RealWorld_DailySales: Story = {+ args: {+ data: testData.dailySales as any,+ categoryKey: "date" as any,+ theme: "ocean",+ icons,+ height: 220,+ },+ render: (args: any) => (+ <Card style={{ width: "700px", padding: "16px" }}>+ <div style={{ marginBottom: "8px", fontSize: "12px", color: "#666" }}>+ <strong>Test:</strong> Daily sales time series | <strong>Days:</strong> 30+ </div>+ <AreaChartCondensed {...args} />+ </Card>+ ),+};++/**+ * ## TEST: Quarterly Financial Data+ *+ * **Purpose**: Test financial reporting scenario+ * **Expected**: Clear visualization of revenue, profit, costs+ */+export const RealWorld_QuarterlySales: Story = {+ args: {+ data: testData.quarterlySales as any,+ categoryKey: "quarter" as any,+ theme: "emerald",+ icons,+ height: 220,+ },+ render: (args: any) => (+ <Card style={{ width: "600px", padding: "16px" }}>+ <div style={{ marginBottom: "8px", fontSize: "12px", color: "#666" }}>+ <strong>Test:</strong> Quarterly financial data | <strong>Quarters:</strong> 5+ </div>+ <AreaChartCondensed {...args} />+ </Card>+ ),+};++/**+ * ## TEST: Weekly Analytics Traffic+ *+ * **Purpose**: Test typical analytics dashboard data+ * **Expected**: Multiple metrics clearly differentiated+ */+export const RealWorld_WeeklyTraffic: Story = {+ args: {+ data: testData.weeklyTraffic as any,+ categoryKey: "day" as any,+ theme: "sunset",+ icons,+ height: 220,+ },+ render: (args: any) => (+ <Card style={{ width: "650px", padding: "16px" }}>+ <div style={{ marginBottom: "8px", fontSize: "12px", color: "#666" }}>+ <strong>Test:</strong> Weekly traffic analytics | <strong>Metrics:</strong> 3+ </div>+ <AreaChartCondensed {...args} />+ </Card>+ ),+};++// ============================================================================+// VARIANT & CONFIGURATION TESTS+// ============================================================================++/**+ * ## TEST: Variant Comparison+ *+ * **Purpose**: Compare all interpolation variants side-by-side+ * **Expected**: Visual difference between linear, natural, step+ */+export const Config_VariantComparison: Story = {+ render: () => (+ <div style={{ display: "flex", flexDirection: "column", gap: "16px" }}>+ <Card style={{ width: "600px", padding: "16px" }}>+ <div style={{ marginBottom: "8px", fontSize: "12px", color: "#666" }}>+ <strong>Variant:</strong> Linear+ </div>+ <AreaChartCondensed+ data={testData.twelvePoints as any}+ categoryKey="month"+ variant="linear"+ theme="ocean"+ height={150}+ />+ </Card>+ <Card style={{ width: "600px", padding: "16px" }}>+ <div style={{ marginBottom: "8px", fontSize: "12px", color: "#666" }}>+ <strong>Variant:</strong> Natural (smooth)+ </div>+ <AreaChartCondensed+ data={testData.twelvePoints as any}+ categoryKey="month"+ variant="natural"+ theme="emerald"+ height={150}+ />+ </Card>+ <Card style={{ width: "600px", padding: "16px" }}>+ <div style={{ marginBottom: "8px", fontSize: "12px", color: "#666" }}>+ <strong>Variant:</strong> Step+ </div>+ <AreaChartCondensed+ data={testData.twelvePoints as any}+ categoryKey="month"+ variant="step"+ theme="sunset"+ height={150}+ />+ </Card>+ </div>+ ),+};++/**+ * ## TEST: Without Y-Axis+ *+ * **Purpose**: Test ultra-compact mode without Y-axis+ * **Expected**: More horizontal space, clean minimal look+ */+export const Config_WithoutYAxis: Story = {+ args: {+ data: testData.twelvePoints as any,+ categoryKey: "month" as any,+ theme: "vivid",+ showYAxis: false,+ grid: false,+ height: 150,+ },+ render: (args: any) => (+ <Card style={{ width: "500px", padding: "16px" }}>+ <div style={{ marginBottom: "8px", fontSize: "12px", color: "#666" }}>+ <strong>Test:</strong> Y-axis hidden, grid off+ </div>+ <AreaChartCondensed {...args} />+ </Card>+ ),+};++/**+ * ## TEST: Custom Color Palette+ *+ * **Purpose**: Verify custom palette override functionality+ * **Expected**: Uses custom colors instead of theme+ */+export const Config_CustomPalette: Story = {+ args: {+ data: testData.twelvePoints as any,+ categoryKey: "month" as any,+ customPalette: ["#FF6B6B", "#4ECDC4", "#45B7D1"],+ height: 200,+ },+ render: (args: any) => (+ <div>+ <div+ style={{+ marginBottom: "12px",+ padding: "12px",+ background: "#f8f9fa",+ borderRadius: "8px",+ width: "550px",+ }}+ >+ <strong>Custom Palette:</strong>+ <div style={{ display: "flex", gap: "8px", marginTop: "8px" }}>+ {args.customPalette?.map((color: string, index: number) => (+ <div+ key={index}+ style={{ display: "flex", alignItems: "center", gap: "4px", fontSize: "12px" }}+ >+ <div+ style={{+ width: "16px",+ height: "16px",+ backgroundColor: color,+ borderRadius: "3px",+ border: "1px solid #ddd",+ }}+ />+ <span style={{ fontFamily: "monospace" }}>{color}</span>+ </div>+ ))}+ </div>+ </div>+ <Card style={{ width: "550px", padding: "16px" }}>+ <AreaChartCondensed {...args} />+ </Card>+ </div>+ ),+};++// ============================================================================+// STRESS & PERFORMANCE TESTS+// ============================================================================++/**+ * ## TEST: Multiple Charts Dashboard+ *+ * **Purpose**: Test rendering multiple charts simultaneously+ * **Expected**: All charts render smoothly without performance issues+ */+export const Stress_MultipleCharts: Story = {+ render: () => (+ <div+ style={{+ display: "grid",+ gridTemplateColumns: "repeat(2, 1fr)",+ gap: "16px",+ width: "900px",+ }}+ >+ <Card style={{ padding: "16px" }}>+ <div style={{ marginBottom: "8px", fontSize: "12px", fontWeight: "600" }}>+ Small Dataset+ </div>+ <AreaChartCondensed+ data={testData.fivePoints as any}+ categoryKey="month"+ theme="ocean"+ height={140}+ />+ </Card>+ <Card style={{ padding: "16px" }}>+ <div style={{ marginBottom: "8px", fontSize: "12px", fontWeight: "600" }}>+ Medium Dataset+ </div>+ <AreaChartCondensed+ data={testData.twelvePoints as any}+ categoryKey="month"+ theme="emerald"+ height={140}+ />+ </Card>+ <Card style={{ padding: "16px" }}>+ <div style={{ marginBottom: "8px", fontSize: "12px", fontWeight: "600" }}>+ Large Dataset (50)+ </div>+ <AreaChartCondensed+ data={testData.large50 as any}+ categoryKey="date"+ theme="sunset"+ height={140}+ />+ </Card>+ <Card style={{ padding: "16px" }}>+ <div style={{ marginBottom: "8px", fontSize: "12px", fontWeight: "600" }}>Time Series</div>+ <AreaChartCondensed+ data={testData.dailySales as any}+ categoryKey="date"+ theme="orchid"+ height={140}+ />+ </Card>+ </div>+ ),+ parameters: {+ docs: {+ description: {+ story: "Stress test with 4 charts rendering simultaneously with varying dataset sizes.",+ },+ },+ },+};++// Test Data for Long Labels+const longLabelData = [+ { category: "Q1 2024 January Total Revenue and Expenses", sales: 186, expenses: 80, profit: 106 },+ {+ category: "Q1 2024 February Marketing Campaign Results",+ sales: 305,+ expenses: 200,+ profit: 105,+ },+ { category: "Q1 2024 March Product Launch Performance", sales: 237, expenses: 120, profit: 117 },+ { category: "Q2 2024 April Customer Acquisition Metrics", sales: 273, expenses: 190, profit: 83 },+ { category: "Q2 2024 May Operational Efficiency Report", sales: 209, expenses: 130, profit: 79 },+ {+ category: "Q2 2024 June Strategic Initiative Outcomes",+ sales: 314,+ expenses: 140,+ profit: 174,+ },+ { category: "Q3 2024 July Market Expansion Analysis", sales: 350, expenses: 180, profit: 170 },+ {+ category: "Q3 2024 August Technology Investment Returns",+ sales: 280,+ expenses: 160,+ profit: 120,+ },+ { category: "Q3 2024 September Partnership Performance", sales: 320, expenses: 170, profit: 150 },+ { category: "Q4 2024 October Year-End Projections", sales: 290, expenses: 150, profit: 140 },+ { category: "Q4 2024 November Holiday Season Preview", sales: 340, expenses: 180, profit: 160 },+ { category: "Q4 2024 December Annual Summary Report", sales: 420, expenses: 220, profit: 200 },+];++// Tick Variant Stories+export const TickVariantSingleLine: Story = {+ render: () => (+ <Card style={{ padding: "24px", width: "900px", maxWidth: "900px" }}>+ <div style={{ marginBottom: "16px", fontSize: "16px", fontWeight: "600" }}>+ Single Line Tick Variant+ </div>+ <div style={{ marginBottom: "8px", fontSize: "13px", color: "#666" }}>+ Standard horizontal labels with automatic collision detection+ </div>+ <AreaChartCondensed+ data={longLabelData as any}+ categoryKey="category"+ tickVariant="singleLine"+ theme="ocean"+ height={200}+ />+ </Card>+ ),+ parameters: {+ docs: {+ description: {+ story:+ "Single line tick variant with standard horizontal labels. Automatically handles collision detection.",+ },+ },+ },+};++export const TickVariantAngled: Story = {+ render: () => (+ <Card style={{ padding: "24px", width: "900px", maxWidth: "900px" }}>+ <div style={{ marginBottom: "16px", fontSize: "16px", fontWeight: "600" }}>+ Angled Tick Variant+ </div>+ <div style={{ marginBottom: "8px", fontSize: "13px", color: "#666" }}>+ -45° rotation perfect for long labels that would overlap horizontally+ </div>+ <AreaChartCondensed+ data={longLabelData as any}+ categoryKey="category"+ tickVariant="angled"+ theme="emerald"+ height={280}+ />+ </Card>+ ),+ parameters: {+ docs: {+ description: {+ story:+ "Angled tick variant with -45° rotation. Perfect for long labels that would overlap horizontally.",+ },+ },+ },+};++// Dense Data with Tick Variants+const denseData = Array.from({ length: 30 }, (_, i) => ({+ day: `Day ${i + 1}`,+ revenue: Math.floor(Math.random() * 500) + 100,+ costs: Math.floor(Math.random() * 300) + 50,+}));++export const TickVariantComparisonDenseData: Story = {+ render: () => (+ <div style={{ display: "grid", gridTemplateColumns: "1fr", gap: "24px", maxWidth: "1100px" }}>+ <Card style={{ padding: "24px" }}>+ <div style={{ marginBottom: "16px", fontSize: "16px", fontWeight: "600" }}>+ Single Line Variant (Dense Data - 30 Points)+ </div>+ <div style={{ marginBottom: "8px", fontSize: "13px", color: "#666" }}>+ Recharts automatically hides overlapping labels+ </div>+ <AreaChartCondensed+ data={denseData as any}+ categoryKey="day"+ tickVariant="singleLine"+ theme="ocean"+ height={200}+ />+ </Card>+ <Card style={{ padding: "24px" }}>+ <div style={{ marginBottom: "16px", fontSize: "16px", fontWeight: "600" }}>+ Angled Variant (Dense Data - 30 Points)+ </div>+ <div style={{ marginBottom: "8px", fontSize: "13px", color: "#666" }}>+ Shows more labels with angled orientation+ </div>+ <AreaChartCondensed+ data={denseData as any}+ categoryKey="day"+ tickVariant="angled"+ theme="emerald"+ height={280}+ />+ </Card>+ </div>+ ),+ parameters: {+ docs: {+ description: {+ story:+ "Comparison of tick variants (singleLine and angled) with dense data (30 data points). Shows how each variant handles label collision with Recharts' built-in collision detection.",+ },+ },+ },+};diff --git a/js/packages/react-ui/src/components/Charts/BarChartCondensed/BarChartCondensed.tsx b/js/packages/react-ui/src/components/Charts/BarChartCondensed/BarChartCondensed.tsxnew file mode 100644index 000000000..44f57db7b--- /dev/null+++ b/js/packages/react-ui/src/components/Charts/BarChartCondensed/BarChartCondensed.tsx@@ -0,0 +1,287 @@+import clsx from "clsx";+import React, { useCallback, useMemo, useRef, useState } from "react";+import { Bar, BarChart as RechartsBarChart, XAxis, YAxis } from "recharts";+import { useId } from "../../../polyfills";+import { useTheme } from "../../ThemeProvider";+import { BarChartData, BarChartVariant } from "../BarChart/types";+import { ChartConfig, ChartContainer, ChartTooltip } from "../Charts";+import { X_AXIS_PADDING } from "../constants";+import { SideBarChartData, SideBarTooltipProvider } from "../context/SideBarTooltipContext";+import {+ useAutoAngleCalculation,+ useMaxLabelWidth,+ useTransformedKeys,+ useYAxisLabelWidth,+} from "../hooks";+import {+ cartesianGrid,+ CondensedXAxisTick,+ CondensedXAxisTickVariant,+ CustomTooltipContent,+ LineInBarShape,+ YAxisTick,+} from "../shared";+import { LabelTooltipProvider } from "../shared/LabelTooltip/LabelTooltip";+import { getBarStackInfo, getRadiusArray } from "../utils/BarCharts/BarChartsUtils";+import { get2dChartConfig, getDataKeys } from "../utils/dataUtils";+import { PaletteName, useChartPalette } from "../utils/PalletUtils";++export interface BarChartCondensedProps<T extends BarChartData> {+ data: T;+ categoryKey: keyof T[number];+ theme?: PaletteName;+ customPalette?: string[];+ variant?: BarChartVariant;+ tickVariant?: CondensedXAxisTickVariant;+ grid?: boolean;+ radius?: number;+ icons?: Partial<Record<keyof T[number], React.ComponentType>>;+ isAnimationActive?: boolean;+ showYAxis?: boolean;+ className?: string;+ height?: number;+ width?: number;+}++const BAR_WIDTH = 16;+const BAR_GAP = 10;+const BAR_CATEGORY_GAP = "20%";+const BAR_INTERNAL_LINE_WIDTH = 1;+const BAR_RADIUS = 4;+const CHART_HEIGHT = 200;+const CHART_CONTAINER_BOTTOM_MARGIN = 10;++const BarChartCondensedComponent = <T extends BarChartData>({+ data,+ categoryKey,+ theme = "ocean",+ customPalette,+ variant = "grouped",+ tickVariant = "singleLine",+ grid = true,+ icons = {},+ radius = BAR_RADIUS,+ isAnimationActive = false,+ showYAxis = true,+ className,+ height = CHART_HEIGHT,+ width,+}: BarChartCondensedProps<T>) => {+ const dataKeys = useMemo(() => {+ return getDataKeys(data, categoryKey as string);+ }, [data, categoryKey]);++ const { yAxisWidth, setLabelWidth } = useYAxisLabelWidth(data, dataKeys);++ const maxLabelWidth = useMaxLabelWidth(data, categoryKey as string);++ const { angle: calculatedAngle, height: xAxisHeight } = useAutoAngleCalculation(+ maxLabelWidth,+ yAxisWidth,+ tickVariant === "angled",+ showYAxis,+ );++ const effectiveHeight = useMemo(() => {+ if (tickVariant === "angled") {+ return xAxisHeight + height;+ }+ return height;+ }, [height, xAxisHeight, tickVariant]);++ const transformedKeys = useTransformedKeys(dataKeys);++ const colors = useChartPalette({+ chartThemeName: theme,+ customPalette,+ themePaletteName: "barChartPalette",+ dataLength: dataKeys.length,+ });++ const chartConfig: ChartConfig = useMemo(() => {+ return get2dChartConfig(dataKeys, colors, transformedKeys, undefined, icons);+ }, [dataKeys, icons, colors, transformedKeys]);++ const id = useId();++ const chartMargin = useMemo(+ () => ({+ top: 10,+ right: 10,+ bottom: CHART_CONTAINER_BOTTOM_MARGIN,+ left: showYAxis ? 10 : 0,+ }),+ [showYAxis],+ );++ const { mode } = useTheme();++ const barInternalLineColor = useMemo(() => {+ if (mode === "light") {+ return "rgba(255, 255, 255, 0.3)";+ }+ return "rgba(0, 0, 0, 0.3)";+ }, [mode]);++ const containerRef = useRef<HTMLDivElement>(null);+ const [isSideBarTooltipOpen, setIsSideBarTooltipOpen] = useState(false);+ const [sideBarTooltipData, setSideBarTooltipData] = useState<SideBarChartData>({+ title: "",+ values: [],+ });+ const [hoveredCategory, setHoveredCategory] = useState<string | number | null>(null);++ // Handle mouse events for bar hovering+ const handleChartMouseMove = useCallback((state: any) => {+ if (state && state.activeLabel !== undefined) {+ setHoveredCategory(state.activeLabel);+ }+ }, []);++ const handleChartMouseLeave = useCallback(() => {+ setHoveredCategory(null);+ }, []);++ const barElements = useMemo(() => {+ return dataKeys.map((key) => {+ const transformedKey = transformedKeys[key];+ const color = `var(--color-${transformedKey})`;++ return (+ <Bar+ key={`bar-${key}`}+ dataKey={key}+ fill={color}+ stackId={variant === "stacked" ? "a" : undefined}+ isAnimationActive={isAnimationActive}+ maxBarSize={BAR_WIDTH}+ barSize={BAR_WIDTH}+ shape={(props: any) => {+ const { payload, value, dataKey } = props;++ const { isNegative, isFirstInStack, isLastInStack, hasNegativeValueInStack } =+ getBarStackInfo(variant, value, dataKey, payload, dataKeys);++ const customRadius = getRadiusArray(+ variant,+ radius,+ "vertical",+ isFirstInStack,+ isLastInStack,+ isNegative,+ );++ return (+ <LineInBarShape+ {...props}+ radius={customRadius}+ internalLineColor={barInternalLineColor}+ internalLineWidth={BAR_INTERNAL_LINE_WIDTH}+ isHovered={hoveredCategory !== null}+ hoveredCategory={hoveredCategory}+ categoryKey={categoryKey as string}+ variant={variant}+ hasNegativeValueInStack={hasNegativeValueInStack}+ />+ );+ }}+ />+ );+ });+ }, [+ dataKeys,+ transformedKeys,+ variant,+ radius,+ isAnimationActive,+ barInternalLineColor,+ hoveredCategory,+ categoryKey,+ ]);++ return (+ <LabelTooltipProvider>+ <SideBarTooltipProvider+ isSideBarTooltipOpen={isSideBarTooltipOpen}+ setIsSideBarTooltipOpen={setIsSideBarTooltipOpen}+ data={sideBarTooltipData}+ setData={setSideBarTooltipData}+ >+ <div+ ref={containerRef}+ className={clsx("crayon-bar-chart-condensed", className)}+ style={{+ width: width ? `${width}px` : "100%",+ height: `${effectiveHeight}px`,+ }}+ >+ <ChartContainer+ config={chartConfig}+ style={{ width: "100%", height: "100%" }}+ rechartsProps={{+ width: "100%",+ height: "100%",+ }}+ >+ <RechartsBarChart+ accessibilityLayer+ key={`bar-chart-condensed-${id}`}+ data={data}+ margin={chartMargin}+ barGap={BAR_GAP}+ barCategoryGap={BAR_CATEGORY_GAP}+ onMouseMove={handleChartMouseMove}+ onMouseLeave={handleChartMouseLeave}+ >+ {grid && cartesianGrid()}++ <XAxis+ dataKey={categoryKey as string}+ tickLine={false}+ axisLine={false}+ textAnchor={tickVariant === "angled" ? "end" : "middle"}+ interval="preserveStartEnd"+ minTickGap={5}+ height={xAxisHeight}+ tick={<CondensedXAxisTick />}+ angle={calculatedAngle}+ orientation="bottom"+ padding={{+ left: X_AXIS_PADDING,+ right: X_AXIS_PADDING,+ }}+ />++ {showYAxis && (+ <YAxis+ tickLine={false}+ axisLine={false}+ tick={<YAxisTick setLabelWidth={setLabelWidth} />}+ width={yAxisWidth}+ />+ )}++ <ChartTooltip+ cursor={{+ fill: "var(--crayon-sunk-fills)",+ stroke: "var(--crayon-stroke-default)",+ opacity: 1,+ strokeWidth: 1,+ }}+ content={<CustomTooltipContent parentRef={containerRef} />}+ offset={10}+ />++ {barElements}+ </RechartsBarChart>+ </ChartContainer>+ </div>+ </SideBarTooltipProvider>+ </LabelTooltipProvider>+ );+};++// Added React.memo for performance optimization to avoid unnecessary re-renders+export const BarChartCondensed = React.memo(+ BarChartCondensedComponent,+) as typeof BarChartCondensedComponent;diff --git a/js/packages/react-ui/src/components/Charts/BarChartCondensed/barChartCondensed.scss b/js/packages/react-ui/src/components/Charts/BarChartCondensed/barChartCondensed.scssnew file mode 100644index 000000000..4e794e7b8--- /dev/null+++ b/js/packages/react-ui/src/components/Charts/BarChartCondensed/barChartCondensed.scss@@ -0,0 +1,8 @@+@use "../../../cssUtils" as cssUtils;++.crayon-bar-chart-condensed {+ width: 100%;+ height: 100%;+ display: flex;+ flex-direction: column;+}diff --git a/js/packages/react-ui/src/components/Charts/BarChartCondensed/dependencies.ts b/js/packages/react-ui/src/components/Charts/BarChartCondensed/dependencies.tsnew file mode 100644index 000000000..abc6c017c--- /dev/null+++ b/js/packages/react-ui/src/components/Charts/BarChartCondensed/dependencies.ts@@ -0,0 +1,2 @@+const dependencies = ["BarChartCondensed"];+export default dependencies;diff --git a/js/packages/react-ui/src/components/Charts/BarChartCondensed/index.ts b/js/packages/react-ui/src/components/Charts/BarChartCondensed/index.tsnew file mode 100644index 000000000..7bd483feb--- /dev/null+++ b/js/packages/react-ui/src/components/Charts/BarChartCondensed/index.ts@@ -0,0 +1,2 @@+export * from "../BarChart/types";+export * from "./BarChartCondensed";diff --git a/js/packages/react-ui/src/components/Charts/BarChartCondensed/stories/barChartCondensed.stories.tsx b/js/packages/react-ui/src/components/Charts/BarChartCondensed/stories/barChartCondensed.stories.tsxnew file mode 100644index 000000000..69331dc87--- /dev/null+++ b/js/packages/react-ui/src/components/Charts/BarChartCondensed/stories/barChartCondensed.stories.tsx@@ -0,0 +1,1383 @@+import type { Meta, StoryObj } from "@storybook/react";+import { Calendar, Globe, Laptop, Monitor, Smartphone, TabletSmartphone } from "lucide-react";+import { Card } from "../../../Card";+import { BarChartCondensed, BarChartCondensedProps } from "../BarChartCondensed";++// Test Data Generators+const generateLargeDataset = (points: number) => {+ return Array.from({ length: points }, (_, i) => ({+ date: `Day ${i + 1}`,+ value1: Math.floor(Math.random() * 1000) + 100,+ value2: Math.floor(Math.random() * 800) + 50,+ value3: Math.floor(Math.random() * 600) + 30,+ }));+};++const generateTimeSeriesData = (days: number) => {+ const startDate = new Date("2024-01-01");+ return Array.from({ length: days }, (_, i) => {+ const date = new Date(startDate);+ date.setDate(date.getDate() + i);+ return {+ date: date.toISOString().split("T")[0],+ sales: Math.floor(Math.random() * 5000) + 1000,+ orders: Math.floor(Math.random() * 200) + 50,+ };+ });+};++// Test Data Variations+const testData = {+ // Edge Cases+ empty: [],+ singlePoint: [{ month: "Jan", value: 100 }],+ twoPoints: [+ { month: "Jan", value: 100 },+ { month: "Feb", value: 200 },+ ],++ // Small Datasets+ threePoints: [+ { month: "Jan", value: 100 },+ { month: "Feb", value: 150 },+ { month: "Mar", value: 120 },+ ],+ fivePoints: [+ { month: "Jan", desktop: 150, mobile: 90 },+ { month: "Feb", desktop: 280, mobile: 180 },+ { month: "Mar", desktop: 220, mobile: 140 },+ { month: "Apr", desktop: 180, mobile: 160 },+ { month: "May", desktop: 250, mobile: 120 },+ ],++ // Medium Datasets+ twelvePoints: [+ { month: "Jan", desktop: 150, mobile: 90, tablet: 120 },+ { month: "Feb", desktop: 280, mobile: 180, tablet: 140 },+ { month: "Mar", desktop: 220, mobile: 140, tablet: 160 },+ { month: "Apr", desktop: 180, mobile: 160, tablet: 180 },+ { month: "May", desktop: 250, mobile: 120, tablet: 140 },+ { month: "Jun", desktop: 300, mobile: 180, tablet: 160 },+ { month: "Jul", desktop: 320, mobile: 200, tablet: 180 },+ { month: "Aug", desktop: 290, mobile: 170, tablet: 150 },+ { month: "Sep", desktop: 310, mobile: 190, tablet: 170 },+ { month: "Oct", desktop: 280, mobile: 160, tablet: 140 },+ { month: "Nov", desktop: 350, mobile: 210, tablet: 190 },+ { month: "Dec", desktop: 400, mobile: 250, tablet: 220 },+ ],++ // Large Datasets+ large50: generateLargeDataset(50),+ large100: generateLargeDataset(100),++ // Special Value Cases+ allZeros: [+ { month: "Jan", value: 0 },+ { month: "Feb", value: 0 },+ { month: "Mar", value: 0 },+ { month: "Apr", value: 0 },+ ],+ withZeros: [+ { month: "Jan", desktop: 100, mobile: 0 },+ { month: "Feb", desktop: 0, mobile: 50 },+ { month: "Mar", desktop: 150, mobile: 0 },+ { month: "Apr", desktop: 0, mobile: 100 },+ ],+ negativeValues: [+ { month: "Jan", profit: -50, loss: -30 },+ { month: "Feb", profit: 100, loss: -20 },+ { month: "Mar", profit: -30, loss: -40 },+ { month: "Apr", profit: 150, loss: -10 },+ ],+ mixedValues: [+ { month: "Jan", value1: -100, value2: 200 },+ { month: "Feb", value1: 150, value2: -50 },+ { month: "Mar", value1: -75, value2: 300 },+ { month: "Apr", value1: 200, value2: -100 },+ ],++ // Extreme Values+ veryLarge: [+ { month: "Jan", value: 1000000, secondary: 500000 },+ { month: "Feb", value: 1500000, secondary: 750000 },+ { month: "Mar", value: 1200000, secondary: 600000 },+ ],+ verySmall: [+ { month: "Jan", value: 0.001, secondary: 0.002 },+ { month: "Feb", value: 0.003, secondary: 0.0015 },+ { month: "Mar", value: 0.002, secondary: 0.0025 },+ ],+ wideRange: [+ { month: "Jan", small: 1, large: 1000000 },+ { month: "Feb", small: 2, large: 1500000 },+ { month: "Mar", small: 1.5, large: 1200000 },+ ],++ // Pattern Tests+ linear: Array.from({ length: 10 }, (_, i) => ({+ x: `Point ${i + 1}`,+ y: i * 10,+ })),+ increasing: Array.from({ length: 8 }, (_, i) => ({+ x: `Point ${i + 1}`,+ y: Math.pow(i + 1, 1.5) * 10,+ })),+ constant: Array.from({ length: 8 }, (_, i) => ({+ x: `Point ${i + 1}`,+ y: 100,+ })),+ volatile: Array.from({ length: 15 }, (_, i) => ({+ x: `Point ${i + 1}`,+ spike: i % 3 === 0 ? 500 : 50,+ normal: 100 + Math.random() * 20,+ })),++ // Real-world Scenarios+ dailySales: generateTimeSeriesData(30),+ quarterlySales: [+ { quarter: "Q1 2023", revenue: 12000, profit: 4000, costs: 8000 },+ { quarter: "Q2 2023", revenue: 15000, profit: 5500, costs: 9500 },+ { quarter: "Q3 2023", revenue: 18000, profit: 7000, costs: 11000 },+ { quarter: "Q4 2023", revenue: 20000, profit: 7000, costs: 13000 },+ { quarter: "Q1 2024", revenue: 22000, profit: 8000, costs: 14000 },+ ],+ weeklyTraffic: [+ { day: "Mon", visits: 2200, conversions: 180, bounces: 800 },+ { day: "Tue", visits: 2500, conversions: 220, bounces: 900 },+ { day: "Wed", visits: 2300, conversions: 190, bounces: 850 },+ { day: "Thu", visits: 2800, conversions: 250, bounces: 1000 },+ { day: "Fri", visits: 3200, conversions: 280, bounces: 1100 },+ { day: "Sat", visits: 1800, conversions: 120, bounces: 600 },+ { day: "Sun", visits: 1500, conversions: 100, bounces: 500 },+ ],+};++const icons = {+ desktop: Monitor,+ mobile: TabletSmartphone,+ tablet: Calendar,+ revenue: Globe,+ profit: Smartphone,+ visits: Monitor,+ conversions: Laptop,+ value: Monitor,+ value1: Monitor,+ value2: TabletSmartphone,+ value3: Calendar,+ small: Smartphone,+ large: Globe,+ sales: Globe,+ orders: Laptop,+ bounces: Calendar,+ costs: Smartphone,+} as const;++/**+ * # BarChartCondensed Test Suite+ *+ * This file contains comprehensive test cases for the BarChartCondensed component,+ * covering edge cases, data variations, and stress testing scenarios.+ *+ * ## Test Categories+ *+ * ### 1. Edge Cases+ * - Empty data+ * - Single data point+ * - Two data points (minimum for comparison)+ *+ * ### 2. Data Size Variations+ * - Small datasets (3-5 points)+ * - Medium datasets (10-20 points)+ * - Large datasets (50-100 points)+ *+ * ### 3. Value Ranges+ * - Zero values+ * - Negative values+ * - Mixed positive/negative+ * - Very large numbers (millions)+ * - Very small decimals+ * - Wide value ranges+ *+ * ### 4. Chart Variants+ * - Grouped bars+ * - Stacked bars+ *+ * ### 5. Real-world Scenarios+ * - Time series data+ * - Financial data+ * - Traffic analytics+ */+const meta: Meta<BarChartCondensedProps<any>> = {+ title: "Components/Charts/BarChartCondensed",+ component: BarChartCondensed,+ parameters: {+ layout: "centered",+ docs: {+ description: {+ component: `+## Test Suite Overview++This comprehensive test suite validates the BarChartCondensed component across various scenarios:++### Test Coverage Areas++1. **Edge Cases**: Empty data, single point, minimal data+2. **Data Size**: Small (3-5), Medium (10-20), Large (50-100+) datasets+3. **Value Ranges**: Zeros, negatives, extremes (millions to decimals)+4. **Chart Variants**: Grouped and stacked bar configurations+5. **Real-world**: Time series, financial, analytics data++### How to Use This Test Suite++Each story represents a specific test case. Use these to:+- Verify component behavior with different data types+- Check rendering performance with large datasets+- Validate handling of edge cases+- Ensure visual consistency across variations++\`\`\`tsx+// Example: Testing with large dataset+<BarChartCondensed+ data={testData.large100}+ categoryKey="date"+ variant="grouped"+ theme="ocean"+ height={200}+/>+\`\`\`+`,+ },+ },+ },+ tags: ["dev", "autodocs"],+ argTypes: {+ data: {+ description: "Array of data objects for the chart. Same format as BarChart.",+ control: false,+ table: {+ type: { summary: "Array<Record<string, string | number>>" },+ category: "📊 Data Configuration",+ },+ },+ categoryKey: {+ description: "The key in your data object for the X-axis category.",+ control: false,+ table: {+ type: { summary: "string" },+ category: "📊 Data Configuration",+ },+ },+ theme: {+ description: "Color palette for the chart. Ignored when customPalette is provided.",+ control: "select",+ options: ["ocean", "orchid", "emerald", "sunset", "spectrum", "vivid"],+ table: {+ defaultValue: { summary: "ocean" },+ category: "🎨 Visual Styling",+ },+ },+ customPalette: {+ description: "Custom color array. Overrides theme when provided.",+ control: "object",+ table: {+ type: { summary: "string[]" },+ category: "🎨 Visual Styling",+ },+ },+ variant: {+ description: "Bar chart layout: grouped (side-by-side) or stacked.",+ control: "radio",+ options: ["grouped", "stacked"],+ table: {+ defaultValue: { summary: "grouped" },+ category: "🎨 Visual Styling",+ },+ },+ tickVariant: {+ description:+ "X-axis tick label style. Choose between singleLine (horizontal) or angled (-45°).",+ control: "radio",+ options: ["singleLine", "angled"],+ table: {+ defaultValue: { summary: "singleLine" },+ category: "🎨 Visual Styling",+ },+ },+ radius: {+ description: "Corner radius for bars in pixels.",+ control: { type: "number", min: 0, max: 12, step: 1 },+ table: {+ defaultValue: { summary: "4" },+ category: "🎨 Visual Styling",+ },+ },+ grid: {+ description: "Show or hide grid lines.",+ control: "boolean",+ table: {+ defaultValue: { summary: "true" },+ category: "📱 Display Options",+ },+ },+ showYAxis: {+ description: "Show or hide Y-axis.",+ control: "boolean",+ table: {+ defaultValue: { summary: "true" },+ category: "📱 Display Options",+ },+ },+ isAnimationActive: {+ description: "Enable loading animation.",+ control: "boolean",+ table: {+ defaultValue: { summary: "false" },+ category: "🎬 Animation",+ },+ },+ height: {+ description: "Chart height in pixels.",+ control: "number",+ table: {+ defaultValue: { summary: "200" },+ type: { summary: "number" },+ category: "Layout & Sizing",+ },+ },+ width: {+ description: "Chart width in pixels. Defaults to 100% of container.",+ control: "number",+ table: {+ type: { summary: "number" },+ category: "Layout & Sizing",+ },+ },+ className: {+ description: "Custom CSS class for the container.",+ control: "text",+ table: {+ type: { summary: "string" },+ category: "Layout & Sizing",+ },+ },+ },+} satisfies Meta<typeof BarChartCondensed>;++export default meta;+type Story = StoryObj<typeof meta>;++// ============================================================================+// EDGE CASES - Testing component behavior with minimal/unusual data+// ============================================================================++/**+ * ## TEST: Empty Data+ *+ * **Purpose**: Verify component handles empty array gracefully+ * **Expected**: Should render without errors, show empty state or message+ */+export const EdgeCase_EmptyData: Story = {+ args: {+ data: testData.empty as any,+ categoryKey: "month" as any,+ theme: "ocean",+ height: 200,+ },+ render: (args: any) => (+ <Card style={{ width: "500px", padding: "16px" }}>+ <div style={{ marginBottom: "8px", fontSize: "12px", color: "#666" }}>+ <strong>Test:</strong> Empty dataset | <strong>Data points:</strong> 0+ </div>+ <BarChartCondensed {...args} />+ </Card>+ ),+};++/**+ * ## TEST: Single Data Point+ *+ * **Purpose**: Verify rendering with only one data point+ * **Expected**: Should render single bar correctly+ */+export const EdgeCase_SinglePoint: Story = {+ args: {+ data: testData.singlePoint as any,+ categoryKey: "month" as any,+ theme: "ocean",+ height: 200,+ },+ render: (args: any) => (+ <Card style={{ width: "500px", padding: "16px" }}>+ <div style={{ marginBottom: "8px", fontSize: "12px", color: "#666" }}>+ <strong>Test:</strong> Single point | <strong>Data points:</strong> 1+ </div>+ <BarChartCondensed {...args} />+ </Card>+ ),+};++/**+ * ## TEST: Two Data Points+ *+ * **Purpose**: Minimum data for comparison (edge case)+ * **Expected**: Should show two bars for comparison+ */+export const EdgeCase_TwoPoints: Story = {+ args: {+ data: testData.twoPoints as any,+ categoryKey: "month" as any,+ theme: "emerald",+ height: 200,+ },+ render: (args: any) => (+ <Card style={{ width: "500px", padding: "16px" }}>+ <div style={{ marginBottom: "8px", fontSize: "12px", color: "#666" }}>+ <strong>Test:</strong> Two points (minimum comparison) | <strong>Data points:</strong> 2+ </div>+ <BarChartCondensed {...args} />+ </Card>+ ),+};++// ============================================================================+// DATA SIZE TESTS - Testing performance with different dataset sizes+// ============================================================================++/**+ * ## TEST: Small Dataset (3 points)+ *+ * **Purpose**: Verify rendering with minimal but valid data+ * **Expected**: Clean rendering, good spacing+ */+export const DataSize_Small3Points: Story = {+ args: {+ data: testData.threePoints as any,+ categoryKey: "month" as any,+ theme: "ocean",+ height: 200,+ },+ render: (args: any) => (+ <Card style={{ width: "400px", padding: "16px" }}>+ <div style={{ marginBottom: "8px", fontSize: "12px", color: "#666" }}>+ <strong>Test:</strong> Small dataset | <strong>Data points:</strong> 3+ </div>+ <BarChartCondensed {...args} />+ </Card>+ ),+};++/**+ * ## TEST: Small Dataset (5 points, multiple series)+ *+ * **Purpose**: Test small data with multiple data series (grouped)+ * **Expected**: All series visible, good color differentiation+ */+export const DataSize_Small5PointsGrouped: Story = {+ args: {+ data: testData.fivePoints as any,+ categoryKey: "month" as any,+ variant: "grouped",+ theme: "sunset",+ icons,+ height: 200,+ },+ render: (args: any) => (+ <Card style={{ width: "450px", padding: "16px" }}>+ <div style={{ marginBottom: "8px", fontSize: "12px", color: "#666" }}>+ <strong>Test:</strong> Small dataset, 2 series (grouped) | <strong>Data points:</strong> 5+ </div>+ <BarChartCondensed {...args} />+ </Card>+ ),+};++/**+ * ## TEST: Small Dataset (5 points, stacked)+ *+ * **Purpose**: Test small data with multiple data series (stacked)+ * **Expected**: All series stacked properly, good visual hierarchy+ */+export const DataSize_Small5PointsStacked: Story = {+ args: {+ data: testData.fivePoints as any,+ categoryKey: "month" as any,+ variant: "stacked",+ theme: "orchid",+ icons,+ height: 200,+ },+ render: (args: any) => (+ <Card style={{ width: "450px", padding: "16px" }}>+ <div style={{ marginBottom: "8px", fontSize: "12px", color: "#666" }}>+ <strong>Test:</strong> Small dataset, 2 series (stacked) | <strong>Data points:</strong> 5+ </div>+ <BarChartCondensed {...args} />+ </Card>+ ),+};++/**+ * ## TEST: Medium Dataset (12 points, 3 series, grouped)+ *+ * **Purpose**: Standard use case with monthly data (grouped)+ * **Expected**: Clean rendering, all bars visible+ */+export const DataSize_Medium12PointsGrouped: Story = {+ args: {+ data: testData.twelvePoints as any,+ categoryKey: "month" as any,+ variant: "grouped",+ theme: "emerald",+ icons,+ height: 200,+ },+ render: (args: any) => (+ <Card style={{ width: "600px", padding: "16px" }}>+ <div style={{ marginBottom: "8px", fontSize: "12px", color: "#666" }}>+ <strong>Test:</strong> Medium dataset, 3 series (grouped) | <strong>Data points:</strong> 12+ </div>+ <BarChartCondensed {...args} />+ </Card>+ ),+};++/**+ * ## TEST: Medium Dataset (12 points, 3 series, stacked)+ *+ * **Purpose**: Standard use case with monthly data (stacked)+ * **Expected**: Clean rendering, all stacks visible+ */+export const DataSize_Medium12PointsStacked: Story = {+ args: {+ data: testData.twelvePoints as any,+ categoryKey: "month" as any,+ variant: "stacked",+ theme: "vivid",+ icons,+ height: 200,+ },+ render: (args: any) => (+ <Card style={{ width: "600px", padding: "16px" }}>+ <div style={{ marginBottom: "8px", fontSize: "12px", color: "#666" }}>+ <strong>Test:</strong> Medium dataset, 3 series (stacked) | <strong>Data points:</strong> 12+ </div>+ <BarChartCondensed {...args} />+ </Card>+ ),+};++/**+ * ## TEST: Large Dataset (50 points, grouped)+ *+ * **Purpose**: Test performance with larger dataset (grouped)+ * **Expected**: Should handle smoothly, condensed layout+ */+export const DataSize_Large50PointsGrouped: Story = {+ args: {+ data: testData.large50 as any,+ categoryKey: "date" as any,+ variant: "grouped",+ theme: "ocean",+ height: 250,+ },+ render: (args: any) => (+ <Card style={{ width: "700px", padding: "16px" }}>+ <div style={{ marginBottom: "8px", fontSize: "12px", color: "#666" }}>+ <strong>Test:</strong> Large dataset, 3 series (grouped) | <strong>Data points:</strong> 50+ </div>+ <BarChartCondensed {...args} />+ </Card>+ ),+};++/**+ * ## TEST: Large Dataset (100 points, stacked)+ *+ * **Purpose**: Stress test rendering performance (stacked)+ * **Expected**: Chart should remain responsive+ */+export const DataSize_Large100PointsStacked: Story = {+ args: {+ data: testData.large100 as any,+ categoryKey: "date" as any,+ variant: "stacked",+ theme: "spectrum",+ height: 250,+ },+ render: (args: any) => (+ <Card style={{ width: "800px", padding: "16px" }}>+ <div style={{ marginBottom: "8px", fontSize: "12px", color: "#666" }}>+ <strong>⚠️ Stress Test:</strong> Large dataset, 3 series (stacked) |{" "}+ <strong>Data points:</strong> 100+ </div>+ <BarChartCondensed {...args} />+ </Card>+ ),+};++// ============================================================================+// VALUE RANGE TESTS - Testing different value types and ranges+// ============================================================================++/**+ * ## TEST: All Zero Values+ *+ * **Purpose**: Verify behavior when all values are zero+ * **Expected**: Should show bars at baseline+ */+export const ValueRange_AllZeros: Story = {+ args: {+ data: testData.allZeros as any,+ categoryKey: "month" as any,+ theme: "ocean",+ height: 200,+ },+ render: (args: any) => (+ <Card style={{ width: "400px", padding: "16px" }}>+ <div style={{ marginBottom: "8px", fontSize: "12px", color: "#666" }}>+ <strong>Test:</strong> All zero values+ </div>+ <BarChartCondensed {...args} />+ </Card>+ ),+};++/**+ * ## TEST: Mixed Zeros in Series (Grouped)+ *+ * **Purpose**: Test handling of zero values mixed with non-zero (grouped)+ * **Expected**: Should show zero-height bars or hide them appropriately+ */+export const ValueRange_WithZerosGrouped: Story = {+ args: {+ data: testData.withZeros as any,+ categoryKey: "month" as any,+ variant: "grouped",+ theme: "emerald",+ icons,+ height: 200,+ },+ render: (args: any) => (+ <Card style={{ width: "450px", padding: "16px" }}>+ <div style={{ marginBottom: "8px", fontSize: "12px", color: "#666" }}>+ <strong>Test:</strong> Zeros mixed with values (grouped)+ </div>+ <BarChartCondensed {...args} />+ </Card>+ ),+};++/**+ * ## TEST: Negative Values (Grouped)+ *+ * **Purpose**: Verify handling of negative numbers (grouped)+ * **Expected**: Should display bars below zero line correctly+ */+export const ValueRange_NegativeGrouped: Story = {+ args: {+ data: testData.negativeValues as any,+ categoryKey: "month" as any,+ variant: "grouped",+ theme: "sunset",+ height: 200,+ },+ render: (args: any) => (+ <Card style={{ width: "450px", padding: "16px" }}>+ <div style={{ marginBottom: "8px", fontSize: "12px", color: "#666" }}>+ <strong>Test:</strong> Negative values (grouped)+ </div>+ <BarChartCondensed {...args} />+ </Card>+ ),+};++/**+ * ## TEST: Negative Values (Stacked)+ *+ * **Purpose**: Verify handling of negative numbers (stacked)+ * **Expected**: Should stack negative values separately from positive+ */+export const ValueRange_NegativeStacked: Story = {+ args: {+ data: testData.negativeValues as any,+ categoryKey: "month" as any,+ variant: "stacked",+ theme: "orchid",+ height: 200,+ },+ render: (args: any) => (+ <Card style={{ width: "450px", padding: "16px" }}>+ <div style={{ marginBottom: "8px", fontSize: "12px", color: "#666" }}>+ <strong>Test:</strong> Negative values (stacked)+ </div>+ <BarChartCondensed {...args} />+ </Card>+ ),+};++/**+ * ## TEST: Mixed Positive/Negative (Grouped)+ *+ * **Purpose**: Test combination of positive and negative values (grouped)+ * **Expected**: Should show bars crossing zero line+ */+export const ValueRange_MixedGrouped: Story = {+ args: {+ data: testData.mixedValues as any,+ categoryKey: "month" as any,+ variant: "grouped",+ theme: "vivid",+ height: 200,+ },+ render: (args: any) => (+ <Card style={{ width: "450px", padding: "16px" }}>+ <div style={{ marginBottom: "8px", fontSize: "12px", color: "#666" }}>+ <strong>Test:</strong> Mixed positive/negative values (grouped)+ </div>+ <BarChartCondensed {...args} />+ </Card>+ ),+};++/**+ * ## TEST: Mixed Positive/Negative (Stacked)+ *+ * **Purpose**: Test combination of positive and negative values (stacked)+ * **Expected**: Should separate positive and negative stacks+ */+export const ValueRange_MixedStacked: Story = {+ args: {+ data: testData.mixedValues as any,+ categoryKey: "month" as any,+ variant: "stacked",+ theme: "emerald",+ height: 200,+ },+ render: (args: any) => (+ <Card style={{ width: "450px", padding: "16px" }}>+ <div style={{ marginBottom: "8px", fontSize: "12px", color: "#666" }}>+ <strong>Test:</strong> Mixed positive/negative values (stacked)+ </div>+ <BarChartCondensed {...args} />+ </Card>+ ),+};++/**+ * ## TEST: Very Large Numbers (Millions)+ *+ * **Purpose**: Test formatting and display of large numbers+ * **Expected**: Should format with appropriate abbreviations (K, M, B)+ */+export const ValueRange_VeryLarge: Story = {+ args: {+ data: testData.veryLarge as any,+ categoryKey: "month" as any,+ variant: "grouped",+ theme: "spectrum",+ height: 200,+ },+ render: (args: any) => (+ <Card style={{ width: "450px", padding: "16px" }}>+ <div style={{ marginBottom: "8px", fontSize: "12px", color: "#666" }}>+ <strong>Test:</strong> Very large numbers (millions)+ </div>+ <BarChartCondensed {...args} />+ </Card>+ ),+};++/**+ * ## TEST: Very Small Decimals+ *+ * **Purpose**: Test precision handling for small decimal values+ * **Expected**: Should display appropriate decimal precision+ */+export const ValueRange_VerySmall: Story = {+ args: {+ data: testData.verySmall as any,+ categoryKey: "month" as any,+ variant: "grouped",+ theme: "ocean",+ height: 200,+ },+ render: (args: any) => (+ <Card style={{ width: "450px", padding: "16px" }}>+ <div style={{ marginBottom: "8px", fontSize: "12px", color: "#666" }}>+ <strong>Test:</strong> Very small decimal values+ </div>+ <BarChartCondensed {...args} />+ </Card>+ ),+};++/**+ * ## TEST: Wide Value Range+ *+ * **Purpose**: Test scaling when series have vastly different magnitudes+ * **Expected**: Should scale appropriately or show warning+ */+export const ValueRange_WideRange: Story = {+ args: {+ data: testData.wideRange as any,+ categoryKey: "month" as any,+ variant: "grouped",+ theme: "sunset",+ height: 200,+ },+ render: (args: any) => (+ <Card style={{ width: "500px", padding: "16px" }}>+ <div style={{ marginBottom: "8px", fontSize: "12px", color: "#666" }}>+ <strong>Test:</strong> Wide range (1 to 1,000,000)+ </div>+ <BarChartCondensed {...args} />+ </Card>+ ),+};++// ============================================================================+// REAL-WORLD SCENARIO TESTS - Practical use cases+// ============================================================================++/**+ * ## TEST: Daily Time Series (30 days, grouped)+ *+ * **Purpose**: Test typical time-series sales data (grouped)+ * **Expected**: Clean rendering of date-based data+ */+export const RealWorld_DailySalesGrouped: Story = {+ args: {+ data: testData.dailySales as any,+ categoryKey: "date" as any,+ variant: "grouped",+ theme: "ocean",+ icons,+ height: 220,+ },+ render: (args: any) => (+ <Card style={{ width: "700px", padding: "16px" }}>+ <div style={{ marginBottom: "8px", fontSize: "12px", color: "#666" }}>+ <strong>Test:</strong> Daily sales time series (grouped) | <strong>Days:</strong> 30+ </div>+ <BarChartCondensed {...args} />+ </Card>+ ),+};++/**+ * ## TEST: Daily Time Series (30 days, stacked)+ *+ * **Purpose**: Test typical time-series sales data (stacked)+ * **Expected**: Clean rendering of date-based data with stacked bars+ */+export const RealWorld_DailySalesStacked: Story = {+ args: {+ data: testData.dailySales as any,+ categoryKey: "date" as any,+ variant: "stacked",+ theme: "emerald",+ icons,+ height: 220,+ },+ render: (args: any) => (+ <Card style={{ width: "700px", padding: "16px" }}>+ <div style={{ marginBottom: "8px", fontSize: "12px", color: "#666" }}>+ <strong>Test:</strong> Daily sales time series (stacked) | <strong>Days:</strong> 30+ </div>+ <BarChartCondensed {...args} />+ </Card>+ ),+};++/**+ * ## TEST: Quarterly Financial Data (Grouped)+ *+ * **Purpose**: Test financial reporting scenario (grouped)+ * **Expected**: Clear visualization of revenue, profit, costs+ */+export const RealWorld_QuarterlySalesGrouped: Story = {+ args: {+ data: testData.quarterlySales as any,+ categoryKey: "quarter" as any,+ variant: "grouped",+ theme: "sunset",+ icons,+ height: 220,+ },+ render: (args: any) => (+ <Card style={{ width: "600px", padding: "16px" }}>+ <div style={{ marginBottom: "8px", fontSize: "12px", color: "#666" }}>+ <strong>Test:</strong> Quarterly financial data (grouped) | <strong>Quarters:</strong> 5+ </div>+ <BarChartCondensed {...args} />+ </Card>+ ),+};++/**+ * ## TEST: Quarterly Financial Data (Stacked)+ *+ * **Purpose**: Test financial reporting scenario (stacked)+ * **Expected**: Clear visualization showing total and components+ */+export const RealWorld_QuarterlySalesStacked: Story = {+ args: {+ data: testData.quarterlySales as any,+ categoryKey: "quarter" as any,+ variant: "stacked",+ theme: "orchid",+ icons,+ height: 220,+ },+ render: (args: any) => (+ <Card style={{ width: "600px", padding: "16px" }}>+ <div style={{ marginBottom: "8px", fontSize: "12px", color: "#666" }}>+ <strong>Test:</strong> Quarterly financial data (stacked) | <strong>Quarters:</strong> 5+ </div>+ <BarChartCondensed {...args} />+ </Card>+ ),+};++/**+ * ## TEST: Weekly Analytics Traffic (Grouped)+ *+ * **Purpose**: Test typical analytics dashboard data (grouped)+ * **Expected**: Multiple metrics clearly differentiated+ */+export const RealWorld_WeeklyTrafficGrouped: Story = {+ args: {+ data: testData.weeklyTraffic as any,+ categoryKey: "day" as any,+ variant: "grouped",+ theme: "vivid",+ icons,+ height: 220,+ },+ render: (args: any) => (+ <Card style={{ width: "650px", padding: "16px" }}>+ <div style={{ marginBottom: "8px", fontSize: "12px", color: "#666" }}>+ <strong>Test:</strong> Weekly traffic analytics (grouped) | <strong>Metrics:</strong> 3+ </div>+ <BarChartCondensed {...args} />+ </Card>+ ),+};++/**+ * ## TEST: Weekly Analytics Traffic (Stacked)+ *+ * **Purpose**: Test typical analytics dashboard data (stacked)+ * **Expected**: Clear total traffic visualization+ */+export const RealWorld_WeeklyTrafficStacked: Story = {+ args: {+ data: testData.weeklyTraffic as any,+ categoryKey: "day" as any,+ variant: "stacked",+ theme: "spectrum",+ icons,+ height: 220,+ },+ render: (args: any) => (+ <Card style={{ width: "650px", padding: "16px" }}>+ <div style={{ marginBottom: "8px", fontSize: "12px", color: "#666" }}>+ <strong>Test:</strong> Weekly traffic analytics (stacked) | <strong>Metrics:</strong> 3+ </div>+ <BarChartCondensed {...args} />+ </Card>+ ),+};++// ============================================================================+// VARIANT & CONFIGURATION TESTS+// ============================================================================++/**+ * ## TEST: Variant Comparison (Grouped vs Stacked)+ *+ * **Purpose**: Compare grouped and stacked variants side-by-side+ * **Expected**: Visual difference between variants+ */+export const Config_VariantComparison: Story = {+ render: () => (+ <div style={{ display: "flex", flexDirection: "column", gap: "16px" }}>+ <Card style={{ width: "600px", padding: "16px" }}>+ <div style={{ marginBottom: "8px", fontSize: "12px", color: "#666" }}>+ <strong>Variant:</strong> Grouped (bars side-by-side)+ </div>+ <BarChartCondensed+ data={testData.twelvePoints as any}+ categoryKey="month"+ variant="grouped"+ theme="ocean"+ height={150}+ />+ </Card>+ <Card style={{ width: "600px", padding: "16px" }}>+ <div style={{ marginBottom: "8px", fontSize: "12px", color: "#666" }}>+ <strong>Variant:</strong> Stacked (bars on top of each other)+ </div>+ <BarChartCondensed+ data={testData.twelvePoints as any}+ categoryKey="month"+ variant="stacked"+ theme="emerald"+ height={150}+ />+ </Card>+ </div>+ ),+};++/**+ * ## TEST: Radius Variations+ *+ * **Purpose**: Test different corner radius values+ * **Expected**: Clear visual difference in bar rounding+ */+export const Config_RadiusVariations: Story = {+ render: () => (+ <div style={{ display: "flex", flexDirection: "column", gap: "16px" }}>+ <Card style={{ width: "600px", padding: "16px" }}>+ <div style={{ marginBottom: "8px", fontSize: "12px", color: "#666" }}>+ <strong>Radius:</strong> 0px (Sharp corners)+ </div>+ <BarChartCondensed+ data={testData.twelvePoints as any}+ categoryKey="month"+ theme="ocean"+ height={150}+ radius={0}+ />+ </Card>+ <Card style={{ width: "600px", padding: "16px" }}>+ <div style={{ marginBottom: "8px", fontSize: "12px", color: "#666" }}>+ <strong>Radius:</strong> 4px (Default)+ </div>+ <BarChartCondensed+ data={testData.twelvePoints as any}+ categoryKey="month"+ theme="emerald"+ height={150}+ radius={4}+ />+ </Card>+ <Card style={{ width: "600px", padding: "16px" }}>+ <div style={{ marginBottom: "8px", fontSize: "12px", color: "#666" }}>+ <strong>Radius:</strong> 8px (Rounded)+ </div>+ <BarChartCondensed+ data={testData.twelvePoints as any}+ categoryKey="month"+ theme="sunset"+ height={150}+ radius={8}+ />+ </Card>+ </div>+ ),+};++/**+ * ## TEST: Without Y-Axis+ *+ * **Purpose**: Test ultra-compact mode without Y-axis+ * **Expected**: More horizontal space, clean minimal look+ */+export const Config_WithoutYAxis: Story = {+ args: {+ data: testData.twelvePoints as any,+ categoryKey: "month" as any,+ variant: "grouped",+ theme: "vivid",+ showYAxis: false,+ grid: false,+ height: 150,+ },+ render: (args: any) => (+ <Card style={{ width: "500px", padding: "16px" }}>+ <div style={{ marginBottom: "8px", fontSize: "12px", color: "#666" }}>+ <strong>Test:</strong> Y-axis hidden, grid off+ </div>+ <BarChartCondensed {...args} />+ </Card>+ ),+};++/**+ * ## TEST: Custom Color Palette+ *+ * **Purpose**: Verify custom palette override functionality+ * **Expected**: Uses custom colors instead of theme+ */+export const Config_CustomPalette: Story = {+ args: {+ data: testData.twelvePoints as any,+ categoryKey: "month" as any,+ variant: "grouped",+ customPalette: ["#FF6B6B", "#4ECDC4", "#45B7D1"],+ height: 200,+ },+ render: (args: any) => (+ <div>+ <div+ style={{+ marginBottom: "12px",+ padding: "12px",+ background: "#f8f9fa",+ borderRadius: "8px",+ width: "550px",+ }}+ >+ <strong>Custom Palette:</strong>+ <div style={{ display: "flex", gap: "8px", marginTop: "8px" }}>+ {args.customPalette?.map((color: string, index: number) => (+ <div+ key={index}+ style={{ display: "flex", alignItems: "center", gap: "4px", fontSize: "12px" }}+ >+ <div+ style={{+ width: "16px",+ height: "16px",+ backgroundColor: color,+ borderRadius: "3px",+ border: "1px solid #ddd",+ }}+ />+ <span style={{ fontFamily: "monospace" }}>{color}</span>+ </div>+ ))}+ </div>+ </div>+ <Card style={{ width: "550px", padding: "16px" }}>+ <BarChartCondensed {...args} />+ </Card>+ </div>+ ),+};++// ============================================================================+// STRESS & PERFORMANCE TESTS+// ============================================================================++/**+ * ## TEST: Multiple Charts Dashboard+ *+ * **Purpose**: Test rendering multiple charts simultaneously+ * **Expected**: All charts render smoothly without performance issues+ */+export const Stress_MultipleCharts: Story = {+ render: () => (+ <div+ style={{+ display: "grid",+ gridTemplateColumns: "repeat(2, 1fr)",+ gap: "16px",+ width: "900px",+ }}+ >+ <Card style={{ padding: "16px" }}>+ <div style={{ marginBottom: "8px", fontSize: "12px", fontWeight: "600" }}>+ Small Dataset (Grouped)+ </div>+ <BarChartCondensed+ data={testData.fivePoints as any}+ categoryKey="month"+ variant="grouped"+ theme="ocean"+ height={140}+ />+ </Card>+ <Card style={{ padding: "16px" }}>+ <div style={{ marginBottom: "8px", fontSize: "12px", fontWeight: "600" }}>+ Medium Dataset (Stacked)+ </div>+ <BarChartCondensed+ data={testData.twelvePoints as any}+ categoryKey="month"+ variant="stacked"+ theme="emerald"+ height={140}+ />+ </Card>+ <Card style={{ padding: "16px" }}>+ <div style={{ marginBottom: "8px", fontSize: "12px", fontWeight: "600" }}>+ Large Dataset (Grouped)+ </div>+ <BarChartCondensed+ data={testData.large50 as any}+ categoryKey="date"+ variant="grouped"+ theme="sunset"+ height={140}+ />+ </Card>+ <Card style={{ padding: "16px" }}>+ <div style={{ marginBottom: "8px", fontSize: "12px", fontWeight: "600" }}>+ Time Series (Stacked)+ </div>+ <BarChartCondensed+ data={testData.dailySales as any}+ categoryKey="date"+ variant="stacked"+ theme="orchid"+ height={140}+ />+ </Card>+ </div>+ ),+ parameters: {+ docs: {+ description: {+ story:+ "Stress test with 4 charts rendering simultaneously with varying dataset sizes and variants.",+ },+ },+ },+};++// Test Data for Long Labels+const longLabelData = [+ { category: "Q1 2024 January Total Revenue and Expenses", sales: 186, expenses: 80, profit: 106 },+ {+ category: "Q1 2024 February Marketing Campaign Results",+ sales: 305,+ expenses: 200,+ profit: 105,+ },+ { category: "Q1 2024 March Product Launch Performance", sales: 237, expenses: 120, profit: 117 },+ { category: "Q2 2024 April Customer Acquisition Metrics", sales: 273, expenses: 190, profit: 83 },+ { category: "Q2 2024 May Operational Efficiency Report", sales: 209, expenses: 130, profit: 79 },+ {+ category: "Q2 2024 June Strategic Initiative Outcomes",+ sales: 314,+ expenses: 140,+ profit: 174,+ },+ { category: "Q3 2024 July Market Expansion Analysis", sales: 350, expenses: 180, profit: 170 },+ {+ category: "Q3 2024 August Technology Investment Returns",+ sales: 280,+ expenses: 160,+ profit: 120,+ },+ { category: "Q3 2024 September Partnership Performance", sales: 320, expenses: 170, profit: 150 },+ { category: "Q4 2024 October Year-End Projections", sales: 290, expenses: 150, profit: 140 },+ { category: "Q4 2024 November Holiday Season Preview", sales: 340, expenses: 180, profit: 160 },+ { category: "Q4 2024 December Annual Summary Report", sales: 420, expenses: 220, profit: 200 },+];++// Tick Variant Stories+export const TickVariantSingleLine: Story = {+ render: () => (+ <Card style={{ padding: "24px", width: "900px", maxWidth: "900px" }}>+ <div style={{ marginBottom: "16px", fontSize: "16px", fontWeight: "600" }}>+ Single Line Tick Variant+ </div>+ <div style={{ marginBottom: "8px", fontSize: "13px", color: "#666" }}>+ Standard horizontal labels with automatic collision detection+ </div>+ <BarChartCondensed+ data={longLabelData as any}+ categoryKey="category"+ variant="grouped"+ tickVariant="singleLine"+ theme="ocean"+ height={200}+ />+ </Card>+ ),+ parameters: {+ docs: {+ description: {+ story:+ "Single line tick variant with standard horizontal labels. Automatically handles collision detection.",+ },+ },+ },+};++export const TickVariantAngled: Story = {+ render: () => (+ <Card style={{ padding: "24px", width: "900px", maxWidth: "900px" }}>+ <div style={{ marginBottom: "16px", fontSize: "16px", fontWeight: "600" }}>+ Angled Tick Variant+ </div>+ <div style={{ marginBottom: "8px", fontSize: "13px", color: "#666" }}>+ -45° rotation perfect for long labels that would overlap horizontally+ </div>+ <BarChartCondensed+ data={longLabelData as any}+ categoryKey="category"+ variant="grouped"+ tickVariant="angled"+ theme="emerald"+ height={280}+ />+ </Card>+ ),+ parameters: {+ docs: {+ description: {+ story:+ "Angled tick variant with -45° rotation. Perfect for long labels that would overlap horizontally.",+ },+ },+ },+};++// Dense Data with Tick Variants+const denseData = Array.from({ length: 30 }, (_, i) => ({+ day: `Day ${i + 1}`,+ revenue: Math.floor(Math.random() * 500) + 100,+ costs: Math.floor(Math.random() * 300) + 50,+}));++export const TickVariantComparisonDenseData: Story = {+ render: () => (+ <div style={{ display: "grid", gridTemplateColumns: "1fr", gap: "24px", maxWidth: "1100px" }}>+ <Card style={{ padding: "24px" }}>+ <div style={{ marginBottom: "16px", fontSize: "16px", fontWeight: "600" }}>+ Single Line Variant (Dense Data - 30 Points, Grouped)+ </div>+ <div style={{ marginBottom: "8px", fontSize: "13px", color: "#666" }}>+ Recharts automatically hides overlapping labels+ </div>+ <BarChartCondensed+ data={denseData as any}+ categoryKey="day"+ variant="grouped"+ tickVariant="singleLine"+ theme="ocean"+ height={200}+ />+ </Card>+ <Card style={{ padding: "24px" }}>+ <div style={{ marginBottom: "16px", fontSize: "16px", fontWeight: "600" }}>+ Angled Variant (Dense Data - 30 Points, Stacked)+ </div>+ <div style={{ marginBottom: "8px", fontSize: "13px", color: "#666" }}>+ Shows more labels with angled orientation+ </div>+ <BarChartCondensed+ data={denseData as any}+ categoryKey="day"+ variant="stacked"+ tickVariant="angled"+ theme="emerald"+ height={280}+ />+ </Card>+ </div>+ ),+ parameters: {+ docs: {+ description: {+ story:+ "Comparison of tick variants (singleLine and angled) with dense data (30 data points). Shows how each variant handles label collision with Recharts' built-in collision detection.",+ },+ },+ },+};diff --git a/js/packages/react-ui/src/components/Charts/LineChartCondensed/LineChartCondensed.tsx b/js/packages/react-ui/src/components/Charts/LineChartCondensed/LineChartCondensed.tsxnew file mode 100644index 000000000..d6480a88e--- /dev/null+++ b/js/packages/react-ui/src/components/Charts/LineChartCondensed/LineChartCondensed.tsx@@ -0,0 +1,207 @@+import clsx from "clsx";+import React, { useMemo, useRef, useState } from "react";+import { Line, LineChart as RechartsLineChart, XAxis, YAxis } from "recharts";+import { useId } from "../../../polyfills";+import { ChartConfig, ChartContainer, ChartTooltip } from "../Charts";+import { X_AXIS_PADDING } from "../constants";+import { SideBarChartData, SideBarTooltipProvider } from "../context/SideBarTooltipContext";+import {+ useAutoAngleCalculation,+ useMaxLabelWidth,+ useTransformedKeys,+ useYAxisLabelWidth,+} from "../hooks";+import { LineChartData, LineChartVariant } from "../LineChart/types";+import {+ ActiveDot,+ cartesianGrid,+ CondensedXAxisTick,+ CondensedXAxisTickVariant,+ CustomTooltipContent,+ YAxisTick,+} from "../shared";+import { LabelTooltipProvider } from "../shared/LabelTooltip/LabelTooltip";+import { get2dChartConfig, getDataKeys } from "../utils/dataUtils";+import { PaletteName, useChartPalette } from "../utils/PalletUtils";++export interface LineChartCondensedProps<T extends LineChartData> {+ data: T;+ categoryKey: keyof T[number];+ theme?: PaletteName;+ customPalette?: string[];+ variant?: LineChartVariant;+ tickVariant?: CondensedXAxisTickVariant;+ grid?: boolean;+ icons?: Partial<Record<keyof T[number], React.ComponentType>>;+ isAnimationActive?: boolean;+ showYAxis?: boolean;+ className?: string;+ height?: number;+ width?: number;+ strokeWidth?: number;+}++const CHART_HEIGHT = 200;+const CHART_CONTAINER_BOTTOM_MARGIN = 10;++const LineChartCondensedComponent = <T extends LineChartData>({+ data,+ categoryKey,+ theme = "ocean",+ customPalette,+ variant = "natural",+ tickVariant = "singleLine",+ grid = true,+ icons = {},+ isAnimationActive = false,+ showYAxis = true,+ className,+ height = CHART_HEIGHT,+ width,+ strokeWidth = 2,+}: LineChartCondensedProps<T>) => {+ const dataKeys = useMemo(() => {+ return getDataKeys(data, categoryKey as string);+ }, [data, categoryKey]);++ const { yAxisWidth, setLabelWidth } = useYAxisLabelWidth(data, dataKeys);++ const maxLabelWidth = useMaxLabelWidth(data, categoryKey as string);++ const { angle: calculatedAngle, height: xAxisHeight } = useAutoAngleCalculation(+ maxLabelWidth,+ yAxisWidth,+ tickVariant === "angled",+ showYAxis,+ );++ const effectiveHeight = useMemo(() => {+ if (tickVariant === "angled") {+ return xAxisHeight + height;+ }+ return height;+ }, [height, xAxisHeight]);++ const transformedKeys = useTransformedKeys(dataKeys);++ const colors = useChartPalette({+ chartThemeName: theme,+ customPalette,+ themePaletteName: "lineChartPalette",+ dataLength: dataKeys.length,+ });++ const chartConfig: ChartConfig = useMemo(() => {+ return get2dChartConfig(dataKeys, colors, transformedKeys, undefined, icons);+ }, [dataKeys, icons, colors, transformedKeys]);++ const id = useId();++ const chartMargin = useMemo(+ () => ({+ top: 10,+ right: 10,+ bottom: CHART_CONTAINER_BOTTOM_MARGIN,+ left: showYAxis ? 10 : 0,+ }),+ [showYAxis],+ );++ const containerRef = useRef<HTMLDivElement>(null);+ const [isSideBarTooltipOpen, setIsSideBarTooltipOpen] = useState(false);+ const [sideBarTooltipData, setSideBarTooltipData] = useState<SideBarChartData>({+ title: "",+ values: [],+ });++ return (+ <LabelTooltipProvider>+ <SideBarTooltipProvider+ isSideBarTooltipOpen={isSideBarTooltipOpen}+ setIsSideBarTooltipOpen={setIsSideBarTooltipOpen}+ data={sideBarTooltipData}+ setData={setSideBarTooltipData}+ >+ <div+ ref={containerRef}+ className={clsx("crayon-line-chart-condensed", className)}+ style={{+ width: width ? `${width}px` : "100%",+ height: `${effectiveHeight}px`,+ }}+ >+ <ChartContainer+ config={chartConfig}+ style={{ width: "100%", height: "100%" }}+ rechartsProps={{+ width: "100%",+ height: "100%",+ }}+ >+ <RechartsLineChart+ accessibilityLayer+ key={`line-chart-condensed-${id}`}+ data={data}+ margin={chartMargin}+ >+ {grid && cartesianGrid()}++ <XAxis+ dataKey={categoryKey as string}+ tickLine={false}+ axisLine={false}+ textAnchor={tickVariant === "angled" ? "end" : "middle"}+ interval="preserveStartEnd"+ minTickGap={5}+ height={xAxisHeight}+ tick={<CondensedXAxisTick />}+ angle={calculatedAngle}+ orientation="bottom"+ padding={{+ left: X_AXIS_PADDING,+ right: X_AXIS_PADDING,+ }}+ />++ {showYAxis && (+ <YAxis+ tickLine={false}+ axisLine={false}+ tick={<YAxisTick setLabelWidth={setLabelWidth} />}+ width={yAxisWidth}+ />+ )}++ <ChartTooltip+ content={<CustomTooltipContent parentRef={containerRef} />}+ offset={10}+ />++ {dataKeys.map((key) => {+ const transformedKey = transformedKeys[key];+ const color = `var(--color-${transformedKey})`;+ return (+ <Line+ key={`line-${key}`}+ dataKey={key}+ type={variant}+ stroke={color}+ strokeWidth={strokeWidth}+ dot={false}+ activeDot={<ActiveDot key={`active-dot-${key}-${id}`} />}+ isAnimationActive={isAnimationActive}+ />+ );+ })}+ </RechartsLineChart>+ </ChartContainer>+ </div>+ </SideBarTooltipProvider>+ </LabelTooltipProvider>+ );+};++// Added React.memo for performance optimization to avoid unnecessary re-renders+export const LineChartCondensed = React.memo(+ LineChartCondensedComponent,+) as typeof LineChartCondensedComponent;diff --git a/js/packages/react-ui/src/components/Charts/LineChartCondensed/dependencies.ts b/js/packages/react-ui/src/components/Charts/LineChartCondensed/dependencies.tsnew file mode 100644index 000000000..815367b8c--- /dev/null+++ b/js/packages/react-ui/src/components/Charts/LineChartCondensed/dependencies.ts@@ -0,0 +1,2 @@+const dependencies = ["LineChartCondensed"];+export default dependencies;diff --git a/js/packages/react-ui/src/components/Charts/LineChartCondensed/index.ts b/js/packages/react-ui/src/components/Charts/LineChartCondensed/index.tsnew file mode 100644index 000000000..767111dfa--- /dev/null+++ b/js/packages/react-ui/src/components/Charts/LineChartCondensed/index.ts@@ -0,0 +1,2 @@+export * from "../LineChart/types";+export * from "./LineChartCondensed";diff --git a/js/packages/react-ui/src/components/Charts/LineChartCondensed/lineChartCondensed.scss b/js/packages/react-ui/src/components/Charts/LineChartCondensed/lineChartCondensed.scssnew file mode 100644index 000000000..df4381bc1--- /dev/null+++ b/js/packages/react-ui/src/components/Charts/LineChartCondensed/lineChartCondensed.scss@@ -0,0 +1,7 @@+@use "../../../cssUtils" as cssUtils;++.crayon-line-chart-condensed {+ display: flex;+ flex-direction: column;+ position: relative;+}diff --git a/js/packages/react-ui/src/components/Charts/LineChartCondensed/stories/lineChartCondensed.stories.tsx b/js/packages/react-ui/src/components/Charts/LineChartCondensed/stories/lineChartCondensed.stories.tsxnew file mode 100644index 000000000..4e6ed25e8--- /dev/null+++ b/js/packages/react-ui/src/components/Charts/LineChartCondensed/stories/lineChartCondensed.stories.tsx@@ -0,0 +1,1348 @@+import type { Meta, StoryObj } from "@storybook/react";+import { Calendar, Globe, Laptop, Monitor, Smartphone, TabletSmartphone } from "lucide-react";+import { Card } from "../../../Card";+import { LineChartCondensed, LineChartCondensedProps } from "../LineChartCondensed";++// Test Data Generators+const generateLargeDataset = (points: number) => {+ return Array.from({ length: points }, (_, i) => ({+ date: `Day ${i + 1}`,+ value1: Math.floor(Math.random() * 1000) + 100,+ value2: Math.floor(Math.random() * 800) + 50,+ value3: Math.floor(Math.random() * 600) + 30,+ }));+};++const generateTimeSeriesData = (days: number) => {+ const startDate = new Date("2024-01-01");+ return Array.from({ length: days }, (_, i) => {+ const date = new Date(startDate);+ date.setDate(date.getDate() + i);+ return {+ date: date.toISOString().split("T")[0],+ sales: Math.floor(Math.random() * 5000) + 1000,+ orders: Math.floor(Math.random() * 200) + 50,+ };+ });+};++// Test Data Variations+const testData = {+ // Edge Cases+ empty: [],+ singlePoint: [{ month: "Jan", value: 100 }],+ twoPoints: [+ { month: "Jan", value: 100 },+ { month: "Feb", value: 200 },+ ],++ // Small Datasets+ threePoints: [+ { month: "Jan", value: 100 },+ { month: "Feb", value: 150 },+ { month: "Mar", value: 120 },+ ],+ fivePoints: [+ { month: "Jan", desktop: 150, mobile: 90 },+ { month: "Feb", desktop: 280, mobile: 180 },+ { month: "Mar", desktop: 220, mobile: 140 },+ { month: "Apr", desktop: 180, mobile: 160 },+ { month: "May", desktop: 250, mobile: 120 },+ ],++ // Medium Datasets+ twelvePoints: [+ { month: "Jan", desktop: 150, mobile: 90, tablet: 120 },+ { month: "Feb", desktop: 280, mobile: 180, tablet: 140 },+ { month: "Mar", desktop: 220, mobile: 140, tablet: 160 },+ { month: "Apr", desktop: 180, mobile: 160, tablet: 180 },+ { month: "May", desktop: 250, mobile: 120, tablet: 140 },+ { month: "Jun", desktop: 300, mobile: 180, tablet: 160 },+ { month: "Jul", desktop: 320, mobile: 200, tablet: 180 },+ { month: "Aug", desktop: 290, mobile: 170, tablet: 150 },+ { month: "Sep", desktop: 310, mobile: 190, tablet: 170 },+ { month: "Oct", desktop: 280, mobile: 160, tablet: 140 },+ { month: "Nov", desktop: 350, mobile: 210, tablet: 190 },+ { month: "Dec", desktop: 400, mobile: 250, tablet: 220 },+ ],++ // Large Datasets+ large50: generateLargeDataset(50),+ large100: generateLargeDataset(100),+ large500: generateLargeDataset(500),++ // Special Value Cases+ allZeros: [+ { month: "Jan", value: 0 },+ { month: "Feb", value: 0 },+ { month: "Mar", value: 0 },+ { month: "Apr", value: 0 },+ ],+ withZeros: [+ { month: "Jan", desktop: 100, mobile: 0 },+ { month: "Feb", desktop: 0, mobile: 50 },+ { month: "Mar", desktop: 150, mobile: 0 },+ { month: "Apr", desktop: 0, mobile: 100 },+ ],+ negativeValues: [+ { month: "Jan", profit: -50, loss: -30 },+ { month: "Feb", profit: 100, loss: -20 },+ { month: "Mar", profit: -30, loss: -40 },+ { month: "Apr", profit: 150, loss: -10 },+ ],+ mixedValues: [+ { month: "Jan", value1: -100, value2: 200 },+ { month: "Feb", value1: 150, value2: -50 },+ { month: "Mar", value1: -75, value2: 300 },+ { month: "Apr", value1: 200, value2: -100 },+ ],++ // Extreme Values+ veryLarge: [+ { month: "Jan", value: 1000000, secondary: 500000 },+ { month: "Feb", value: 1500000, secondary: 750000 },+ { month: "Mar", value: 1200000, secondary: 600000 },+ ],+ verySmall: [+ { month: "Jan", value: 0.001, secondary: 0.002 },+ { month: "Feb", value: 0.003, secondary: 0.0015 },+ { month: "Mar", value: 0.002, secondary: 0.0025 },+ ],+ wideRange: [+ { month: "Jan", small: 1, large: 1000000 },+ { month: "Feb", small: 2, large: 1500000 },+ { month: "Mar", small: 1.5, large: 1200000 },+ ],++ // Pattern Tests+ linear: Array.from({ length: 10 }, (_, i) => ({+ x: `pat${i + 1}`,+ y: i * 10,+ })),+ exponential: Array.from({ length: 10 }, (_, i) => ({+ x: `pat${i + 1}`,+ y: Math.pow(2, i),+ })),+ sinusoidal: Array.from({ length: 20 }, (_, i) => ({+ x: `pat${i + 1}`,+ y: Math.sin(i / 3) * 100 + 150,+ })),+ constant: Array.from({ length: 8 }, (_, i) => ({+ x: `pat${i + 1}`,+ y: 100,+ })),+ volatile: Array.from({ length: 15 }, (_, i) => ({+ x: `pat${i + 1}`,+ spike: i % 3 === 0 ? 500 : 50,+ normal: 100 + Math.random() * 20,+ })),++ // Real-world Scenarios+ dailySales: generateTimeSeriesData(30),+ quarterlySales: [+ { quarter: "Q1 2023", revenue: 12000, profit: 4000, costs: 8000 },+ { quarter: "Q2 2023", revenue: 15000, profit: 5500, costs: 9500 },+ { quarter: "Q3 2023", revenue: 18000, profit: 7000, costs: 11000 },+ { quarter: "Q4 2023", revenue: 20000, profit: 7000, costs: 13000 },+ { quarter: "Q1 2024", revenue: 22000, profit: 8000, costs: 14000 },+ ],+ weeklyTraffic: [+ { day: "Mon", visits: 2200, conversions: 180, bounces: 800 },+ { day: "Tue", visits: 2500, conversions: 220, bounces: 900 },+ { day: "Wed", visits: 2300, conversions: 190, bounces: 850 },+ { day: "Thu", visits: 2800, conversions: 250, bounces: 1000 },+ { day: "Fri", visits: 3200, conversions: 280, bounces: 1100 },+ { day: "Sat", visits: 1800, conversions: 120, bounces: 600 },+ { day: "Sun", visits: 1500, conversions: 100, bounces: 500 },+ ],+};++const icons = {+ desktop: Monitor,+ mobile: TabletSmartphone,+ tablet: Calendar,+ revenue: Globe,+ profit: Smartphone,+ visits: Monitor,+ conversions: Laptop,+ value: Monitor,+ value1: Monitor,+ value2: TabletSmartphone,+ value3: Calendar,+ small: Smartphone,+ large: Globe,+ sales: Globe,+ orders: Laptop,+ bounces: Calendar,+ costs: Smartphone,+} as const;++/**+ * # LineChartCondensed Test Suite+ *+ * This file contains comprehensive test cases for the LineChartCondensed component,+ * covering edge cases, data variations, and stress testing scenarios.+ *+ * ## Test Categories+ *+ * ### 1. Edge Cases+ * - Empty data+ * - Single data point+ * - Two data points (minimum for line)+ *+ * ### 2. Data Size Variations+ * - Small datasets (3-5 points)+ * - Medium datasets (10-20 points)+ * - Large datasets (50-500 points)+ *+ * ### 3. Value Ranges+ * - Zero values+ * - Negative values+ * - Mixed positive/negative+ * - Very large numbers (millions)+ * - Very small decimals+ * - Wide value ranges+ *+ * ### 4. Data Patterns+ * - Linear progression+ * - Exponential growth+ * - Sinusoidal waves+ * - Constant values+ * - Volatile/spike patterns+ *+ * ### 5. Real-world Scenarios+ * - Time series data+ * - Financial data+ * - Traffic analytics+ */+const meta: Meta<LineChartCondensedProps<any>> = {+ title: "Components/Charts/LineChartCondensed",+ component: LineChartCondensed,+ parameters: {+ layout: "centered",+ docs: {+ description: {+ component: `+## Test Suite Overview++This comprehensive test suite validates the LineChartCondensed component across various scenarios:++### Test Coverage Areas++1. **Edge Cases**: Empty data, single point, minimal data+2. **Data Size**: Small (3-5), Medium (10-20), Large (50-500+) datasets+3. **Value Ranges**: Zeros, negatives, extremes (millions to decimals)+4. **Data Patterns**: Linear, exponential, sinusoidal, constant, volatile+5. **Real-world**: Time series, financial, analytics data++### How to Use This Test Suite++Each story represents a specific test case. Use these to:+- Verify component behavior with different data types+- Check rendering performance with large datasets+- Validate handling of edge cases+- Ensure visual consistency across variations++\`\`\`tsx+// Example: Testing with large dataset+<LineChartCondensed+ data={testData.large100}+ categoryKey="date"+ theme="ocean"+ height={200}+/>+\`\`\`+`,+ },+ },+ },+ tags: ["dev", "autodocs"],+ argTypes: {+ data: {+ description: "Array of data objects for the chart. Same format as LineChart.",+ control: false,+ table: {+ type: { summary: "Array<Record<string, string | number>>" },+ category: "📊 Data Configuration",+ },+ },+ categoryKey: {+ description: "The key in your data object for the X-axis category.",+ control: false,+ table: {+ type: { summary: "string" },+ category: "📊 Data Configuration",+ },+ },+ theme: {+ description: "Color palette for the chart. Ignored when customPalette is provided.",+ control: "select",+ options: ["ocean", "orchid", "emerald", "sunset", "spectrum", "vivid"],+ table: {+ defaultValue: { summary: "ocean" },+ category: "🎨 Visual Styling",+ },+ },+ customPalette: {+ description: "Custom color array. Overrides theme when provided.",+ control: "object",+ table: {+ type: { summary: "string[]" },+ category: "🎨 Visual Styling",+ },+ },+ variant: {+ description: "Line interpolation method.",+ control: "radio",+ options: ["linear", "natural", "step"],+ table: {+ defaultValue: { summary: "natural" },+ category: "🎨 Visual Styling",+ },+ },+ tickVariant: {+ description:+ "X-axis tick label style. Choose between singleLine (horizontal) or angled (-45°).",+ control: "radio",+ options: ["singleLine", "angled"],+ table: {+ defaultValue: { summary: "singleLine" },+ category: "🎨 Visual Styling",+ },+ },+ strokeWidth: {+ description: "Line thickness in pixels.",+ control: { type: "number", min: 1, max: 10, step: 1 },+ table: {+ defaultValue: { summary: "2" },+ category: "🎨 Visual Styling",+ },+ },+ grid: {+ description: "Show or hide grid lines.",+ control: "boolean",+ table: {+ defaultValue: { summary: "true" },+ category: "📱 Display Options",+ },+ },+ showYAxis: {+ description: "Show or hide Y-axis.",+ control: "boolean",+ table: {+ defaultValue: { summary: "true" },+ category: "📱 Display Options",+ },+ },+ isAnimationActive: {+ description: "Enable loading animation.",+ control: "boolean",+ table: {+ defaultValue: { summary: "false" },+ category: "🎬 Animation",+ },+ },+ height: {+ description: "Chart height in pixels.",+ control: "number",+ table: {+ defaultValue: { summary: "200" },+ type: { summary: "number" },+ category: "Layout & Sizing",+ },+ },+ width: {+ description: "Chart width in pixels. Defaults to 100% of container.",+ control: "number",+ table: {+ type: { summary: "number" },+ category: "Layout & Sizing",+ },+ },+ className: {+ description: "Custom CSS class for the container.",+ control: "text",+ table: {+ type: { summary: "string" },+ category: "Layout & Sizing",+ },+ },+ },+} satisfies Meta<typeof LineChartCondensed>;++export default meta;+type Story = StoryObj<typeof meta>;++// ============================================================================+// EDGE CASES - Testing component behavior with minimal/unusual data+// ============================================================================++/**+ * ## TEST: Empty Data+ *+ * **Purpose**: Verify component handles empty array gracefully+ * **Expected**: Should render without errors, show empty state or message+ */+export const EdgeCase_EmptyData: Story = {+ args: {+ data: testData.empty as any,+ categoryKey: "month" as any,+ theme: "ocean",+ height: 200,+ },+ render: (args: any) => (+ <Card style={{ width: "500px", padding: "16px" }}>+ <div style={{ marginBottom: "8px", fontSize: "12px", color: "#666" }}>+ <strong>Test:</strong> Empty dataset | <strong>Data points:</strong> 0+ </div>+ <LineChartCondensed {...args} />+ </Card>+ ),+};++/**+ * ## TEST: Single Data Point+ *+ * **Purpose**: Verify rendering with only one data point+ * **Expected**: Should render single point, may not show line+ */+export const EdgeCase_SinglePoint: Story = {+ args: {+ data: testData.singlePoint as any,+ categoryKey: "month" as any,+ theme: "ocean",+ height: 200,+ },+ render: (args: any) => (+ <Card style={{ width: "500px", padding: "16px" }}>+ <div style={{ marginBottom: "8px", fontSize: "12px", color: "#666" }}>+ <strong>Test:</strong> Single point | <strong>Data points:</strong> 1+ </div>+ <LineChartCondensed {...args} />+ </Card>+ ),+};++/**+ * ## TEST: Two Data Points+ *+ * **Purpose**: Minimum data to show a line (edge case)+ * **Expected**: Should show basic line between two points+ */+export const EdgeCase_TwoPoints: Story = {+ args: {+ data: testData.twoPoints as any,+ categoryKey: "month" as any,+ theme: "emerald",+ height: 200,+ },+ render: (args: any) => (+ <Card style={{ width: "500px", padding: "16px" }}>+ <div style={{ marginBottom: "8px", fontSize: "12px", color: "#666" }}>+ <strong>Test:</strong> Two points (minimum line) | <strong>Data points:</strong> 2+ </div>+ <LineChartCondensed {...args} />+ </Card>+ ),+};++// ============================================================================+// DATA SIZE TESTS - Testing performance with different dataset sizes+// ============================================================================++/**+ * ## TEST: Small Dataset (3 points)+ *+ * **Purpose**: Verify rendering with minimal but valid data+ * **Expected**: Clean rendering, good spacing+ */+export const DataSize_Small3Points: Story = {+ args: {+ data: testData.threePoints as any,+ categoryKey: "month" as any,+ theme: "ocean",+ height: 200,+ },+ render: (args: any) => (+ <Card style={{ width: "400px", padding: "16px" }}>+ <div style={{ marginBottom: "8px", fontSize: "12px", color: "#666" }}>+ <strong>Test:</strong> Small dataset | <strong>Data points:</strong> 3+ </div>+ <LineChartCondensed {...args} />+ </Card>+ ),+};++/**+ * ## TEST: Small Dataset (5 points, multiple series)+ *+ * **Purpose**: Test small data with multiple data series+ * **Expected**: All series visible, good color differentiation+ */+export const DataSize_Small5Points: Story = {+ args: {+ data: testData.fivePoints as any,+ categoryKey: "month" as any,+ theme: "sunset",+ icons,+ height: 200,+ },+ render: (args: any) => (+ <Card style={{ width: "450px", padding: "16px" }}>+ <div style={{ marginBottom: "8px", fontSize: "12px", color: "#666" }}>+ <strong>Test:</strong> Small dataset, 2 series | <strong>Data points:</strong> 5+ </div>+ <LineChartCondensed {...args} />+ </Card>+ ),+};++/**+ * ## TEST: Medium Dataset (12 points, 3 series)+ *+ * **Purpose**: Standard use case with monthly data+ * **Expected**: Clean rendering, all points visible+ */+export const DataSize_Medium12Points: Story = {+ args: {+ data: testData.twelvePoints as any,+ categoryKey: "month" as any,+ theme: "orchid",+ icons,+ height: 200,+ },+ render: (args: any) => (+ <Card style={{ width: "600px", padding: "16px" }}>+ <div style={{ marginBottom: "8px", fontSize: "12px", color: "#666" }}>+ <strong>Test:</strong> Medium dataset, 3 series | <strong>Data points:</strong> 12+ </div>+ <LineChartCondensed {...args} />+ </Card>+ ),+};++/**+ * ## TEST: Large Dataset (50 points)+ *+ * **Purpose**: Test performance with larger dataset+ * **Expected**: Should handle smoothly, may need scrolling or compression+ */+export const DataSize_Large50Points: Story = {+ args: {+ data: testData.large50 as any,+ categoryKey: "date" as any,+ theme: "emerald",+ height: 250,+ },+ render: (args: any) => (+ <Card style={{ width: "700px", padding: "16px" }}>+ <div style={{ marginBottom: "8px", fontSize: "12px", color: "#666" }}>+ <strong>Test:</strong> Large dataset, 3 series | <strong>Data points:</strong> 50+ </div>+ <LineChartCondensed {...args} />+ </Card>+ ),+};++/**+ * ## TEST: Large Dataset (100 points)+ *+ * **Purpose**: Stress test rendering performance+ * **Expected**: Chart should remain responsive+ */+export const DataSize_Large100Points: Story = {+ args: {+ data: testData.large100 as any,+ categoryKey: "date" as any,+ theme: "vivid",+ height: 250,+ },+ render: (args: any) => (+ <Card style={{ width: "800px", padding: "16px" }}>+ <div style={{ marginBottom: "8px", fontSize: "12px", color: "#666" }}>+ <strong>Test:</strong> Large dataset, 3 series | <strong>Data points:</strong> 100+ </div>+ <LineChartCondensed {...args} />+ </Card>+ ),+};++/**+ * ## TEST: Very Large Dataset (500 points)+ *+ * **Purpose**: Maximum stress test for performance+ * **Expected**: Should handle without crashing, check render time+ */+export const DataSize_VeryLarge500Points: Story = {+ args: {+ data: testData.large500 as any,+ categoryKey: "date" as any,+ theme: "spectrum",+ height: 300,+ showYAxis: true,+ },+ render: (args: any) => (+ <Card style={{ width: "1000px", padding: "16px" }}>+ <div style={{ marginBottom: "8px", fontSize: "12px", color: "#666" }}>+ <strong>⚠️ Stress Test:</strong> Very large dataset | <strong>Data points:</strong> 500+ </div>+ <LineChartCondensed {...args} />+ </Card>+ ),+};++// ============================================================================+// VALUE RANGE TESTS - Testing different value types and ranges+// ============================================================================++/**+ * ## TEST: All Zero Values+ *+ * **Purpose**: Verify behavior when all values are zero+ * **Expected**: Should show flat line at zero+ */+export const ValueRange_AllZeros: Story = {+ args: {+ data: testData.allZeros as any,+ categoryKey: "month" as any,+ theme: "ocean",+ height: 200,+ },+ render: (args: any) => (+ <Card style={{ width: "400px", padding: "16px" }}>+ <div style={{ marginBottom: "8px", fontSize: "12px", color: "#666" }}>+ <strong>Test:</strong> All zero values+ </div>+ <LineChartCondensed {...args} />+ </Card>+ ),+};++/**+ * ## TEST: Mixed Zeros in Series+ *+ * **Purpose**: Test handling of zero values mixed with non-zero+ * **Expected**: Should handle gaps/zeros gracefully+ */+export const ValueRange_WithZeros: Story = {+ args: {+ data: testData.withZeros as any,+ categoryKey: "month" as any,+ theme: "emerald",+ icons,+ height: 200,+ },+ render: (args: any) => (+ <Card style={{ width: "450px", padding: "16px" }}>+ <div style={{ marginBottom: "8px", fontSize: "12px", color: "#666" }}>+ <strong>Test:</strong> Zeros mixed with values+ </div>+ <LineChartCondensed {...args} />+ </Card>+ ),+};++/**+ * ## TEST: Negative Values+ *+ * **Purpose**: Verify handling of negative numbers+ * **Expected**: Should display below zero line correctly+ */+export const ValueRange_Negative: Story = {+ args: {+ data: testData.negativeValues as any,+ categoryKey: "month" as any,+ theme: "sunset",+ height: 200,+ },+ render: (args: any) => (+ <Card style={{ width: "450px", padding: "16px" }}>+ <div style={{ marginBottom: "8px", fontSize: "12px", color: "#666" }}>+ <strong>Test:</strong> Negative values+ </div>+ <LineChartCondensed {...args} />+ </Card>+ ),+};++/**+ * ## TEST: Mixed Positive/Negative+ *+ * **Purpose**: Test combination of positive and negative values+ * **Expected**: Should show crossing zero line+ */+export const ValueRange_Mixed: Story = {+ args: {+ data: testData.mixedValues as any,+ categoryKey: "month" as any,+ theme: "orchid",+ height: 200,+ },+ render: (args: any) => (+ <Card style={{ width: "450px", padding: "16px" }}>+ <div style={{ marginBottom: "8px", fontSize: "12px", color: "#666" }}>+ <strong>Test:</strong> Mixed positive/negative values+ </div>+ <LineChartCondensed {...args} />+ </Card>+ ),+};++/**+ * ## TEST: Very Large Numbers (Millions)+ *+ * **Purpose**: Test formatting and display of large numbers+ * **Expected**: Should format with appropriate abbreviations (K, M, B)+ */+export const ValueRange_VeryLarge: Story = {+ args: {+ data: testData.veryLarge as any,+ categoryKey: "month" as any,+ theme: "vivid",+ height: 200,+ },+ render: (args: any) => (+ <Card style={{ width: "450px", padding: "16px" }}>+ <div style={{ marginBottom: "8px", fontSize: "12px", color: "#666" }}>+ <strong>Test:</strong> Very large numbers (millions)+ </div>+ <LineChartCondensed {...args} />+ </Card>+ ),+};++/**+ * ## TEST: Very Small Decimals+ *+ * **Purpose**: Test precision handling for small decimal values+ * **Expected**: Should display appropriate decimal precision+ */+export const ValueRange_VerySmall: Story = {+ args: {+ data: testData.verySmall as any,+ categoryKey: "month" as any,+ theme: "emerald",+ height: 200,+ },+ render: (args: any) => (+ <Card style={{ width: "450px", padding: "16px" }}>+ <div style={{ marginBottom: "8px", fontSize: "12px", color: "#666" }}>+ <strong>Test:</strong> Very small decimal values+ </div>+ <LineChartCondensed {...args} />+ </Card>+ ),+};++/**+ * ## TEST: Wide Value Range+ *+ * **Purpose**: Test scaling when series have vastly different magnitudes+ * **Expected**: Should scale appropriately or show warning+ */+export const ValueRange_WideRange: Story = {+ args: {+ data: testData.wideRange as any,+ categoryKey: "month" as any,+ theme: "spectrum",+ height: 200,+ },+ render: (args: any) => (+ <Card style={{ width: "500px", padding: "16px" }}>+ <div style={{ marginBottom: "8px", fontSize: "12px", color: "#666" }}>+ <strong>Test:</strong> Wide range (1 to 1,000,000)+ </div>+ <LineChartCondensed {...args} />+ </Card>+ ),+};++// ============================================================================+// PATTERN TESTS - Testing different data patterns and shapes+// ============================================================================++/**+ * ## TEST: Linear Progression+ *+ * **Purpose**: Verify rendering of linear increasing data+ * **Expected**: Clean straight line progression+ */+export const Pattern_Linear: Story = {+ args: {+ data: testData.linear as any,+ categoryKey: "x" as any,+ theme: "ocean",+ variant: "linear",+ height: 200,+ },+ render: (args: any) => (+ <Card style={{ width: "500px", padding: "16px" }}>+ <div style={{ marginBottom: "8px", fontSize: "12px", color: "#666" }}>+ <strong>Test:</strong> Linear progression pattern+ </div>+ <LineChartCondensed {...args} />+ </Card>+ ),+};++/**+ * ## TEST: Exponential Growth+ *+ * **Purpose**: Test rendering of exponentially increasing values+ * **Expected**: Should handle steep curve and wide Y-axis range+ */+export const Pattern_Exponential: Story = {+ args: {+ data: testData.exponential as any,+ categoryKey: "x" as any,+ theme: "emerald",+ variant: "natural",+ height: 200,+ },+ render: (args: any) => (+ <Card style={{ width: "500px", padding: "16px" }}>+ <div style={{ marginBottom: "8px", fontSize: "12px", color: "#666" }}>+ <strong>Test:</strong> Exponential growth pattern+ </div>+ <LineChartCondensed {...args} />+ </Card>+ ),+};++/**+ * ## TEST: Sinusoidal Wave+ *+ * **Purpose**: Test smooth curves with wave pattern+ * **Expected**: Natural variant should show smooth sine wave+ */+export const Pattern_Sinusoidal: Story = {+ args: {+ data: testData.sinusoidal as any,+ categoryKey: "x" as any,+ theme: "orchid",+ variant: "natural",+ height: 200,+ },+ render: (args: any) => (+ <Card style={{ width: "600px", padding: "16px" }}>+ <div style={{ marginBottom: "8px", fontSize: "12px", color: "#666" }}>+ <strong>Test:</strong> Sinusoidal wave pattern+ </div>+ <LineChartCondensed {...args} />+ </Card>+ ),+};++/**+ * ## TEST: Constant Values+ *+ * **Purpose**: Test behavior with no variation in data+ * **Expected**: Flat horizontal line+ */+export const Pattern_Constant: Story = {+ args: {+ data: testData.constant as any,+ categoryKey: "x" as any,+ theme: "sunset",+ height: 200,+ },+ render: (args: any) => (+ <Card style={{ width: "450px", padding: "16px" }}>+ <div style={{ marginBottom: "8px", fontSize: "12px", color: "#666" }}>+ <strong>Test:</strong> Constant value pattern+ </div>+ <LineChartCondensed {...args} />+ </Card>+ ),+};++/**+ * ## TEST: Volatile/Spike Pattern+ *+ * **Purpose**: Test rendering of data with extreme spikes+ * **Expected**: Should handle spikes without distortion+ */+export const Pattern_Volatile: Story = {+ args: {+ data: testData.volatile as any,+ categoryKey: "x" as any,+ theme: "vivid",+ height: 200,+ },+ render: (args: any) => (+ <Card style={{ width: "550px", padding: "16px" }}>+ <div style={{ marginBottom: "8px", fontSize: "12px", color: "#666" }}>+ <strong>Test:</strong> Volatile pattern with spikes+ </div>+ <LineChartCondensed {...args} />+ </Card>+ ),+};++// ============================================================================+// REAL-WORLD SCENARIO TESTS - Practical use cases+// ============================================================================++/**+ * ## TEST: Daily Time Series (30 days)+ *+ * **Purpose**: Test typical time-series sales data+ * **Expected**: Clean rendering of date-based data+ */+export const RealWorld_DailySales: Story = {+ args: {+ data: testData.dailySales as any,+ categoryKey: "date" as any,+ theme: "ocean",+ icons,+ height: 220,+ },+ render: (args: any) => (+ <Card style={{ width: "700px", padding: "16px" }}>+ <div style={{ marginBottom: "8px", fontSize: "12px", color: "#666" }}>+ <strong>Test:</strong> Daily sales time series | <strong>Days:</strong> 30+ </div>+ <LineChartCondensed {...args} />+ </Card>+ ),+};++/**+ * ## TEST: Quarterly Financial Data+ *+ * **Purpose**: Test financial reporting scenario+ * **Expected**: Clear visualization of revenue, profit, costs+ */+export const RealWorld_QuarterlySales: Story = {+ args: {+ data: testData.quarterlySales as any,+ categoryKey: "quarter" as any,+ theme: "emerald",+ icons,+ height: 220,+ },+ render: (args: any) => (+ <Card style={{ width: "600px", padding: "16px" }}>+ <div style={{ marginBottom: "8px", fontSize: "12px", color: "#666" }}>+ <strong>Test:</strong> Quarterly financial data | <strong>Quarters:</strong> 5+ </div>+ <LineChartCondensed {...args} />+ </Card>+ ),+};++/**+ * ## TEST: Weekly Analytics Traffic+ *+ * **Purpose**: Test typical analytics dashboard data+ * **Expected**: Multiple metrics clearly differentiated+ */+export const RealWorld_WeeklyTraffic: Story = {+ args: {+ data: testData.weeklyTraffic as any,+ categoryKey: "day" as any,+ theme: "sunset",+ icons,+ height: 220,+ },+ render: (args: any) => (+ <Card style={{ width: "650px", padding: "16px" }}>+ <div style={{ marginBottom: "8px", fontSize: "12px", color: "#666" }}>+ <strong>Test:</strong> Weekly traffic analytics | <strong>Metrics:</strong> 3+ </div>+ <LineChartCondensed {...args} />+ </Card>+ ),+};++// ============================================================================+// VARIANT & CONFIGURATION TESTS+// ============================================================================++/**+ * ## TEST: Variant Comparison+ *+ * **Purpose**: Compare all interpolation variants side-by-side+ * **Expected**: Visual difference between linear, natural, step+ */+export const Config_VariantComparison: Story = {+ render: () => (+ <div style={{ display: "flex", flexDirection: "column", gap: "16px" }}>+ <Card style={{ width: "600px", padding: "16px" }}>+ <div style={{ marginBottom: "8px", fontSize: "12px", color: "#666" }}>+ <strong>Variant:</strong> Linear+ </div>+ <LineChartCondensed+ data={testData.twelvePoints as any}+ categoryKey="month"+ variant="linear"+ theme="ocean"+ height={150}+ />+ </Card>+ <Card style={{ width: "600px", padding: "16px" }}>+ <div style={{ marginBottom: "8px", fontSize: "12px", color: "#666" }}>+ <strong>Variant:</strong> Natural (smooth)+ </div>+ <LineChartCondensed+ data={testData.twelvePoints as any}+ categoryKey="month"+ variant="natural"+ theme="emerald"+ height={150}+ />+ </Card>+ <Card style={{ width: "600px", padding: "16px" }}>+ <div style={{ marginBottom: "8px", fontSize: "12px", color: "#666" }}>+ <strong>Variant:</strong> Step+ </div>+ <LineChartCondensed+ data={testData.twelvePoints as any}+ categoryKey="month"+ variant="step"+ theme="sunset"+ height={150}+ />+ </Card>+ </div>+ ),+};++/**+ * ## TEST: Stroke Width Variations+ *+ * **Purpose**: Test different line thicknesses+ * **Expected**: Clear visual difference in line width+ */+export const Config_StrokeWidthVariations: Story = {+ render: () => (+ <div style={{ display: "flex", flexDirection: "column", gap: "16px" }}>+ <Card style={{ width: "600px", padding: "16px" }}>+ <div style={{ marginBottom: "8px", fontSize: "12px", color: "#666" }}>+ <strong>Stroke Width:</strong> 1px (Thin)+ </div>+ <LineChartCondensed+ data={testData.twelvePoints as any}+ categoryKey="month"+ theme="ocean"+ height={150}+ strokeWidth={1}+ />+ </Card>+ <Card style={{ width: "600px", padding: "16px" }}>+ <div style={{ marginBottom: "8px", fontSize: "12px", color: "#666" }}>+ <strong>Stroke Width:</strong> 2px (Default)+ </div>+ <LineChartCondensed+ data={testData.twelvePoints as any}+ categoryKey="month"+ theme="emerald"+ height={150}+ strokeWidth={2}+ />+ </Card>+ <Card style={{ width: "600px", padding: "16px" }}>+ <div style={{ marginBottom: "8px", fontSize: "12px", color: "#666" }}>+ <strong>Stroke Width:</strong> 4px (Thick)+ </div>+ <LineChartCondensed+ data={testData.twelvePoints as any}+ categoryKey="month"+ theme="sunset"+ height={150}+ strokeWidth={4}+ />+ </Card>+ </div>+ ),+};++/**+ * ## TEST: Without Y-Axis+ *+ * **Purpose**: Test ultra-compact mode without Y-axis+ * **Expected**: More horizontal space, clean minimal look+ */+export const Config_WithoutYAxis: Story = {+ args: {+ data: testData.twelvePoints as any,+ categoryKey: "month" as any,+ theme: "vivid",+ showYAxis: false,+ grid: false,+ height: 150,+ },+ render: (args: any) => (+ <Card style={{ width: "500px", padding: "16px" }}>+ <div style={{ marginBottom: "8px", fontSize: "12px", color: "#666" }}>+ <strong>Test:</strong> Y-axis hidden, grid off+ </div>+ <LineChartCondensed {...args} />+ </Card>+ ),+};++/**+ * ## TEST: Custom Color Palette+ *+ * **Purpose**: Verify custom palette override functionality+ * **Expected**: Uses custom colors instead of theme+ */+export const Config_CustomPalette: Story = {+ args: {+ data: testData.twelvePoints as any,+ categoryKey: "month" as any,+ customPalette: ["#FF6B6B", "#4ECDC4", "#45B7D1"],+ height: 200,+ },+ render: (args: any) => (+ <div>+ <div+ style={{+ marginBottom: "12px",+ padding: "12px",+ background: "#f8f9fa",+ borderRadius: "8px",+ width: "550px",+ }}+ >+ <strong>Custom Palette:</strong>+ <div style={{ display: "flex", gap: "8px", marginTop: "8px" }}>+ {args.customPalette?.map((color: string, index: number) => (+ <div+ key={index}+ style={{ display: "flex", alignItems: "center", gap: "4px", fontSize: "12px" }}+ >+ <div+ style={{+ width: "16px",+ height: "16px",+ backgroundColor: color,+ borderRadius: "3px",+ border: "1px solid #ddd",+ }}+ />+ <span style={{ fontFamily: "monospace" }}>{color}</span>+ </div>+ ))}+ </div>+ </div>+ <Card style={{ width: "550px", padding: "16px" }}>+ <LineChartCondensed {...args} />+ </Card>+ </div>+ ),+};++// ============================================================================+// STRESS & PERFORMANCE TESTS+// ============================================================================++/**+ * ## TEST: Multiple Charts Dashboard+ *+ * **Purpose**: Test rendering multiple charts simultaneously+ * **Expected**: All charts render smoothly without performance issues+ */+export const Stress_MultipleCharts: Story = {+ render: () => (+ <div+ style={{+ display: "grid",+ gridTemplateColumns: "repeat(2, 1fr)",+ gap: "16px",+ width: "900px",+ }}+ >+ <Card style={{ padding: "16px" }}>+ <div style={{ marginBottom: "8px", fontSize: "12px", fontWeight: "600" }}>+ Small Dataset+ </div>+ <LineChartCondensed+ data={testData.fivePoints as any}+ categoryKey="month"+ theme="ocean"+ height={140}+ />+ </Card>+ <Card style={{ padding: "16px" }}>+ <div style={{ marginBottom: "8px", fontSize: "12px", fontWeight: "600" }}>+ Medium Dataset+ </div>+ <LineChartCondensed+ data={testData.twelvePoints as any}+ categoryKey="month"+ theme="emerald"+ height={140}+ />+ </Card>+ <Card style={{ padding: "16px" }}>+ <div style={{ marginBottom: "8px", fontSize: "12px", fontWeight: "600" }}>+ Large Dataset (50)+ </div>+ <LineChartCondensed+ data={testData.large50 as any}+ categoryKey="date"+ theme="sunset"+ height={140}+ />+ </Card>+ <Card style={{ padding: "16px" }}>+ <div style={{ marginBottom: "8px", fontSize: "12px", fontWeight: "600" }}>Time Series</div>+ <LineChartCondensed+ data={testData.dailySales as any}+ categoryKey="date"+ theme="orchid"+ height={140}+ />+ </Card>+ </div>+ ),+ parameters: {+ docs: {+ description: {+ story: "Stress test with 4 charts rendering simultaneously with varying dataset sizes.",+ },+ },+ },+};++// Test Data for Long Labels+const longLabelData = [+ { category: "Q1 2024 January Total Revenue and Expenses", sales: 186, expenses: 80, profit: 106 },+ {+ category: "Q1 2024 February Marketing Campaign Results",+ sales: 305,+ expenses: 200,+ profit: 105,+ },+ { category: "Q1 2024 March Product Launch Performance", sales: 237, expenses: 120, profit: 117 },+ { category: "Q2 2024 April Customer Acquisition Metrics", sales: 273, expenses: 190, profit: 83 },+ { category: "Q2 2024 May Operational Efficiency Report", sales: 209, expenses: 130, profit: 79 },+ {+ category: "Q2 2024 June Strategic Initiative Outcomes",+ sales: 314,+ expenses: 140,+ profit: 174,+ },+ { category: "Q3 2024 July Market Expansion Analysis", sales: 350, expenses: 180, profit: 170 },+ {+ category: "Q3 2024 August Technology Investment Returns",+ sales: 280,+ expenses: 160,+ profit: 120,+ },+ { category: "Q3 2024 September Partnership Performance", sales: 320, expenses: 170, profit: 150 },+ { category: "Q4 2024 October Year-End Projections", sales: 290, expenses: 150, profit: 140 },+ { category: "Q4 2024 November Holiday Season Preview", sales: 340, expenses: 180, profit: 160 },+ { category: "Q4 2024 December Annual Summary Report", sales: 420, expenses: 220, profit: 200 },+];++// Tick Variant Stories+export const TickVariantSingleLine: Story = {+ render: () => (+ <Card style={{ padding: "24px", width: "900px", maxWidth: "900px" }}>+ <div style={{ marginBottom: "16px", fontSize: "16px", fontWeight: "600" }}>+ Single Line Tick Variant+ </div>+ <div style={{ marginBottom: "8px", fontSize: "13px", color: "#666" }}>+ Standard horizontal labels with automatic collision detection+ </div>+ <LineChartCondensed+ data={longLabelData as any}+ categoryKey="category"+ tickVariant="singleLine"+ theme="ocean"+ height={200}+ />+ </Card>+ ),+ parameters: {+ docs: {+ description: {+ story:+ "Single line tick variant with standard horizontal labels. Automatically handles collision detection.",+ },+ },+ },+};++export const TickVariantAngled: Story = {+ render: () => (+ <Card style={{ padding: "24px", width: "900px", maxWidth: "900px" }}>+ <div style={{ marginBottom: "16px", fontSize: "16px", fontWeight: "600" }}>+ Angled Tick Variant+ </div>+ <div style={{ marginBottom: "8px", fontSize: "13px", color: "#666" }}>+ -45° rotation perfect for long labels that would overlap horizontally+ </div>+ <LineChartCondensed+ data={longLabelData as any}+ categoryKey="category"+ tickVariant="angled"+ theme="emerald"+ height={280}+ />+ </Card>+ ),+ parameters: {+ docs: {+ description: {+ story:+ "Angled tick variant with -45° rotation. Perfect for long labels that would overlap horizontally.",+ },+ },+ },+};++// Dense Data with Tick Variants+const denseData = Array.from({ length: 30 }, (_, i) => ({+ day: `Day ${i + 1}`,+ revenue: Math.floor(Math.random() * 500) + 100,+ costs: Math.floor(Math.random() * 300) + 50,+}));++export const TickVariantComparisonDenseData: Story = {+ render: () => (+ <div style={{ display: "grid", gridTemplateColumns: "1fr", gap: "24px", maxWidth: "1100px" }}>+ <Card style={{ padding: "24px" }}>+ <div style={{ marginBottom: "16px", fontSize: "16px", fontWeight: "600" }}>+ Single Line Variant (Dense Data - 30 Points)+ </div>+ <div style={{ marginBottom: "8px", fontSize: "13px", color: "#666" }}>+ Recharts automatically hides overlapping labels+ </div>+ <LineChartCondensed+ data={denseData as any}+ categoryKey="day"+ tickVariant="singleLine"+ theme="ocean"+ height={200}+ />+ </Card>+ <Card style={{ padding: "24px" }}>+ <div style={{ marginBottom: "16px", fontSize: "16px", fontWeight: "600" }}>+ Angled Variant (Dense Data - 30 Points)+ </div>+ <div style={{ marginBottom: "8px", fontSize: "13px", color: "#666" }}>+ Shows more labels with angled orientation+ </div>+ <LineChartCondensed+ data={denseData as any}+ categoryKey="day"+ tickVariant="angled"+ theme="emerald"+ height={280}+ />+ </Card>+ </div>+ ),+ parameters: {+ docs: {+ description: {+ story:+ "Comparison of tick variants (singleLine and angled) with dense data (30 data points). Shows how each variant handles label collision with Recharts' built-in collision detection.",+ },+ },+ },+};diff --git a/js/packages/react-ui/src/components/Charts/charts.scss b/js/packages/react-ui/src/components/Charts/charts.scssindex f9894b101..08364d4e4 100644--- a/js/packages/react-ui/src/components/Charts/charts.scss+++ b/js/packages/react-ui/src/components/Charts/charts.scss@@ -2,13 +2,16 @@// bar chart css@forward "./BarChart/barChart.scss";+@forward "./BarChartCondensed/barChartCondensed.scss";@forward "./HorizontalBarChart/horizontalBarChart.scss";// area chart css@forward "./AreaChart/areaChart.scss";+@forward "./AreaChartCondensed/areaChartCondensed.scss";// line chart css@forward "./LineChart/lineChart.scss";+@forward "./LineChartCondensed/lineChartCondensed.scss";// scatter chart css@forward "./ScatterChart/scatterChart.scss";@@ -27,6 +30,7 @@// shared components css@forward "./shared/XAxisTick/xAxisTick.scss";+@forward "./shared/CondensedXAxisTick/condensedXAxisTick.scss";@forward "./shared/DefaultLegend/defaultLegend.scss";@forward "./shared/StackedLegend/stackedLegend.scss";@forward "./shared/YAxisTick/yAxisTick.scss";diff --git a/js/packages/react-ui/src/components/Charts/constants/CondensedCharts.ts b/js/packages/react-ui/src/components/Charts/constants/CondensedCharts.tsnew file mode 100644index 000000000..6e4485b47--- /dev/null+++ b/js/packages/react-ui/src/components/Charts/constants/CondensedCharts.ts@@ -0,0 +1,3 @@+export const X_AXIS_PADDING = 10;+export const MIN_ROTATION_ANGLE = 15;+export const DEFAULT_X_AXIS_HEIGHT = 30;diff --git a/js/packages/react-ui/src/components/Charts/constants/index.ts b/js/packages/react-ui/src/components/Charts/constants/index.tsnew file mode 100644index 000000000..3b4637efd--- /dev/null+++ b/js/packages/react-ui/src/components/Charts/constants/index.ts@@ -0,0 +1 @@+export * from "./CondensedCharts";diff --git a/js/packages/react-ui/src/components/Charts/hooks/index.ts b/js/packages/react-ui/src/components/Charts/hooks/index.tsindex 43d79c214..ad182fdf0 100644--- a/js/packages/react-ui/src/components/Charts/hooks/index.ts+++ b/js/packages/react-ui/src/components/Charts/hooks/index.ts@@ -1,4 +1,6 @@+export * from "./useAutoAngleCalculation";export * from "./useCanvasContextForLabelSize";export * from "./useMaxLabelHeight";+export * from "./useMaxLabelWidth";export * from "./useTransformKey";export * from "./useYAxisLabelWidth";diff --git a/js/packages/react-ui/src/components/Charts/hooks/useAutoAngleCalculation.ts b/js/packages/react-ui/src/components/Charts/hooks/useAutoAngleCalculation.tsnew file mode 100644index 000000000..881bd1267--- /dev/null+++ b/js/packages/react-ui/src/components/Charts/hooks/useAutoAngleCalculation.ts@@ -0,0 +1,90 @@+import { useMemo } from "react";+import { DEFAULT_X_AXIS_HEIGHT, MIN_ROTATION_ANGLE, X_AXIS_PADDING } from "../constants";++interface AngleCalculationResult {+ angle: number;+ height: number;+}++/**+ * Calculates the optimal rotation angle and height for X-axis labels using trigonometry.+ *+ * This hook uses the Pythagorean theorem to determine the optimal angle for rotating+ * labels based on the maximum label width and available horizontal space.+ *+ * Mathematical approach:+ * - Hypotenuse = maxLabelWidth (the label length)+ * - Base = X_AXIS_PADDING + yAxisWidth (available horizontal space from left edge to first label)+ * - Height = sqrt(hypotenuse² - base²)+ * - Angle = atan(height / base) converted to degrees+ *+ * @param maxLabelWidth - The maximum width of all labels in pixels+ * @param yAxisWidth - The width of the Y-axis in pixels+ * @param enabled - Whether to calculate the angle (typically based on tickVariant)+ * @returns Object containing the calculated angle (in degrees) and required height+ */+export const useAutoAngleCalculation = (+ maxLabelWidth: number,+ yAxisWidth: number,+ enabled: boolean,+ showYAxis: boolean,+): AngleCalculationResult => {+ return useMemo(() => {+ // If not enabled, return default values for horizontal labels+ if (!enabled) {+ return {+ angle: 0,+ height: DEFAULT_X_AXIS_HEIGHT,+ };+ }++ // Calculate the base (horizontal distance from left edge to first label anchor)+ let base = 0;++ if (showYAxis) {+ base = X_AXIS_PADDING + yAxisWidth;+ } else {+ base = X_AXIS_PADDING;+ }++ // The hypotenuse is the maximum label width+ const hypotenuse = maxLabelWidth;++ // Edge case: if base is greater than or equal to hypotenuse,+ // labels would fit horizontally, but we always apply rotation per requirement+ if (base >= hypotenuse) {+ // Apply minimum rotation angle+ const angleRadians = (MIN_ROTATION_ANGLE * Math.PI) / 180;+ const height = Math.ceil(hypotenuse * Math.sin(angleRadians));++ return {+ angle: -MIN_ROTATION_ANGLE, // Negative for counter-clockwise rotation+ height: Math.max(height, DEFAULT_X_AXIS_HEIGHT), // Ensure minimum height+ };+ }++ // Calculate height using Pythagorean theorem: height = sqrt(hypotenuse² - base²)+ const heightSquared = hypotenuse * hypotenuse - base * base;+ const height = Math.sqrt(Math.max(0, heightSquared)); // Ensure non-negative++ // Calculate angle using arctangent: angle = atan(height / base)+ const angleRadians = Math.atan(height / base);++ // Convert radians to degrees+ const angleDegrees = (angleRadians * 180) / Math.PI;++ // Apply minimum rotation angle if calculated angle is too small+ const finalAngle = Math.max(angleDegrees, MIN_ROTATION_ANGLE);++ // Recalculate height if we used minimum angle+ const finalHeight =+ finalAngle > angleDegrees+ ? Math.ceil(hypotenuse * Math.sin((finalAngle * Math.PI) / 180))+ : Math.ceil(height);++ return {+ angle: -finalAngle, // Negative for counter-clockwise rotation+ height: Math.max(finalHeight + 16, DEFAULT_X_AXIS_HEIGHT), // Ensure minimum height+ };+ }, [maxLabelWidth, yAxisWidth, enabled, showYAxis]);+};diff --git a/js/packages/react-ui/src/components/Charts/hooks/useMaxLabelWidth.ts b/js/packages/react-ui/src/components/Charts/hooks/useMaxLabelWidth.tsnew file mode 100644index 000000000..d352a4b66--- /dev/null+++ b/js/packages/react-ui/src/components/Charts/hooks/useMaxLabelWidth.ts@@ -0,0 +1,41 @@+import { useMemo } from "react";++import { useCanvasContextForLabelSize } from "./useCanvasContextForLabelSize";++/**+ * Calculates the maximum width of all labels in the chart data.+ *+ * This hook measures the pixel width of each category label and returns+ * the maximum width found. It uses a canvas context to accurately measure+ * text dimensions based on the current theme's font settings.+ *+ * @param data - The chart data array+ * @param categoryKey - The key in the data object that contains the label text+ * @returns The maximum label width in pixels+ */+export const useMaxLabelWidth = <T extends Record<string, any>>(+ data: T[],+ categoryKey: keyof T,+): number => {+ const context = useCanvasContextForLabelSize();++ return useMemo(() => {+ if (!data || data.length === 0) {+ return 0;+ }++ let maxWidth = 0;++ for (const item of data) {+ const labelValue = String(item[categoryKey] ?? "");+ const metrics = context.measureText(labelValue);+ const width = metrics.width;++ if (width > maxWidth) {+ maxWidth = width;+ }+ }++ return maxWidth;+ }, [data, categoryKey, context]);+};diff --git a/js/packages/react-ui/src/components/Charts/hooks/useYAxisLabelWidth.tsx b/js/packages/react-ui/src/components/Charts/hooks/useYAxisLabelWidth.tsxindex ec276a97c..8433b13a8 100644--- a/js/packages/react-ui/src/components/Charts/hooks/useYAxisLabelWidth.tsx+++ b/js/packages/react-ui/src/components/Charts/hooks/useYAxisLabelWidth.tsx@@ -17,7 +17,7 @@ export const useYAxisLabelWidth = (dataKeys: string[],) => {const context = useCanvasContextForLabelSize();- const [maxLabelWidthRecieved, setMaxLabelWidthRecieved] = useState(0);+ const [maxLabelWidthReceived, setMaxLabelWidthReceived] = useState(0);const maxLabelWidth = useMemo(() => {if (typeof window === "undefined" || !data || data.length === 0 || !dataKeys.length) {@@ -53,15 +53,12 @@ export const useYAxisLabelWidth = (}, [data, dataKeys, context]);const maxLabelWidthRef = useRef(maxLabelWidth);- maxLabelWidthRef.current = Math.max(maxLabelWidthRecieved, maxLabelWidth);+ maxLabelWidthRef.current = maxLabelWidthReceived || maxLabelWidth;const setLabelWidth = useCallback((displayValue: string) => {const textWidth = context.measureText(displayValue).width + LABEL_PADDING;-- if (textWidth > maxLabelWidthRef.current) {- setMaxLabelWidthRecieved(textWidth);- }+ setMaxLabelWidthReceived((currentWidth) => Math.max(currentWidth, textWidth));},[context],);diff --git a/js/packages/react-ui/src/components/Charts/index.ts b/js/packages/react-ui/src/components/Charts/index.tsindex a1bf1bc40..914a4e0a2 100644--- a/js/packages/react-ui/src/components/Charts/index.ts+++ b/js/packages/react-ui/src/components/Charts/index.ts@@ -1,7 +1,10 @@export * from "./AreaChart";+export * from "./AreaChartCondensed";export * from "./BarChart";+export * from "./BarChartCondensed";export * from "./HorizontalBarChart";export * from "./LineChart";+export * from "./LineChartCondensed";export * from "./MiniAreaChart";export * from "./MiniBarChart";export * from "./MiniLineChart";diff --git a/js/packages/react-ui/src/components/Charts/shared/CondensedXAxisTick/CondensedXAxisTick.tsx b/js/packages/react-ui/src/components/Charts/shared/CondensedXAxisTick/CondensedXAxisTick.tsxnew file mode 100644index 000000000..60719de18--- /dev/null+++ b/js/packages/react-ui/src/components/Charts/shared/CondensedXAxisTick/CondensedXAxisTick.tsx@@ -0,0 +1,51 @@+import clsx from "clsx";+import React from "react";++export type CondensedXAxisTickVariant = "singleLine" | "angled";++interface CondensedXAxisTickProps {+ x?: number;+ y?: number;+ payload?: {+ value: any;+ };+ fill?: string;+ className?: string;+ angle?: number;+ textAnchor?: string;+}++const CondensedXAxisTick = React.forwardRef<SVGTextElement, CondensedXAxisTickProps>(+ (props, ref) => {+ const { x, y, payload, fill, className, angle = 0, textAnchor = "middle" } = props;++ const value = String(payload?.value || "");++ if (x === undefined || y === undefined) {+ return null;+ }++ // Apply rotation transform if angle is provided+ const transform = angle !== 0 ? `rotate(${angle}, ${x}, ${y})` : undefined;++ return (+ <text+ ref={ref}+ className={clsx("crayon-chart-condensed-x-axis-tick", className)}+ x={x}+ y={y}+ dy={16}+ fill={fill}+ textAnchor={textAnchor}+ transform={transform}+ >+ {value}+ </text>+ );+ },+);++CondensedXAxisTick.displayName = "CondensedXAxisTick";++export { CondensedXAxisTick };+export type { CondensedXAxisTickProps };diff --git a/js/packages/react-ui/src/components/Charts/shared/CondensedXAxisTick/condensedXAxisTick.scss b/js/packages/react-ui/src/components/Charts/shared/CondensedXAxisTick/condensedXAxisTick.scssnew file mode 100644index 000000000..d1e626142--- /dev/null+++ b/js/packages/react-ui/src/components/Charts/shared/CondensedXAxisTick/condensedXAxisTick.scss@@ -0,0 +1,11 @@+@use "../../../../cssUtils" as cssUtils;++.crayon-chart-condensed-x-axis-tick {+ @include cssUtils.typography(label, extra-small);+ color: cssUtils.$secondary-text;+}++.crayon-chart-condensed-x-axis-tick-angled {+ @include cssUtils.typography(label, extra-small);+ color: cssUtils.$secondary-text;+}diff --git a/js/packages/react-ui/src/components/Charts/shared/CondensedXAxisTick/index.ts b/js/packages/react-ui/src/components/Charts/shared/CondensedXAxisTick/index.tsnew file mode 100644index 000000000..25b824215--- /dev/null+++ b/js/packages/react-ui/src/components/Charts/shared/CondensedXAxisTick/index.ts@@ -0,0 +1,2 @@+export { CondensedXAxisTick } from "./CondensedXAxisTick";+export type { CondensedXAxisTickProps, CondensedXAxisTickVariant } from "./CondensedXAxisTick";diff --git a/js/packages/react-ui/src/components/Charts/shared/StackedLegend/StackedLegend.tsx b/js/packages/react-ui/src/components/Charts/shared/StackedLegend/StackedLegend.tsxindex f578e1559..b2e57b11a 100644--- a/js/packages/react-ui/src/components/Charts/shared/StackedLegend/StackedLegend.tsx+++ b/js/packages/react-ui/src/components/Charts/shared/StackedLegend/StackedLegend.tsx@@ -1,6 +1,6 @@import clsx from "clsx";import { ChevronDown, ChevronUp } from "lucide-react";-import { useEffect, useRef, useState } from "react";+import React, { useEffect, useRef, useState } from "react";import { Button } from "../../../Button";import { IconButton } from "../../../IconButton";import { Separator } from "../../../Separator";@@ -171,9 +171,8 @@ export const StackedLegend = ({)}<div ref={listRef} className="crayon-stacked-legend">{itemsToDisplay.map((item, index) => (- <>+ <React.Fragment key={item.key}><div- key={item.key}className={`crayon-stacked-legend__item ${activeKey === item.key ? "crayon-stacked-legend__item--active" : ""}`}@@ -196,7 +195,7 @@ export const StackedLegend = ({{index !== itemsToDisplay.length - 1 && separator && (<Separator className="crayon-stacked-legend-separator" />)}- </>+ </React.Fragment>))}</div>{isShowMoreLayout && !showAll && items.length > LEGEND_ITEM_LIMIT && (diff --git a/js/packages/react-ui/src/components/Charts/shared/index.ts b/js/packages/react-ui/src/components/Charts/shared/index.tsindex b6d36939c..e3c26acb4 100644--- a/js/packages/react-ui/src/components/Charts/shared/index.ts+++ b/js/packages/react-ui/src/components/Charts/shared/index.ts@@ -1,5 +1,6 @@export * from "./ActiveDot/ActiveDot";export * from "./CartesianGrid/cartesianGrid";+export * from "./CondensedXAxisTick";export * from "./DefaultLegend/DefaultLegend";export * from "./LineInBarShape";export * from "./PortalTooltip";