The Open Standard for Generative UI
feat(react-ui)!: replace the Recharts charts with D3 (#1263)
Ankit Das453b820dacfd
diff --git a/.changeset/react-ui-d3-charts.md b/.changeset/react-ui-d3-charts.mdindex e7873ce5d..85245c8d9 100644--- a/.changeset/react-ui-d3-charts.md+++ b/.changeset/react-ui-d3-charts.md@@ -1,5 +1,14 @@----"@openuidev/react-ui": patch+"@openuidev/react-ui": minor----Add D3-based charts under `@openuidev/react-ui/D3Charts`: Area, Line, Bar (vertical and horizontal), Pie, Radial, Radar, Scatter, Heatmap, Funnel, SegmentedBar, CalendarHeatmap and the MiniArea / MiniBar / MiniLine sparklines, plus `StackedLegend` with `LegendStoreProvider`. They take the same `data` + `categoryKey` / `dataKey` shape and default to the same look as the existing charts (stacked-area totals, Pie/Radial stacked legend, SingleStackedBar compact legend, outline radar), and ship alongside them with `openui-d3-` prefixed classes; the existing Recharts charts are unchanged. Area, Line and Bar keep a fixed height: their x-axis labels never take more than half of it and truncate when they don't fit.+Charts are now drawn with D3 instead of Recharts. Every chart keeps its name and export (`AreaChart`, `AreaChartCondensed`, `BarChart`, `BarChartCondensed`, `HorizontalBarChart`, `LineChart`, `LineChartCondensed`, `PieChart`, `RadarChart`, `RadialChart`, `ScatterChart`, `SingleStackedBar`, the Mini charts and the scatter helpers) and takes the same `data` + `categoryKey` / `dataKey` shape; genui-lib's chart components and their props are unchanged. New charts: `HeatmapChart`, `FunnelChart`, `SegmentedBar` (the same component as `SingleStackedBar`), `CalendarHeatmap`, plus `StackedLegend` with `LegendStoreProvider`.++Changes for direct users:++- `theme` (named palettes) is gone; set colors with `customPalette` or the ThemeProvider's chart palettes (`defaultChartPalette`, `barChartPalette`, …).+- `height` is the whole chart: the x-axis labels and legend fit inside it instead of being added below. Labels take at most half of it and truncate when they don't fit.+- Renamed: bar `radius` → `barRadius`; SingleStackedBar `animated` → `isAnimationActive`.+- Dropped: line and radar `strokeWidth`; HorizontalBarChart `showXAxis`; Pie and Radial `onMouseEnter` / `onMouseLeave`; scatter `shape`.+- Legend and tooltip text is shown as given, no longer capitalized ("iOS" stays "iOS"; a lowercase data key shows lowercase).+- `recharts` is no longer a dependency.diff --git a/.changeset/widen-ui-peer-windows-0-17.md b/.changeset/widen-ui-peer-windows-0-17.mdnew file mode 100644index 000000000..8a39f3059--- /dev/null+++ b/.changeset/widen-ui-peer-windows-0-17.md@@ -0,0 +1,7 @@+---+"@openuidev/assistant-ui": patch+---++Widen the internal `react-headless`/`react-ui` peer windows to include the+0.17.x line that the D3 charts release (a minor bump of the react-ui /+react-headless pair) publishes.diff --git a/packages/assistant-ui/package.json b/packages/assistant-ui/package.jsonindex da0d9c2c8..ee728c11b 100644--- a/packages/assistant-ui/package.json+++ b/packages/assistant-ui/package.json@@ -79,9 +79,9 @@"author": "[email protected]","peerDependencies": {"@assistant-ui/react": "^0.15.0",- "@openuidev/react-headless": ">=0.14.0 <0.17.0",+ "@openuidev/react-headless": ">=0.14.0 <0.18.0","@openuidev/react-lang": ">=0.3.0 <0.4.0",- "@openuidev/react-ui": ">=0.14.0 <0.17.0",+ "@openuidev/react-ui": ">=0.14.0 <0.18.0","ai": "^6.0.0 || ^7.0.0","react": "catalog:","react-dom": "catalog:",diff --git a/packages/react-ui/.storybook/preview.tsx b/packages/react-ui/.storybook/preview.tsxindex b8275b16f..7464bb79f 100644--- a/packages/react-ui/.storybook/preview.tsx+++ b/packages/react-ui/.storybook/preview.tsx@@ -96,6 +96,7 @@ const preview: Preview = {<><style>{`+ body,.docs-story {background-color: ${selectedMode === "dark" ? "#333" : "#F7F9F2"};}diff --git a/packages/react-ui/package.json b/packages/react-ui/package.jsonindex 66433d4d5..3ac2c7bc7 100644--- a/packages/react-ui/package.json+++ b/packages/react-ui/package.json@@ -109,7 +109,7 @@"ci": "pnpm run lint:check && pnpm run format:check && pnpm run test"},"peerDependencies": {- "@openuidev/react-headless": ">=0.14.0 <0.17.0",+ "@openuidev/react-headless": ">=0.14.0 <0.18.0","@openuidev/react-lang": ">=0.3.0 <0.4.0","react": "catalog:","react-dom": "catalog:",@@ -144,7 +144,6 @@"react-day-picker": "^9.5.1","react-markdown": "^10.1.0","react-syntax-highlighter": "^16.1.1",- "recharts": "^2.15.4","rehype-katex": "^7.0.1","remark-breaks": "^4.0.0","remark-emoji": "^5.0.1",@@ -220,7 +219,7 @@"streaming","tailwind","radix",- "recharts",+ "d3","markdown"],"homepage": "https://openui.com",diff --git a/packages/react-ui/src/components/Charts/AreaChart/AreaChart.tsx b/packages/react-ui/src/components/Charts/AreaChart/AreaChart.tsxindex d93e92fbb..3d28887d9 100644--- a/packages/react-ui/src/components/Charts/AreaChart/AreaChart.tsx+++ b/packages/react-ui/src/components/Charts/AreaChart/AreaChart.tsx@@ -1,448 +1,233 @@import clsx from "clsx";-import React, { useCallback, useEffect, useId, useMemo, useRef, useState } from "react";-import { Area, AreaChart as RechartsAreaChart, XAxis, YAxis } from "recharts";-import { usePrintContext } from "../../../context/PrintContext";-import { ChartConfig, ChartContainer, ChartTooltip } from "../Charts";-import { SideBarChartData, SideBarTooltipProvider } from "../context/SideBarTooltipContext";+import { useCallback, useMemo } from "react";+import {+ useCartesianChartOrchestrator,+ useEffectiveAnimation,useExportChartData,- useMaxLabelHeight,- useTransformedKeys,- useYAxisLabelWidth,+ useStackedData,+ useXScale,+ useYScale,} from "../hooks";-import {- ActiveDot,- cartesianGrid,- CustomTooltipContent,- DefaultLegend,- ScrollButtonsHorizontal,- SideBarTooltip,- XAxisTick,- YAxisTick,-} from "../shared";-import { LabelTooltipProvider } from "../shared/LabelTooltip/LabelTooltip";-import { LegendItem, XAxisTickVariant } from "../types";-import {- findNearestSnapPosition,- getSnapPositions,- getWidthOfData,- getWidthOfGroup,-} from "../utils/AreaAndLine/AreaAndLineUtils";-import { getLineType } from "../utils/AreaAndLine/common";-import { PaletteName, useChartPalette } from "../utils/PalletUtils";-import {- get2dChartConfig,- getColorForDataKey,- getDataKeys,- getLegendItems,-} from "../utils/dataUtils";-import { AreaChartData, AreaChartVariant } from "./types";--// this a technic to get the type of the onClick event of the bar chart-// we need to do this because the onClick event type is not exported by recharts-type AreaChartOnClick = React.ComponentProps<typeof RechartsAreaChart>["onClick"];-type AreaClickData = Parameters<NonNullable<AreaChartOnClick>>[0];--export interface AreaChartProps<T extends AreaChartData> {- data: T;- categoryKey: keyof T[number];- theme?: PaletteName;- customPalette?: string[];- variant?: AreaChartVariant;- tickVariant?: XAxisTickVariant;- grid?: boolean;- legend?: boolean;- icons?: Partial<Record<keyof T[number], React.ComponentType>>;- isAnimationActive?: boolean;- showYAxis?: boolean;- xAxisLabel?: React.ReactNode;- yAxisLabel?: React.ReactNode;- className?: string;- height?: number;- width?: number;+import { CartesianXAxis } from "../shared/cartesian/axes/CartesianXAxis";+import { CartesianChartLayout } from "../shared/cartesian/layouts/CartesianChartLayout";+import { LineDotCrosshair } from "../shared/cartesian/LineDotCrosshair";+import { findNearestDataIndex } from "../utils/mouseUtils";+import { AreaSeries } from "./parts/AreaSeries";+import { GradientDefs } from "./parts/GradientDefs";++import { CHART_CLASS_PREFIX } from "../utils/constants";+import type { AreaChartData, AreaChartProps } from "./types";++/**+ * Empty-data guard lives here, in a hook-free dispatcher: the chart impl below+ * calls hooks unconditionally, so the "no data" branch must short-circuit+ * *before* any hook runs (a count → 0 transition on a mounted chart would+ * otherwise break the Rules of Hooks).+ */+export function AreaChart<T extends AreaChartData>(props: AreaChartProps<T>) {+ if (!props.data || props.data.length === 0) {+ return (+ <div+ className={clsx(+ `${CHART_CLASS_PREFIX}-area-chart-container ${CHART_CLASS_PREFIX}-chart-empty`,+ props.className,+ )}+ >+ <span className={`${CHART_CLASS_PREFIX}-chart-empty-text`}>No data available</span>+ </div>+ );+ }+ return <AreaChartImpl {...props} />;}-const X_AXIS_PADDING = 36;-const CHART_CONTAINER_BOTTOM_MARGIN = 10;+// Stacked areas keep one running total per row — a negative value lowers the+// stack — matching Recharts' area charts (bars stack by sign instead).+const AREA_STACK_OFFSET = "none";-const AreaChartComponent = <T extends AreaChartData>({+function AreaChartImpl<T extends AreaChartData>({data,categoryKey,- theme = "ocean",customPalette,- variant: areaChartVariant = "natural",- tickVariant = "multiLine",+ variant = "natural",+ tickVariant: tickVariantProp,+ stacked = true,grid = true,- icons = {},+ legend: showLegend = true,+ icons,isAnimationActive = false,showYAxis = true,xAxisLabel,yAxisLabel,- legend = true,className,height,- width,-}: AreaChartProps<T>) => {- const printContext = usePrintContext();- isAnimationActive = printContext ? false : isAnimationActive;-- const dataKeys = useMemo(() => {- return getDataKeys(data, categoryKey as string);- }, [data, categoryKey]);-- const variant = getLineType(areaChartVariant);-- const { yAxisWidth, setLabelWidth } = useYAxisLabelWidth(data, dataKeys);-- const widthOfGroup = useMemo(() => {- return getWidthOfGroup(data);- }, [data]);-- const maxLabelHeight = useMaxLabelHeight(data, categoryKey as string, tickVariant, widthOfGroup);-- const transformedKeys = useTransformedKeys(dataKeys);-- const colors = useChartPalette({- chartThemeName: theme,- customPalette,+ width: fixedWidth,+ fitLegendInHeight,+ condensed = false,+ density,+ onClick,+ crosshair = false,+ highlight = false,+ activeDots = true,+ yTickCount,+}: AreaChartProps<T>) {+ const animate = useEffectiveAnimation(isAnimationActive);+ const mode = condensed ? "fit" : "scroll";++ const orch = useCartesianChartOrchestrator({+ layout: mode,+ data,+ categoryKey,themePaletteName: "areaChartPalette",- dataLength: dataKeys.length,- });-- const chartConfig: ChartConfig = useMemo(() => {- return get2dChartConfig(dataKeys, colors, transformedKeys, undefined, icons);- }, [dataKeys, icons, colors, transformedKeys]);-- const chartContainerRef = useRef<HTMLDivElement>(null);- const mainContainerRef = useRef<HTMLDivElement>(null);- const [containerWidth, setContainerWidth] = useState<number>(0);- const [canScrollLeft, setCanScrollLeft] = useState(false);- const [canScrollRight, setCanScrollRight] = useState(false);- const [isSideBarTooltipOpen, setIsSideBarTooltipOpen] = useState(false);- const [isLegendExpanded, setIsLegendExpanded] = useState(false);- const [sideBarTooltipData, setSideBarTooltipData] = useState<SideBarChartData>({- title: "",- values: [],+ customPalette,+ showLegend,+ showYAxis,+ height,+ fixedWidth,+ fitLegendInHeight,+ tickVariantProp: tickVariantProp ?? (condensed ? "singleLine" : "multiLine"),+ chartIdPrefix: "d3ac",+ icons,+ onClick,+ density,+ stacked,+ stackOffset: AREA_STACK_OFFSET,+ yTickCount,});- // Use provided width or observed width- const effectiveWidth = useMemo(() => {- return width ?? containerWidth;- }, [width, containerWidth]);-- const effectiveContainerWidth = useMemo(() => {- const dynamicYAxisWidth = showYAxis ? yAxisWidth : 0;- return Math.max(0, effectiveWidth - dynamicYAxisWidth - 40); // -40 because we are giving 20px padding in xAxis on each side- }, [effectiveWidth, showYAxis, yAxisWidth]);-- const dataWidth = useMemo(() => {- return getWidthOfData(data, effectiveContainerWidth);- }, [data, effectiveContainerWidth]);-- // Calculate snap positions for proper scrolling alignment- const snapPositions = useMemo(() => {- return getSnapPositions(data);- }, [data]);-- const chartHeight = useMemo(() => {- return height ?? 296 + maxLabelHeight;- }, [height, maxLabelHeight]);-- // Check scroll boundaries- const updateScrollState = useCallback(() => {- if (mainContainerRef.current) {- const { scrollLeft, scrollWidth, clientWidth } = mainContainerRef.current;- setCanScrollLeft(scrollLeft > 0);- setCanScrollRight(scrollLeft < scrollWidth - clientWidth - 1); // -1 for floating point precision- }- }, []);-- const scrollLeft = useCallback(() => {- if (mainContainerRef.current) {- const currentScroll = mainContainerRef.current.scrollLeft;- const targetIndex = findNearestSnapPosition(snapPositions, currentScroll, "left");- const targetPosition = snapPositions[targetIndex] ?? 0;-- mainContainerRef.current.scrollTo({- left: targetPosition,- behavior: "smooth",- });- }- }, [snapPositions]);-- const scrollRight = useCallback(() => {- if (mainContainerRef.current) {- const currentScroll = mainContainerRef.current.scrollLeft;- const targetIndex = findNearestSnapPosition(snapPositions, currentScroll, "right");- const targetPosition = snapPositions[targetIndex] ?? 0;-- mainContainerRef.current.scrollTo({- left: targetPosition,- behavior: "smooth",- });- }- }, [snapPositions]);-- useEffect(() => {- // Only set up ResizeObserver if width is not provided- if (width || !chartContainerRef.current) {- return () => {};+ const xScale = useXScale(+ data,+ orch.data.catKey,+ orch.dimensions.chartAreaWidth,+ orch.dimensions.widthOfGroup,+ );+ const stackedData = useStackedData(data, orch.data.dataKeys, stacked, AREA_STACK_OFFSET);++ // Unstacked series whose values are entirely <= 0 hang below the zero line —+ // flip their fill gradient so the strongest opacity stays at the data edge.+ // Stacked series sit on the running total, so their gradient never flips.+ const negativeKeys = useMemo(() => {+ const keys = new Set<string>();+ if (stacked) return keys;+ for (const key of orch.data.dataKeys) {+ let max = -Infinity;+ for (const row of data) max = Math.max(max, Number(row[key]) || 0);+ if (max <= 0) keys.add(key);}+ return keys;+ }, [data, orch.data.dataKeys, stacked]);+ const yScale = useYScale(+ data,+ orch.data.dataKeys,+ orch.dimensions.chartInnerHeight,+ stacked,+ AREA_STACK_OFFSET,+ );- const resizeObserver = new ResizeObserver((entries) => {- // there is only one entry in the entries array because we are observing the chart container- for (const entry of entries) {- setContainerWidth(entry.contentRect.width);+ const getYValue = useCallback(+ (_row: Record<string, string | number>, key: string, seriesIndex: number) => {+ if (stackedData && orch.hover.hoveredIndex !== null) {+ const series = stackedData[seriesIndex];+ const point = series?.[orch.hover.hoveredIndex];+ // The running total after this series — the edge its line is drawn on.+ return point ? point[1] : 0;}- });-- resizeObserver.observe(chartContainerRef.current);- setContainerWidth(chartContainerRef.current.getBoundingClientRect().width);-- return () => {- resizeObserver.disconnect();- };- }, [width]);-- // Update scroll state when container width or data width changes- useEffect(() => {- updateScrollState();- }, [effectiveWidth, dataWidth, updateScrollState]);-- useEffect(() => {- setIsSideBarTooltipOpen(false);- setIsLegendExpanded(false);- }, [dataKeys]);-- // Add scroll event listener to update button states- useEffect(() => {- const mainContainer = mainContainerRef.current;- if (!mainContainer) return;-- const handleScroll = () => {- updateScrollState();- };-- mainContainer.addEventListener("scroll", handleScroll);- return () => {- mainContainer.removeEventListener("scroll", handleScroll);- };- }, [updateScrollState]);+ return Number(_row[key]) || 0;+ },+ [stackedData, orch.hover.hoveredIndex],+ );- const legendItems: LegendItem[] = useMemo(() => {- return getLegendItems(dataKeys, colors, icons);- }, [dataKeys, colors, icons]);+ const findIndex = useCallback((mouseX: number) => findNearestDataIndex(xScale, mouseX), [xScale]);+ const mouseHandlers = orch.hover.createMouseHandlers(findIndex);+ // PPTX print-export JSON — mirrors react-ui's AreaChart call (type:'area',+ // no extraOptions). Undefined off the print path.const exportData = useExportChartData({type: "area",data,- categoryKey: categoryKey as string,- dataKeys,- colors,- legend,+ categoryKey: orch.data.catKey,+ dataKeys: orch.data.dataKeys,+ colors: orch.data.colors,+ legend: showLegend,xAxisLabel,yAxisLabel,});- const id = useId();-- const gradientID = useMemo(() => `area-chart-gradient-${id}`, [id]);-- const onAreaClick = useCallback(- (data: AreaClickData) => {- if (data?.activePayload?.length && data.activePayload.length > 10) {- setIsSideBarTooltipOpen(true);- setSideBarTooltipData({- title: data.activeLabel as string,- values: data.activePayload.map((payload) => ({- value: payload.value as number,- label: payload.name || payload.dataKey,- color: getColorForDataKey(payload.dataKey, dataKeys, colors),- })),- });+ return (+ <CartesianChartLayout+ orch={orch}+ yScale={yScale}+ mouseHandlers={mouseHandlers}+ classPrefix="area-chart"+ chartType="area"+ exportData={exportData}+ ariaLabel="Area chart"+ showYAxis={showYAxis}+ grid={grid}+ showLegend={showLegend}+ xAxisLabel={xAxisLabel}+ yAxisLabel={yAxisLabel}+ yTickCount={yTickCount}+ className={className}+ defs={+ <GradientDefs+ negativeKeys={negativeKeys}+ dataKeys={orch.data.dataKeys}+ transformedKeys={orch.data.transformedKeys}+ colors={orch.data.colorMap}+ chartId={orch.identity.chartId}+ chartWidth={orch.dimensions.chartAreaWidth}+ chartHeight={orch.dimensions.chartInnerHeight}+ />}- },- [dataKeys, colors],- );-- const yAxis = useMemo(() => {- if (!showYAxis) {- return null;- }- return (- <div className="openui-area-chart-y-axis-container">- {/* Y-axis only chart - synchronized with main chart */}- <RechartsAreaChart- key={`y-axis-chart-${id}`}- width={yAxisWidth}- height={chartHeight}- data={data}- margin={{- top: 20,- bottom: maxLabelHeight + CHART_CONTAINER_BOTTOM_MARGIN, // this is required for to give space for x-axis- left: 0,- right: 0,- }}- >- <YAxis- width={yAxisWidth}- tickLine={false}- axisLine={false}- tick={<YAxisTick setLabelWidth={setLabelWidth} />}+ series={+ <>+ <AreaSeries+ data={data}+ dataKeys={orch.data.dataKeys}+ xScale={xScale}+ yScale={yScale}+ variant={variant}+ stackedData={stackedData}+ categoryKey={orch.data.catKey}+ transformedKeys={orch.data.transformedKeys}+ colors={orch.data.colorMap}+ chartId={orch.identity.chartId}+ isAnimationActive={animate}/>- {/* Invisible area to maintain scale synchronization */}- {dataKeys.map((key) => {- return (- <Area- key={`y-axis-${key}`}- dataKey={key}- type={variant}- stroke="none"- fill="transparent"- fillOpacity={0}- stackId="a"- />- );- })}- </RechartsAreaChart>- </div>- );- }, [showYAxis, chartHeight, data, dataKeys, variant, id, maxLabelHeight, yAxisWidth]);-- return (- <LabelTooltipProvider>- <SideBarTooltipProvider- isSideBarTooltipOpen={isSideBarTooltipOpen}- setIsSideBarTooltipOpen={setIsSideBarTooltipOpen}- data={sideBarTooltipData}- setData={setSideBarTooltipData}- >- <div- className={clsx("openui-area-chart-container", className)}- data-openui-chart={exportData}- style={{- width: width ? `${width}px` : undefined,- }}- >- <div className="openui-area-chart-container-inner" ref={chartContainerRef}>- {/* Y-axis of the chart */}- {yAxis}- <div className="openui-area-chart-main-container" ref={mainContainerRef}>- <ChartContainer- config={chartConfig}- style={{ width: dataWidth, minWidth: "100%", height: chartHeight }}- rechartsProps={{- width: "100%",- height: "100%",- minHeight: 1,- minWidth: 1,- initialDimension: { width: 1, height: 1 },- }}- >- <RechartsAreaChart- accessibilityLayer- key={`area-chart-${id}`}- data={data}- margin={{- top: 20,- bottom: CHART_CONTAINER_BOTTOM_MARGIN,- }}- onClick={onAreaClick}- >- {grid && cartesianGrid()}- <XAxis- dataKey={categoryKey as string}- tickLine={false}- axisLine={false}- textAnchor="middle"- interval={0}- height={maxLabelHeight}- tick={- <XAxisTick- variant={tickVariant}- widthOfGroup={widthOfGroup}- labelHeight={maxLabelHeight}- />- }- orientation="bottom"- padding={{- left: X_AXIS_PADDING,- right: X_AXIS_PADDING,- }}- />-- <ChartTooltip- content={<CustomTooltipContent parentRef={mainContainerRef} />}- offset={15}- />-- {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={`main-${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}- />- );- })}- </RechartsAreaChart>- </ChartContainer>- </div>- {isSideBarTooltipOpen && <SideBarTooltip height={chartHeight} />}- </div>- {/* if the data width is greater than the effective width, then show the scroll buttons */}- <ScrollButtonsHorizontal- dataWidth={dataWidth}- effectiveWidth={effectiveWidth}- canScrollLeft={canScrollLeft}- canScrollRight={canScrollRight}- isSideBarTooltipOpen={isSideBarTooltipOpen}- onScrollLeft={scrollLeft}- onScrollRight={scrollRight}+ <LineDotCrosshair+ hoveredIndex={orch.hover.hoveredIndex}+ xScale={xScale}+ yScale={yScale}+ data={data}+ dataKeys={orch.data.dataKeys}+ categoryKey={orch.data.catKey}+ colors={orch.data.colorMap}+ chartHeight={orch.dimensions.chartInnerHeight}+ getYValue={getYValue}+ classPrefix={`${CHART_CLASS_PREFIX}-area-chart`}+ crosshair={crosshair}+ highlight={highlight}+ activeDots={activeDots}/>- {legend && (- <DefaultLegend- items={legendItems}- yAxisLabel={yAxisLabel}- xAxisLabel={xAxisLabel}- containerWidth={effectiveWidth}- isExpanded={isLegendExpanded}- setIsExpanded={setIsLegendExpanded}- />- )}- </div>- </SideBarTooltipProvider>- </LabelTooltipProvider>+ </>+ }+ xAxis={+ <CartesianXAxis+ mode={mode}+ scale={xScale}+ classPrefix={`${CHART_CLASS_PREFIX}-area-chart`}+ tickVariant={orch.dimensions.tickVariant}+ widthOfGroup={orch.dimensions.widthOfGroup}+ labelHeight={orch.xAxis.xAxisHeight}+ labelWidth={orch.xAxis.labelWidth}+ maxLines={orch.xAxis.maxLines}+ labelInterval={orch.dimensions.labelInterval}+ angle={orch.xAxis.angle}+ chartWidth={orch.dimensions.chartAreaWidth}+ yAxisWidth={orch.dimensions.effectiveYAxisWidth}+ />+ }+ />);-};--// Added React.memo for performance optimization to avoid unnecessary re-renders-export const AreaChart = React.memo(AreaChartComponent) as typeof AreaChartComponent;+}diff --git a/packages/react-ui/src/components/Charts/AreaChart/AreaChartCondensed.tsx b/packages/react-ui/src/components/Charts/AreaChart/AreaChartCondensed.tsxnew file mode 100644index 000000000..cc903bb7b--- /dev/null+++ b/packages/react-ui/src/components/Charts/AreaChart/AreaChartCondensed.tsx@@ -0,0 +1,9 @@+import { AreaChart } from "./AreaChart";+import type { AreaChartData, AreaChartProps } from "./types";++export type AreaChartCondensedProps<T extends AreaChartData> = Omit<AreaChartProps<T>, "condensed">;++/** An `AreaChart` that fits its container's width instead of scrolling. */+export const AreaChartCondensed = <T extends AreaChartData>(props: AreaChartCondensedProps<T>) => (+ <AreaChart {...props} condensed />+);diff --git a/packages/react-ui/src/components/Charts/AreaChart/areaChart.scss b/packages/react-ui/src/components/Charts/AreaChart/areaChart.scssindex 2ae25dd3b..2203eb1a1 100644--- a/packages/react-ui/src/components/Charts/AreaChart/areaChart.scss+++ b/packages/react-ui/src/components/Charts/AreaChart/areaChart.scss@@ -1,25 +1,33 @@-@use "../../../cssUtils" as cssUtils;+@use "../shared/cartesian/chartBase" as base;+@use "../prefix" as brand;-.openui-area-chart-container-inner {- display: flex;- width: 100%;+@include base.chart-base("area-chart");+@include base.crosshair-styles("area-chart");++// No `transition: d` here: data-change motion is the spring data morph in+// AreaSeries (gated on isAnimationActive). A CSS transition restarted from+// progress 0 on every attribute write, so per-frame streaming rewrites pinned+// the rendered geometry (and would fight the morph's per-tick writes).+.#{brand.$prefix}-area-chart-area-path {+ transition: opacity 0.2s ease;}-.openui-area-chart-y-axis-container {- flex-shrink: 0;+.#{brand.$prefix}-area-chart-area-line {+ fill: none;+ stroke-width: 2;}-.openui-area-chart-main-container {- width: 100%;- overflow-x: auto;- /* Hide scrollbar for Chrome, Safari and Opera */- &::-webkit-scrollbar {- display: none;+// Entrances are decorative: gate the whole rule (pre-state included) behind+// reduced-motion so users who opt out get the natural static state immediately+// — gating only the animation would strand elements at the opacity: 0 start.+@media (prefers-reduced-motion: no-preference) {+ .#{brand.$prefix}-area-chart-area-line--animated {+ stroke-dasharray: var(--path-length);+ stroke-dashoffset: var(--path-length);+ animation: #{brand.$prefix}-draw-line 1s ease-out forwards;+ }+ .#{brand.$prefix}-area-chart-area-path--animated {+ opacity: 0;+ animation: #{brand.$prefix}-fade-appear 0.6s ease-out 0.4s forwards;}-- /* Hide scrollbar for Firefox */- scrollbar-width: none;-- /* Hide scrollbar for IE and Edge */- -ms-overflow-style: none;}diff --git a/packages/react-ui/src/components/Charts/AreaChart/dependencies.ts b/packages/react-ui/src/components/Charts/AreaChart/dependencies.tsdeleted file mode 100644index 5819b0194..000000000--- a/packages/react-ui/src/components/Charts/AreaChart/dependencies.ts+++ /dev/null@@ -1,2 +0,0 @@-const dependencies = ["AreaChart", "IconButton"];-export default dependencies;diff --git a/packages/react-ui/src/components/Charts/AreaChart/index.ts b/packages/react-ui/src/components/Charts/AreaChart/index.tsindex 72dd774a1..8806678c1 100644--- a/packages/react-ui/src/components/Charts/AreaChart/index.ts+++ b/packages/react-ui/src/components/Charts/AreaChart/index.ts@@ -1,2 +1,4 @@-export * from "./AreaChart";-export * from "./types";+export { AreaChart } from "./AreaChart";+export { AreaChartCondensed } from "./AreaChartCondensed";+export type { AreaChartCondensedProps } from "./AreaChartCondensed";+export type { AreaChartData, AreaChartProps, AreaChartVariant } from "./types";diff --git a/packages/react-ui/src/components/D3Charts/AreaChart/parts/AreaSeries.tsx b/packages/react-ui/src/components/Charts/AreaChart/parts/AreaSeries.tsxsimilarity index 100%rename from packages/react-ui/src/components/D3Charts/AreaChart/parts/AreaSeries.tsxrename to packages/react-ui/src/components/Charts/AreaChart/parts/AreaSeries.tsxdiff --git a/packages/react-ui/src/components/D3Charts/AreaChart/parts/GradientDefs.tsx b/packages/react-ui/src/components/Charts/AreaChart/parts/GradientDefs.tsxsimilarity index 100%rename from packages/react-ui/src/components/D3Charts/AreaChart/parts/GradientDefs.tsxrename to packages/react-ui/src/components/Charts/AreaChart/parts/GradientDefs.tsxdiff --git a/packages/react-ui/src/components/Charts/AreaChart/stories/areaChart.stories.tsx b/packages/react-ui/src/components/Charts/AreaChart/stories/areaChart.stories.tsxindex 8b41b4f5c..4d9b90267 100644--- a/packages/react-ui/src/components/Charts/AreaChart/stories/areaChart.stories.tsx+++ b/packages/react-ui/src/components/Charts/AreaChart/stories/areaChart.stories.tsx@@ -10,8 +10,8 @@ import {Watch,} from "lucide-react";import { useState } from "react";+import { AreaChart, AreaChartProps } from "../..";import { Card } from "../../../Card";-import { AreaChart, AreaChartProps } from "../AreaChart";// 🔥 COMPREHENSIVE DATA VARIATIONS - Designed to test label collision scenariosconst dataVariations = {@@ -468,7 +468,7 @@ const icons = {* - **Responsive Design**: Adapts fluidly to its container's size.** ### Customization- * - **Theming**: Comes with six pre-built color palettes.+ * - **Colors**: Uses the ThemeProvider's chart palette, or custom colors with `customPalette`.* - **Area Styles**: Supports `linear`, `natural` (smooth), and `step` interpolation.* - **Styling Options**: Control grid visibility, axes, and more.*/@@ -495,7 +495,6 @@ const trafficData = [<ScrollableAreaChartdata={trafficData}categoryKey="date"- theme="ocean"/>\`\`\`@@ -544,19 +543,8 @@ const salesData = [category: "📊 Data Configuration",},},- theme: {- description:- "Specifies the color palette for the chart's areas, tooltips, and legend. Ignored when customPalette is provided.",- control: "select",- options: ["ocean", "orchid", "emerald", "sunset", "spectrum", "vivid"],- table: {- defaultValue: { summary: "ocean" },- category: "🎨 Visual Styling",- },- },customPalette: {- description:- "Custom array of colors to use instead of the theme palette. Overrides the theme prop when provided.",+ description: "Custom array of colors to use instead of the ThemeProvider's chart palette.",control: "object",table: {type: { summary: "string[]" },@@ -676,7 +664,6 @@ export const DataExplorer: Story = {args: {data: areaChartData,categoryKey: "month",- theme: "ocean",variant: "natural",grid: true,legend: true,@@ -831,7 +818,6 @@ export const BigLabelsStory: Story = {args: {data: dataVariations.bigLabels as any,categoryKey: "category" as any,- theme: "emerald",variant: "natural",grid: true,legend: true,@@ -865,7 +851,6 @@ export const DenseTimelineStory: Story = {args: {data: dataVariations.denseTimeline as any,categoryKey: "period" as any,- theme: "sunset",variant: "natural",grid: true,legend: true,@@ -898,7 +883,6 @@ export const CompanyNamesStory: Story = {args: {data: dataVariations.companyNames as any,categoryKey: "company" as any,- theme: "vivid",variant: "natural",grid: true,legend: true,@@ -931,7 +915,6 @@ export const CountryDataStory: Story = {args: {data: dataVariations.countryData as any,categoryKey: "country" as any,- theme: "orchid",variant: "natural",grid: true,legend: true,@@ -964,7 +947,6 @@ export const MixedLengthsStory: Story = {args: {data: dataVariations.mixedLengths as any,categoryKey: "item" as any,- theme: "spectrum",variant: "linear",grid: true,legend: true,@@ -997,7 +979,6 @@ export const EdgeCasesStory: Story = {args: {data: dataVariations.edgeCases as any,categoryKey: "name" as any,- theme: "ocean",variant: "step",grid: true,legend: true,@@ -1030,7 +1011,6 @@ export const MinimalDataStory: Story = {args: {data: dataVariations.minimal as any,categoryKey: "category" as any,- theme: "emerald",variant: "natural",grid: true,legend: true,@@ -1064,7 +1044,6 @@ export const ExpandCollapseMarketingStory: Story = {args: {data: dataVariations.expandCollapseMarketing as any,categoryKey: "channel" as any,- theme: "vivid",variant: "natural",grid: true,legend: true,@@ -1099,7 +1078,6 @@ export const CustomPaletteStory: Story = {args: {data: dataVariations.default as any,categoryKey: "month" as any,- theme: "ocean", // This will be overridden by customPalettevariant: "natural",grid: true,legend: true,@@ -1161,7 +1139,7 @@ export const CustomPaletteStory: Story = {docs: {description: {story:- 'Demonstrates how to use the `customPalette` prop to provide your own color scheme for the chart. When `customPalette` is provided, it overrides the `theme` prop and uses your specified colors instead of the predefined theme palettes.\n\n**Key Features:**\n- 🎨 **Custom Colors**: Override default theme colors with your own palette\n- 🔄 **Theme Override**: The `theme` prop is ignored when `customPalette` is provided\n- 📊 **Consistent Distribution**: Colors are distributed evenly across data series\n- 🎯 **Brand Matching**: Perfect for matching your application\'s brand colors\n\n**Usage:**\n```tsx\n<AreaChart\n data={data}\n categoryKey="month"\n customPalette={["#FF6B6B", "#4ECDC4", "#45B7D1"]}\n // theme prop is ignored when customPalette is provided\n/>\n```',+ 'Demonstrates how to use the `customPalette` prop to provide your own color scheme for the chart. When `customPalette` is provided, it overrides the ThemeProvider\'s chart palette and uses your specified colors instead.\n\n**Key Features:**\n- 🎨 **Custom Colors**: Override the default chart colors with your own palette\n- 📊 **Consistent Distribution**: Colors are distributed evenly across data series\n- 🎯 **Brand Matching**: Perfect for matching your application\'s brand colors\n\n**Usage:**\n```tsx\n<AreaChart\n data={data}\n categoryKey="month"\n customPalette={["#FF6B6B", "#4ECDC4", "#45B7D1"]}\n/>\n```',},},},@@ -1183,7 +1161,6 @@ export const ResponsiveBehaviorDemo: Story = {args: {data: dataVariations.bigLabels as any,categoryKey: "category" as any,- theme: "sunset",variant: "natural",grid: true,legend: true,diff --git a/packages/react-ui/src/components/Charts/AreaChartCondensed/stories/areaChartCondensed.stories.tsx b/packages/react-ui/src/components/Charts/AreaChart/stories/areaChartCondensed.stories.tsxsimilarity index 95%rename from packages/react-ui/src/components/Charts/AreaChartCondensed/stories/areaChartCondensed.stories.tsxrename to packages/react-ui/src/components/Charts/AreaChart/stories/areaChartCondensed.stories.tsxindex b862b0e7a..ff4f2b794 100644--- a/packages/react-ui/src/components/Charts/AreaChartCondensed/stories/areaChartCondensed.stories.tsx+++ b/packages/react-ui/src/components/Charts/AreaChart/stories/areaChartCondensed.stories.tsx@@ -10,8 +10,8 @@ import {Watch,} from "lucide-react";import { useState } from "react";+import { AreaChartCondensed, AreaChartCondensedProps } from "../..";import { Card } from "../../../Card";-import { AreaChartCondensed, AreaChartCondensedProps } from "../AreaChartCondensed";// 🔥 COMPREHENSIVE DATA VARIATIONS - Designed to test various scenariosconst dataVariations = {@@ -259,7 +259,7 @@ const icons = {* - **Responsive Design**: Adapts fluidly to its container's size** ### Customization- * - **Theming**: Comes with six pre-built color palettes+ * - **Colors**: Uses the ThemeProvider's chart palette, or custom colors with `customPalette`* - **Area Styles**: Supports `linear`, `natural` (smooth), and `step` interpolation* - **Styling Options**: Control grid visibility, axes, and more*/@@ -286,7 +286,6 @@ const trafficData = [<AreaChartdata={trafficData}categoryKey="date"- theme="ocean"height={200}/>\`\`\`@@ -343,19 +342,8 @@ const salesData = [category: "📊 Data Configuration",},},- theme: {- description:- "Specifies the color palette for the chart's areas and tooltips. Ignored when customPalette is provided.",- control: "select",- options: ["ocean", "orchid", "emerald", "sunset", "spectrum", "vivid"],- table: {- defaultValue: { summary: "ocean" },- category: "🎨 Visual Styling",- },- },customPalette: {- description:- "Custom array of colors to use instead of the theme palette. Overrides the theme prop when provided.",+ description: "Custom array of colors to use instead of the ThemeProvider's chart palette.",control: "object",table: {type: { summary: "string[]" },@@ -373,7 +361,7 @@ const salesData = [},tickVariant: {description:- "X-axis tick label style. Choose between 'singleLine' (horizontal) or 'angled' (rotated at optimal angle).",+ "X-axis tick label style. Choose between 'singleLine' (horizontal) or 'angled' (rotated 45° when they don't fit).",control: "radio",options: ["singleLine", "angled"],table: {@@ -478,7 +466,6 @@ export const DataExplorer: Story = {args: {data: areaChartCondensedData,categoryKey: "month",- theme: "ocean",variant: "natural",tickVariant: "singleLine",grid: true,@@ -862,7 +849,6 @@ export const LargeDatasetWithSidebarTooltip: Story = {},] as any,categoryKey: "month" as any,- theme: "ocean",variant: "natural",tickVariant: "singleLine",grid: true,@@ -926,7 +912,6 @@ export const BigLabelsStory: Story = {args: {data: dataVariations.bigLabels as any,categoryKey: "category" as any,- theme: "emerald",variant: "natural",tickVariant: "angled",grid: true,@@ -943,7 +928,7 @@ export const BigLabelsStory: Story = {docs: {description: {story:- "Tests the chart with extremely long category names. The angled tick variant automatically rotates labels at an optimal angle to prevent overlapping and maximize readability.",+ "Tests the chart with extremely long category names. The angled tick variant rotates labels 45° to prevent overlapping and maximize readability.",},},},@@ -960,7 +945,6 @@ export const DenseTimelineStory: Story = {args: {data: dataVariations.denseTimeline as any,categoryKey: "period" as any,- theme: "sunset",variant: "natural",tickVariant: "angled",grid: true,@@ -994,7 +978,6 @@ export const CompanyNamesStory: Story = {args: {data: dataVariations.companyNames as any,categoryKey: "company" as any,- theme: "vivid",variant: "natural",tickVariant: "angled",grid: true,@@ -1028,7 +1011,6 @@ export const CountryDataStory: Story = {args: {data: dataVariations.countryData as any,categoryKey: "country" as any,- theme: "orchid",variant: "natural",tickVariant: "angled",grid: true,@@ -1062,7 +1044,6 @@ export const MixedLengthsStory: Story = {args: {data: dataVariations.mixedLengths as any,categoryKey: "item" as any,- theme: "spectrum",variant: "linear",tickVariant: "singleLine",grid: true,@@ -1095,7 +1076,6 @@ export const EdgeCasesStory: Story = {args: {data: dataVariations.edgeCases as any,categoryKey: "name" as any,- theme: "ocean",variant: "step",tickVariant: "angled",grid: true,@@ -1129,7 +1109,6 @@ export const MinimalDataStory: Story = {args: {data: dataVariations.minimal as any,categoryKey: "category" as any,- theme: "emerald",variant: "natural",tickVariant: "singleLine",grid: true,@@ -1163,7 +1142,6 @@ export const CustomPaletteStory: Story = {args: {data: dataVariations.default as any,categoryKey: "month" as any,- theme: "ocean", // This will be overridden by customPalettevariant: "natural",tickVariant: "singleLine",grid: true,@@ -1228,7 +1206,7 @@ export const CustomPaletteStory: Story = {docs: {description: {story:- 'Demonstrates how to use the `customPalette` prop to provide your own color scheme. When `customPalette` is provided, it overrides the `theme` prop.\n\n**Usage:**\n```tsx\n<AreaChartCondensed\n data={data}\n categoryKey="month"\n customPalette={["#FF6B6B", "#4ECDC4", "#45B7D1"]}\n/>\n```',+ 'Demonstrates how to use the `customPalette` prop to provide your own color scheme. When `customPalette` is provided, it overrides the ThemeProvider\'s chart palette.\n\n**Usage:**\n```tsx\n<AreaChartCondensed\n data={data}\n categoryKey="month"\n customPalette={["#FF6B6B", "#4ECDC4", "#45B7D1"]}\n/>\n```',},},},@@ -1250,14 +1228,13 @@ export const TickVariantComparison: Story = {Single Line Variant (Horizontal)</div><div style={{ fontSize: "13px", color: "#666" }}>- Standard horizontal labels. Recharts automatically hides overlapping labels.+ Standard horizontal labels, truncated with an ellipsis when they don't fit.</div></div><AreaChartCondenseddata={dataVariations.bigLabels as any}categoryKey="category"tickVariant="singleLine"- theme="ocean"height={200}/></Card>@@ -1267,14 +1244,13 @@ export const TickVariantComparison: Story = {Angled Variant (Rotated)</div><div style={{ fontSize: "13px", color: "#666" }}>- Automatically rotates labels at an optimal angle. Shows more labels without collision.+ Rotates labels 45° when they don't fit horizontally.</div></div><AreaChartCondenseddata={dataVariations.bigLabels as any}categoryKey="category"tickVariant="angled"- theme="emerald"height={260}/></Card>@@ -1284,7 +1260,7 @@ export const TickVariantComparison: Story = {docs: {description: {story:- "**Side-by-side comparison** of tick variants:\n\n- **Single Line**: Standard horizontal labels with automatic collision detection. Recharts hides overlapping labels.\n- **Angled**: Rotates labels at an optimal angle calculated based on label width and available space. Shows more labels without collision.\n\n**When to use each:**\n- Use **singleLine** for short labels or when you have few data points\n- Use **angled** for long labels or many data points where horizontal labels would overlap",+ "**Side-by-side comparison** of tick variants:\n\n- **Single Line**: Standard horizontal labels, truncated with an ellipsis when they don't fit.\n- **Angled**: Rotates labels 45° when they don't fit horizontally.\n\n**When to use each:**\n- Use **singleLine** for short labels or when you have few data points\n- Use **angled** for long labels or many data points where horizontal labels would overlap",},},},@@ -1301,7 +1277,6 @@ export const ResponsiveBehaviorDemo: Story = {args: {data: dataVariations.bigLabels as any,categoryKey: "category" as any,- theme: "sunset",variant: "natural",tickVariant: "angled",grid: true,diff --git a/packages/react-ui/src/components/D3Charts/AreaChart/types.ts b/packages/react-ui/src/components/Charts/AreaChart/types.tssimilarity index 100%rename from packages/react-ui/src/components/D3Charts/AreaChart/types.tsrename to packages/react-ui/src/components/Charts/AreaChart/types.tsdiff --git a/packages/react-ui/src/components/Charts/AreaChart/types/index.ts b/packages/react-ui/src/components/Charts/AreaChart/types/index.tsdeleted file mode 100644index b01afe131..000000000--- a/packages/react-ui/src/components/Charts/AreaChart/types/index.ts+++ /dev/null@@ -1,3 +0,0 @@-export type AreaChartVariant = "linear" | "natural" | "step";--export type AreaChartData = Array<Record<string, string | number>>;diff --git a/packages/react-ui/src/components/Charts/AreaChartCondensed/AreaChartCondensed.tsx b/packages/react-ui/src/components/Charts/AreaChartCondensed/AreaChartCondensed.tsxdeleted file mode 100644index ea3f13eda..000000000--- a/packages/react-ui/src/components/Charts/AreaChartCondensed/AreaChartCondensed.tsx+++ /dev/null@@ -1,410 +0,0 @@-import clsx from "clsx";-import React, { useCallback, useEffect, useId, useMemo, useRef, useState } from "react";-import { Area, AreaChart as RechartsAreaChart, XAxis, YAxis } from "recharts";-import { usePrintContext } from "../../../context/PrintContext";-import { AreaChartData, AreaChartVariant } from "../AreaChart/types";-import { ChartConfig, ChartContainer, ChartTooltip } from "../Charts";-import { DEFAULT_X_AXIS_HEIGHT, X_AXIS_PADDING } from "../constants";-import { SideBarChartData, SideBarTooltipProvider } from "../context/SideBarTooltipContext";-import {- useAutoAngleCalculation,- useExportChartData,- useMaxLabelWidth,- useTransformedKeys,- useYAxisLabelWidth,-} from "../hooks";-import {- ActiveDot,- cartesianGrid,- CustomTooltipContent,- DefaultLegend,- SideBarTooltip,- SVGXAxisTick,- SVGXAxisTickVariant,- YAxisTick,-} from "../shared";-import { LabelTooltipProvider } from "../shared/LabelTooltip/LabelTooltip";-import { LegendItem } from "../types";-import { getLineType } from "../utils/AreaAndLine/common";-import {- get2dChartConfig,- getColorForDataKey,- getDataKeys,- getLegendItems,-} from "../utils/dataUtils";-import { PaletteName, useChartPalette } from "../utils/PalletUtils";--// this a technic to get the type of the onClick event of the area chart-// we need to do this because the onClick event type is not exported by recharts-type AreaChartOnClick = React.ComponentProps<typeof RechartsAreaChart>["onClick"];-type AreaClickData = Parameters<NonNullable<AreaChartOnClick>>[0];--export interface AreaChartCondensedProps<T extends AreaChartData> {- data: T;- categoryKey: keyof T[number];- theme?: PaletteName;- customPalette?: string[];- variant?: AreaChartVariant;- tickVariant?: SVGXAxisTickVariant;- grid?: boolean;- icons?: Partial<Record<keyof T[number], React.ComponentType>>;- isAnimationActive?: boolean;- showYAxis?: boolean;- xAxisLabel?: React.ReactNode;- yAxisLabel?: React.ReactNode;- legend?: boolean;- className?: string;- height?: number;- width?: number;-}--const CHART_HEIGHT = 296;-const CHART_CONTAINER_BOTTOM_MARGIN = 10;--const AreaChartCondensedComponent = <T extends AreaChartData>({- data,- categoryKey,- theme = "ocean",- customPalette,- variant: areaChartVariant = "natural",- tickVariant = "singleLine",- grid = true,- icons = {},- isAnimationActive = false,- showYAxis = true,- xAxisLabel,- yAxisLabel,- legend = true,- className,- height = CHART_HEIGHT,- width,-}: AreaChartCondensedProps<T>) => {- const printContext = usePrintContext();- isAnimationActive = printContext ? false : isAnimationActive;-- const dataKeys = useMemo(() => {- return getDataKeys(data, categoryKey as string);- }, [data, categoryKey]);-- const variant = getLineType(areaChartVariant);-- const { yAxisWidth, setLabelWidth } = useYAxisLabelWidth(data, dataKeys);-- const maxLabelWidth = useMaxLabelWidth(data, categoryKey as string);-- const chartContainerRef = useRef<HTMLDivElement>(null);- const [chartContainerWidth, setChartContainerWidth] = useState<number>(0);-- const widthOfData = useMemo(() => {- if (data.length === 0) {- return 0;- }- // Use passed width if available, otherwise use observed chartContainerWidth- const chartWidth = width ?? chartContainerWidth;- return chartWidth / data.length;- }, [width, chartContainerWidth, data]);-- const { angle: calculatedAngle, height: xAxisHeight } = useAutoAngleCalculation(- maxLabelWidth,- tickVariant === "angled",- // if the max label width is less than 100px, then we use the width of the data to calculate the angle, gives better results for small datasets- maxLabelWidth < 100 ? widthOfData : undefined,- );-- const isAngled = useMemo(() => {- return calculatedAngle !== 0;- }, [calculatedAngle]);-- const effectiveHeight = useMemo(() => {- if (tickVariant === "angled") {- return xAxisHeight + height;- }- return height + DEFAULT_X_AXIS_HEIGHT;- }, [height, xAxisHeight, tickVariant]);-- 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 exportData = useExportChartData({- type: "area",- data,- categoryKey: categoryKey as string,- dataKeys,- colors,- legend,- xAxisLabel,- yAxisLabel,- });- 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 onAreaClick = useCallback(- (data: AreaClickData) => {- if (data?.activePayload?.length && data.activePayload.length > 10) {- setIsSideBarTooltipOpen(true);- setSideBarTooltipData({- title: data.activeLabel as string,- values: data.activePayload.map((payload) => ({- value: payload.value as number,- label: payload.name || payload.dataKey,- color: getColorForDataKey(payload.dataKey, dataKeys, colors),- })),- });- }- },- [dataKeys, colors],- );-- const containerRef = useRef<HTMLDivElement>(null);- const [containerWidth, setContainerWidth] = useState<number>(0);- const [isSideBarTooltipOpen, setIsSideBarTooltipOpen] = useState(false);- const [sideBarTooltipData, setSideBarTooltipData] = useState<SideBarChartData>({- title: "",- values: [],- });- const [isLegendExpanded, setIsLegendExpanded] = useState(false);-- // Use provided width or observed width- const effectiveWidth = useMemo(() => {- return width ?? containerWidth;- }, [width, containerWidth]);-- // Observe container width for legend- useEffect(() => {- // Only set up ResizeObserver if width is not provided- if (width || !containerRef.current || !chartContainerRef.current) {- return () => {};- }-- const resizeObserver = new ResizeObserver((entries) => {- // there is only one entry in the entries array because we are observing the chart container- for (const entry of entries) {- if (entry.target === containerRef.current) {- setContainerWidth(entry.contentRect.width);- }- if (entry.target === chartContainerRef.current) {- setChartContainerWidth(entry.contentRect.width);- }- }- });-- resizeObserver.observe(containerRef.current);- resizeObserver.observe(chartContainerRef.current);-- return () => {- resizeObserver.disconnect();- };- }, [width]);-- useEffect(() => {- setIsLegendExpanded(false);- }, [dataKeys]);-- // Memoize legend items creation- const legendItems: LegendItem[] = useMemo(() => {- if (!legend) {- return [];- }- return getLegendItems(dataKeys, colors, icons);- }, [dataKeys, colors, icons, legend]);-- const yAxis = useMemo(() => {- if (!showYAxis) {- return null;- }- return (- <div className="openui-area-chart-condensed-y-axis-container">- {/* Y-axis only chart - synchronized with main chart */}- <RechartsAreaChart- key={`y-axis-area-chart-condensed-${id}`}- width={yAxisWidth}- height={effectiveHeight}- data={data}- margin={{- top: chartMargin.top,- bottom: xAxisHeight + chartMargin.bottom, // this is required to give space for x-axis- left: 0,- right: 0,- }}- >- <YAxis- width={yAxisWidth}- tickLine={false}- axisLine={false}- tick={<YAxisTick setLabelWidth={setLabelWidth} />}- />- {/* Invisible areas to maintain scale synchronization */}- {dataKeys.map((key) => {- return (- <Area- key={`yaxis-area-chart-condensed-${key}`}- dataKey={key}- fill="transparent"- stroke="transparent"- stackId="a"- isAnimationActive={false}- />- );- })}- </RechartsAreaChart>- </div>- );- }, [- showYAxis,- effectiveHeight,- data,- dataKeys,- id,- yAxisWidth,- chartMargin,- xAxisHeight,- setLabelWidth,- ]);-- return (- <LabelTooltipProvider>- <SideBarTooltipProvider- isSideBarTooltipOpen={isSideBarTooltipOpen}- setIsSideBarTooltipOpen={setIsSideBarTooltipOpen}- data={sideBarTooltipData}- setData={setSideBarTooltipData}- >- <div- className={clsx("openui-area-chart-condensed-container", className)}- data-openui-chart={exportData}- style={{- width: width ? `${width}px` : undefined,- }}- >- {yAxisLabel && (- <div className="openui-area-chart-condensed-y-axis-label">{yAxisLabel}</div>- )}- <div className="openui-area-chart-condensed-container-inner" ref={containerRef}>- {/* Y-axis of the chart */}- {yAxis}- <div className="openui-area-chart-condensed" ref={chartContainerRef}>- <ChartContainer- config={chartConfig}- style={{ width: "100%", height: effectiveHeight }}- rechartsProps={{- width: "100%",- height: "100%",- }}- >- <RechartsAreaChart- accessibilityLayer- key={`area-chart-condensed-${id}`}- data={data}- margin={chartMargin}- onClick={onAreaClick}- >- {grid && cartesianGrid()}-- <XAxis- dataKey={categoryKey as string}- tickLine={false}- axisLine={false}- textAnchor={isAngled ? "end" : "middle"}- interval="preserveStartEnd"- minTickGap={5}- height={xAxisHeight}- tick={<SVGXAxisTick />}- angle={calculatedAngle}- orientation="bottom"- padding={{- left: X_AXIS_PADDING,- right: X_AXIS_PADDING,- }}- />- {/* Y-axis is rendered in the separate synchronized chart */}-- <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>- {isSideBarTooltipOpen && <SideBarTooltip height={effectiveHeight} />}- </div>- {xAxisLabel && (- <div className="openui-area-chart-condensed-x-axis-label">{xAxisLabel}</div>- )}- {legend && (- <DefaultLegend- items={legendItems}- containerWidth={effectiveWidth}- isExpanded={isLegendExpanded}- setIsExpanded={setIsLegendExpanded}- />- )}- </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/packages/react-ui/src/components/Charts/AreaChartCondensed/areaChartCondensed.scss b/packages/react-ui/src/components/Charts/AreaChartCondensed/areaChartCondensed.scssdeleted file mode 100644index 558d7f2d8..000000000--- a/packages/react-ui/src/components/Charts/AreaChartCondensed/areaChartCondensed.scss+++ /dev/null@@ -1,32 +0,0 @@-@use "../../../cssUtils" as cssUtils;--.openui-area-chart-condensed-container {- display: flex;- flex-direction: column;-}--.openui-area-chart-condensed-container-inner {- display: flex;- width: 100%;-}--.openui-area-chart-condensed-y-axis-container {- flex-shrink: 0;-}--.openui-area-chart-condensed {- width: 100%;- height: 100%;-- &-x-axis-label {- @include cssUtils.typography(label, extra-small);- color: cssUtils.$text-neutral-secondary;- text-align: center;- }-- &-y-axis-label {- @include cssUtils.typography(label, extra-small);- color: cssUtils.$text-neutral-secondary;- padding-bottom: cssUtils.$space-s;- }-}diff --git a/packages/react-ui/src/components/Charts/AreaChartCondensed/dependencies.ts b/packages/react-ui/src/components/Charts/AreaChartCondensed/dependencies.tsdeleted file mode 100644index 9168685c2..000000000--- a/packages/react-ui/src/components/Charts/AreaChartCondensed/dependencies.ts+++ /dev/null@@ -1,2 +0,0 @@-const dependencies = ["AreaChartCondensed"];-export default dependencies;diff --git a/packages/react-ui/src/components/Charts/AreaChartCondensed/index.ts b/packages/react-ui/src/components/Charts/AreaChartCondensed/index.tsdeleted file mode 100644index d2c029164..000000000--- a/packages/react-ui/src/components/Charts/AreaChartCondensed/index.ts+++ /dev/null@@ -1,2 +0,0 @@-export * from "../AreaChart/types";-export * from "./AreaChartCondensed";diff --git a/packages/react-ui/src/components/Charts/BarChart/BarChart.tsx b/packages/react-ui/src/components/Charts/BarChart/BarChart.tsxindex cd6225040..f355a9494 100644--- a/packages/react-ui/src/components/Charts/BarChart/BarChart.tsx+++ b/packages/react-ui/src/components/Charts/BarChart/BarChart.tsx@@ -1,549 +1,189 @@import clsx from "clsx";-import React, { useCallback, useEffect, useId, useMemo, useRef, useState } from "react";-import { Bar, BarChart as RechartsBarChart, XAxis, YAxis } from "recharts";-import { usePrintContext } from "../../../context/PrintContext";-import { useTheme } from "../../ThemeProvider";-import { ChartConfig, ChartContainer, ChartTooltip } from "../Charts";-import { SideBarChartData, SideBarTooltipProvider } from "../context/SideBarTooltipContext";+import { useCallback } from "react";+import {+ useCartesianChartOrchestrator,+ useEffectiveAnimation,useExportChartData,- useMaxLabelHeight,- useTransformedKeys,- useYAxisLabelWidth,+ useStackedData,+ useXBandScale,+ useYScale,} from "../hooks";-import {- cartesianGrid,- CustomTooltipContent,- DefaultLegend,- LineInBarShape,- SideBarTooltip,- XAxisTick,- XAxisTickProps,- YAxisTick,-} from "../shared";--import { ScrollButtonsHorizontal } from "../shared/ScrollButtonsHorizontal/ScrollButtonsHorizontal";-import { XAxisTickVariant } from "../types";-import { type LegendItem } from "../types/Legend";-import { useChartPalette, type PaletteName } from "../utils/PalletUtils";--import { LabelTooltipProvider } from "../shared/LabelTooltip/LabelTooltip";-import {- findNearestSnapPosition,- getBarStackInfo,- getRadiusArray,-} from "../utils/BarCharts/BarChartsUtils";-import {- get2dChartConfig,- getColorForDataKey,- getDataKeys,- getLegendItems,-} from "../utils/dataUtils";-import { BarChartData, BarChartVariant } from "./types";-import {- BAR_WIDTH,- getPadding,- getSnapPositions,- getWidthOfData,- getWidthOfGroup,-} from "./utils/BarChartUtils";--// this a technic to get the type of the onClick event of the bar chart-// we need to do this because the onClick event type is not exported by recharts-type BarChartOnClick = React.ComponentProps<typeof RechartsBarChart>["onClick"];-type BarClickData = Parameters<NonNullable<BarChartOnClick>>[0];-export interface BarChartProps<T extends BarChartData> {- data: T;- categoryKey: keyof T[number];- theme?: PaletteName;- customPalette?: string[];- variant?: BarChartVariant;- tickVariant?: XAxisTickVariant;- grid?: boolean;- radius?: number;- icons?: Partial<Record<keyof T[number], React.ComponentType>>;- isAnimationActive?: boolean;- showYAxis?: boolean;- xAxisLabel?: React.ReactNode;- yAxisLabel?: React.ReactNode;- legend?: boolean;- className?: string;- height?: number;- width?: number;+import { ClipDefs } from "../shared/cartesian/ClipDefs";+import { CartesianXAxis } from "../shared/cartesian/axes/CartesianXAxis";+import { CartesianChartLayout } from "../shared/cartesian/layouts/CartesianChartLayout";+import { findBandIndex } from "../utils/mouseUtils";+import { BarSeries } from "./parts/BarSeries";+import { Crosshair } from "./parts/Crosshair";+import { HorizontalBarChartImpl } from "./parts/HorizontalBarChartImpl";++import { CHART_CLASS_PREFIX } from "../utils/constants";+import type { BarChartData, BarChartProps } from "./types";++/**+ * Empty-data guard lives here, in a hook-free dispatcher: the chart impl below+ * calls hooks unconditionally, so the "no data" branch must short-circuit+ * *before* any hook runs (a count → 0 transition on a mounted chart would+ * otherwise break the Rules of Hooks).+ */+export function BarChart<T extends BarChartData>(props: BarChartProps<T>) {+ if (!props.data || props.data.length === 0) {+ return (+ <div+ className={clsx(+ `${CHART_CLASS_PREFIX}-bar-chart-container ${CHART_CLASS_PREFIX}-chart-empty`,+ props.className,+ )}+ >+ <span className={`${CHART_CLASS_PREFIX}-chart-empty-text`}>No data available</span>+ </div>+ );+ }+ if (props.orientation === "horizontal") {+ return <HorizontalBarChartImpl {...props} />;+ }+ return <BarChartImpl {...props} />;}-const BAR_GAP = 10; // Gap between bars-const BAR_CATEGORY_GAP = "20%"; // Gap between categories-const BAR_INTERNAL_LINE_WIDTH = 1;-const BAR_RADIUS = 4;-const CHART_CONTAINER_BOTTOM_MARGIN = 10;--const BarChartComponent = <T extends BarChartData>({+function BarChartImpl<T extends BarChartData>({data,categoryKey,- theme = "ocean",customPalette,variant = "grouped",- tickVariant = "multiLine",+ tickVariant: tickVariantProp,+ barRadius = 4,+ maxBarWidth,+ internalLine = true,+ internalLineColor,+ internalLineWidth,grid = true,- icons = {},- radius,+ legend: showLegend = true,+ icons,isAnimationActive = false,showYAxis = true,xAxisLabel,yAxisLabel,- legend = true,className,height,- width,-}: BarChartProps<T>) => {- const printContext = usePrintContext();- isAnimationActive = printContext ? false : isAnimationActive;-- const widthOfGroup = getWidthOfGroup(data, categoryKey as string, variant);-- const maxLabelHeight = useMaxLabelHeight(data, categoryKey as string, tickVariant, widthOfGroup);-- const dataKeys = useMemo(() => {- return getDataKeys(data, categoryKey as string);- }, [data, categoryKey]);-- const { yAxisWidth, setLabelWidth } = useYAxisLabelWidth(data, dataKeys);-- const transformedKeys = useTransformedKeys(dataKeys);-- const colors = useChartPalette({- chartThemeName: theme,- customPalette,+ width: fixedWidth,+ fitLegendInHeight,+ condensed = false,+ density,+ onClick,+ yTickCount,+}: BarChartProps<T>) {+ const animate = useEffectiveAnimation(isAnimationActive);+ const mode = condensed ? "fit" : "scroll";++ const orch = useCartesianChartOrchestrator({+ layout: mode,+ data,+ categoryKey,themePaletteName: "barChartPalette",- dataLength: dataKeys.length,- });-- const chartConfig: ChartConfig = useMemo(() => {- return get2dChartConfig(dataKeys, colors, transformedKeys, undefined, icons);- }, [dataKeys, icons, colors, transformedKeys]);-- const chartContainerRef = useRef<HTMLDivElement>(null);- const mainContainerRef = useRef<HTMLDivElement>(null);- const [containerWidth, setContainerWidth] = useState<number>(0);- const [canScrollLeft, setCanScrollLeft] = useState(false);- const [canScrollRight, setCanScrollRight] = useState(false);- const [hoveredCategory, setHoveredCategory] = useState<string | number | null>(null);- const [isLegendExpanded, setIsLegendExpanded] = useState(false);- const [isSideBarTooltipOpen, setIsSideBarTooltipOpen] = useState(false);- const [sideBarTooltipData, setSideBarTooltipData] = useState<SideBarChartData>({- title: "",- values: [],+ customPalette,+ showLegend,+ showYAxis,+ height,+ fixedWidth,+ fitLegendInHeight,+ tickVariantProp: tickVariantProp ?? (condensed ? "singleLine" : "multiLine"),+ chartIdPrefix: "d3bc",+ icons,+ onClick,+ density,+ stacked: variant === "stacked",+ yTickCount,});- // Use provided width or observed width- const effectiveWidth = useMemo(() => {- return width ?? containerWidth;- }, [width, containerWidth]);-- // need this to calculate the padding for the chart container, because the y-axis is rendered in a separate chart- const effectiveContainerWidth = useMemo(() => {- const dynamicYAxisWidth = showYAxis ? yAxisWidth : 0;- return Math.max(0, effectiveWidth - dynamicYAxisWidth);- }, [effectiveWidth, showYAxis, yAxisWidth]);-- const padding = useMemo(() => {- return getPadding(data, categoryKey as string, effectiveContainerWidth, variant);- }, [data, categoryKey, effectiveContainerWidth, variant]);-- const dataWidth = useMemo(() => {- return getWidthOfData(data, categoryKey as string, variant);- }, [data, categoryKey, variant]);-- // Calculate snap positions for proper group alignment- const snapPositions = useMemo(() => {- return getSnapPositions(data, categoryKey as string, variant);- }, [data, categoryKey, variant]);-- // self note:- // Use provided height or calculated height based on container width- // if height is provided, it will be used to set the height of the chart- // if height is not provided, it will be calculated based on the container width (effectiveWidth)- // getChartHeight(effectiveWidth) this function is not used here, request of the designer, we will use fix height- // 296 is the height of the chart by default, given by designer- // we want to chart to scale with width but height will be fixed-- const chartHeight = useMemo(() => {- return height ?? 296 + maxLabelHeight;- }, [height, maxLabelHeight]);-- // Check scroll boundaries- const updateScrollState = useCallback(() => {- if (mainContainerRef.current) {- const { scrollLeft, scrollWidth, clientWidth } = mainContainerRef.current;- setCanScrollLeft(scrollLeft > 0);- setCanScrollRight(scrollLeft < scrollWidth - clientWidth - 1); // -1 for floating point precision- }- }, []);-- const scrollLeft = useCallback(() => {- if (mainContainerRef.current) {- const currentScroll = mainContainerRef.current.scrollLeft;- const targetIndex = findNearestSnapPosition(snapPositions, currentScroll, "left");- const targetPosition = snapPositions[targetIndex] ?? 0;-- mainContainerRef.current.scrollTo({- left: targetPosition,- behavior: "smooth",- });- }- }, [snapPositions]);-- const scrollRight = useCallback(() => {- if (mainContainerRef.current) {- const currentScroll = mainContainerRef.current.scrollLeft;- const targetIndex = findNearestSnapPosition(snapPositions, currentScroll, "right");- const targetPosition = snapPositions[targetIndex] ?? 0;-- mainContainerRef.current.scrollTo({- left: targetPosition,- behavior: "smooth",- });- }- }, [snapPositions]);-- useEffect(() => {- // Only set up ResizeObserver if width is not provided- if (width || !chartContainerRef.current) {- return () => {};- }-- const resizeObserver = new ResizeObserver((entries) => {- // there is only one entry in the entries array because we are observing the chart container- for (const entry of entries) {- setContainerWidth(entry.contentRect.width);- }- });-- resizeObserver.observe(chartContainerRef.current);-- return () => {- resizeObserver.disconnect();- };- }, [width]);-- // Update scroll state when container width or data width changes- useEffect(() => {- updateScrollState();- }, [effectiveWidth, dataWidth, updateScrollState]);-- useEffect(() => {- setIsSideBarTooltipOpen(false);- setIsLegendExpanded(false);- }, [dataKeys]);-- // Add scroll event listener to update button states- useEffect(() => {- const mainContainer = mainContainerRef.current;- if (!mainContainer) return;+ const isStacked = variant === "stacked";+ const xScale = useXBandScale(data, orch.data.catKey, orch.dimensions.chartAreaWidth);+ const stackedData = useStackedData(data, orch.data.dataKeys, isStacked);+ const yScale = useYScale(data, orch.data.dataKeys, orch.dimensions.chartInnerHeight, isStacked);- const handleScroll = () => {- updateScrollState();- };-- mainContainer.addEventListener("scroll", handleScroll);- return () => {- mainContainer.removeEventListener("scroll", handleScroll);- };- }, [updateScrollState]);-- // Memoize legend items creation- const legendItems: LegendItem[] = useMemo(() => {- return getLegendItems(dataKeys, colors, icons);- }, [dataKeys, colors, icons]);+ const findIndex = useCallback((mouseX: number) => findBandIndex(xScale, mouseX), [xScale]);+ const mouseHandlers = orch.hover.createMouseHandlers(findIndex);+ // PPTX print-export JSON — mirrors react-ui's vertical BarChart call+ // (type:'bar', no extraOptions → barDir defaults to "col"). Undefined off+ // the print path.const exportData = useExportChartData({type: "bar",data,- categoryKey: categoryKey as string,- dataKeys,- colors,- legend,+ categoryKey: orch.data.catKey,+ dataKeys: orch.data.dataKeys,+ colors: orch.data.colors,+ legend: showLegend,xAxisLabel,yAxisLabel,});- const id = useId();-- const yAxis = useMemo(() => {- if (!showYAxis) {- return null;- }- return (- <div className="openui-bar-chart-y-axis-container">- {/* Y-axis only chart - synchronized with main chart */}- <RechartsBarChart- key={`y-axis-bar-chart-${id}`}- width={yAxisWidth}- height={chartHeight}- data={data}- stackOffset="sign"- margin={{- top: 20,- bottom: maxLabelHeight + CHART_CONTAINER_BOTTOM_MARGIN, // this is required for to give space for x-axis- left: 0,- right: 0,- }}- >- <YAxis- width={yAxisWidth}- tickLine={false}- axisLine={false}- tick={<YAxisTick setLabelWidth={setLabelWidth} />}+ return (+ <CartesianChartLayout+ orch={orch}+ yScale={yScale}+ mouseHandlers={mouseHandlers}+ classPrefix="bar-chart"+ chartType="bar"+ exportData={exportData}+ ariaLabel="Bar chart"+ showYAxis={showYAxis}+ grid={grid}+ showLegend={showLegend}+ xAxisLabel={xAxisLabel}+ yAxisLabel={yAxisLabel}+ yTickCount={yTickCount}+ className={className}+ defs={+ <defs>+ <ClipDefs+ chartId={orch.identity.chartId}+ chartWidth={orch.dimensions.chartAreaWidth}+ chartHeight={orch.dimensions.chartInnerHeight}/>- {/* Invisible bars to maintain scale synchronization */}- {dataKeys.map((key) => {- return (- <Bar- key={`yaxis-bar-chart-${key}`}- dataKey={key}- fill="transparent"- stackId={variant === "stacked" ? "a" : undefined}- isAnimationActive={false}- maxBarSize={0}- />- );- })}- </RechartsBarChart>- </div>- );- }, [showYAxis, chartHeight, data, dataKeys, variant, id, maxLabelHeight, yAxisWidth]);-- // Handle mouse events for group hovering- const handleChartMouseMove = useCallback((state: any) => {- if (state && state.activeLabel !== undefined) {- setHoveredCategory(state.activeLabel);- }- }, []);-- const handleChartMouseLeave = useCallback(() => {- setHoveredCategory(null);- }, []);-- const handleXAxisTickMouseEnter = useCallback((tickProps: XAxisTickProps) => {- if (typeof tickProps.payload?.value === "string") {- setHoveredCategory(tickProps.payload.value);- }- }, []);-- const handleXAxisTickMouseLeave = useCallback(() => {- setHoveredCategory(null);- }, []);-- const { mode, theme: userTheme } = useTheme();-- const barInternalLineColor = useMemo(() => {- if (mode === "light") {- return "rgba(255, 255, 255, 0.3)";- }- return "rgba(0, 0, 0, 0.3)";- }, [mode]);-- const calculatedRadius = useMemo(() => {- let radiusValue: number = BAR_RADIUS;-- if (typeof radius === "number") {- radiusValue = radius;- } else {- const radiusTheme = userTheme.radius2xs;- if (radiusTheme) {- radiusValue = typeof radiusTheme === "string" ? parseInt(radiusTheme) : radiusTheme;+ </defs>}- }-- return radiusValue;- }, [userTheme.radius2xs, radius]);-- const onBarsClick = useCallback(- (data: BarClickData) => {- if (data?.activePayload?.length && data.activePayload.length > 10) {- setIsSideBarTooltipOpen(true);- setSideBarTooltipData({- title: data.activeLabel as string,- values: data.activePayload.map((payload) => ({- value: payload.value as number,- label: payload.name || payload.dataKey,- color: getColorForDataKey(payload.dataKey, dataKeys, colors),- })),- });+ series={+ <>+ <Crosshair+ hoveredIndex={orch.hover.hoveredIndex}+ xScale={xScale}+ data={data}+ categoryKey={orch.data.catKey}+ chartHeight={orch.dimensions.chartInnerHeight}+ />+ <BarSeries+ data={data}+ dataKeys={orch.data.dataKeys}+ xScale={xScale}+ yScale={yScale}+ variant={variant}+ stackedData={stackedData}+ categoryKey={orch.data.catKey}+ colors={orch.data.colorMap}+ barRadius={barRadius}+ maxBarWidth={maxBarWidth}+ internalLine={internalLine}+ internalLineColor={internalLineColor}+ internalLineWidth={internalLineWidth}+ isAnimationActive={animate}+ />+ </>}- },- [dataKeys, colors],- );-- const barElements = useMemo(() => {- return dataKeys.map((key) => {- const transformedKey = transformedKeys[key];- const color = `var(--color-${transformedKey})`;-- return (- <Bar- key={`main-${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,- calculatedRadius,- "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}- />- );- }}+ xAxis={+ <CartesianXAxis+ mode={mode}+ scale={xScale}+ classPrefix={`${CHART_CLASS_PREFIX}-bar-chart`}+ tickVariant={orch.dimensions.tickVariant}+ labelHeight={orch.xAxis.xAxisHeight}+ labelWidth={orch.xAxis.labelWidth}+ maxLines={orch.xAxis.maxLines}+ labelInterval={orch.dimensions.labelInterval}+ angle={orch.xAxis.angle}+ chartWidth={orch.dimensions.chartAreaWidth}+ yAxisWidth={orch.dimensions.effectiveYAxisWidth}/>- );- });- }, [- dataKeys,- transformedKeys,- variant,- calculatedRadius,- isAnimationActive,- barInternalLineColor,- hoveredCategory,- categoryKey,- ]);-- return (- <LabelTooltipProvider>- <SideBarTooltipProvider- isSideBarTooltipOpen={isSideBarTooltipOpen}- setIsSideBarTooltipOpen={setIsSideBarTooltipOpen}- data={sideBarTooltipData}- setData={setSideBarTooltipData}- >- <div- className={clsx("openui-bar-chart-container", className)}- data-openui-chart={exportData}- style={{- width: width ? `${width}px` : undefined,- }}- >- <div className="openui-bar-chart-container-inner" ref={chartContainerRef}>- {/* Y-axis of the chart */}- {yAxis}- <div className="openui-bar-chart-main-container" ref={mainContainerRef}>- <ChartContainer- config={chartConfig}- style={{ width: dataWidth, minWidth: "100%", height: chartHeight }}- rechartsProps={{- width: "100%",- height: "100%",- minHeight: 1,- minWidth: 1,- initialDimension: { width: 1, height: 1 },- }}- >- <RechartsBarChart- stackOffset="sign"- accessibilityLayer- key={`bar-chart-${id}`}- data={data}- margin={{- top: 20,- bottom: CHART_CONTAINER_BOTTOM_MARGIN,- }}- onClick={onBarsClick}- onMouseMove={handleChartMouseMove}- onMouseLeave={handleChartMouseLeave}- barGap={BAR_GAP}- barCategoryGap={BAR_CATEGORY_GAP}- >- {grid && cartesianGrid()}- <XAxis- dataKey={categoryKey as string}- tickLine={false}- axisLine={false}- textAnchor={"middle"}- interval={0}- height={maxLabelHeight}- tick={- <XAxisTick- variant={tickVariant}- widthOfGroup={widthOfGroup}- labelHeight={maxLabelHeight}- onMouseEnter={handleXAxisTickMouseEnter}- onMouseLeave={handleXAxisTickMouseLeave}- />- }- orientation="bottom"- // gives the padding on the 2 sides see the function for reference- padding={padding}- />- {/* Y-axis is rendered in the separate synchronized chart */}-- <ChartTooltip- // cursor={<SimpleCursor />}- cursor={{- fill: "var(--openui-highlight)",- stroke: "var(--openui-stroke-default)",- opacity: 1,- strokeWidth: 1,- }}- content={<CustomTooltipContent parentRef={mainContainerRef} />}- offset={15}- />-- {barElements}- </RechartsBarChart>- </ChartContainer>- </div>- {isSideBarTooltipOpen && <SideBarTooltip height={chartHeight} />}- </div>- {/* if the data width is greater than the effective width, then show the scroll buttons */}- <ScrollButtonsHorizontal- dataWidth={dataWidth}- effectiveWidth={effectiveWidth}- canScrollLeft={canScrollLeft}- canScrollRight={canScrollRight}- isSideBarTooltipOpen={isSideBarTooltipOpen}- onScrollLeft={scrollLeft}- onScrollRight={scrollRight}- />- {legend && (- <DefaultLegend- items={legendItems}- yAxisLabel={yAxisLabel}- xAxisLabel={xAxisLabel}- containerWidth={effectiveWidth}- isExpanded={isLegendExpanded}- setIsExpanded={setIsLegendExpanded}- />- )}- </div>- </SideBarTooltipProvider>- </LabelTooltipProvider>+ }+ />);-};--// Added React.memo for performance optimization to avoid unnecessary re-renders-export const BarChart = React.memo(BarChartComponent) as typeof BarChartComponent;+}diff --git a/packages/react-ui/src/components/Charts/BarChart/BarChartCondensed.tsx b/packages/react-ui/src/components/Charts/BarChart/BarChartCondensed.tsxnew file mode 100644index 000000000..af5e24683--- /dev/null+++ b/packages/react-ui/src/components/Charts/BarChart/BarChartCondensed.tsx@@ -0,0 +1,12 @@+import { BarChart } from "./BarChart";+import type { BarChartData, BarChartProps } from "./types";++export type BarChartCondensedProps<T extends BarChartData> = Omit<+ BarChartProps<T>,+ "condensed" | "orientation"+>;++/** A vertical `BarChart` that fits its container's width instead of scrolling. */+export const BarChartCondensed = <T extends BarChartData>(props: BarChartCondensedProps<T>) => (+ <BarChart {...props} condensed />+);diff --git a/packages/react-ui/src/components/Charts/BarChart/HorizontalBarChart.tsx b/packages/react-ui/src/components/Charts/BarChart/HorizontalBarChart.tsxnew file mode 100644index 000000000..ff6224a2d--- /dev/null+++ b/packages/react-ui/src/components/Charts/BarChart/HorizontalBarChart.tsx@@ -0,0 +1,14 @@+import { BarChart } from "./BarChart";+import type { BarChartData, BarChartProps, BarChartVariant } from "./types";++export type HorizontalBarChartData = BarChartData;+export type HorizontalBarChartVariant = BarChartVariant;+export type HorizontalBarChartProps<T extends HorizontalBarChartData> = Omit<+ BarChartProps<T>,+ "orientation"+>;++/** A `BarChart` with `orientation="horizontal"`: one labeled row per category. */+export const HorizontalBarChart = <T extends HorizontalBarChartData>(+ props: HorizontalBarChartProps<T>,+) => <BarChart {...props} orientation="horizontal" />;diff --git a/packages/react-ui/src/components/Charts/BarChart/barChart.scss b/packages/react-ui/src/components/Charts/BarChart/barChart.scssindex 5bf37b84c..caf9b8a43 100644--- a/packages/react-ui/src/components/Charts/BarChart/barChart.scss+++ b/packages/react-ui/src/components/Charts/BarChart/barChart.scss@@ -1,25 +1,44 @@@use "../../../cssUtils" as cssUtils;+@use "../shared/cartesian/chartBase" as base;+@use "../prefix" as brand;-.openui-bar-chart-container-inner {- display: flex;- width: 100%;+@include base.chart-base("bar-chart");++// (No data-change transition on the bar-chart-bar class: the old+// `height/y 0.3s` rule was inert — bars render as <path d=roundedBarPath(…)>,+// and height/y are rect geometry properties — so bars have always snapped.+// Removed rather than ported to the spring morph: no behavior to preserve.)++.#{brand.$prefix}-bar-chart-hover-highlight {+ fill: cssUtils.$text-neutral-primary;+ opacity: 0.04;+ pointer-events: none;}-.openui-bar-chart-y-axis-container {- flex-shrink: 0;+.#{brand.$prefix}-bar-chart-internal-line {+ pointer-events: none;}-.openui-bar-chart-main-container {- width: 100%;- overflow-x: auto;- /* Hide scrollbar for Chrome, Safari and Opera */- &::-webkit-scrollbar {- display: none;+// Entrances are decorative: gate the whole rule (pre-state included) behind+// reduced-motion so users who opt out get the natural static state immediately+// — gating only the animation would strand elements at the opacity: 0 start.+@media (prefers-reduced-motion: no-preference) {+ .#{brand.$prefix}-bar-chart-bar--animated {+ transform-box: fill-box;+ transform-origin: center bottom;+ animation: #{brand.$prefix}-bar-grow 0.6s ease-out both;}+ // A negative bar's zero-line edge is its TOP — grow downward from there.+ .#{brand.$prefix}-bar-chart-bar--animated.#{brand.$prefix}-bar-chart-bar--negative {+ transform-origin: center top;+ }+}- /* Hide scrollbar for Firefox */- scrollbar-width: none;-- /* Hide scrollbar for IE and Edge */- -ms-overflow-style: none;+@keyframes #{brand.$prefix}-bar-grow {+ from {+ transform: scaleY(0);+ }+ to {+ transform: scaleY(1);+ }}diff --git a/packages/react-ui/src/components/Charts/BarChart/dependencies.ts b/packages/react-ui/src/components/Charts/BarChart/dependencies.tsdeleted file mode 100644index 4cfac500e..000000000--- a/packages/react-ui/src/components/Charts/BarChart/dependencies.ts+++ /dev/null@@ -1,2 +0,0 @@-const dependencies = ["BarChart", "IconButton"];-export default dependencies;diff --git a/packages/react-ui/src/components/D3Charts/BarChart/horizontalBarChart.scss b/packages/react-ui/src/components/Charts/BarChart/horizontalBarChart.scsssimilarity index 100%rename from packages/react-ui/src/components/D3Charts/BarChart/horizontalBarChart.scssrename to packages/react-ui/src/components/Charts/BarChart/horizontalBarChart.scssdiff --git a/packages/react-ui/src/components/Charts/BarChart/index.ts b/packages/react-ui/src/components/Charts/BarChart/index.tsindex ddbf3231c..a20068315 100644--- a/packages/react-ui/src/components/Charts/BarChart/index.ts+++ b/packages/react-ui/src/components/Charts/BarChart/index.ts@@ -1,2 +1,10 @@-export * from "./BarChart";-export * from "./types";+export { BarChart } from "./BarChart";+export { BarChartCondensed } from "./BarChartCondensed";+export type { BarChartCondensedProps } from "./BarChartCondensed";+export { HorizontalBarChart } from "./HorizontalBarChart";+export type {+ HorizontalBarChartData,+ HorizontalBarChartProps,+ HorizontalBarChartVariant,+} from "./HorizontalBarChart";+export type { BarChartData, BarChartProps, BarChartVariant } from "./types";diff --git a/packages/react-ui/src/components/D3Charts/BarChart/parts/BarSeries.tsx b/packages/react-ui/src/components/Charts/BarChart/parts/BarSeries.tsxsimilarity index 100%rename from packages/react-ui/src/components/D3Charts/BarChart/parts/BarSeries.tsxrename to packages/react-ui/src/components/Charts/BarChart/parts/BarSeries.tsxdiff --git a/packages/react-ui/src/components/D3Charts/BarChart/parts/Crosshair.tsx b/packages/react-ui/src/components/Charts/BarChart/parts/Crosshair.tsxsimilarity index 100%rename from packages/react-ui/src/components/D3Charts/BarChart/parts/Crosshair.tsxrename to packages/react-ui/src/components/Charts/BarChart/parts/Crosshair.tsxdiff --git a/packages/react-ui/src/components/D3Charts/BarChart/parts/HorizontalBarChartImpl.tsx b/packages/react-ui/src/components/Charts/BarChart/parts/HorizontalBarChartImpl.tsxsimilarity index 100%rename from packages/react-ui/src/components/D3Charts/BarChart/parts/HorizontalBarChartImpl.tsxrename to packages/react-ui/src/components/Charts/BarChart/parts/HorizontalBarChartImpl.tsxdiff --git a/packages/react-ui/src/components/D3Charts/BarChart/parts/HorizontalBarSeries.tsx b/packages/react-ui/src/components/Charts/BarChart/parts/HorizontalBarSeries.tsxsimilarity index 100%rename from packages/react-ui/src/components/D3Charts/BarChart/parts/HorizontalBarSeries.tsxrename to packages/react-ui/src/components/Charts/BarChart/parts/HorizontalBarSeries.tsxdiff --git a/packages/react-ui/src/components/D3Charts/BarChart/parts/HorizontalCrosshair.tsx b/packages/react-ui/src/components/Charts/BarChart/parts/HorizontalCrosshair.tsxsimilarity index 100%rename from packages/react-ui/src/components/D3Charts/BarChart/parts/HorizontalCrosshair.tsxrename to packages/react-ui/src/components/Charts/BarChart/parts/HorizontalCrosshair.tsxdiff --git a/packages/react-ui/src/components/D3Charts/BarChart/parts/horizontalBarGeometry.test.ts b/packages/react-ui/src/components/Charts/BarChart/parts/horizontalBarGeometry.test.tssimilarity index 100%rename from packages/react-ui/src/components/D3Charts/BarChart/parts/horizontalBarGeometry.test.tsrename to packages/react-ui/src/components/Charts/BarChart/parts/horizontalBarGeometry.test.tsdiff --git a/packages/react-ui/src/components/D3Charts/BarChart/parts/horizontalBarGeometry.ts b/packages/react-ui/src/components/Charts/BarChart/parts/horizontalBarGeometry.tssimilarity index 100%rename from packages/react-ui/src/components/D3Charts/BarChart/parts/horizontalBarGeometry.tsrename to packages/react-ui/src/components/Charts/BarChart/parts/horizontalBarGeometry.tsdiff --git a/packages/react-ui/src/components/D3Charts/BarChart/parts/verticalBarRadii.test.ts b/packages/react-ui/src/components/Charts/BarChart/parts/verticalBarRadii.test.tssimilarity index 100%rename from packages/react-ui/src/components/D3Charts/BarChart/parts/verticalBarRadii.test.tsrename to packages/react-ui/src/components/Charts/BarChart/parts/verticalBarRadii.test.tsdiff --git a/packages/react-ui/src/components/D3Charts/BarChart/parts/verticalBarRadii.ts b/packages/react-ui/src/components/Charts/BarChart/parts/verticalBarRadii.tssimilarity index 100%rename from packages/react-ui/src/components/D3Charts/BarChart/parts/verticalBarRadii.tsrename to packages/react-ui/src/components/Charts/BarChart/parts/verticalBarRadii.tsdiff --git a/packages/react-ui/src/components/Charts/HorizontalBarChart/stories/HorizontalBarChart.stories.tsx b/packages/react-ui/src/components/Charts/BarChart/stories/HorizontalBarChart.stories.tsxsimilarity index 95%rename from packages/react-ui/src/components/Charts/HorizontalBarChart/stories/HorizontalBarChart.stories.tsxrename to packages/react-ui/src/components/Charts/BarChart/stories/HorizontalBarChart.stories.tsxindex 235d2b096..e45b87645 100644--- a/packages/react-ui/src/components/Charts/HorizontalBarChart/stories/HorizontalBarChart.stories.tsx+++ b/packages/react-ui/src/components/Charts/BarChart/stories/HorizontalBarChart.stories.tsx@@ -1,8 +1,8 @@import type { Meta, StoryObj } from "@storybook/react";import { Monitor, TabletSmartphone } from "lucide-react";import { useState } from "react";+import { HorizontalBarChart, HorizontalBarChartProps } from "../..";import { Card } from "../../../Card";-import { HorizontalBarChart, HorizontalBarChartProps } from "../HorizontalBarChart";// 📊 ALL DATA VARIATIONS - For easy switching in storiesconst dataVariations = {@@ -421,7 +421,7 @@ const icons = {* - **Responsive Design**: Adjusts gracefully to the size of its container.** ### Customization- * - **Theming**: Six built-in color palettes, or use custom colors with `customPalette`.+ * - **Colors**: Uses the ThemeProvider's chart palette, or custom colors with `customPalette`.* - **Bar Styling**: Customize the corner radius of the bars.* - **Axis and Grid Control**: Toggle visibility of axes and grid lines.*/@@ -448,7 +448,6 @@ const salesData = [<HorizontalBarChartdata={salesData}categoryKey="region"- theme="ocean"/>// With custom colors@@ -504,19 +503,8 @@ const performanceData = [category: "📊 Data Configuration",},},- theme: {- description:- "Specifies the color palette for the chart's bars, tooltips, and legend. Ignored when customPalette is provided.",- control: "select",- options: ["ocean", "orchid", "emerald", "sunset", "spectrum", "vivid"],- table: {- defaultValue: { summary: "ocean" },- category: "🎨 Visual Styling",- },- },customPalette: {- description:- "Custom array of colors to use instead of the theme palette. Overrides the theme prop when provided.",+ description: "Custom array of colors to use instead of the ThemeProvider's chart palette.",control: "object",table: {type: { summary: "string[]" },@@ -533,7 +521,7 @@ const performanceData = [category: "🎨 Visual Styling",},},- radius: {+ barRadius: {description: "Sets the corner radius for the bars, creating a rounded look.",control: { type: "number", min: 0, max: 20 },table: {@@ -567,14 +555,6 @@ const performanceData = [category: "📱 Display Options",},},- showXAxis: {- description: "Toggles the visibility of the X-axis line and labels.",- control: "boolean",- table: {- defaultValue: { summary: "true" },- category: "📱 Display Options",- },- },xAxisLabel: {description: "A label to display below the X-axis.",control: "text",@@ -639,12 +619,10 @@ export const DataExplorer: Story = {args: {data: horizontalBarChartData,categoryKey: "category",- theme: "ocean",variant: "grouped",- radius: 4,+ barRadius: 4,grid: true,isAnimationActive: false,- showXAxis: true,legend: true,height: 400,width: 600,@@ -762,7 +740,6 @@ export const Default: Story = {args: {data: dataVariations.default,categoryKey: "category",- theme: "ocean",variant: "grouped",height: 400,width: 600,@@ -778,7 +755,6 @@ export const Stacked: Story = {args: {data: dataVariations.default,categoryKey: "category",- theme: "ocean",variant: "stacked",height: 400,width: 600,@@ -794,7 +770,6 @@ export const WithAnimations: Story = {args: {data: dataVariations.default,categoryKey: "category",- theme: "ocean",variant: "grouped",isAnimationActive: true,height: 400,@@ -844,7 +819,6 @@ export const BigNumbers: Story = {args: {data: dataVariations.bigNumbers,categoryKey: "company",- theme: "vivid",variant: "grouped",height: 400,width: 600,@@ -860,7 +834,6 @@ export const LargeDataset: Story = {args: {data: dataVariations.large,categoryKey: "category",- theme: "emerald",variant: "grouped",height: 400,width: 600,@@ -877,7 +850,6 @@ export const MixedPositiveNegative: Story = {args: {data: dataVariations.mixedPositiveNegative,categoryKey: "category",- theme: "spectrum",variant: "grouped",height: 400,width: 600,@@ -893,7 +865,6 @@ export const WithIcons: Story = {args: {data: dataVariations.default,categoryKey: "category",- theme: "ocean",variant: "grouped",height: 400,width: 600,diff --git a/packages/react-ui/src/components/Charts/BarChart/stories/barChart.stories.tsx b/packages/react-ui/src/components/Charts/BarChart/stories/barChart.stories.tsxindex a955cfd00..9df59dbb1 100644--- a/packages/react-ui/src/components/Charts/BarChart/stories/barChart.stories.tsx+++ b/packages/react-ui/src/components/Charts/BarChart/stories/barChart.stories.tsx@@ -1,8 +1,8 @@import type { Meta, StoryObj } from "@storybook/react";import { Monitor, TabletSmartphone } from "lucide-react";import { useState } from "react";+import { BarChart, BarChartProps } from "../..";import { Card } from "../../../Card";-import { BarChart, BarChartProps } from "../BarChart";// 📊 ALL DATA VARIATIONS - For easy switching in storiesconst dataVariations = {@@ -603,7 +603,7 @@ const icons = {* - **Responsive Design**: Adjusts gracefully to the size of its container.** ### Customization- * - **Theming**: Six built-in color palettes, or use custom colors with `customPalette`.+ * - **Colors**: Uses the ThemeProvider's chart palette, or custom colors with `customPalette`.* - **Bar Styling**: Customize the corner radius of the bars.* - **Axis and Grid Control**: Toggle visibility of axes and grid lines.*/@@ -630,7 +630,6 @@ const monthlyData = [<ScrollableBarChartdata={monthlyData}categoryKey="month"- theme="ocean"/>// With custom colors@@ -686,19 +685,8 @@ const salesData = [category: "📊 Data Configuration",},},- theme: {- description:- "Specifies the color palette for the chart's bars, tooltips, and legend. Ignored when customPalette is provided.",- control: "select",- options: ["ocean", "orchid", "emerald", "sunset", "spectrum", "vivid"],- table: {- defaultValue: { summary: "ocean" },- category: "🎨 Visual Styling",- },- },customPalette: {- description:- "Custom array of colors to use instead of the theme palette. Overrides the theme prop when provided.",+ description: "Custom array of colors to use instead of the ThemeProvider's chart palette.",control: "object",table: {type: { summary: "string[]" },@@ -715,7 +703,7 @@ const salesData = [category: "🎨 Visual Styling",},},- radius: {+ barRadius: {description: "Sets the corner radius for the top of each bar, creating a rounded look.",control: { type: "number", min: 0, max: 20 },table: {@@ -820,9 +808,8 @@ export const DataExplorer: Story = {args: {data: barChartData,categoryKey: "month",- theme: "ocean",variant: "grouped",- radius: 4,+ barRadius: 4,grid: true,isAnimationActive: true,showYAxis: true,@@ -961,9 +948,8 @@ export const SmallDataStory: Story = {args: {data: dataVariations.small as any,categoryKey: "month" as any,- theme: "ocean",variant: "grouped",- radius: 2,+ barRadius: 2,grid: true,isAnimationActive: true,showYAxis: true,@@ -987,9 +973,8 @@ export const LargeDataStory: Story = {args: {data: dataVariations.large as any,categoryKey: "month" as any,- theme: "emerald",variant: "grouped",- radius: 2,+ barRadius: 2,grid: true,isAnimationActive: true,showYAxis: true,@@ -1013,9 +998,8 @@ export const WeeklyDataStory: Story = {args: {data: dataVariations.weekly as any,categoryKey: "week" as any,- theme: "sunset",variant: "grouped",- radius: 2,+ barRadius: 2,grid: true,isAnimationActive: true,showYAxis: true,@@ -1040,9 +1024,8 @@ export const BigNumbersStory: Story = {args: {data: dataVariations.bigNumbers as any,categoryKey: "company" as any,- theme: "vivid",variant: "grouped",- radius: 2,+ barRadius: 2,grid: true,isAnimationActive: true,showYAxis: true,@@ -1066,9 +1049,8 @@ export const EdgeCaseStory: Story = {args: {data: dataVariations.edge as any,categoryKey: "period" as any,- theme: "orchid",variant: "grouped",- radius: 2,+ barRadius: 2,grid: true,isAnimationActive: true,showYAxis: true,@@ -1092,9 +1074,8 @@ export const NumberRangesStory: Story = {args: {data: dataVariations.numbers as any,categoryKey: "category" as any,- theme: "spectrum",variant: "grouped",- radius: 2,+ barRadius: 2,grid: true,isAnimationActive: true,showYAxis: true,@@ -1119,9 +1100,8 @@ export const ExpandCollapseMarketingStory: Story = {args: {data: dataVariations.expandCollapseMarketing as any,categoryKey: "channel" as any,- theme: "emerald",variant: "grouped",- radius: 4,+ barRadius: 4,grid: true,isAnimationActive: true,showYAxis: true,@@ -1166,9 +1146,8 @@ export const CustomPaletteStory: Story = {"#B4C6FF","#CBD7FF",],- theme: "ocean", // This will be overridden by customPalettevariant: "grouped",- radius: 4,+ barRadius: 4,grid: true,legend: true,isAnimationActive: true,@@ -1229,7 +1208,7 @@ export const CustomPaletteStory: Story = {docs: {description: {story:- 'Demonstrates how to use the `customPalette` prop to provide your own color scheme for the chart. When `customPalette` is provided, it overrides the `theme` prop and uses your specified colors instead of the predefined theme palettes.\n\n**Key Features:**\n- 🎨 **Custom Colors**: Override default theme colors with your own palette\n- 🔄 **Theme Override**: The `theme` prop is ignored when `customPalette` is provided\n- 📊 **Consistent Distribution**: Colors are distributed evenly across data series\n- 🎯 **Brand Matching**: Perfect for matching your application\'s brand colors\n\n**Usage:**\n```tsx\n<BarChart\n data={data}\n categoryKey="month"\n customPalette={["#FF6B6B", "#4ECDC4", "#45B7D1"]}\n // theme prop is ignored when customPalette is provided\n/>\n```',+ 'Demonstrates how to use the `customPalette` prop to provide your own color scheme for the chart. When `customPalette` is provided, it overrides the ThemeProvider\'s chart palette and uses your specified colors instead.\n\n**Key Features:**\n- 🎨 **Custom Colors**: Override the default chart colors with your own palette\n- 📊 **Consistent Distribution**: Colors are distributed evenly across data series\n- 🎯 **Brand Matching**: Perfect for matching your application\'s brand colors\n\n**Usage:**\n```tsx\n<BarChart\n data={data}\n categoryKey="month"\n customPalette={["#FF6B6B", "#4ECDC4", "#45B7D1"]}\n/>\n```',},},},@@ -1251,7 +1230,6 @@ export const ResponsiveBehaviorDemo: Story = {args: {data: dataVariations.default as any,categoryKey: "month" as any,- theme: "sunset",variant: "grouped",grid: true,legend: true,diff --git a/packages/react-ui/src/components/Charts/BarChartCondensed/stories/barChartCondensed.stories.tsx b/packages/react-ui/src/components/Charts/BarChart/stories/barChartCondensed.stories.tsxsimilarity index 96%rename from packages/react-ui/src/components/Charts/BarChartCondensed/stories/barChartCondensed.stories.tsxrename to packages/react-ui/src/components/Charts/BarChart/stories/barChartCondensed.stories.tsxindex ae1e98e03..3cdc5cf6e 100644--- a/packages/react-ui/src/components/Charts/BarChartCondensed/stories/barChartCondensed.stories.tsx+++ b/packages/react-ui/src/components/Charts/BarChart/stories/barChartCondensed.stories.tsx@@ -10,8 +10,8 @@ import {Watch,} from "lucide-react";import { useState } from "react";+import { BarChartCondensed, BarChartCondensedProps } from "../..";import { Card } from "../../../Card";-import { BarChartCondensed, BarChartCondensedProps } from "../BarChartCondensed";// 🔥 COMPREHENSIVE DATA VARIATIONS - Designed to test various scenariosconst dataVariations = {@@ -204,8 +204,8 @@ const icons = {* - **Responsive Design**: Adapts fluidly to its container's size** ### Customization- * - **Theming**: Comes with six pre-built color palettes- * - **Bar Styling**: Customize corner radius with the radius prop+ * - **Colors**: Uses the ThemeProvider's chart palette, or custom colors with `customPalette`+ * - **Bar Styling**: Customize corner radius with the barRadius prop* - **Styling Options**: Control grid visibility, axes, and more*/const meta: Meta<BarChartCondensedProps<typeof barChartCondensedData>> = {@@ -231,7 +231,6 @@ const salesData = [<BarChartdata={salesData}categoryKey="month"- theme="ocean"height={200}/>\`\`\`@@ -288,19 +287,8 @@ const salesData = [category: "📊 Data Configuration",},},- theme: {- description:- "Specifies the color palette for the chart's bars and tooltips. Ignored when customPalette is provided.",- control: "select",- options: ["ocean", "orchid", "emerald", "sunset", "spectrum", "vivid"],- table: {- defaultValue: { summary: "ocean" },- category: "🎨 Visual Styling",- },- },customPalette: {- description:- "Custom array of colors to use instead of the theme palette. Overrides the theme prop when provided.",+ description: "Custom array of colors to use instead of the ThemeProvider's chart palette.",control: "object",table: {type: { summary: "string[]" },@@ -319,7 +307,7 @@ const salesData = [},tickVariant: {description:- "X-axis tick label style. Choose between 'singleLine' (horizontal) or 'angled' (rotated at optimal angle).",+ "X-axis tick label style. Choose between 'singleLine' (horizontal) or 'angled' (rotated 45° when they don't fit).",control: "radio",options: ["singleLine", "angled"],table: {@@ -327,7 +315,7 @@ const salesData = [category: "🎨 Visual Styling",},},- radius: {+ barRadius: {description: "Sets the corner radius for the top of each bar, creating a rounded look.",control: { type: "number", min: 0, max: 12, step: 1 },table: {@@ -433,10 +421,9 @@ export const DataExplorer: Story = {args: {data: barChartCondensedData,categoryKey: "month",- theme: "ocean",variant: "grouped",tickVariant: "singleLine",- radius: 4,+ barRadius: 4,grid: true,isAnimationActive: false,showYAxis: true,@@ -676,7 +663,6 @@ export const LargeDatasetWithSidebarTooltip: Story = {},] as any,categoryKey: "quarter" as any,- theme: "ocean",variant: "grouped",tickVariant: "singleLine",grid: true,@@ -752,7 +738,6 @@ export const VariantComparison: Story = {data={dataVariations.default as any}categoryKey="month"variant="grouped"- theme="ocean"height={200}/></Card>@@ -769,7 +754,6 @@ export const VariantComparison: Story = {data={dataVariations.default as any}categoryKey="month"variant="stacked"- theme="emerald"height={200}/></Card>@@ -796,10 +780,9 @@ export const BigLabelsStory: Story = {args: {data: dataVariations.bigLabels as any,categoryKey: "category" as any,- theme: "emerald",variant: "grouped",tickVariant: "angled",- radius: 4,+ barRadius: 4,grid: true,isAnimationActive: false,showYAxis: true,@@ -814,7 +797,7 @@ export const BigLabelsStory: Story = {docs: {description: {story:- "Tests the chart with extremely long category names. The angled tick variant automatically rotates labels at an optimal angle to prevent overlapping and maximize readability.",+ "Tests the chart with extremely long category names. The angled tick variant rotates labels 45° to prevent overlapping and maximize readability.",},},},@@ -831,10 +814,9 @@ export const CompanyNamesStory: Story = {args: {data: dataVariations.companyNames as any,categoryKey: "company" as any,- theme: "vivid",variant: "grouped",tickVariant: "angled",- radius: 4,+ barRadius: 4,grid: true,isAnimationActive: false,showYAxis: true,@@ -865,10 +847,9 @@ export const FinancialQuartersGrouped: Story = {args: {data: dataVariations.financialQuarters as any,categoryKey: "quarter" as any,- theme: "sunset",variant: "grouped",tickVariant: "singleLine",- radius: 4,+ barRadius: 4,grid: true,isAnimationActive: false,showYAxis: true,@@ -899,10 +880,9 @@ export const FinancialQuartersStacked: Story = {args: {data: dataVariations.financialQuarters as any,categoryKey: "quarter" as any,- theme: "orchid",variant: "stacked",tickVariant: "singleLine",- radius: 4,+ barRadius: 4,grid: true,isAnimationActive: false,showYAxis: true,@@ -933,10 +913,9 @@ export const WeeklyTrafficStory: Story = {args: {data: dataVariations.weeklyTraffic as any,categoryKey: "day" as any,- theme: "spectrum",variant: "grouped",tickVariant: "singleLine",- radius: 4,+ barRadius: 4,grid: true,isAnimationActive: false,showYAxis: true,@@ -966,10 +945,9 @@ export const MinimalDataStory: Story = {args: {data: dataVariations.minimal as any,categoryKey: "category" as any,- theme: "emerald",variant: "grouped",tickVariant: "singleLine",- radius: 4,+ barRadius: 4,grid: true,isAnimationActive: false,showYAxis: true,@@ -999,10 +977,9 @@ export const CustomPaletteStory: Story = {args: {data: dataVariations.default as any,categoryKey: "month" as any,- theme: "ocean", // This will be overridden by customPalettevariant: "grouped",tickVariant: "singleLine",- radius: 4,+ barRadius: 4,grid: true,isAnimationActive: false,showYAxis: true,@@ -1065,7 +1042,7 @@ export const CustomPaletteStory: Story = {docs: {description: {story:- 'Demonstrates how to use the `customPalette` prop to provide your own color scheme. When `customPalette` is provided, it overrides the `theme` prop.\n\n**Usage:**\n```tsx\n<BarChartCondensed\n data={data}\n categoryKey="month"\n customPalette={["#FF6B6B", "#4ECDC4", "#45B7D1"]}\n/>\n```',+ 'Demonstrates how to use the `customPalette` prop to provide your own color scheme. When `customPalette` is provided, it overrides the ThemeProvider\'s chart palette.\n\n**Usage:**\n```tsx\n<BarChartCondensed\n data={data}\n categoryKey="month"\n customPalette={["#FF6B6B", "#4ECDC4", "#45B7D1"]}\n/>\n```',},},},@@ -1091,8 +1068,7 @@ export const RadiusComparison: Story = {data={dataVariations.default as any}categoryKey="month"variant="grouped"- theme="ocean"- radius={0}+ barRadius={0}height={180}/></Card>@@ -1107,8 +1083,7 @@ export const RadiusComparison: Story = {data={dataVariations.default as any}categoryKey="month"variant="grouped"- theme="emerald"- radius={4}+ barRadius={4}height={180}/></Card>@@ -1123,8 +1098,7 @@ export const RadiusComparison: Story = {data={dataVariations.default as any}categoryKey="month"variant="grouped"- theme="sunset"- radius={8}+ barRadius={8}height={180}/></Card>@@ -1155,7 +1129,7 @@ export const TickVariantComparison: Story = {Single Line Variant (Horizontal)</div><div style={{ fontSize: "13px", color: "#666" }}>- Standard horizontal labels. Recharts automatically hides overlapping labels.+ Standard horizontal labels, truncated with an ellipsis when they don't fit.</div></div><BarChartCondensed@@ -1163,7 +1137,6 @@ export const TickVariantComparison: Story = {categoryKey="category"variant="grouped"tickVariant="singleLine"- theme="ocean"height={200}/></Card>@@ -1173,7 +1146,7 @@ export const TickVariantComparison: Story = {Angled Variant (Rotated)</div><div style={{ fontSize: "13px", color: "#666" }}>- Automatically rotates labels at an optimal angle. Shows more labels without collision.+ Rotates labels 45° when they don't fit horizontally.</div></div><BarChartCondensed@@ -1181,7 +1154,6 @@ export const TickVariantComparison: Story = {categoryKey="category"variant="grouped"tickVariant="angled"- theme="emerald"height={260}/></Card>@@ -1191,7 +1163,7 @@ export const TickVariantComparison: Story = {docs: {description: {story:- "**Side-by-side comparison** of tick variants:\n\n- **Single Line**: Standard horizontal labels with automatic collision detection. Recharts hides overlapping labels.\n- **Angled**: Rotates labels at an optimal angle calculated based on label width and available space. Shows more labels without collision.\n\n**When to use each:**\n- Use **singleLine** for short labels or when you have few data points\n- Use **angled** for long labels or many data points where horizontal labels would overlap",+ "**Side-by-side comparison** of tick variants:\n\n- **Single Line**: Standard horizontal labels, truncated with an ellipsis when they don't fit.\n- **Angled**: Rotates labels 45° when they don't fit horizontally.\n\n**When to use each:**\n- Use **singleLine** for short labels or when you have few data points\n- Use **angled** for long labels or many data points where horizontal labels would overlap",},},},@@ -1234,10 +1206,9 @@ export const SuperCondensedStory: Story = {{ month: "Dec '24", desktop: 900, mobile: 560, tablet: 470 },] as any,categoryKey: "month" as any,- theme: "ocean",variant: "grouped",tickVariant: "angled",- radius: 4,+ barRadius: 4,grid: true,isAnimationActive: false,showYAxis: true,@@ -1292,10 +1263,9 @@ export const ResponsiveBehaviorDemo: Story = {args: {data: dataVariations.bigLabels as any,categoryKey: "category" as any,- theme: "sunset",variant: "grouped",tickVariant: "angled",- radius: 4,+ barRadius: 4,grid: true,isAnimationActive: false,showYAxis: true,diff --git a/packages/react-ui/src/components/D3Charts/BarChart/types.ts b/packages/react-ui/src/components/Charts/BarChart/types.tssimilarity index 100%rename from packages/react-ui/src/components/D3Charts/BarChart/types.tsrename to packages/react-ui/src/components/Charts/BarChart/types.tsdiff --git a/packages/react-ui/src/components/Charts/BarChart/types/index.ts b/packages/react-ui/src/components/Charts/BarChart/types/index.tsdeleted file mode 100644index 6f3195c54..000000000--- a/packages/react-ui/src/components/Charts/BarChart/types/index.ts+++ /dev/null@@ -1,3 +0,0 @@-export type BarChartVariant = "grouped" | "stacked";--export type BarChartData = Array<Record<string, string | number>>;diff --git a/packages/react-ui/src/components/Charts/BarChart/utils/BarChartUtils.ts b/packages/react-ui/src/components/Charts/BarChart/utils/BarChartUtils.tsdeleted file mode 100644index ea465fa27..000000000--- a/packages/react-ui/src/components/Charts/BarChart/utils/BarChartUtils.ts+++ /dev/null@@ -1,138 +0,0 @@-import { getDataKeys } from "../../utils/dataUtils";-import { BarChartVariant } from "../types";--export const BAR_WIDTH = 16;--// Internal constants - not exported as they're only used within this file-const ELEMENT_SPACING_GROUPED = 56; // Spacing per bar in grouped charts--const ELEMENT_SPACING_STACKED = 56; // Spacing per stack in stacked charts--/**- * INTERNAL HELPER FUNCTION- * Get the appropriate element spacing based on chart variant- * @param variant - The chart variant- * @returns The spacing value for the given variant- */-const getElementSpacing = (variant: BarChartVariant): number => {- switch (variant) {- case "stacked":- return ELEMENT_SPACING_STACKED;- case "grouped":- default:- return ELEMENT_SPACING_GROUPED;- }-};--/**- * This function returns the width of the data in the chart, used for padding calculation, scroll amount calculation, and- * for the width of the chart container.- * @param data - The data to be displayed in the chart.- * @param categoryKey - The key of the category to be displayed in the chart.- * @param variant - The variant of the chart.- */-const getWidthOfData = (- data: Array<Record<string, string | number>>,- categoryKey: string,- variant: BarChartVariant,-) => {- if (data.length === 0) {- return 0;- }-- const width = data.length * getWidthOfGroup(data, categoryKey, variant);-- if (data.length === 1) {- const minSingleDataWidth = 200; // Minimum width for single data points- return Math.max(width, minSingleDataWidth);- }- return width;-};--/**- * This function returns the padding for the chart, used for the padding of the chart container.- * @param data - The data to be displayed in the chart.- * @param categoryKey - The key of the category to be displayed in the chart.- * @param containerWidth - The width of the container of the chart.- * @param variant - The variant of the chart.- */-const getPadding = (- data: Array<Record<string, string | number>>,- categoryKey: string,- containerWidth: number,- variant: BarChartVariant,-) => {- const chartWidth = getWidthOfData(data, categoryKey, variant);- const paddingValue = containerWidth - chartWidth;-- if (paddingValue < 0) {- // If chart content is wider than container, no padding- return {- left: 10,- right: 10,- };- } else {- return {- left: paddingValue / 2,- right: paddingValue / 2,- };- }-};--/**- * This function returns the scroll amount for the chart, used for the scroll amount of the chart.- * This can also be used to calculate the width of each group/category.- * @param data - The data to be displayed in the chart.- * @param categoryKey - The key of the category to be displayed in the chart.- * @param variant - The variant of the chart.- */-const getWidthOfGroup = (- data: Array<Record<string, string | number>>,- categoryKey: string,- variant: BarChartVariant,-) => {- if (data.length === 0) return 200; // Fallback-- // Get the number of data keys (excluding categoryKey)- const dataKeys = getDataKeys(data, categoryKey);- const elementSpacing = getElementSpacing(variant);-- if (variant === "stacked") {- // For stacked: each category is one stack- // Example: month "January" = 1 stack = BAR_WIDTH + ELEMENT_SPACING_STACKED (60)- return BAR_WIDTH + elementSpacing;- } else {- // For grouped: each category contains multiple bars- // Example: month "January" with desktop+mobile+tablet = 3 bars- // Width = 3 * (BAR_WIDTH + gap between bars) - gap between bars for the last bar + elementSpacing- const seriesPerCategory = dataKeys.length;- return seriesPerCategory * (BAR_WIDTH + 8) - 8 + elementSpacing;- }-};--/**- * This function returns the snap positions for the chart, used for the snap positions of the chart.- * @param data - The data to be displayed in the chart.- * @param categoryKey - The key of the category to be displayed in the chart.- * @param variant - The variant of the chart.- * @returns The snap positions for the chart.- */-const getSnapPositions = (- data: Array<Record<string, string | number>>,- categoryKey: string,- variant: BarChartVariant,-): number[] => {- if (data.length === 0) return [0];-- const positions = [0]; // Start position- const groupWidthValue = getWidthOfGroup(data, categoryKey, variant);-- // Calculate all valid snap positions based on groups- for (let i = 1; i < data.length; i++) {- positions.push(i * groupWidthValue);- }-- return positions;-};--export { getPadding, getSnapPositions, getWidthOfData, getWidthOfGroup };diff --git a/packages/react-ui/src/components/Charts/BarChartCondensed/BarChartCondensed.tsx b/packages/react-ui/src/components/Charts/BarChartCondensed/BarChartCondensed.tsxdeleted file mode 100644index 4f5089cba..000000000--- a/packages/react-ui/src/components/Charts/BarChartCondensed/BarChartCondensed.tsx+++ /dev/null@@ -1,534 +0,0 @@-import clsx from "clsx";-import React, { useCallback, useEffect, useId, useMemo, useRef, useState } from "react";-import { Bar, BarChart as RechartsBarChart, XAxis, YAxis } from "recharts";-import { usePrintContext } from "../../../context/PrintContext";-import { useTheme } from "../../ThemeProvider";-import { BarChartData, BarChartVariant } from "../BarChart/types";-import { ChartConfig, ChartContainer, ChartTooltip } from "../Charts";-import { DEFAULT_X_AXIS_HEIGHT, X_AXIS_PADDING } from "../constants";-import { SideBarChartData, SideBarTooltipProvider } from "../context/SideBarTooltipContext";-import {- useAutoAngleCalculation,- useExportChartData,- useMaxLabelWidth,- useTransformedKeys,- useYAxisLabelWidth,-} from "../hooks";-import {- cartesianGrid,- CustomTooltipContent,- DefaultLegend,- LineInBarShape,- SideBarTooltip,- SVGXAxisTick,- SVGXAxisTickVariant,- YAxisTick,-} from "../shared";-import { LabelTooltipProvider } from "../shared/LabelTooltip/LabelTooltip";-import { LegendItem } from "../types";-import { getBarStackInfo, getRadiusArray } from "../utils/BarCharts/BarChartsUtils";-import {- get2dChartConfig,- getColorForDataKey,- getDataKeys,- getLegendItems,-} from "../utils/dataUtils";-import { PaletteName, useChartPalette } from "../utils/PalletUtils";--// this a technic to get the type of the onClick event of the bar chart-// we need to do this because the onClick event type is not exported by recharts-type BarChartOnClick = React.ComponentProps<typeof RechartsBarChart>["onClick"];-type BarClickData = Parameters<NonNullable<BarChartOnClick>>[0];--export interface BarChartCondensedProps<T extends BarChartData> {- data: T;- categoryKey: keyof T[number];- theme?: PaletteName;- customPalette?: string[];- variant?: BarChartVariant;- tickVariant?: SVGXAxisTickVariant;- grid?: boolean;- radius?: number;- icons?: Partial<Record<keyof T[number], React.ComponentType>>;- isAnimationActive?: boolean;- showYAxis?: boolean;- xAxisLabel?: React.ReactNode;- yAxisLabel?: React.ReactNode;- legend?: boolean;- className?: string;- height?: number;- width?: number;- /** Maximum bar width in pixels. Prevents bars from becoming too wide. Default: 12 */- maxBarWidth?: number;-}--// Default maximum bar width - prevents bars from becoming too wide with sparse data-const DEFAULT_MAX_BAR_WIDTH = 12;--// Layout constants-const BAR_GAP = 10;-const BAR_CATEGORY_GAP = "20%";-const BAR_INTERNAL_LINE_WIDTH = 1;-const BAR_RADIUS = 4;-const CHART_HEIGHT = 296;-const CHART_CONTAINER_BOTTOM_MARGIN = 10;--const BarChartCondensedComponent = <T extends BarChartData>({- data,- categoryKey,- theme = "ocean",- customPalette,- variant = "grouped",- tickVariant = "singleLine",- grid = true,- icons = {},- radius,- isAnimationActive = false,- showYAxis = true,- xAxisLabel,- yAxisLabel,- legend = true,- className,- height = CHART_HEIGHT,- width,- maxBarWidth = DEFAULT_MAX_BAR_WIDTH,-}: BarChartCondensedProps<T>) => {- const printContext = usePrintContext();- isAnimationActive = printContext ? false : isAnimationActive;-- 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 chartContainerRef = useRef<HTMLDivElement>(null);- const [chartContainerWidth, setChartContainerWidth] = useState<number>(0);-- const widthOfData = useMemo(() => {- if (data.length === 0) {- return 0;- }- // Use passed width if available, otherwise use observed chartContainerWidth- const chartWidth = width ?? chartContainerWidth;- return chartWidth / data.length;- }, [chartContainerWidth, data, width]);-- const { angle: calculatedAngle, height: xAxisHeight } = useAutoAngleCalculation(- maxLabelWidth,- tickVariant === "angled",- maxLabelWidth < 100 ? widthOfData : undefined,- );-- const isAngled = useMemo(() => {- return calculatedAngle !== 0;- }, [calculatedAngle]);-- const effectiveHeight = useMemo(() => {- if (tickVariant === "angled") {- return xAxisHeight + height;- }- return height + DEFAULT_X_AXIS_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 exportData = useExportChartData({- type: "bar",- data,- categoryKey: categoryKey as string,- dataKeys,- colors,- legend,- xAxisLabel,- yAxisLabel,- });-- const chartMargin = useMemo(- () => ({- top: 10,- right: 10,- bottom: CHART_CONTAINER_BOTTOM_MARGIN,- left: showYAxis ? 10 : 0,- }),- [showYAxis],- );-- const { mode, theme: userTheme } = useTheme();-- const calculatedRadius = useMemo(() => {- let radiusValue: number = BAR_RADIUS;-- if (typeof radius === "number") {- radiusValue = radius;- } else {- const radiusTheme = userTheme.radius2xs;- if (radiusTheme) {- radiusValue = typeof radiusTheme === "string" ? parseInt(radiusTheme) : radiusTheme;- }- }-- return radiusValue;- }, [userTheme.radius2xs, radius]);-- 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 [containerWidth, setContainerWidth] = useState<number>(0);- const [isSideBarTooltipOpen, setIsSideBarTooltipOpen] = useState(false);- const [sideBarTooltipData, setSideBarTooltipData] = useState<SideBarChartData>({- title: "",- values: [],- });- const [hoveredCategory, setHoveredCategory] = useState<string | number | null>(null);- const [isLegendExpanded, setIsLegendExpanded] = useState(false);-- // Use provided width or observed width- const effectiveWidth = useMemo(() => {- return width ?? containerWidth;- }, [width, containerWidth]);-- // Calculate explicit chart width when width prop is provided- // This allows Recharts to calculate bar dimensions on first render- const explicitChartWidth = useMemo(() => {- if (!width) return undefined;- // Subtract Y-axis width and margins to get the actual chart area width- const yAxisSpace = showYAxis ? yAxisWidth : 0;- return width - yAxisSpace - chartMargin.left - chartMargin.right;- }, [width, showYAxis, yAxisWidth, chartMargin.left, chartMargin.right]);-- // Calculate optimal bar width based on available space- // Only applies maximum constraint - Recharts handles thin bars automatically- const calculatedBarWidth = useMemo(() => {- // Use explicitChartWidth if available, otherwise fall back to chartContainerWidth- const availableWidth = explicitChartWidth ?? chartContainerWidth;-- // If no width available, return undefined and let Recharts auto-size- if (!availableWidth || availableWidth === 0 || data.length === 0) {- return undefined;- }-- // Calculate space per category (Recharts handles gaps automatically via barGap and barCategoryGap props)- const spacePerCategory = availableWidth / data.length;-- // For grouped charts, multiple bars share the category space- const barsPerCategory = variant === "stacked" ? 1 : dataKeys.length;-- // Simple division - let Recharts apply gaps via barGap and barCategoryGap props- const barWidth = spacePerCategory / barsPerCategory;-- // Only apply maximum constraint, let Recharts handle thin bars automatically- return Math.min(maxBarWidth, barWidth);- }, [explicitChartWidth, chartContainerWidth, data.length, dataKeys.length, variant, maxBarWidth]);-- // 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 onBarClick = useCallback(- (data: BarClickData) => {- if (data?.activePayload?.length && data.activePayload.length > 10) {- setIsSideBarTooltipOpen(true);- setSideBarTooltipData({- title: data.activeLabel as string,- values: data.activePayload.map((payload) => ({- value: payload.value as number,- label: payload.name || payload.dataKey,- color: getColorForDataKey(payload.dataKey, dataKeys, colors),- })),- });- }- },- [dataKeys, colors],- );-- // Observe container width for legend- useEffect(() => {- // Always set up ResizeObserver for chartContainerRef to get accurate bar width calculations- if (!chartContainerRef.current) {- return () => {};- }-- const resizeObserver = new ResizeObserver((entries) => {- // there is only one entry in the entries array because we are observing the chart container- for (const entry of entries) {- if (entry.target === containerRef.current && !width) {- // Only observe containerRef if width is not provided- setContainerWidth(entry.contentRect.width);- }- if (entry.target === chartContainerRef.current) {- setChartContainerWidth(entry.contentRect.width);- }- }- });-- // Always observe chartContainerRef- resizeObserver.observe(chartContainerRef.current);-- // Only observe containerRef if width is not provided- if (!width && containerRef.current) {- resizeObserver.observe(containerRef.current);- }-- return () => {- resizeObserver.disconnect();- };- }, [width]);-- useEffect(() => {- setIsLegendExpanded(false);- }, [dataKeys]);-- // Memoize legend items creation- const legendItems: LegendItem[] = useMemo(() => {- if (!legend) {- return [];- }- return getLegendItems(dataKeys, colors, icons);- }, [dataKeys, colors, icons, legend]);-- const yAxis = useMemo(() => {- if (!showYAxis) {- return null;- }- return (- <div className="openui-bar-chart-condensed-y-axis-container">- {/* Y-axis only chart - synchronized with main chart */}- <RechartsBarChart- key={`y-axis-bar-chart-condensed-${id}`}- width={yAxisWidth}- height={effectiveHeight}- data={data}- stackOffset="sign"- margin={{- top: chartMargin.top,- bottom: xAxisHeight + chartMargin.bottom, // this is required to give space for x-axis- left: 0,- right: 0,- }}- >- <YAxis- width={yAxisWidth}- tickLine={false}- axisLine={false}- tick={<YAxisTick setLabelWidth={setLabelWidth} />}- />- {/* Invisible bars to maintain scale synchronization */}- {dataKeys.map((key) => {- return (- <Bar- key={`yaxis-bar-chart-condensed-${key}`}- dataKey={key}- fill="transparent"- stackId={variant === "stacked" ? "a" : undefined}- isAnimationActive={false}- maxBarSize={0}- />- );- })}- </RechartsBarChart>- </div>- );- }, [- showYAxis,- effectiveHeight,- data,- dataKeys,- variant,- id,- yAxisWidth,- chartMargin,- xAxisHeight,- setLabelWidth,- ]);-- 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={calculatedBarWidth}- barSize={calculatedBarWidth}- shape={(props: any) => {- const { payload, value, dataKey } = props;-- const { isNegative, isFirstInStack, isLastInStack, hasNegativeValueInStack } =- getBarStackInfo(variant, value, dataKey, payload, dataKeys);-- const customRadius = getRadiusArray(- variant,- calculatedRadius,- "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,- calculatedRadius,- isAnimationActive,- barInternalLineColor,- hoveredCategory,- categoryKey,- calculatedBarWidth,- ]);-- return (- <LabelTooltipProvider>- <SideBarTooltipProvider- isSideBarTooltipOpen={isSideBarTooltipOpen}- setIsSideBarTooltipOpen={setIsSideBarTooltipOpen}- data={sideBarTooltipData}- setData={setSideBarTooltipData}- >- <div- className={clsx("openui-bar-chart-condensed-container", className)}- data-openui-chart={exportData}- style={{- width: width ? `${width}px` : undefined,- }}- >- {yAxisLabel && (- <div className="openui-bar-chart-condensed-y-axis-label">{yAxisLabel}</div>- )}- <div className="openui-bar-chart-condensed-container-inner" ref={containerRef}>- {/* Y-axis of the chart */}- {yAxis}- <div className="openui-bar-chart-condensed" ref={chartContainerRef}>- <ChartContainer- config={chartConfig}- style={{- width: explicitChartWidth ? `${explicitChartWidth}px` : "100%",- height: effectiveHeight,- }}- rechartsProps={{- width: explicitChartWidth ?? "100%",- height: effectiveHeight,- }}- >- <RechartsBarChart- stackOffset="sign"- accessibilityLayer- key={`bar-chart-condensed-${id}`}- data={data}- margin={chartMargin}- barGap={BAR_GAP}- barCategoryGap={BAR_CATEGORY_GAP}- onMouseMove={handleChartMouseMove}- onMouseLeave={handleChartMouseLeave}- onClick={onBarClick}- width={explicitChartWidth}- height={effectiveHeight}- >- {grid && cartesianGrid()}-- <XAxis- dataKey={categoryKey as string}- tickLine={false}- axisLine={false}- textAnchor={isAngled ? "end" : "middle"}- interval="preserveStartEnd"- minTickGap={5}- height={xAxisHeight}- tick={<SVGXAxisTick />}- angle={calculatedAngle}- orientation="bottom"- padding={{- left: X_AXIS_PADDING,- right: X_AXIS_PADDING,- }}- />- {/* Y-axis is rendered in the separate synchronized chart */}-- <ChartTooltip- cursor={{- fill: "var(--openui-highlight)",- stroke: "var(--openui-stroke-default)",- opacity: 1,- strokeWidth: 1,- }}- content={<CustomTooltipContent parentRef={containerRef} />}- offset={10}- />-- {barElements}- </RechartsBarChart>- </ChartContainer>- </div>- {isSideBarTooltipOpen && <SideBarTooltip height={effectiveHeight} />}- </div>- {xAxisLabel && (- <div className="openui-bar-chart-condensed-x-axis-label">{xAxisLabel}</div>- )}- {legend && (- <DefaultLegend- items={legendItems}- containerWidth={effectiveWidth}- isExpanded={isLegendExpanded}- setIsExpanded={setIsLegendExpanded}- />- )}- </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/packages/react-ui/src/components/Charts/BarChartCondensed/barChartCondensed.scss b/packages/react-ui/src/components/Charts/BarChartCondensed/barChartCondensed.scssdeleted file mode 100644index 806b4905e..000000000--- a/packages/react-ui/src/components/Charts/BarChartCondensed/barChartCondensed.scss+++ /dev/null@@ -1,32 +0,0 @@-@use "../../../cssUtils" as cssUtils;--.openui-bar-chart-condensed-container {- display: flex;- flex-direction: column;-}--.openui-bar-chart-condensed-container-inner {- display: flex;- width: 100%;-}--.openui-bar-chart-condensed-y-axis-container {- flex-shrink: 0;-}--.openui-bar-chart-condensed {- width: 100%;- height: 100%;-- &-x-axis-label {- @include cssUtils.typography(label, extra-small);- color: cssUtils.$text-neutral-secondary;- text-align: center;- }-- &-y-axis-label {- @include cssUtils.typography(label, extra-small);- color: cssUtils.$text-neutral-secondary;- padding-bottom: cssUtils.$space-s;- }-}diff --git a/packages/react-ui/src/components/Charts/BarChartCondensed/dependencies.ts b/packages/react-ui/src/components/Charts/BarChartCondensed/dependencies.tsdeleted file mode 100644index abc6c017c..000000000--- a/packages/react-ui/src/components/Charts/BarChartCondensed/dependencies.ts+++ /dev/null@@ -1,2 +0,0 @@-const dependencies = ["BarChartCondensed"];-export default dependencies;diff --git a/packages/react-ui/src/components/Charts/BarChartCondensed/index.ts b/packages/react-ui/src/components/Charts/BarChartCondensed/index.tsdeleted file mode 100644index 7bd483feb..000000000--- a/packages/react-ui/src/components/Charts/BarChartCondensed/index.ts+++ /dev/null@@ -1,2 +0,0 @@-export * from "../BarChart/types";-export * from "./BarChartCondensed";diff --git a/packages/react-ui/src/components/D3Charts/CalendarHeatmap/CalendarHeatmap.tsx b/packages/react-ui/src/components/Charts/CalendarHeatmap/CalendarHeatmap.tsxsimilarity index 99%rename from packages/react-ui/src/components/D3Charts/CalendarHeatmap/CalendarHeatmap.tsxrename to packages/react-ui/src/components/Charts/CalendarHeatmap/CalendarHeatmap.tsxindex 2c7ea077d..abb7970e4 100644--- a/packages/react-ui/src/components/D3Charts/CalendarHeatmap/CalendarHeatmap.tsx+++ b/packages/react-ui/src/components/Charts/CalendarHeatmap/CalendarHeatmap.tsx@@ -36,6 +36,7 @@ export function CalendarHeatmap(props: CalendarHeatmapProps) {columnSeparators,legendVariant = "swatches",legendLabels,+ valueLabel = "Contributions",formatTooltipLabel,tooltipDelay,rowOpacity,@@ -70,6 +71,7 @@ export function CalendarHeatmap(props: CalendarHeatmapProps) {showMonthLabels,columnSeparators,showLegend,+ valueLabel,formatTooltipLabel,width,height,diff --git a/packages/react-ui/src/components/D3Charts/CalendarHeatmap/calendarHeatmap.scss b/packages/react-ui/src/components/Charts/CalendarHeatmap/calendarHeatmap.scsssimilarity index 100%rename from packages/react-ui/src/components/D3Charts/CalendarHeatmap/calendarHeatmap.scssrename to packages/react-ui/src/components/Charts/CalendarHeatmap/calendarHeatmap.scssdiff --git a/packages/react-ui/src/components/D3Charts/CalendarHeatmap/index.ts b/packages/react-ui/src/components/Charts/CalendarHeatmap/index.tssimilarity index 100%rename from packages/react-ui/src/components/D3Charts/CalendarHeatmap/index.tsrename to packages/react-ui/src/components/Charts/CalendarHeatmap/index.tsdiff --git a/packages/react-ui/src/components/D3Charts/CalendarHeatmap/parts/CalendarCells.tsx b/packages/react-ui/src/components/Charts/CalendarHeatmap/parts/CalendarCells.tsxsimilarity index 100%rename from packages/react-ui/src/components/D3Charts/CalendarHeatmap/parts/CalendarCells.tsxrename to packages/react-ui/src/components/Charts/CalendarHeatmap/parts/CalendarCells.tsxdiff --git a/packages/react-ui/src/components/D3Charts/CalendarHeatmap/parts/CalendarLegend.tsx b/packages/react-ui/src/components/Charts/CalendarHeatmap/parts/CalendarLegend.tsxsimilarity index 100%rename from packages/react-ui/src/components/D3Charts/CalendarHeatmap/parts/CalendarLegend.tsxrename to packages/react-ui/src/components/Charts/CalendarHeatmap/parts/CalendarLegend.tsxdiff --git a/packages/react-ui/src/components/D3Charts/CalendarHeatmap/parts/CalendarPatternDefs.tsx b/packages/react-ui/src/components/Charts/CalendarHeatmap/parts/CalendarPatternDefs.tsxsimilarity index 100%rename from packages/react-ui/src/components/D3Charts/CalendarHeatmap/parts/CalendarPatternDefs.tsxrename to packages/react-ui/src/components/Charts/CalendarHeatmap/parts/CalendarPatternDefs.tsxdiff --git a/packages/react-ui/src/components/D3Charts/CalendarHeatmap/parts/CalendarSeparators.tsx b/packages/react-ui/src/components/Charts/CalendarHeatmap/parts/CalendarSeparators.tsxsimilarity index 95%rename from packages/react-ui/src/components/D3Charts/CalendarHeatmap/parts/CalendarSeparators.tsxrename to packages/react-ui/src/components/Charts/CalendarHeatmap/parts/CalendarSeparators.tsxindex 19f71785d..40748fd4a 100644--- a/packages/react-ui/src/components/D3Charts/CalendarHeatmap/parts/CalendarSeparators.tsx+++ b/packages/react-ui/src/components/Charts/CalendarHeatmap/parts/CalendarSeparators.tsx@@ -50,7 +50,8 @@ export function CalendarSeparators({x2={x}y1={0}y2={plotHeight}- stroke={stroke}+ // Inline style: a presentation attribute would lose to the class rule.+ style={stroke ? { stroke } : undefined}strokeDasharray={dashed ? "4,4" : undefined}/>);diff --git a/packages/react-ui/src/components/D3Charts/CalendarHeatmap/parts/MonthAxis.tsx b/packages/react-ui/src/components/Charts/CalendarHeatmap/parts/MonthAxis.tsxsimilarity index 100%rename from packages/react-ui/src/components/D3Charts/CalendarHeatmap/parts/MonthAxis.tsxrename to packages/react-ui/src/components/Charts/CalendarHeatmap/parts/MonthAxis.tsxdiff --git a/packages/react-ui/src/components/D3Charts/CalendarHeatmap/parts/WeekdayAxis.tsx b/packages/react-ui/src/components/Charts/CalendarHeatmap/parts/WeekdayAxis.tsxsimilarity index 100%rename from packages/react-ui/src/components/D3Charts/CalendarHeatmap/parts/WeekdayAxis.tsxrename to packages/react-ui/src/components/Charts/CalendarHeatmap/parts/WeekdayAxis.tsxdiff --git a/packages/react-ui/src/components/D3Charts/CalendarHeatmap/parts/calendarMath.test.ts b/packages/react-ui/src/components/Charts/CalendarHeatmap/parts/calendarMath.test.tssimilarity index 100%rename from packages/react-ui/src/components/D3Charts/CalendarHeatmap/parts/calendarMath.test.tsrename to packages/react-ui/src/components/Charts/CalendarHeatmap/parts/calendarMath.test.tsdiff --git a/packages/react-ui/src/components/D3Charts/CalendarHeatmap/parts/calendarMath.ts b/packages/react-ui/src/components/Charts/CalendarHeatmap/parts/calendarMath.tssimilarity index 100%rename from packages/react-ui/src/components/D3Charts/CalendarHeatmap/parts/calendarMath.tsrename to packages/react-ui/src/components/Charts/CalendarHeatmap/parts/calendarMath.tsdiff --git a/packages/react-ui/src/components/D3Charts/CalendarHeatmap/parts/levelScale.test.ts b/packages/react-ui/src/components/Charts/CalendarHeatmap/parts/levelScale.test.tssimilarity index 100%rename from packages/react-ui/src/components/D3Charts/CalendarHeatmap/parts/levelScale.test.tsrename to packages/react-ui/src/components/Charts/CalendarHeatmap/parts/levelScale.test.tsdiff --git a/packages/react-ui/src/components/D3Charts/CalendarHeatmap/parts/levelScale.ts b/packages/react-ui/src/components/Charts/CalendarHeatmap/parts/levelScale.tssimilarity index 100%rename from packages/react-ui/src/components/D3Charts/CalendarHeatmap/parts/levelScale.tsrename to packages/react-ui/src/components/Charts/CalendarHeatmap/parts/levelScale.tsdiff --git a/packages/react-ui/src/components/D3Charts/CalendarHeatmap/parts/separatorLayout.test.ts b/packages/react-ui/src/components/Charts/CalendarHeatmap/parts/separatorLayout.test.tssimilarity index 100%rename from packages/react-ui/src/components/D3Charts/CalendarHeatmap/parts/separatorLayout.test.tsrename to packages/react-ui/src/components/Charts/CalendarHeatmap/parts/separatorLayout.test.tsdiff --git a/packages/react-ui/src/components/D3Charts/CalendarHeatmap/parts/separatorLayout.ts b/packages/react-ui/src/components/Charts/CalendarHeatmap/parts/separatorLayout.tssimilarity index 100%rename from packages/react-ui/src/components/D3Charts/CalendarHeatmap/parts/separatorLayout.tsrename to packages/react-ui/src/components/Charts/CalendarHeatmap/parts/separatorLayout.tsdiff --git a/packages/react-ui/src/components/D3Charts/CalendarHeatmap/parts/staggerSeed.test.ts b/packages/react-ui/src/components/Charts/CalendarHeatmap/parts/staggerSeed.test.tssimilarity index 100%rename from packages/react-ui/src/components/D3Charts/CalendarHeatmap/parts/staggerSeed.test.tsrename to packages/react-ui/src/components/Charts/CalendarHeatmap/parts/staggerSeed.test.tsdiff --git a/packages/react-ui/src/components/D3Charts/CalendarHeatmap/parts/staggerSeed.ts b/packages/react-ui/src/components/Charts/CalendarHeatmap/parts/staggerSeed.tssimilarity index 100%rename from packages/react-ui/src/components/D3Charts/CalendarHeatmap/parts/staggerSeed.tsrename to packages/react-ui/src/components/Charts/CalendarHeatmap/parts/staggerSeed.tsdiff --git a/packages/react-ui/src/components/D3Charts/CalendarHeatmap/parts/useDelayedHover.ts b/packages/react-ui/src/components/Charts/CalendarHeatmap/parts/useDelayedHover.tssimilarity index 100%rename from packages/react-ui/src/components/D3Charts/CalendarHeatmap/parts/useDelayedHover.tsrename to packages/react-ui/src/components/Charts/CalendarHeatmap/parts/useDelayedHover.tsdiff --git a/packages/react-ui/src/components/Charts/CalendarHeatmap/stories/CalendarHeatmap.stories.tsx b/packages/react-ui/src/components/Charts/CalendarHeatmap/stories/CalendarHeatmap.stories.tsxnew file mode 100644index 000000000..971899257--- /dev/null+++ b/packages/react-ui/src/components/Charts/CalendarHeatmap/stories/CalendarHeatmap.stories.tsx@@ -0,0 +1,1121 @@+import type { Meta, StoryObj } from "@storybook/react";+import { useState } from "react";+import { CalendarHeatmap, CalendarHeatmapDatum, CalendarHeatmapProps } from "../..";+import { Card } from "../../../Card";++// 📊 DATA VARIATIONS - every dataset is built from FIXED dates with a seeded PRNG,+// so each render (and every visual snapshot) is identical. No Date.now(), no Math.random().++/** Seeded PRNG (mulberry32): the same seed always yields the same sequence. */+function seededRandom(seed: number) {+ let state = seed >>> 0;+ return () => {+ state = (state + 0x6d2b79f5) >>> 0;+ let t = state;+ t = Math.imul(t ^ (t >>> 15), t | 1);+ t ^= t + Math.imul(t ^ (t >>> 7), t | 61);+ return ((t ^ (t >>> 14)) >>> 0) / 4294967296;+ };+}++/** Local `YYYY-MM-DD` for a Date (never routed through UTC, so no day drifts). */+function isoDay(date: Date): string {+ const month = String(date.getMonth() + 1).padStart(2, "0");+ const day = String(date.getDate()).padStart(2, "0");+ return `${date.getFullYear()}-${month}-${day}`;+}++/** One datum per day from `start` to `end` (inclusive), valued by `valueFor`. */+function eachDay(start: Date, end: Date, valueFor: (date: Date) => number): CalendarHeatmapDatum[] {+ const days: CalendarHeatmapDatum[] = [];+ for (const cursor = new Date(start); cursor <= end; cursor.setDate(cursor.getDate() + 1)) {+ days.push({ date: isoDay(cursor), value: valueFor(cursor) });+ }+ return days;+}++/**+ * GitHub-style daily commit counts: mostly 0-4, quieter weekends, the odd busy+ * day, short zero-value stretches and a two-week summer break (Aug 4-15).+ */+function commitActivity(start: Date, end: Date, seed: number): CalendarHeatmapDatum[] {+ const random = seededRandom(seed);+ let quietDays = 0;+ return eachDay(start, end, (date) => {+ const isWeekend = date.getDay() === 0 || date.getDay() === 6;+ const isSummerBreak = date.getMonth() === 7 && date.getDate() >= 4 && date.getDate() <= 15;+ if (isSummerBreak) return 0;+ if (quietDays === 0 && random() < 0.04) quietDays = 2 + Math.floor(random() * 4);+ if (quietDays > 0) {+ quietDays--;+ return 0;+ }+ if (isWeekend) return random() < 0.65 ? 0 : 1 + Math.floor(random() * 2);+ return Math.floor(Math.pow(random(), 1.6) * 8);+ });+}++/** Daily store revenue in dollars: busier weekends, a Nov-Dec holiday lift, closed on 3 holidays. */+function dailyRevenue(year: number, seed: number): CalendarHeatmapDatum[] {+ const random = seededRandom(seed);+ const closed = new Set([`${year}-01-01`, `${year}-07-04`, `${year}-12-25`]);+ return eachDay(new Date(year, 0, 1), new Date(year, 11, 31), (date) => {+ if (closed.has(isoDay(date))) return 0;+ const isWeekend = date.getDay() === 0 || date.getDay() === 6;+ const holidayLift = date.getMonth() >= 10 ? 1400 : 0;+ return Math.round((isWeekend ? 2600 : 1500) + holidayLift + random() * 1400 - 400);+ });+}++// Same seed + same start date → the 2025 half of the two-year series equals `commits2025`.+const twoYearsOfCommits = commitActivity(new Date(2025, 0, 1), new Date(2026, 11, 31), 7);+const commits2025 = commitActivity(new Date(2025, 0, 1), new Date(2025, 11, 31), 7);+const projectActivity = commitActivity(new Date(2025, 1, 10), new Date(2025, 10, 21), 11);+const revenue2025 = dailyRevenue(2025, 3);+const quietYear = eachDay(new Date(2025, 0, 1), new Date(2025, 11, 31), () => 0);++// Sparse input: a release train every third Tuesday (skipping the August freeze).+// Missing days are simply level 0 — no need to pad the array.+const productionReleases: CalendarHeatmapDatum[] = [+ { date: "2025-01-14", value: 1 },+ { date: "2025-02-04", value: 2 },+ { date: "2025-02-25", value: 1 },+ { date: "2025-03-18", value: 3 },+ { date: "2025-04-08", value: 1 },+ { date: "2025-04-29", value: 2 },+ { date: "2025-05-20", value: 1 },+ { date: "2025-05-22", value: 4 }, // hotfix day+ { date: "2025-06-10", value: 1 },+ { date: "2025-07-01", value: 2 },+ { date: "2025-07-22", value: 1 },+ { date: "2025-09-02", value: 3 },+ { date: "2025-09-23", value: 1 },+ { date: "2025-10-14", value: 2 },+ { date: "2025-11-04", value: 1 },+ { date: "2025-11-25", value: 2 },+ // Two entries on the same day are SUMMED onto one cell (1 + 2 = 3).+ { date: "2025-12-16", value: 1 },+ { date: "2025-12-16", value: 2 },+];++const YEAR_2025: [string, string] = ["2025-01-01", "2025-12-31"];++// GitHub-green levels 0-4. Level 0 is a translucent slate so it reads on light and dark cards.+const GREEN_LEVELS: [string, string, string, string, string] = [+ "rgba(148, 163, 184, 0.2)",+ "#9BE9A8",+ "#40C463",+ "#30A14E",+ "#216E39",+];++// `range` presets for the playground's select control, mapped to real values. Keys stay+// URL-safe (letters, digits, spaces, hyphens) so a chosen preset survives in the story URL.+const RANGE_PRESETS: Record<string, CalendarHeatmapProps["range"]> = {+ "Jan-Dec 2025": YEAR_2025,+ "Jul-Dec 2025 - 6 months": ["2025-07-01", "2025-12-31"],+ "Oct 2025 - Mar 2026": ["2025-10-01", "2026-03-31"],+ "Data extent - range omitted": undefined,+ "12m - ending today": "12m",+ "6m - ending today": "6m",+};++const usd = new Intl.NumberFormat("en-US", {+ style: "currency",+ currency: "USD",+ maximumFractionDigits: 0,+});++const totalOf = (data: CalendarHeatmapDatum[]) => data.reduce((sum, day) => sum + day.value, 0);++/** Shared card chrome: a title, an optional caption, then the chart. */+function ChartCard({+ title,+ caption,+ width = 760,+ children,+}: {+ title: string;+ caption?: React.ReactNode;+ width?: number;+ children: React.ReactNode;+}) {+ return (+ <Card style={{ width: `${width}px`, height: "auto", padding: "24px" }}>+ <div>+ <h3 style={{ margin: "0 0 8px 0", fontSize: "18px", fontWeight: "600" }}>{title}</h3>+ {caption && <p style={{ margin: 0, opacity: 0.7, fontSize: "14px" }}>{caption}</p>}+ </div>+ {children}+ </Card>+ );+}++/**+ * # CalendarHeatmap Component Documentation+ *+ * The CalendarHeatmap lays daily values out as a GitHub-contributions-style grid:+ * one column per week, one row per weekday, each day shaded by a discrete 0-4+ * activity level. It's highly effective for:+ *+ * - **Activity Tracking**: Commits, deploys, workouts, support tickets per day+ * - **Seasonality**: Spotting weekly rhythms, holidays and busy seasons at a glance+ * - **Streaks & Gaps**: Making quiet stretches and bursts of activity obvious+ *+ * ## Key Features+ * - **Date Windows**: `"6m"` / `"12m"` (ending today), an explicit `[start, end]`, or the data's own extent+ * - **Level Scale**: Configurable `thresholds` and `levelColors`, or a ramp sampled from the theme / `customPalette`+ * - **Level Patterns**: Hatch and dot tiles per level for colorblind-safe and print-friendly output+ * - **Layout**: `fluid` square cells, `fill` to stretch into a fixed height, or a fixed `binSize`+ * - **Column Separators**: Quarter or every-N-weeks rules, optional gutters and quarter labels+ * - **Interactive**: Hover tooltips, a Less→More legend linked to the grid, and `onClick`+ */+const meta: Meta<CalendarHeatmapProps> = {+ title: "Components/Charts/CalendarHeatmap",+ component: CalendarHeatmap,+ parameters: {+ layout: "centered",+ docs: {+ description: {+ component: `+## Installation and Basic Usage++\`\`\`tsx+import { CalendarHeatmap } from '@openuidev/react-ui/Charts/CalendarHeatmap';++// Basic implementation: the window is the data's own first → last day+<CalendarHeatmap data={dailyCommits} />++// GitHub-style: the last 12 months, ending today+<CalendarHeatmap data={dailyCommits} range="12m" />+\`\`\`++## Data Structure Requirements++Your data should be an array of \`{ date, value }\` objects:+- **date** (\`string | Date\`): A date-only string (\`"2025-03-14"\`) or a \`Date\`. Parsed in LOCAL time, so a day never drifts across a timezone boundary.+- **value** (\`number\`): The day's magnitude (commits, sales, events…).++Sparse data is fine: missing days render as level 0. Several entries on the same day are **summed** onto one cell.++\`\`\`tsx+const dailyCommits = [+ { date: "2025-01-02", value: 3 },+ { date: "2025-01-03", value: 1 },+ { date: "2025-01-06", value: 7 },+];+\`\`\`++## How values become colors++Each day maps to one of five levels. With the default \`thresholds={[1, 2, 3, 4]}\` a day with 0+is level 0 (the "empty" level) and 4+ saturates to level 4. The five level colors are sampled+from the theme's chart palette unless you pass \`customPalette\` (a ramp) or \`levelColors\`+(five exact colors).++## When to Use+- **Use it** for one value per day over weeks to a couple of years.+- **Prefer a LineChart / AreaChart** for trends in precise magnitudes, or a **HeatmapChart** for arbitrary row × column matrices.++## Performance Considerations+- **Data Size**: One SVG cell per day; a year is ~370 cells, two years ~740.+- **Responsiveness**: \`fluid\` and \`fill\` layouts re-measure the container on resize.+- **Animation**: Off by default (streaming-safe); enable \`isAnimationActive\` for a staggered entrance.+ `,+ },+ },+ },+ tags: ["dev", "autodocs"],+ argTypes: {+ data: {+ description: `+**Required.** An array of \`{ date, value }\` objects, one per day.++**Best Practices:**+- Use date-only strings (\`"2025-03-14"\`) to avoid timezone surprises.+- You don't need an entry for every day: missing days are level 0.+- Duplicate dates are summed onto a single cell.+`,+ control: false,+ table: {+ type: { summary: "Array<{ date: string | Date; value: number }>" },+ category: "📊 Data Configuration",+ },+ },+ range: {+ description: `+**Date window** to display.++- **"6m" / "12m"**: a calendar-month window ending on **today** (GitHub-style; the data does not move it).+- **[start, end]**: an explicit window (Dates or date-only strings).+- **omitted**: the data's own earliest → latest day.++The first column is always aligned to \`weekStartDay\`.+`,+ control: false,+ table: {+ type: { summary: '"6m" | "12m" | [Date | string, Date | string]' },+ defaultValue: { summary: "data extent" },+ category: "📊 Data Configuration",+ },+ },+ thresholds: {+ description: `+**Level cutoffs** \`[t1, t2, t3, t4]\` (ascending) for levels 1-4. A day maps to the highest level whose+cutoff it meets; anything below \`t1\` is level 0.++**Tip:** The default is the GitHub scale (4+ saturates). Raise it for larger magnitudes, e.g. \`[1000, 2000, 3000, 4000]\` for revenue.+`,+ control: "object",+ table: {+ type: { summary: "[number, number, number, number]" },+ defaultValue: { summary: "[1, 2, 3, 4]" },+ category: "📊 Data Configuration",+ },+ },+ levelColors: {+ description:+ "Five explicit colors for levels 0-4 (empty → most active). Overrides the theme ramp and `customPalette`.",+ control: "object",+ table: {+ type: { summary: "[string, string, string, string, string]" },+ defaultValue: { summary: "sampled from the theme palette" },+ category: "🎨 Visual Styling",+ },+ },+ customPalette: {+ description:+ "An ordered color ramp (low → high) that five level colors are sampled from, overriding the ThemeProvider's chart palette. Superseded by `levelColors` when both are set.",+ control: "object",+ table: {+ type: { summary: "string[]" },+ category: "🎨 Visual Styling",+ },+ },+ levelStyles: {+ description: `+**Per-level overrides**, indexed 0-4. Each entry may be \`null\` to keep the default.++- **color**: recolor that level (supersedes \`levelColors\` / the palette).+- **pattern**: overlay a tile: \`"diagonal"\`, \`"dots"\`, \`"cross"\`, \`"horizontal"\`, \`"vertical"\`.+- **patternColor**: the pattern's stroke (defaults to the theme foreground).+`,+ control: "object",+ table: {+ type: {+ summary:+ "Array<{ color?: string; pattern?: CalendarLevelPattern; patternColor?: string } | null>",+ },+ category: "🎨 Visual Styling",+ },+ },+ gap: {+ description: "Gap between cells in px. The drawn square is the cell slot minus the gap.",+ control: { type: "number", min: 0, max: 10 },+ table: {+ type: { summary: "number" },+ defaultValue: { summary: "3" },+ category: "🎨 Visual Styling",+ },+ },+ rowOpacity: {+ description:+ "Per-row opacity multiplier. A number dims every row; an array is indexed by display row (row 0 = top). Handy for de-emphasising weekends.",+ control: "object",+ table: {+ type: { summary: "number | number[]" },+ defaultValue: { summary: "1" },+ category: "🎨 Visual Styling",+ },+ },+ columnSeparators: {+ description: `+**Group the week columns** with vertical rules.++- **groupBy**: \`{ every: N }\` (a rule before every Nth column) or \`"quarter"\` (Jan / Apr / Jul / Oct).+- **spacing**: extra gutter in px opened at each rule (default 0, a hairline).+- **stroke** / **dashed**: rule color and dash style.+- **showLabels** / **labelFormat**: quarter labels (quarter mode only), default \`Q1 2025\`.+`,+ control: "object",+ table: {+ type: { summary: "CalendarColumnSeparators" },+ category: "🎨 Visual Styling",+ },+ },+ className: {+ description: "Extra class name for the chart container.",+ control: "text",+ table: {+ type: { summary: "string" },+ category: "🎨 Visual Styling",+ },+ },+ layout: {+ description: `+**How the grid sizes to its container:**++- **fluid**: square cells sized from the container width; the height hugs the seven rows.+- **fill**: cells stretch to fill both the width and the height (set \`height\`).+`,+ control: "radio",+ options: ["fluid", "fill"],+ table: {+ defaultValue: { summary: "fluid" },+ category: "📱 Display Options",+ },+ },+ binSize: {+ description:+ "Fixed cell slot size in px, overriding the auto-size from `layout`. The drawn square is `binSize - gap`.",+ control: { type: "number", min: 4, max: 32 },+ table: {+ type: { summary: "number" },+ defaultValue: { summary: "auto" },+ category: "📱 Display Options",+ },+ },+ weekStartDay: {+ description: "The weekday that opens each column (row 0): 0 = Sunday (GitHub), 1 = Monday, …",+ control: {+ type: "select",+ labels: {+ 0: "Sunday",+ 1: "Monday",+ 2: "Tuesday",+ 3: "Wednesday",+ 4: "Thursday",+ 5: "Friday",+ 6: "Saturday",+ },+ },+ options: [0, 1, 2, 3, 4, 5, 6],+ table: {+ type: { summary: "0 | 1 | 2 | 3 | 4 | 5 | 6" },+ defaultValue: { summary: "0" },+ category: "📱 Display Options",+ },+ },+ hideGhostCells: {+ description:+ "Drop the padding days outside the window (the corners of the first and last week). Set `false` to draw them as faded level-0 cells.",+ control: "boolean",+ table: {+ type: { summary: "boolean" },+ defaultValue: { summary: "true" },+ category: "📱 Display Options",+ },+ },+ weekdayTickFilter: {+ description:+ "Which weekday rows get a label: `odd` (Mon / Wed / Fri for a Sunday start), `even`, or `all`.",+ control: "radio",+ options: ["odd", "even", "all"],+ table: {+ defaultValue: { summary: "odd" },+ category: "📱 Display Options",+ },+ },+ weekdayLabelFormat: {+ description: "Weekday label style: `full` (`Mon`) or `initial` (`M`).",+ control: "radio",+ options: ["full", "initial"],+ table: {+ defaultValue: { summary: "full" },+ category: "📱 Display Options",+ },+ },+ showMonthLabels: {+ description: "Show the short month labels along the top.",+ control: "boolean",+ table: {+ type: { summary: "boolean" },+ defaultValue: { summary: "true" },+ category: "📱 Display Options",+ },+ },+ legendVariant: {+ description:+ "The Less → More legend under the grid: five `swatches`, a continuous `gradient` bar, or `none`.",+ control: "radio",+ options: ["swatches", "gradient", "none"],+ table: {+ defaultValue: { summary: "swatches" },+ category: "📱 Display Options",+ },+ },+ legendLabels: {+ description: "Override the legend's bracketing labels.",+ control: "object",+ table: {+ type: { summary: "{ less?: string; more?: string }" },+ defaultValue: { summary: '{ less: "Less", more: "More" }' },+ category: "📱 Display Options",+ },+ },+ height: {+ description: 'The height of the chart. Required for `layout="fill"` to have room to fill.',+ control: "text",+ table: {+ type: { summary: "string | number" },+ category: "📱 Display Options",+ },+ },+ width: {+ description: "The width of the chart.",+ control: "text",+ table: {+ type: { summary: "string | number" },+ category: "📱 Display Options",+ },+ },+ isAnimationActive: {+ description:+ "Play the staggered fade-in entrance. Off by default so charts mounted while data streams in don't replay it; printing always disables it.",+ control: "boolean",+ table: {+ type: { summary: "boolean" },+ defaultValue: { summary: "false" },+ category: "🎬 Animation & Interaction",+ },+ },+ animationDuration: {+ description:+ "Entrance window in ms: the span the per-cell stagger scatters the fade-ins over. Only used when `isAnimationActive`.",+ control: { type: "number", min: 0, max: 5000, step: 100 },+ table: {+ type: { summary: "number" },+ defaultValue: { summary: "1600" },+ category: "🎬 Animation & Interaction",+ },+ },+ valueLabel: {+ description: "Name of the day's value in the tooltip.",+ control: "text",+ table: {+ type: { summary: "string" },+ defaultValue: { summary: '"Contributions"' },+ category: "🎬 Animation & Interaction",+ },+ },+ formatTooltipLabel: {+ description:+ "Format the tooltip value from the day's summed `value` and its `Date`, e.g. to add units or a currency symbol.",+ control: false,+ table: {+ type: { summary: "(value: number, date: Date) => string" },+ defaultValue: { summary: "the raw value" },+ category: "🎬 Animation & Interaction",+ },+ },+ tooltipDelay: {+ description:+ "Tooltip show / hide delays in ms. The hide grace period keeps the tooltip alive while the pointer crosses between cells.",+ control: "object",+ table: {+ type: { summary: "{ show?: number; hide?: number }" },+ defaultValue: { summary: "{ show: 0, hide: 120 }" },+ category: "🎬 Animation & Interaction",+ },+ },+ onClick: {+ description: "Called when a day is clicked, with its `Date` and summed `value`.",+ control: false,+ table: {+ type: { summary: "(date: Date, value: number) => void" },+ category: "🎬 Animation & Interaction",+ },+ },+ },+} satisfies Meta<typeof CalendarHeatmap>;++export default meta;+type Story = StoryObj<typeof meta>;++export const InteractivePlayground: Story = {+ name: "🎮 Interactive Playground",+ args: {+ data: twoYearsOfCommits,+ // A preset label; Storybook maps it to its value via `argTypes.range.mapping`.+ range: "Jan-Dec 2025" as unknown as CalendarHeatmapProps["range"],+ thresholds: [1, 2, 3, 4],+ layout: "fluid",+ gap: 3,+ weekStartDay: 0,+ hideGhostCells: true,+ weekdayTickFilter: "odd",+ weekdayLabelFormat: "full",+ showMonthLabels: true,+ legendVariant: "swatches",+ legendLabels: { less: "Less", more: "More" },+ tooltipDelay: { show: 0, hide: 120 },+ isAnimationActive: false,+ animationDuration: 1600,+ },+ argTypes: {+ range: {+ control: "select",+ options: Object.keys(RANGE_PRESETS),+ mapping: RANGE_PRESETS,+ },+ },+ render: (args: any) => (+ <Card style={{ width: "760px", height: "auto", padding: "24px" }}>+ <CalendarHeatmap {...args} />+ </Card>+ ),+ parameters: {+ docs: {+ description: {+ story:+ 'Use the Controls panel to try every prop. `"12m"` and `"6m"` end on **today**, so their grid moves day by day; the fixed presets always render the same window.',+ },+ },+ },+};++export const DefaultConfiguration: Story = {+ name: "📊 Default Configuration",+ args: {+ data: commits2025,+ },+ render: (args: any) => (+ <ChartCard+ title="Contribution Activity"+ caption={`${totalOf(commits2025).toLocaleString("en-US")} commits in 2025`}+ >+ <CalendarHeatmap {...args} />+ </ChartCard>+ ),+ parameters: {+ docs: {+ description: {+ story: `+The recommended starting point: pass one \`{ date, value }\` per day and nothing else.++**Configuration Details:**+- **Window**: the data's first → last day (Jan 1 - Dec 31 2025), starting on a Sunday column.+- **Levels**: \`[1, 2, 3, 4]\`, so days with 4+ commits saturate the darkest shade.+- **Colors**: five stops sampled from the ThemeProvider's chart palette.+- **Hover**: a cell shows its date and value; hovering a legend swatch dims the other levels.+ `,+ },+ source: {+ code: `+const dailyCommits = [+ { date: "2025-01-01", value: 0 },+ { date: "2025-01-02", value: 3 },+ // ... one entry per day+];++<CalendarHeatmap data={dailyCommits} />+`,+ },+ },+ },+};++export const DateWindows: Story = {+ name: "📅 Date Windows",+ args: {+ levelColors: GREEN_LEVELS,+ data: twoYearsOfCommits,+ },+ render: (args: any) => (+ <div style={{ display: "grid", gridTemplateColumns: "1fr 1fr", gap: "24px", width: "784px" }}>+ <ChartCard+ width={380}+ title="Six Months"+ caption={<code>range=["2025-07-01", "2025-12-31"]</code>}+ >+ <CalendarHeatmap {...args} range={["2025-07-01", "2025-12-31"]} />+ </ChartCard>+ <ChartCard+ width={380}+ title="Across a Year Boundary"+ caption={<code>range=["2025-10-01", "2026-03-31"]</code>}+ >+ <CalendarHeatmap {...args} range={["2025-10-01", "2026-03-31"]} />+ </ChartCard>+ <div style={{ gridColumn: "1 / -1" }}>+ <ChartCard+ width={784}+ title="Data Extent (range omitted)"+ caption="A project that ran from Mon Feb 10 to Fri Nov 21 2025: the grid spans exactly those days."+ >+ <CalendarHeatmap {...args} data={projectActivity} />+ </ChartCard>+ </div>+ </div>+ ),+ parameters: {+ docs: {+ description: {+ story: `+**Window options:**+- **\`[start, end]\`**: an explicit window. The first column is aligned to \`weekStartDay\`, and the padding days before \`start\` / after \`end\` are hidden.+- **omitted**: the data's earliest → latest day.+- **\`"6m"\` / \`"12m"\`**: a GitHub-style window ending **today**. It moves every day, so these examples use fixed windows; try the relative ones in the Interactive Playground.+ `,+ },+ source: {+ code: `+// Last six months of 2025+<CalendarHeatmap data={dailyCommits} range={["2025-07-01", "2025-12-31"]} />++// Any window, including across a year boundary+<CalendarHeatmap data={dailyCommits} range={["2025-10-01", "2026-03-31"]} />++// Rolling window ending today (GitHub-style)+<CalendarHeatmap data={dailyCommits} range="12m" />+`,+ },+ },+ },+};++function RevenueCalendars(args: CalendarHeatmapProps) {+ const [selected, setSelected] = useState<{ date: Date; value: number } | null>(null);++ return (+ <div style={{ display: "flex", flexDirection: "column", gap: "24px" }}>+ <ChartCard+ title="Daily Store Revenue: 2025"+ caption="Custom thresholds and level colors, currency tooltips. Click a day to inspect it."+ >+ <CalendarHeatmap {...args} onClick={(date, value) => setSelected({ date, value })} />+ <div style={{ fontSize: "13px", opacity: 0.8 }}>+ {selected+ ? `Selected: ${selected.date.toDateString()} · ${usd.format(selected.value)}`+ : "Selected: none"}+ </div>+ </ChartCard>+ <ChartCard+ title="Ramp from customPalette"+ caption="Same thresholds; five level colors sampled evenly from a 9-color blue ramp."+ >+ <CalendarHeatmap+ {...args}+ levelColors={undefined}+ customPalette={[+ "#EFF6FF",+ "#DBEAFE",+ "#BFDBFE",+ "#93C5FD",+ "#60A5FA",+ "#3B82F6",+ "#2563EB",+ "#1D4ED8",+ "#1E3A8A",+ ]}+ />+ </ChartCard>+ <ChartCard+ title="Without thresholds"+ caption="The default [1, 2, 3, 4] scale saturates: every open day is level 4."+ >+ <CalendarHeatmap {...args} thresholds={undefined} legendLabels={undefined} />+ </ChartCard>+ </div>+ );+}++export const ThresholdsAndLevelColors: Story = {+ name: "🎚️ Thresholds & Level Colors",+ args: {+ data: revenue2025,+ thresholds: [1000, 2000, 3000, 4000],+ levelColors: ["rgba(148, 163, 184, 0.2)", "#FDE68A", "#FBBF24", "#F59E0B", "#B45309"],+ legendLabels: { less: "$0", more: "$4k+" },+ valueLabel: "Revenue",+ formatTooltipLabel: (value: number) => usd.format(value),+ },+ render: (args: any) => <RevenueCalendars {...args} />,+ parameters: {+ docs: {+ description: {+ story: `+Revenue runs into the thousands, so the GitHub scale (4+ = darkest) would paint every open day the same. Custom+\`thresholds\` spread the values across all five levels: closed days are level 0, weekdays sit around levels 1-2,+weekends at 3 and the Nov-Dec holiday season at 4.++**Color options (highest precedence first):**+- **\`levelStyles[i].color\`**: recolor a single level.+- **\`levelColors\`**: five exact colors, level 0 → 4.+- **\`customPalette\`**: a ramp of any length; five stops are sampled from it, endpoints included.+- **Theme**: the ThemeProvider's chart palette.+ `,+ },+ source: {+ code: `+const usd = new Intl.NumberFormat("en-US", { style: "currency", currency: "USD", maximumFractionDigits: 0 });++<CalendarHeatmap+ data={dailyRevenue}+ thresholds={[1000, 2000, 3000, 4000]}+ levelColors={["rgba(148, 163, 184, 0.2)", "#FDE68A", "#FBBF24", "#F59E0B", "#B45309"]}+ legendLabels={{ less: "$0", more: "$4k+" }}+ valueLabel="Revenue"+ formatTooltipLabel={(value) => usd.format(value)}+ onClick={(date, value) => console.log(date, value)}+/>+`,+ },+ },+ },+};++export const LevelPatterns: Story = {+ name: "♿ Level Patterns",+ args: {+ levelColors: GREEN_LEVELS,+ data: commits2025,+ levelStyles: [+ null,+ { pattern: "diagonal" },+ { pattern: "dots" },+ { pattern: "cross" },+ { pattern: "horizontal" },+ ],+ },+ render: (args: any) => (+ <div style={{ display: "flex", flexDirection: "column", gap: "24px" }}>+ <ChartCard+ title="Pattern-Coded Levels"+ caption="Each active level adds a distinct tile, so the scale survives colorblindness and low-contrast screens."+ >+ <CalendarHeatmap {...args} />+ </ChartCard>+ <ChartCard+ title="Grayscale for Print"+ caption="Gray levelColors plus patterns with explicit patternColor: legible on a black-and-white printer."+ >+ <CalendarHeatmap+ {...args}+ levelColors={["rgba(148, 163, 184, 0.2)", "#D4D4D8", "#A1A1AA", "#52525B", "#27272A"]}+ levelStyles={[+ null,+ { pattern: "vertical", patternColor: "#18181B" },+ { pattern: "horizontal", patternColor: "#18181B" },+ { pattern: "diagonal", patternColor: "#FAFAFA" },+ { pattern: "cross", patternColor: "#FAFAFA" },+ ]}+ />+ </ChartCard>+ <ChartCard+ title="Flag One Level"+ caption="thresholds={[1, 2, 3, 6]} and a red level 4: crunch days (6+ commits) stand out."+ >+ <CalendarHeatmap+ {...args}+ thresholds={[1, 2, 3, 6]}+ levelStyles={[null, null, null, null, { color: "#E11D48" }]}+ />+ </ChartCard>+ </div>+ ),+ parameters: {+ docs: {+ description: {+ story: `+\`levelStyles\` is indexed by level (0 = empty … 4 = most active); use \`null\` to leave a level alone.++**Available patterns:** \`diagonal\`, \`dots\`, \`cross\`, \`horizontal\`, \`vertical\`. Each pattern is drawn over the+level's color in \`patternColor\` (the theme foreground by default), and the legend swatches show the same tiles.+ `,+ },+ source: {+ code: `+<CalendarHeatmap+ data={dailyCommits}+ levelStyles={[+ null, // level 0 keeps the plain empty shade+ { pattern: "diagonal" },+ { pattern: "dots" },+ { pattern: "cross" },+ { pattern: "horizontal" },+ ]}+/>++// Recolor a single level+<CalendarHeatmap data={dailyCommits} levelStyles={[null, null, null, null, { color: "#E11D48" }]} />+`,+ },+ },+ },+};++export const LayoutAndSizing: Story = {+ name: "📐 Layout & Sizing",+ args: {+ levelColors: GREEN_LEVELS,+ data: commits2025,+ range: ["2025-01-01", "2025-04-30"],+ },+ render: (args: any) => (+ <div style={{ display: "grid", gridTemplateColumns: "1fr 1fr", gap: "24px", width: "784px" }}>+ <ChartCard width={380} title="Fluid (default)" caption="Square cells sized from the width.">+ <CalendarHeatmap {...args} layout="fluid" />+ </ChartCard>+ <ChartCard+ width={380}+ title="Fill"+ caption={<code>layout="fill" height={220}</code>}+ >+ <CalendarHeatmap {...args} layout="fill" height={220} />+ </ChartCard>+ <ChartCard+ width={380}+ title="Fixed Bin Size"+ caption={<code>binSize={10} gap={1}</code>}+ >+ <CalendarHeatmap {...args} binSize={10} gap={1} />+ </ChartCard>+ <ChartCard width={380} title="Wide Gap" caption={<code>gap={6}</code>}>+ <CalendarHeatmap {...args} gap={6} />+ </ChartCard>+ </div>+ ),+ parameters: {+ docs: {+ description: {+ story: `+**Sizing modes:**+- **\`fluid\`** (default): square cells sized from the container width; the chart height follows.+- **\`fill\`**: cells stretch to fill both the width and a fixed \`height\`, so they become rectangles.+- **\`binSize\`**: a fixed cell slot in px that ignores the container (the drawn square is \`binSize - gap\`).+- **\`gap\`**: space between cells in px (default 3).+ `,+ },+ source: {+ code: `+<CalendarHeatmap data={dailyCommits} layout="fluid" />+<CalendarHeatmap data={dailyCommits} layout="fill" height={220} />+<CalendarHeatmap data={dailyCommits} binSize={10} gap={1} />+<CalendarHeatmap data={dailyCommits} gap={6} />+`,+ },+ },+ },+};++/** FY runs Apr → Mar and is named by its ending year: Apr 2025 opens FY26 Q1. */+const fiscalQuarterLabel = (quarter: number, year: number) => {+ const fiscalQuarter = ((quarter + 2) % 4) + 1;+ const fiscalYear = quarter >= 2 ? year + 1 : year;+ return `FY${String(fiscalYear).slice(2)} Q${fiscalQuarter}`;+};++export const ColumnSeparators: Story = {+ name: "🧱 Column Separators",+ args: {+ levelColors: GREEN_LEVELS,+ data: commits2025,+ columnSeparators: { groupBy: "quarter", showLabels: true, spacing: 8 },+ },+ render: (args: any) => (+ <div style={{ display: "flex", flexDirection: "column", gap: "24px" }}>+ <ChartCard title="Quarters" caption="A labelled 8px gutter at each quarter start.">+ <CalendarHeatmap {...args} />+ </ChartCard>+ <ChartCard+ title="Every 4 Weeks"+ caption="Dashed hairlines marking four-week sprints, no gutter."+ >+ <CalendarHeatmap+ {...args}+ columnSeparators={{ groupBy: { every: 4 }, dashed: true, stroke: "#94A3B8" }}+ />+ </ChartCard>+ <ChartCard+ title="Fiscal Quarters"+ caption="An Apr - Mar fiscal year with a custom labelFormat."+ >+ <CalendarHeatmap+ {...args}+ data={twoYearsOfCommits}+ range={["2025-04-01", "2026-03-31"]}+ columnSeparators={{+ groupBy: "quarter",+ showLabels: true,+ spacing: 8,+ labelFormat: fiscalQuarterLabel,+ }}+ />+ </ChartCard>+ </div>+ ),+ parameters: {+ docs: {+ description: {+ story: `+**Options:**+- **\`groupBy: "quarter"\`**: a rule at each Jan / Apr / Jul / Oct start; **\`groupBy: { every: N }\`**: a rule before every Nth week column.+- **\`spacing\`**: opens a gutter at each rule (default 0 keeps a hairline that doesn't move the grid).+- **\`stroke\`** / **\`dashed\`**: rule styling (defaults to the theme border color, solid).+- **\`showLabels\`** / **\`labelFormat\`**: quarter labels above each group (quarter mode only), default \`Q1 2025\`.+ `,+ },+ source: {+ code: `+<CalendarHeatmap+ data={dailyCommits}+ columnSeparators={{ groupBy: "quarter", showLabels: true, spacing: 8 }}+/>++<CalendarHeatmap+ data={dailyCommits}+ columnSeparators={{ groupBy: { every: 4 }, dashed: true, stroke: "#94A3B8" }}+/>++// Fiscal year Apr → Mar+<CalendarHeatmap+ data={dailyCommits}+ range={["2025-04-01", "2026-03-31"]}+ columnSeparators={{+ groupBy: "quarter",+ showLabels: true,+ labelFormat: (q, year) => \`FY\${String(q >= 2 ? year + 1 : year).slice(2)} Q\${((q + 2) % 4) + 1}\`,+ }}+/>+`,+ },+ },+ },+};++export const LegendAndAxisOptions: Story = {+ name: "🏷️ Legend & Axis Options",+ args: {+ levelColors: GREEN_LEVELS,+ data: commits2025,+ },+ render: (args: any) => (+ <div style={{ display: "flex", flexDirection: "column", gap: "24px" }}>+ <ChartCard+ title="Gradient Legend"+ caption='legendVariant="gradient" with custom legendLabels.'+ >+ <CalendarHeatmap+ {...args}+ legendVariant="gradient"+ legendLabels={{ less: "No commits", more: "4+ commits" }}+ />+ </ChartCard>+ <ChartCard+ title="Monday Start, Weekends Dimmed"+ caption='weekStartDay={1}, weekdayTickFilter="all", weekdayLabelFormat="initial", rowOpacity on Sat / Sun.'+ >+ <CalendarHeatmap+ {...args}+ weekStartDay={1}+ weekdayTickFilter="all"+ weekdayLabelFormat="initial"+ rowOpacity={[1, 1, 1, 1, 1, 0.4, 0.4]}+ />+ </ChartCard>+ <div style={{ display: "flex", gap: "24px" }}>+ <ChartCard width={368} title="Minimal Widget" caption="No legend, no month labels.">+ <CalendarHeatmap+ {...args}+ range={["2025-10-01", "2025-12-31"]}+ legendVariant="none"+ showMonthLabels={false}+ />+ </ChartCard>+ <ChartCard+ width={368}+ title="Ghost Cells Shown"+ caption="hideGhostCells={false}: padding days drawn faded."+ >+ <CalendarHeatmap {...args} range={["2025-10-01", "2025-12-31"]} hideGhostCells={false} />+ </ChartCard>+ </div>+ </div>+ ),+ parameters: {+ docs: {+ description: {+ story: `+**Legend:** \`legendVariant\` is \`swatches\` (default), \`gradient\` or \`none\`; \`legendLabels\` renames the ends.++**Axes:**+- **\`weekStartDay\`**: the weekday in the top row (0 = Sunday … 6 = Saturday).+- **\`weekdayTickFilter\`**: label \`odd\` rows (default), \`even\` rows or \`all\` of them.+- **\`weekdayLabelFormat\`**: \`full\` (\`Mon\`) or \`initial\` (\`M\`).+- **\`showMonthLabels\`**: hide the month row for compact widgets.++**Cells:** \`hideGhostCells={false}\` draws the padding days before and after the window; \`rowOpacity\` dims rows by index.+ `,+ },+ source: {+ code: `+<CalendarHeatmap data={dailyCommits} legendVariant="gradient" legendLabels={{ less: "No commits", more: "4+ commits" }} />++<CalendarHeatmap+ data={dailyCommits}+ weekStartDay={1}+ weekdayTickFilter="all"+ weekdayLabelFormat="initial"+ rowOpacity={[1, 1, 1, 1, 1, 0.4, 0.4]}+/>++<CalendarHeatmap data={dailyCommits} range={["2025-10-01", "2025-12-31"]} legendVariant="none" showMonthLabels={false} />+`,+ },+ },+ },+};++export const SparseAndEmptyData: Story = {+ name: "🌱 Sparse & Empty Data",+ args: {+ levelColors: GREEN_LEVELS,+ data: productionReleases,+ range: YEAR_2025,+ },+ render: (args: any) => (+ <div style={{ display: "flex", flexDirection: "column", gap: "24px" }}>+ <ChartCard+ title="Production Releases"+ caption={`${productionReleases.length} entries for the whole year; Dec 16 has two entries that sum to 3.`}+ >+ <CalendarHeatmap {...args} />+ </ChartCard>+ <ChartCard+ title="A Quiet Year"+ caption="365 days, every value 0: the grid renders entirely at level 0."+ >+ <CalendarHeatmap {...args} data={quietYear} range={undefined} />+ </ChartCard>+ <ChartCard title="No Data" caption="data={[]}">+ <CalendarHeatmap {...args} data={[]} />+ </ChartCard>+ </div>+ ),+ parameters: {+ docs: {+ description: {+ story: `+- **Sparse**: pass only the days that happened. Pair it with a fixed \`range\`; without one the window would shrink to+ the first and last release.+- **All zero**: every day maps to level 0, so the grid still shows the full year.+- **Empty array**: the chart shows its "No data available" state instead of a grid.+ `,+ },+ source: {+ code: `+const releases = [+ { date: "2025-01-14", value: 1 },+ { date: "2025-02-04", value: 2 },+ // ...+ { date: "2025-12-16", value: 1 },+ { date: "2025-12-16", value: 2 }, // same day → summed to 3+];++<CalendarHeatmap data={releases} range={["2025-01-01", "2025-12-31"]} />+`,+ },+ },+ },+};diff --git a/packages/react-ui/src/components/D3Charts/CalendarHeatmap/types.ts b/packages/react-ui/src/components/Charts/CalendarHeatmap/types.tssimilarity index 98%rename from packages/react-ui/src/components/D3Charts/CalendarHeatmap/types.tsrename to packages/react-ui/src/components/Charts/CalendarHeatmap/types.tsindex f79ae5b0b..4d0b17ef9 100644--- a/packages/react-ui/src/components/D3Charts/CalendarHeatmap/types.ts+++ b/packages/react-ui/src/components/Charts/CalendarHeatmap/types.ts@@ -163,6 +163,8 @@ export interface CalendarHeatmapProps {legendVariant?: "swatches" | "gradient" | "none";/** Override the legend's bracketing labels. Default `{ less: 'Less', more: 'More' }`. */legendLabels?: { less?: string; more?: string };+ /** Name of the day's value in the tooltip. Default `"Contributions"`. */+ valueLabel?: string;/*** Format the tooltip's contribution value from the day's summed `value` and* its `Date` (e.g. add units or a currency symbol). Default: the raw value.diff --git a/packages/react-ui/src/components/Charts/Charts.tsx b/packages/react-ui/src/components/Charts/Charts.tsxdeleted file mode 100644index fcba12f0b..000000000--- a/packages/react-ui/src/components/Charts/Charts.tsx+++ /dev/null@@ -1,443 +0,0 @@-import clsx from "clsx";-import { uniqueId } from "lodash-es";-import { ComponentProps, createContext, forwardRef, useContext, useId, useMemo } from "react";-import * as RechartsPrimitive from "recharts";-import { useTheme } from "../ThemeProvider";--/**- * @module Charts- * A collection of chart components built on top of Recharts with enhanced styling and theming capabilities.- */--/**- * Available themes for chart customization- * @constant- * @type {Record<'light' | 'dark', string>}- */-const THEMES = { light: "", dark: ".dark" } as const;--/**- * Configuration type for chart elements- */-export type ChartConfig = {- [k in string]: {- label?: React.ReactNode;- icon?: React.ComponentType;- transformed?: string;- } & (- | { color?: string; secondaryColor?: string; theme?: never }- | {- color?: never;- theme: Record<- keyof typeof THEMES,- | string- | {- color: string;- secondaryColor?: string;- }- >;- }- );-};--/**- * Data structure for chart export (e.g., to PPTX)- */-export type ExportChartData = {- type: "line" | "bar" | "area" | "pie" | "radar" | "scatter";- data: {- name: string;- labels?: string[];- values?: number[];- x?: number[];- y?: number[];- }[];- options?: {- chartColors?: string[];- showLegend?: boolean;- legendPos?: "b" | "t" | "l" | "r";- title?: string;- showTitle?: boolean;- catAxisTitle?: string;- showCatAxisTitle?: boolean;- valAxisTitle?: string;- showValAxisTitle?: boolean;- lineSize?: number;- barDir?: "bar" | "col";- barGrouping?: "stacked" | "clustered" | "percent" | "standard";- };-};--/**- * Context props for chart configuration- */-type ChartContextProps = {- config: ChartConfig;- id: string;-};--const ChartContext = createContext<ChartContextProps | null>(null);--/**- * Hook to access chart context- * @throws Error if used outside of ChartContainer- */-function useChart() {- const context = useContext(ChartContext);-- if (!context) {- throw new Error("useChart must be used within a <ChartContainer />");- }-- return context;-}--/**- * Component that generates theme-specific styles for chart elements- */-const ChartStyle = ({ id, config }: { id: string; config: ChartConfig }) => {- const colorConfig = Object.entries(config).filter(([_, config]) => config.theme || config.color);-- if (!colorConfig.length) {- return null;- }-- return (- <style- dangerouslySetInnerHTML={{- __html: Object.entries(THEMES)- .map(- ([theme, prefix]) => `- ${prefix} [data-chart=${id}] {- ${colorConfig- .map(([_, itemConfig]) => {- const transformedKey = itemConfig.transformed;- const themeValue = itemConfig.theme?.[theme as keyof typeof itemConfig.theme];- const color =- typeof themeValue === "string" ? themeValue : themeValue?.color || itemConfig.color;- const secondaryColor =- typeof themeValue === "object"- ? themeValue?.secondaryColor- : "secondaryColor" in itemConfig- ? itemConfig.secondaryColor- : undefined;-- return [- color ? ` --color-${transformedKey}: ${color};` : null,- secondaryColor ? ` --color-${transformedKey}-secondary: ${secondaryColor};` : null,- ]- .filter(Boolean)- .join("\n");- })- .filter(Boolean)- .join("\n")}- }- `,- )- .join("\n"),- }}- />- );-};--/**- * Container component for charts that provides configuration context and styling- */-const ChartContainer = forwardRef<- HTMLDivElement,- ComponentProps<"div"> & {- config: ChartConfig;- children: React.ComponentProps<typeof RechartsPrimitive.ResponsiveContainer>["children"];- rechartsProps?: Omit<- React.ComponentProps<typeof RechartsPrimitive.ResponsiveContainer>,- "children"- >;- }->(({ id, className, children, config, rechartsProps, style, ...props }, ref) => {- const uniqueId = useId();- const chartId = `openui-chart-${id || uniqueId.replace(/:/g, "")}`;- const { theme } = useTheme();-- return (- <ChartContext.Provider value={{ config, id: chartId }}>- <div- data-chart={chartId}- ref={ref}- className={clsx("openui-chart-container", className)}- style={- {- //TODO: remove this once we have a proper theme for charts- "--openui-foreground": theme.foreground,- "--openui-text-neutral-primary": theme.textNeutralPrimary,- width: "100%",- height: "100%",- ...style,- } as React.CSSProperties- }- {...props}- >- <ChartStyle id={chartId} config={config} />- <RechartsPrimitive.ResponsiveContainer- width={rechartsProps?.width ?? "100%"}- height={rechartsProps?.height ?? "100%"}- minWidth={rechartsProps?.minWidth ?? 1}- minHeight={rechartsProps?.minHeight ?? 1}- initialDimension={rechartsProps?.initialDimension ?? { width: 1, height: 1 }}- id={rechartsProps?.id ?? chartId}- {...rechartsProps}- >- {children}- </RechartsPrimitive.ResponsiveContainer>- </div>- </ChartContext.Provider>- );-});-ChartContainer.displayName = "Chart";--/**- * Re-exported Tooltip component from Recharts- */-const ChartTooltip = RechartsPrimitive.Tooltip;--/**- * Custom tooltip content component with enhanced styling and formatting- */-type ChartTooltipContentProps = React.ComponentProps<typeof RechartsPrimitive.Tooltip> &- React.ComponentProps<"div"> & {- hideLabel?: boolean;- hideIndicator?: boolean;- indicator?: "line" | "dot" | "dashed";- nameKey?: string;- labelKey?: string;- showPercentage?: boolean;- };--function ChartTooltipContentRender(- {- active,- payload,- className,- indicator = "dot",- hideLabel = false,- hideIndicator = false,- label,- labelFormatter,- labelClassName,- formatter,- color,- nameKey,- labelKey,- showPercentage = false,- }: ChartTooltipContentProps,- ref: React.ForwardedRef<HTMLDivElement>,-) {- const { config } = useChart();-- const tooltipLabel = useMemo(() => {- if (hideLabel || !payload?.length) {- return null;- }-- const [item] = payload;- const key = `${labelKey ?? item?.dataKey ?? item?.name ?? "value"}`;- const itemConfig = getPayloadConfigFromPayload(config, item, key);- const value =- !labelKey && typeof label === "string" ? config[label]?.label || label : itemConfig?.label;-- if (labelFormatter) {- return (- <div className={clsx("openui-chart-tooltip-label-heavy", labelClassName)}>- {labelFormatter(value, payload)}- </div>- );- }-- if (!value) {- return null;- }-- return <div className={clsx("openui-chart-tooltip-label", labelClassName)}>{value}</div>;- }, [label, labelFormatter, payload, hideLabel, labelClassName, config, labelKey]);-- if (!active || !payload?.length) {- return null;- }-- const nestLabel = payload.length === 1 && indicator !== "dot";-- return (- <div ref={ref} className={clsx("openui-chart-tooltip", className)}>- {!nestLabel && tooltipLabel}- <div className="openui-chart-tooltip-content">- {payload.map((item, index) => {- const key = `${nameKey ?? item.name ?? item.dataKey ?? "value"}`;- const itemConfig = getPayloadConfigFromPayload(config, item, key);- const indicatorColor = (color ?? item.payload.fill) || item.color;-- return (- <div- key={item.dataKey}- className={clsx(- "openui-chart-tooltip-content-item",- indicator === "dot" && "openui-chart-tooltip-content-item--dot",- )}- >- {formatter && item?.value !== undefined && item.name ? (- formatter(item.value, item.name, item, index, item.payload)- ) : (- <>- {itemConfig?.icon ? (- <itemConfig.icon />- ) : (- !hideIndicator && (- <div- className={clsx(- "openui-chart-tooltip-content-indicator",- `openui-chart-tooltip-content-indicator--${indicator}`,- )}- style={- {- "--color-bg": indicatorColor,- "--color-border": indicatorColor,- } as React.CSSProperties- }- />- )- )}- <div- className={clsx(- "openui-chart-tooltip-content-value-wrapper",- nestLabel- ? "openui-chart-tooltip-content-value-wrapper--nested"- : "openui-chart-tooltip-content-value-wrapper--standard",- )}- >- <div className="openui-chart-tooltip-content-label">- {nestLabel && tooltipLabel}- <span>{itemConfig?.label || item.name}</span>- </div>- {item.value !== undefined && (- <span- className={clsx(- "openui-chart-tooltip-content-value",- showPercentage && "percentage",- )}- >- {item.value.toLocaleString()}- {showPercentage ? "%" : ""}- </span>- )}- </div>- </>- )}- </div>- );- })}- </div>- </div>- );-}--const ChartTooltipContent = forwardRef(ChartTooltipContentRender);-ChartTooltipContent.displayName = "ChartTooltip";--// this is not used any more, in the new chart, we are using the default legend which is rendered outside the charts container,-// older charts are still using this legend.--/**- * Re-exported Legend component from Recharts- */-const ChartLegend = RechartsPrimitive.Legend;--/**- * Custom legend content component with enhanced styling- */-const ChartLegendContent = forwardRef<- HTMLDivElement,- React.ComponentProps<"div"> &- Pick<RechartsPrimitive.LegendProps, "payload" | "verticalAlign"> & {- hideIcon?: boolean;- nameKey?: string;- }->(({ className, hideIcon = false, payload, verticalAlign = "bottom", nameKey }, ref) => {- const { config } = useChart();-- const payloadWithKeys = useMemo(- () =>- payload?.map((item) => ({- ...item,- uniqueKey: uniqueId(`chart-legend-${item.dataKey || item.value || ""}-`),- })),- [payload],- );-- if (!payload?.length) {- return null;- }-- return (- <div- ref={ref}- className={clsx("openui-chart-legend", `openui-chart-legend--${verticalAlign}`, className)}- >- {payloadWithKeys?.map((item) => {- const key = `${nameKey || item.dataKey || "value"}`;- const itemConfig = getPayloadConfigFromPayload(config, item, key);-- return (- <div key={item.uniqueKey} className="openui-chart-legend-item">- {itemConfig?.icon && !hideIcon ? (- <itemConfig.icon />- ) : (- <div- className="openui-chart-legend-item-indicator"- style={{ backgroundColor: item.color }}- />- )}- <span className="openui-chart-legend-item-label">{itemConfig?.label}</span>- </div>- );- })}- </div>- );-});-ChartLegendContent.displayName = "ChartLegend";--/**- * Helper function to extract configuration for a chart element from a payload- */-function getPayloadConfigFromPayload(config: ChartConfig, payload: unknown, key: string) {- if (typeof payload !== "object" || payload === null) {- return undefined;- }-- const payloadPayload =- "payload" in payload && typeof payload.payload === "object" && payload.payload !== null- ? payload.payload- : undefined;-- let configLabelKey: string = key;-- if (key in payload && typeof payload[key as keyof typeof payload] === "string") {- configLabelKey = payload[key as keyof typeof payload] as string;- } else if (- payloadPayload &&- key in payloadPayload &&- typeof payloadPayload[key as keyof typeof payloadPayload] === "string"- ) {- configLabelKey = payloadPayload[key as keyof typeof payloadPayload] as string;- }-- return configLabelKey in config ? config[configLabelKey] : config[key];-}--export {- ChartContainer,- ChartLegend,- ChartLegendContent,- ChartStyle,- ChartTooltip,- ChartTooltipContent,- getPayloadConfigFromPayload,- useChart,-};diff --git a/packages/react-ui/src/components/D3Charts/FunnelChart/FunnelChart.tsx b/packages/react-ui/src/components/Charts/FunnelChart/FunnelChart.tsxsimilarity index 96%rename from packages/react-ui/src/components/D3Charts/FunnelChart/FunnelChart.tsxrename to packages/react-ui/src/components/Charts/FunnelChart/FunnelChart.tsxindex 38ba87483..f04e0cb5b 100644--- a/packages/react-ui/src/components/D3Charts/FunnelChart/FunnelChart.tsx+++ b/packages/react-ui/src/components/Charts/FunnelChart/FunnelChart.tsx@@ -53,7 +53,7 @@ export function FunnelChart<T extends FunnelChartData>(props: FunnelChartProps<Tconst animate = useEffectiveAnimation(isAnimationActive);const {- dimensions: { W, H, ringW, ringH, labelColWidth, labelAngle },+ dimensions: { W, H, ringW, ringH, labelColWidth, labelAngle, angledLabelMaxWidth },} = orch;return (@@ -87,6 +87,7 @@ export function FunnelChart<T extends FunnelChartData>(props: FunnelChartProps<TringH={ringH}labelColWidth={labelColWidth}labelAngle={labelAngle}+ angledLabelMaxWidth={angledLabelMaxWidth}gap={STAGE_GAP}showLabels={showLabels}showValues={showValues}diff --git a/packages/react-ui/src/components/D3Charts/FunnelChart/funnelChart.scss b/packages/react-ui/src/components/Charts/FunnelChart/funnelChart.scsssimilarity index 100%rename from packages/react-ui/src/components/D3Charts/FunnelChart/funnelChart.scssrename to packages/react-ui/src/components/Charts/FunnelChart/funnelChart.scssdiff --git a/packages/react-ui/src/components/D3Charts/FunnelChart/index.ts b/packages/react-ui/src/components/Charts/FunnelChart/index.tssimilarity index 100%rename from packages/react-ui/src/components/D3Charts/FunnelChart/index.tsrename to packages/react-ui/src/components/Charts/FunnelChart/index.tsdiff --git a/packages/react-ui/src/components/D3Charts/FunnelChart/parts/FunnelStages.tsx b/packages/react-ui/src/components/Charts/FunnelChart/parts/FunnelStages.tsxsimilarity index 93%rename from packages/react-ui/src/components/D3Charts/FunnelChart/parts/FunnelStages.tsxrename to packages/react-ui/src/components/Charts/FunnelChart/parts/FunnelStages.tsxindex 9e3614f32..b4fff2df7 100644--- a/packages/react-ui/src/components/D3Charts/FunnelChart/parts/FunnelStages.tsx+++ b/packages/react-ui/src/components/Charts/FunnelChart/parts/FunnelStages.tsx@@ -14,11 +14,12 @@ import {} from "../../utils/labelWrap";import { numberTickFormatter } from "../../utils/styleUtils";import {- type FunnelEdges,- type FunnelOrientation,+ formatFunnelPercentage,funnelHaloRamp,hSegmentPath,vSegmentPath,+ type FunnelEdges,+ type FunnelOrientation,} from "./funnelGeometry";const CLASS = `${CHART_CLASS_PREFIX}-funnel-chart`;@@ -51,6 +52,8 @@ interface FunnelStagesProps<T> {labelColWidth: number;/** Shared rotation (deg) for horizontal labels that don't fit; 0 = upright. */labelAngle: number;+ /** Longest text an angled label keeps before truncating (fits the label band). */+ angledLabelMaxWidth: number;gap: number;showLabels: boolean;showValues: boolean;@@ -89,6 +92,7 @@ export function FunnelStages<T>({ringH,labelColWidth,labelAngle,+ angledLabelMaxWidth,gap,showLabels,showValues,@@ -141,8 +145,14 @@ export function FunnelStages<T>({const valueY = horiz ? 14 : mainSize / 2;const pctX = horiz ? mainSize / 2 : crossSize / 2;const pctY = horiz ? crossSize / 2 : mainSize / 2;- const pctText = `${Math.round(stage.pct)}%`;+ const pctText = formatFunnelPercentage(stage.pct);const pillW = pctText.length * PILL_CHAR_PX + 16;+ // The pill stays inside its stage; the value (above the pill) is+ // dropped where the plot is too short for both — the percentage is the+ // headline.+ const pctShown = showPercentage && (horiz ? mainSize : crossSize) >= pillW + 4;+ const valueShown =+ showValues && (!horiz || !pctShown || pctY - 10 >= valueY + lineHeight + 2);// Label anchor — at the start of the reserved band/column.const labelX = horiz ? mainSize / 2 : crossSize + LABEL_GAP;@@ -156,10 +166,13 @@ export function FunnelStages<T>({MAX_LABEL_LINES,): null;+ // An angled label is truncated to the band, and to the room left of its+ // anchor so the first labels stay inside the chart.+ const angledReach = (offset + labelX) / Math.cos((labelAngle * Math.PI) / 180);const horizLabel =showLabels && horiz? isAngled- ? stage.label+ ? truncateToWidth(ctx, stage.label, Math.min(angledLabelMaxWidth, angledReach)): truncateToWidth(ctx, stage.label, mainSize): null;@@ -217,7 +230,7 @@ export function FunnelStages<T>({opacity: dimFactor === DIM ? 0.55 : 1,}}>- {showValues && (+ {valueShown && (<textclassName={`${CLASS}-value`}x={valueX}@@ -228,7 +241,7 @@ export function FunnelStages<T>({{numberTickFormatter(stage.value)}</text>)}- {showPercentage && (+ {pctShown && (<><rectclassName={`${CLASS}-pct-pill`}diff --git a/packages/react-ui/src/components/D3Charts/FunnelChart/parts/funnelGeometry.test.ts b/packages/react-ui/src/components/Charts/FunnelChart/parts/funnelGeometry.test.tssimilarity index 85%rename from packages/react-ui/src/components/D3Charts/FunnelChart/parts/funnelGeometry.test.tsrename to packages/react-ui/src/components/Charts/FunnelChart/parts/funnelGeometry.test.tsindex 1390b944e..11c0d3952 100644--- a/packages/react-ui/src/components/D3Charts/FunnelChart/parts/funnelGeometry.test.ts+++ b/packages/react-ui/src/components/Charts/FunnelChart/parts/funnelGeometry.test.ts@@ -1,5 +1,11 @@import { describe, expect, it } from "vitest";-import { funnelHaloRamp, funnelPercentage, hSegmentPath, vSegmentPath } from "./funnelGeometry";+import {+ formatFunnelPercentage,+ funnelHaloRamp,+ funnelPercentage,+ hSegmentPath,+ vSegmentPath,+} from "./funnelGeometry";describe("funnelHaloRamp", () => {it("default 3 layers: outermost-first, the bklit opacity ramp", () => {@@ -90,3 +96,16 @@ describe("segment paths", () => {expect(inner).toContain("M 0 56");});});++describe("formatFunnelPercentage", () => {+ it("rounds to whole percentages", () => {+ expect(formatFunnelPercentage(100)).toBe("100%");+ expect(formatFunnelPercentage(26.4)).toBe("26%");+ expect(formatFunnelPercentage(0.5)).toBe("1%");+ });++ it("reads a non-empty stage that rounds to zero as <1%", () => {+ expect(formatFunnelPercentage(0.39)).toBe("<1%");+ expect(formatFunnelPercentage(0)).toBe("0%");+ });+});diff --git a/packages/react-ui/src/components/D3Charts/FunnelChart/parts/funnelGeometry.ts b/packages/react-ui/src/components/Charts/FunnelChart/parts/funnelGeometry.tssimilarity index 93%rename from packages/react-ui/src/components/D3Charts/FunnelChart/parts/funnelGeometry.tsrename to packages/react-ui/src/components/Charts/FunnelChart/parts/funnelGeometry.tsindex e74110127..0a2ea4763 100644--- a/packages/react-ui/src/components/D3Charts/FunnelChart/parts/funnelGeometry.ts+++ b/packages/react-ui/src/components/Charts/FunnelChart/parts/funnelGeometry.ts@@ -97,3 +97,10 @@ export function funnelPercentage(value: number, reference: number): number {if (!Number.isFinite(reference) || reference === 0) return 0;return (value / reference) * 100;}++/** A funnel percentage for display: whole numbers, and "<1%" for a stage that+ * isn't empty but rounds to zero. */+export function formatFunnelPercentage(pct: number): string {+ if (pct > 0 && pct < 0.5) return "<1%";+ return `${Math.round(pct)}%`;+}diff --git a/packages/react-ui/src/components/Charts/FunnelChart/stories/FunnelChart.stories.tsx b/packages/react-ui/src/components/Charts/FunnelChart/stories/FunnelChart.stories.tsxnew file mode 100644index 000000000..6edc3568e--- /dev/null+++ b/packages/react-ui/src/components/Charts/FunnelChart/stories/FunnelChart.stories.tsx@@ -0,0 +1,927 @@+import type { Meta, StoryObj } from "@storybook/react";+import { useState } from "react";+import { FunnelChart, FunnelChartProps } from "../..";+import { Card } from "../../../Card";++// 📊 DATA VARIATIONS - One row per stage, ordered from the top (widest) stage+// to the bottom. Every dataset shares the same `stage` / `count` keys so they+// can be swapped freely in the playground.+type FunnelRow = { stage: string; count: number };++const dataVariations = {+ // Classic SaaS conversion funnel — the default specimen.+ saas: [+ { stage: "Visited", count: 12480 },+ { stage: "Signed up", count: 5210 },+ { stage: "Activated", count: 3140 },+ { stage: "Subscribed", count: 1380 },+ { stage: "Renewed", count: 940 },+ ],+ // E-commerce checkout — six stages with a steep first drop.+ ecommerce: [+ { stage: "Product views", count: 48200 },+ { stage: "Added to cart", count: 14650 },+ { stage: "Checkout started", count: 7820 },+ { stage: "Shipping entered", count: 6130 },+ { stage: "Payment entered", count: 5410 },+ { stage: "Order placed", count: 4980 },+ ],+ // Hiring pipeline — small absolute numbers, very steep taper.+ hiring: [+ { stage: "Applications", count: 1240 },+ { stage: "Phone screen", count: 386 },+ { stage: "Onsite", count: 94 },+ { stage: "Offer", count: 21 },+ { stage: "Hired", count: 17 },+ ],+ // Two-stage funnel — the smallest meaningful funnel.+ twoStage: [+ { stage: "Trial started", count: 2400 },+ { stage: "Converted to paid", count: 612 },+ ],+ // Ten stages — a dense acquisition funnel spanning three orders of magnitude.+ manyStages: [+ { stage: "Impressions", count: 184000 },+ { stage: "Ad clicks", count: 9420 },+ { stage: "Landing views", count: 8110 },+ { stage: "Sign-up started", count: 3260 },+ { stage: "Email verified", count: 2540 },+ { stage: "Onboarded", count: 1870 },+ { stage: "First project", count: 1310 },+ { stage: "Invited team", count: 720 },+ { stage: "Converted", count: 410 },+ { stage: "Annual plan", count: 128 },+ ],+ // A near-empty stage and a zero stage at the bottom of the funnel.+ tinyAndZero: [+ { stage: "Leads", count: 4800 },+ { stage: "Qualified", count: 1150 },+ { stage: "Proposal", count: 310 },+ { stage: "Closed won", count: 6 },+ { stage: "Expansion", count: 0 },+ ],+ // Non-monotonic: the replay audience is larger than the live audience.+ nonMonotonic: [+ { stage: "Registered", count: 1200 },+ { stage: "Attended live", count: 540 },+ { stage: "Watched replay", count: 760 },+ { stage: "Booked demo", count: 180 },+ { stage: "Closed", count: 45 },+ ],+ // Long, sentence-like stage names — exercises label angling and wrapping.+ longNames: [+ { stage: "Landed on the pricing page from paid search", count: 9600 },+ { stage: "Started the 14-day free trial", count: 3820 },+ { stage: "Connected a first data source", count: 2210 },+ { stage: "Invited at least one teammate", count: 1180 },+ { stage: "Upgraded to a paid workspace", count: 530 },+ ],+} satisfies Record<string, FunnelRow[]>;++type DatasetKey = keyof typeof dataVariations;++const brandPalette = ["#10451D", "#1A7431", "#25A244", "#4AD66D", "#92E6A7", "#B7EFC5"];+const categoricalPalette = ["#F97316", "#EC4899", "#8B5CF6"];++/**+ * # FunnelChart Component Documentation+ *+ * The FunnelChart visualizes how a quantity shrinks as it flows through an+ * ordered sequence of stages — conversion funnels, sales and hiring pipelines,+ * onboarding flows. Each stage tapers into the next, so the steepest drop-off+ * is visible at a glance.+ *+ * ## Key Features+ * - **Orientation**: Horizontal (left → right) or vertical (top → bottom)+ * - **Shape**: Curved or straight edges, plus a multi-ring halo (`layers`)+ * - **Readouts**: Stage labels, compact values and retention percentages+ * - **Interactive**: Hover bloom + tooltip, legend toggling, `onClick`+ * - **Colors**: The ThemeProvider's chart palette, or `customPalette`+ */++const meta: Meta<FunnelChartProps<FunnelRow[]>> = {+ title: "Components/Charts/FunnelChart",+ component: FunnelChart,+ parameters: {+ layout: "centered",+ docs: {+ description: {+ component: `+## Installation and Basic Usage++\`\`\`tsx+import { FunnelChart } from '@openuidev/react-ui';++// Basic implementation+<FunnelChart+ data={yourData}+ categoryKey="stage"+ dataKey="count"+/>++// Vertical, straight-edged funnel with a custom palette+<FunnelChart+ data={yourData}+ categoryKey="stage"+ dataKey="count"+ orientation="vertical"+ edges="straight"+ customPalette={["#10451D", "#1A7431", "#25A244", "#4AD66D"]}+/>+\`\`\`++## Data Structure Requirements++Your data should be an array of objects, **one per stage, ordered from the top+(widest) stage to the bottom**. Each object contains:+- A **category field** (string): The stage name, used for labels, legend and tooltip+- A **value field** (number): The volume that reached that stage++\`\`\`tsx+const signupFunnel = [+ { stage: "Visited", count: 12480 },+ { stage: "Signed up", count: 5210 },+ { stage: "Activated", count: 3140 },+ { stage: "Subscribed", count: 1380 },+];+\`\`\`++Stage widths are scaled against the **largest visible value**, so the shape always+fits even when the data is not strictly decreasing. Missing or non-numeric values+are treated as \`0\`.++## Percentages Are Retention++The percentage pill shows each stage's value **relative to the first visible stage**+(which is always 100%). It is not a share of the total, so a later stage that is larger+than the first reads above 100%.++## When to Use++- ✅ Sequential processes where each stage is a subset of the previous one+- ✅ Highlighting where the largest drop-off happens+- ❌ Unordered categories or part-to-whole breakdowns — use a PieChart or BarChart+- ❌ Comparing several series — the funnel is single-series++## Performance Considerations++- **Stage Count**: Best with 3–8 stages. In-stage values and percentages are hidden+ once a stage is narrower than ~44px; the tooltip still shows them.+- **Responsiveness**: Fills its container's width; height defaults to 296px.+- **Animation**: The entrance animation is off by default so streamed data never replays it.+ `,+ },+ },+ },+ tags: ["dev", "autodocs"],+ argTypes: {+ data: {+ description: `+**Required.** An array of data objects, one per funnel stage, ordered from the top (widest) stage to the bottom. Each object should contain a stage name (string) and a numeric value.++**Best Practices:**+- Use 3-8 stages for optimal readability.+- Keep stage names short; long names are angled (horizontal) or wrapped (vertical).+`,+ control: false,+ table: {+ type: { summary: "Array<Record<string, string | number>>" },+ defaultValue: { summary: "[]" },+ category: "📊 Data Configuration",+ },+ },+ categoryKey: {+ description:+ "**Required.** The key in your data objects that holds the stage name (e.g., 'stage', 'step'). Used for labels, the legend and the tooltip.",+ control: false,+ table: {+ type: { summary: "string" },+ category: "📊 Data Configuration",+ },+ },+ dataKey: {+ description:+ "**Required.** The key in your data objects that holds each stage's numeric value (e.g., 'count', 'users'). Non-numeric or missing values are treated as 0.",+ control: false,+ table: {+ type: { summary: "string" },+ category: "📊 Data Configuration",+ },+ },+ orientation: {+ description: `+**Flow Direction:**+- **horizontal**: Stages flow left → right. Labels sit in a band below and angle when they don't fit.+- **vertical**: Stages flow top → bottom. Labels sit in a right-hand column and wrap onto up to 3 lines.+`,+ control: "radio",+ options: ["horizontal", "vertical"],+ table: {+ type: { summary: '"horizontal" | "vertical"' },+ defaultValue: { summary: "horizontal" },+ category: "🎨 Visual Styling",+ },+ },+ edges: {+ description:+ "Stage-to-stage edge shape: `curved` tapers smoothly with a bezier belly; `straight` uses flat trapezoid sides.",+ control: "radio",+ options: ["curved", "straight"],+ table: {+ type: { summary: '"curved" | "straight"' },+ defaultValue: { summary: "curved" },+ category: "🎨 Visual Styling",+ },+ },+ layers: {+ description:+ "Number of concentric halo rings drawn per stage. Outer rings are larger and fainter; the innermost is the solid core. `1` draws a single solid shape. Clamped to ≥ 1 and rounded.",+ control: { type: "number", min: 1, max: 6, step: 1 },+ table: {+ type: { summary: "number" },+ defaultValue: { summary: "3" },+ category: "🎨 Visual Styling",+ },+ },+ customPalette: {+ description:+ "Ordered colors for the stages, top → bottom; overrides the ThemeProvider's chart palette. One color per stage (the halo is built from opacity, not extra hues); colors cycle when there are more stages than colors.",+ control: "object",+ table: {+ type: { summary: "string[]" },+ category: "🎨 Visual Styling",+ },+ },+ showLabels: {+ description:+ "Show each stage's name. When hidden, the reserved label band/column is reclaimed by the funnel.",+ control: "boolean",+ table: {+ type: { summary: "boolean" },+ defaultValue: { summary: "true" },+ category: "📱 Display Options",+ },+ },+ showValues: {+ description:+ "Show each stage's raw value inside the stage, compact-formatted (e.g. 940, 5.2K, 12K). Hidden automatically when a stage is too small to fit it.",+ control: "boolean",+ table: {+ type: { summary: "boolean" },+ defaultValue: { summary: "true" },+ category: "📱 Display Options",+ },+ },+ showPercentage: {+ description:+ "Show each stage's percentage **relative to the first visible stage** (which is 100%) in a pill — funnel retention, not share of total.",+ control: "boolean",+ table: {+ type: { summary: "boolean" },+ defaultValue: { summary: "true" },+ category: "📱 Display Options",+ },+ },+ legend: {+ description:+ "Show the legend (one swatch per stage). Clicking an item hides or shows that stage; percentages then re-base on the first visible stage.",+ control: "boolean",+ table: {+ type: { summary: "boolean" },+ defaultValue: { summary: "true" },+ category: "📱 Display Options",+ },+ },+ height: {+ description: "The height of the chart. Defaults to 296px, with the legend placed below.",+ control: "text",+ table: {+ type: { summary: "string | number" },+ category: "📱 Display Options",+ },+ },+ width: {+ description: "The width of the chart. Defaults to the full width of its container.",+ control: "text",+ table: {+ type: { summary: "string | number" },+ category: "📱 Display Options",+ },+ },+ fitLegendInHeight: {+ description:+ "When true, the legend's height is subtracted from `height` so the funnel and legend together fit it. Defaults to true when `height` is set, false otherwise.",+ control: "boolean",+ table: {+ type: { summary: "boolean" },+ category: "📱 Display Options",+ },+ },+ className: {+ description: "Custom CSS class to apply to the chart's container.",+ control: "text",+ table: {+ type: { summary: "string" },+ category: "📱 Display Options",+ },+ },+ isAnimationActive: {+ description:+ "Plays the staggered entrance animation. Off by default so stages that mount while data streams in don't replay it. Hover and data-update motion are independent of this flag.",+ control: "boolean",+ table: {+ type: { summary: "boolean" },+ defaultValue: { summary: "false" },+ category: "🎬 Animation & Interaction",+ },+ },+ onClick: {+ description:+ "Called when a stage is clicked, with the original data row and its index among the currently **visible** stages (top = 0; the index shifts when stages are hidden via the legend).",+ action: "onClick",+ control: false,+ table: {+ type: { summary: "(row: T[number], index: number) => void" },+ category: "🎬 Animation & Interaction",+ },+ },+ },+} satisfies Meta<typeof FunnelChart>;++export default meta;+type Story = StoryObj<typeof meta>;++const panelTitleStyle: React.CSSProperties = {+ margin: "0 0 12px 0",+ fontSize: "14px",+ fontWeight: 600,+ textAlign: "center",+};++// Cards shrink to their content by default; grid panels must fill their cell.+const panelCardStyle: React.CSSProperties = { width: "100%", padding: "20px" };++const gridStyle = (width: number): React.CSSProperties => ({+ display: "grid",+ gridTemplateColumns: "1fr 1fr",+ gap: "24px",+ width: `${width}px`,+});++export const InteractivePlayground: Story = {+ name: "🎮 Interactive Playground",+ args: {+ categoryKey: "stage",+ dataKey: "count",+ orientation: "horizontal",+ edges: "curved",+ layers: 3,+ showLabels: true,+ showValues: true,+ showPercentage: true,+ legend: true,+ isAnimationActive: false,+ },+ render: (args: any) => {+ const [selectedDataType, setSelectedDataType] = useState<DatasetKey>("saas");+ const [lastClick, setLastClick] = useState<string | null>(null);+ const currentData = dataVariations[selectedDataType];++ const buttonStyle: React.CSSProperties = {+ margin: "2px",+ padding: "6px 12px",+ fontSize: "12px",+ border: "1px solid #ddd",+ borderRadius: "4px",+ cursor: "pointer",+ background: "#fff",+ color: "#333",+ fontFamily: "monospace",+ transition: "all 0.2s",+ };++ const activeButtonStyle: React.CSSProperties = {+ ...buttonStyle,+ background: "#3b82f6",+ color: "white",+ border: "1px solid #3b82f6",+ fontWeight: 600,+ };++ return (+ <div style={{ width: "760px" }}>+ <Card style={{ width: "100%", padding: "20px", marginBottom: "20px" }}>+ <h3 style={{ margin: "0 0 12px 0", fontSize: "16px", fontWeight: "600" }}>+ 🔻 Funnel Chart Test Suite+ </h3>+ <div style={{ display: "flex", flexWrap: "wrap", gap: "6px" }}>+ {(Object.keys(dataVariations) as DatasetKey[]).map((key) => (+ <button+ key={key}+ onClick={() => {+ setSelectedDataType(key);+ setLastClick(null);+ }}+ style={selectedDataType === key ? activeButtonStyle : buttonStyle}+ >+ {key.replace(/([A-Z])/g, " $1").replace(/^./, (str) => str.toUpperCase())}+ </button>+ ))}+ </div>+ <div style={{ marginTop: "12px", fontSize: "12px", color: "#666" }}>+ <strong>Current Dataset:</strong> {selectedDataType} | <strong>Stages:</strong>{" "}+ {currentData.length} | <strong>Last Click:</strong> {lastClick ?? "—"}+ </div>+ </Card>+ <Card+ style={{+ width: "100%",+ padding: "24px",+ resize: "both",+ overflow: "hidden",+ minWidth: "280px",+ }}+ >+ <FunnelChart+ {...args}+ data={currentData}+ onClick={(row: FunnelRow, index: number) => {+ args.onClick?.(row, index);+ setLastClick(+ `${row.stage} (${row.count.toLocaleString()}) at visible index ${index}`,+ );+ }}+ />+ </Card>+ </div>+ );+ },+ parameters: {+ docs: {+ description: {+ story: `+Swap datasets to see how the funnel handles steep drops, tiny and zero stages,+non-monotonic data and long stage names. Every other prop is driven by the Controls panel.++**Things to try:**+- Hover a stage to see the bloom, the dimmed siblings and the value/retention tooltip+- Click a legend item to hide a stage — percentages re-base on the first visible stage+- Click a stage to see the \`onClick\` payload (also logged in the Actions panel)+ `,+ },+ },+ },+};++export const DefaultConfiguration: Story = {+ name: "📊 Default Configuration",+ args: {+ data: dataVariations.saas,+ categoryKey: "stage",+ dataKey: "count",+ isAnimationActive: true,+ },+ render: (args: any) => (+ <Card style={{ width: "640px", height: "auto", padding: "24px" }}>+ <div style={{ marginBottom: "16px" }}>+ <h3 style={{ margin: "0 0 8px 0", fontSize: "18px", fontWeight: "600" }}>+ Signup Conversion Funnel+ </h3>+ <p style={{ margin: 0, color: "#666", fontSize: "14px" }}>+ How last quarter's 12,480 visitors converted into renewing customers.+ </p>+ </div>+ <FunnelChart {...args} />+ </Card>+ ),+ parameters: {+ docs: {+ description: {+ story: `+This is the recommended starting configuration for most use cases.++**Configuration Details:**+- **Orientation**: Horizontal, stages flowing left → right+- **Edges**: Curved bezier taper between stages+- **Layers**: 3 halo rings around a solid core+- **Readouts**: Stage names below, compact values on top, retention % in the pill+- **Colors**: The ThemeProvider's chart palette, applied in stage order+- **Animation**: Enabled here to show the staggered entrance (off by default)+ `,+ },+ source: {+ code: `+const signupFunnel = [+ { stage: "Visited", count: 12480 },+ { stage: "Signed up", count: 5210 },+ { stage: "Activated", count: 3140 },+ { stage: "Subscribed", count: 1380 },+ { stage: "Renewed", count: 940 },+];++<FunnelChart data={signupFunnel} categoryKey="stage" dataKey="count" isAnimationActive />+`,+ },+ },+ },+};++export const OrientationComparison: Story = {+ name: "↕️ Horizontal vs Vertical",+ args: {+ data: dataVariations.hiring,+ categoryKey: "stage",+ dataKey: "count",+ },+ render: (args: any) => (+ <div style={gridStyle(880)}>+ <div>+ <h4 style={panelTitleStyle}>orientation="horizontal"</h4>+ <Card style={panelCardStyle}>+ <FunnelChart {...args} orientation="horizontal" />+ </Card>+ </div>+ <div>+ <h4 style={panelTitleStyle}>orientation="vertical"</h4>+ <Card style={panelCardStyle}>+ <FunnelChart {...args} orientation="vertical" />+ </Card>+ </div>+ </div>+ ),+ parameters: {+ docs: {+ description: {+ story: `+**Choosing an orientation:**++- **Horizontal** (default): Stages flow left → right. Stage names live in a band below the+ funnel; when any name is wider than its stage, all labels angle together.+- **Vertical**: Stages flow top → bottom, like a physical funnel. Stage names live in a+ right-hand column (capped at about a third of the width) and wrap onto up to 3 lines.++Vertical funnels suit narrow containers and long stage names; horizontal funnels suit wide+dashboard rows.+ `,+ },+ source: {+ code: `+<FunnelChart data={hiringPipeline} categoryKey="stage" dataKey="count" orientation="horizontal" />+<FunnelChart data={hiringPipeline} categoryKey="stage" dataKey="count" orientation="vertical" />+`,+ },+ },+ },+};++export const EdgesAndLayers: Story = {+ name: "🎨 Edges & Halo Layers",+ args: {+ data: dataVariations.saas,+ categoryKey: "stage",+ dataKey: "count",+ legend: false,+ },+ render: (args: any) => (+ <div style={gridStyle(900)}>+ <div>+ <h4 style={panelTitleStyle}>edges="curved" (default, layers=3)</h4>+ <Card style={panelCardStyle}>+ <FunnelChart {...args} edges="curved" />+ </Card>+ </div>+ <div>+ <h4 style={panelTitleStyle}>edges="straight"</h4>+ <Card style={panelCardStyle}>+ <FunnelChart {...args} edges="straight" />+ </Card>+ </div>+ <div>+ <h4 style={panelTitleStyle}>layers={"{1}"} — solid, no halo</h4>+ <Card style={panelCardStyle}>+ <FunnelChart {...args} layers={1} />+ </Card>+ </div>+ <div>+ <h4 style={panelTitleStyle}>layers={"{5}"} — deep halo</h4>+ <Card style={panelCardStyle}>+ <FunnelChart {...args} layers={5} />+ </Card>+ </div>+ </div>+ ),+ parameters: {+ docs: {+ description: {+ story: `+**Edges:**+- **curved**: A bezier taper between stages — soft and organic.+- **straight**: Flat trapezoid sides — precise and geometric.++**Layers:** Each stage is drawn as \`layers\` concentric rings, outermost first. Outer rings+are larger and fainter; the innermost ring is the solid core. \`layers={1}\` draws a single,+fully opaque shape. On hover, the core swells outward through the halo.+ `,+ },+ source: {+ code: `+<FunnelChart data={data} categoryKey="stage" dataKey="count" edges="straight" />+<FunnelChart data={data} categoryKey="stage" dataKey="count" layers={1} />+<FunnelChart data={data} categoryKey="stage" dataKey="count" layers={5} />+`,+ },+ },+ },+};++export const LabelsValuesAndLegend: Story = {+ name: "🏷️ Labels, Values & Legend",+ args: {+ data: dataVariations.ecommerce,+ categoryKey: "stage",+ dataKey: "count",+ },+ render: (args: any) => (+ <div style={gridStyle(960)}>+ <div>+ <h4 style={panelTitleStyle}>All readouts (default)</h4>+ <Card style={panelCardStyle}>+ <FunnelChart {...args} />+ </Card>+ </div>+ <div>+ <h4 style={panelTitleStyle}>Values only — showPercentage=false</h4>+ <Card style={panelCardStyle}>+ <FunnelChart {...args} showPercentage={false} />+ </Card>+ </div>+ <div>+ <h4 style={panelTitleStyle}>Retention only — showValues=false, legend=false</h4>+ <Card style={panelCardStyle}>+ <FunnelChart {...args} showValues={false} legend={false} />+ </Card>+ </div>+ <div>+ <h4 style={panelTitleStyle}>Shape + legend — all readouts off</h4>+ <Card style={panelCardStyle}>+ <FunnelChart {...args} showLabels={false} showValues={false} showPercentage={false} />+ </Card>+ </div>+ </div>+ ),+ parameters: {+ docs: {+ description: {+ story: `+**Readouts:**+- **showLabels**: Stage names in their own band (horizontal) or column (vertical). When+ hidden, the funnel reclaims that space.+- **showValues**: Compact-formatted raw values (48K, 15K, 7.8K, …) at the top of each stage.+- **showPercentage**: Retention relative to the first stage, in a high-contrast pill.++**Legend:** One swatch per stage. Clicking an item hides that stage; the other stages keep+their colors and percentages re-base on the first visible stage. With every readout off,+the legend and tooltip carry all the information — useful for compact dashboard widgets.++Values and percentages are dropped automatically when a stage is too small to hold them;+the tooltip always shows both.+ `,+ },+ source: {+ code: `+<FunnelChart data={data} categoryKey="stage" dataKey="count" showPercentage={false} />+<FunnelChart data={data} categoryKey="stage" dataKey="count" showValues={false} legend={false} />+<FunnelChart+ data={data}+ categoryKey="stage"+ dataKey="count"+ showLabels={false}+ showValues={false}+ showPercentage={false}+/>+`,+ },+ },+ },+};++export const CustomPalette: Story = {+ name: "🖌️ Custom Palette",+ args: {+ data: dataVariations.ecommerce,+ categoryKey: "stage",+ dataKey: "count",+ customPalette: brandPalette,+ },+ render: (args: any) => {+ const swatches = (colors: string[]) => (+ <div style={{ display: "flex", gap: "6px", flexWrap: "wrap", marginTop: "12px" }}>+ {colors.map((color) => (+ <div+ key={color}+ style={{+ display: "flex",+ alignItems: "center",+ gap: "4px",+ padding: "4px 8px",+ background: "white",+ borderRadius: "4px",+ border: "1px solid #ddd",+ fontSize: "12px",+ }}+ >+ <div+ style={{ width: "12px", height: "12px", borderRadius: "2px", background: color }}+ />+ <span style={{ fontFamily: "monospace", color: "#333" }}>{color}</span>+ </div>+ ))}+ </div>+ );++ return (+ <div style={gridStyle(960)}>+ <Card style={{ ...panelCardStyle, padding: "24px" }}>+ <h3 style={{ margin: "0 0 8px 0", fontSize: "16px", fontWeight: 600 }}>+ Sequential brand ramp+ </h3>+ <p style={{ margin: "0 0 16px 0", color: "#666", fontSize: "14px" }}>+ Dark → light, one color per stage.+ </p>+ <FunnelChart {...args} />+ {swatches(args.customPalette ?? [])}+ </Card>+ <Card style={{ ...panelCardStyle, padding: "24px" }}>+ <h3 style={{ margin: "0 0 8px 0", fontSize: "16px", fontWeight: 600 }}>+ Short categorical palette+ </h3>+ <p style={{ margin: "0 0 16px 0", color: "#666", fontSize: "14px" }}>+ Three colors cycle across six stages.+ </p>+ <FunnelChart {...args} customPalette={categoricalPalette} />+ {swatches(categoricalPalette)}+ </Card>+ </div>+ );+ },+ parameters: {+ docs: {+ description: {+ story: `+When \`customPalette\` is provided, it overrides the ThemeProvider's chart palette.++**How colors are applied:**+- 🎯 **In data order**: the first color paints the top stage, the second the next, and so on+- 🔁 **Cycling**: with fewer colors than stages, colors repeat from the start+- 🔒 **Stable**: hiding a stage via the legend never recolors the remaining stages+- 🌫️ **One hue per stage**: the halo rings are built from opacity, not extra colors++A sequential ramp (dark → light) reinforces the funnel's narrowing; a categorical palette+emphasizes that each stage is distinct.+ `,+ },+ source: {+ code: `+<FunnelChart+ data={checkoutFunnel}+ categoryKey="stage"+ dataKey="count"+ customPalette={["#10451D", "#1A7431", "#25A244", "#4AD66D", "#92E6A7", "#B7EFC5"]}+/>+`,+ },+ },+ },+};++export const DataEdgeCases: Story = {+ name: "🧪 Data Edge Cases",+ args: {+ categoryKey: "stage",+ dataKey: "count",+ },+ render: (args: any) => (+ <div style={gridStyle(920)}>+ <div style={{ gridColumn: "1 / -1" }}>+ <h4 style={panelTitleStyle}>Ten stages</h4>+ <Card style={panelCardStyle}>+ <FunnelChart {...args} data={dataVariations.manyStages} />+ </Card>+ </div>+ <div>+ <h4 style={panelTitleStyle}>Two stages</h4>+ <Card style={panelCardStyle}>+ <FunnelChart {...args} data={dataVariations.twoStage} />+ </Card>+ </div>+ <div>+ <h4 style={panelTitleStyle}>Tiny (6) and zero stages</h4>+ <Card style={panelCardStyle}>+ <FunnelChart {...args} data={dataVariations.tinyAndZero} />+ </Card>+ </div>+ <div>+ <h4 style={panelTitleStyle}>Non-monotonic data</h4>+ <Card style={panelCardStyle}>+ <FunnelChart {...args} data={dataVariations.nonMonotonic} />+ </Card>+ </div>+ <div>+ <h4 style={panelTitleStyle}>Long stage names — vertical (wrapped)</h4>+ <Card style={panelCardStyle}>+ <FunnelChart {...args} data={dataVariations.longNames} orientation="vertical" />+ </Card>+ </div>+ <div style={{ gridColumn: "1 / -1" }}>+ <h4 style={panelTitleStyle}>Long stage names — horizontal (angled), height=440</h4>+ <Card style={panelCardStyle}>+ <FunnelChart {...args} data={dataVariations.longNames} height={440} />+ </Card>+ </div>+ </div>+ ),+ parameters: {+ docs: {+ description: {+ story: `+**Stage count:**+- **Ten stages**: Stages narrow and labels angle once they no longer fit their stage.+- **Two stages**: The smallest meaningful funnel — a single taper into a flat final stage.++**Values:**+- **Tiny and zero stages**: A near-zero stage tapers to a sliver and a zero stage collapses;+ both read 0% (percentages are rounded to whole numbers) without breaking the layout.+- **Non-monotonic data**: Widths scale against the largest value, so a stage larger than+ the one before simply widens again. Percentages stay relative to the first stage.++**Long stage names:**+- **Vertical**: Names wrap onto up to 3 lines in the right-hand column, then truncate.+- **Horizontal**: Labels angle but are not truncated, so the label band grows with the+ longest name. Prefer the vertical orientation for long names, or pin a taller \`height\`.+ `,+ },+ source: {+ code: `+const dealPipeline = [+ { stage: "Leads", count: 4800 },+ { stage: "Qualified", count: 1150 },+ { stage: "Proposal", count: 310 },+ { stage: "Closed won", count: 6 },+ { stage: "Expansion", count: 0 },+];++<FunnelChart data={dealPipeline} categoryKey="stage" dataKey="count" />+<FunnelChart data={longNamedStages} categoryKey="stage" dataKey="count" orientation="vertical" />+`,+ },+ },+ },+};++export const ResponsiveWidths: Story = {+ name: "📱 Responsive Widths",+ args: {+ data: dataVariations.ecommerce,+ categoryKey: "stage",+ dataKey: "count",+ legend: false,+ },+ render: (args: any) => (+ <div style={{ display: "flex", flexDirection: "column", gap: "24px", alignItems: "center" }}>+ {[320, 480, 760].map((width) => (+ <div key={width}>+ <h4 style={panelTitleStyle}>{width}px container</h4>+ <Card style={{ width: `${width}px`, padding: "20px", border: "2px dashed #9ca3af" }}>+ <FunnelChart {...args} height={220} />+ </Card>+ </div>+ ))}+ </div>+ ),+ parameters: {+ docs: {+ description: {+ story: `+The funnel always fills its container's width and adapts its readouts to the space available:++- **Narrow (320px)**: Stages are too small for in-stage values and percentages, so they are+ dropped (the tooltip still shows them) and labels angle to fit.+- **Medium (480px)**: Values and percentages return; labels still angle.+- **Wide (760px)**: Every label fits its stage and stands upright.++**Implementation Notes:**+- Uses ResizeObserver to track the container size+- Label angling is shared across all stages so the band stays aligned+- Pass \`height\` to pin the chart height (the legend then fits inside it)+ `,+ },+ source: {+ code: `+<div style={{ width: 320 }}>+ <FunnelChart data={checkoutFunnel} categoryKey="stage" dataKey="count" height={220} />+</div>+`,+ },+ },+ },+};diff --git a/packages/react-ui/src/components/D3Charts/FunnelChart/types.ts b/packages/react-ui/src/components/Charts/FunnelChart/types.tssimilarity index 100%rename from packages/react-ui/src/components/D3Charts/FunnelChart/types.tsrename to packages/react-ui/src/components/Charts/FunnelChart/types.tsdiff --git a/packages/react-ui/src/components/D3Charts/HeatmapChart/HeatmapChart.tsx b/packages/react-ui/src/components/Charts/HeatmapChart/HeatmapChart.tsxsimilarity index 100%rename from packages/react-ui/src/components/D3Charts/HeatmapChart/HeatmapChart.tsxrename to packages/react-ui/src/components/Charts/HeatmapChart/HeatmapChart.tsxdiff --git a/packages/react-ui/src/components/D3Charts/HeatmapChart/heatmapChart.scss b/packages/react-ui/src/components/Charts/HeatmapChart/heatmapChart.scsssimilarity index 95%rename from packages/react-ui/src/components/D3Charts/HeatmapChart/heatmapChart.scssrename to packages/react-ui/src/components/Charts/HeatmapChart/heatmapChart.scssindex 68065c6e3..685684caa 100644--- a/packages/react-ui/src/components/D3Charts/HeatmapChart/heatmapChart.scss+++ b/packages/react-ui/src/components/Charts/HeatmapChart/heatmapChart.scss@@ -32,8 +32,9 @@}}+// Ink, not $foreground: react-ui's $foreground is a light surface neutral..#{brand.$prefix}-heatmap-chart-cell:hover {- stroke: cssUtils.$foreground;+ stroke: cssUtils.$text-neutral-primary;stroke-width: 1.5;}@@ -103,6 +104,6 @@bottom: 0;width: 2px;transform: translateX(-50%);- background: cssUtils.$foreground;+ background: cssUtils.$text-neutral-primary;opacity: 0.55;}diff --git a/packages/react-ui/src/components/D3Charts/HeatmapChart/index.ts b/packages/react-ui/src/components/Charts/HeatmapChart/index.tssimilarity index 100%rename from packages/react-ui/src/components/D3Charts/HeatmapChart/index.tsrename to packages/react-ui/src/components/Charts/HeatmapChart/index.tsdiff --git a/packages/react-ui/src/components/D3Charts/HeatmapChart/parts/HeatmapCells.tsx b/packages/react-ui/src/components/Charts/HeatmapChart/parts/HeatmapCells.tsxsimilarity index 100%rename from packages/react-ui/src/components/D3Charts/HeatmapChart/parts/HeatmapCells.tsxrename to packages/react-ui/src/components/Charts/HeatmapChart/parts/HeatmapCells.tsxdiff --git a/packages/react-ui/src/components/D3Charts/HeatmapChart/parts/HeatmapColorScale.tsx b/packages/react-ui/src/components/Charts/HeatmapChart/parts/HeatmapColorScale.tsxsimilarity index 100%rename from packages/react-ui/src/components/D3Charts/HeatmapChart/parts/HeatmapColorScale.tsxrename to packages/react-ui/src/components/Charts/HeatmapChart/parts/HeatmapColorScale.tsxdiff --git a/packages/react-ui/src/components/D3Charts/HeatmapChart/parts/HeatmapYAxis.tsx b/packages/react-ui/src/components/Charts/HeatmapChart/parts/HeatmapYAxis.tsxsimilarity index 100%rename from packages/react-ui/src/components/D3Charts/HeatmapChart/parts/HeatmapYAxis.tsxrename to packages/react-ui/src/components/Charts/HeatmapChart/parts/HeatmapYAxis.tsxdiff --git a/packages/react-ui/src/components/Charts/HeatmapChart/stories/HeatmapChart.stories.tsx b/packages/react-ui/src/components/Charts/HeatmapChart/stories/HeatmapChart.stories.tsxnew file mode 100644index 000000000..1b9b8fe25--- /dev/null+++ b/packages/react-ui/src/components/Charts/HeatmapChart/stories/HeatmapChart.stories.tsx@@ -0,0 +1,1064 @@+import type { Meta, StoryObj } from "@storybook/react";+import { useState } from "react";+import { HeatmapChart, HeatmapChartData, HeatmapChartProps } from "../..";+import { Card } from "../../../Card";++// 📊 COMPREHENSIVE DATA VARIATIONS - Designed to test various heatmap scenarios.+// Heatmap data is row-shaped like every other chart: each object is one COLUMN+// (its `categoryKey` field is the x-axis label) and every other key of the+// first object becomes a ROW (y-axis). `object[rowKey]` is the cell value.++// Website sessions per 2-hour slot, one row per weekday.+const weeklyTrafficData: HeatmapChartData = [+ { slot: "6 AM", Mon: 120, Tue: 135, Wed: 128, Thu: 142, Fri: 118, Sat: 62, Sun: 48 },+ { slot: "8 AM", Mon: 410, Tue: 438, Wed: 425, Thu: 447, Fri: 392, Sat: 118, Sun: 96 },+ { slot: "10 AM", Mon: 690, Tue: 712, Wed: 705, Thu: 731, Fri: 640, Sat: 244, Sun: 187 },+ { slot: "12 PM", Mon: 585, Tue: 604, Wed: 612, Thu: 598, Fri: 552, Sat: 352, Sun: 298 },+ { slot: "2 PM", Mon: 742, Tue: 768, Wed: 781, Thu: 756, Fri: 614, Sat: 331, Sun: 276 },+ { slot: "4 PM", Mon: 655, Tue: 671, Wed: 688, Thu: 642, Fri: 488, Sat: 287, Sun: 262 },+ { slot: "6 PM", Mon: 402, Tue: 418, Wed: 421, Thu: 395, Fri: 301, Sat: 256, Sun: 318 },+ { slot: "8 PM", Mon: 288, Tue: 297, Wed: 305, Thu: 276, Fri: 214, Sat: 231, Sun: 352 },+];++// Monthly revenue ($K) per sales region.+const regionalRevenueData: HeatmapChartData = [+ { month: "Jan", "North America": 412, Europe: 318, "Asia Pacific": 256, "Latin America": 124 },+ { month: "Feb", "North America": 398, Europe: 305, "Asia Pacific": 271, "Latin America": 118 },+ { month: "Mar", "North America": 455, Europe: 342, "Asia Pacific": 298, "Latin America": 139 },+ { month: "Apr", "North America": 468, Europe: 351, "Asia Pacific": 312, "Latin America": 146 },+ { month: "May", "North America": 482, Europe: 337, "Asia Pacific": 335, "Latin America": 158 },+ { month: "Jun", "North America": 510, Europe: 322, "Asia Pacific": 348, "Latin America": 171 },+ { month: "Jul", "North America": 494, Europe: 286, "Asia Pacific": 362, "Latin America": 165 },+ { month: "Aug", "North America": 476, Europe: 264, "Asia Pacific": 371, "Latin America": 162 },+ { month: "Sep", "North America": 521, Europe: 348, "Asia Pacific": 384, "Latin America": 177 },+ { month: "Oct", "North America": 548, Europe: 372, "Asia Pacific": 396, "Latin America": 189 },+ { month: "Nov", "North America": 596, Europe: 405, "Asia Pacific": 418, "Latin America": 204 },+ { month: "Dec", "North America": 642, Europe: 438, "Asia Pacific": 402, "Latin America": 231 },+];++// Month-over-month revenue change (%) per product line — SIGNED and deliberately+// asymmetric (-14…+32) so a zero-centered diverging ramp is visibly different+// from a plain min→max ramp.+const revenueChangeData: HeatmapChartData = [+ { month: "Jan", Hardware: -8, Software: 12, Services: 4, Support: -2, Training: -14 },+ { month: "Feb", Hardware: -5, Software: 9, Services: 6, Support: 1, Training: -9 },+ { month: "Mar", Hardware: 3, Software: 15, Services: 8, Support: 2, Training: -4 },+ { month: "Apr", Hardware: 6, Software: 18, Services: 5, Support: 0, Training: 2 },+ { month: "May", Hardware: 2, Software: 21, Services: -3, Support: -1, Training: 7 },+ { month: "Jun", Hardware: -4, Software: 24, Services: -6, Support: 3, Training: 11 },+ { month: "Jul", Hardware: -11, Software: 19, Services: -2, Support: 4, Training: 6 },+ { month: "Aug", Hardware: -7, Software: 14, Services: 1, Support: 2, Training: -3 },+ { month: "Sep", Hardware: 5, Software: 22, Services: 7, Support: -2, Training: 9 },+ { month: "Oct", Hardware: 9, Software: 27, Services: 10, Support: -4, Training: 13 },+ { month: "Nov", Hardware: 14, Software: 32, Services: 12, Support: -3, Training: 4 },+ { month: "Dec", Hardware: 18, Software: 29, Services: 6, Support: -6, Training: -5 },+];++// Builds the column objects from a row-major table — the natural way to write+// a matrix down. Each row array holds one value per column, in column order.+const fromRowTable = (+ categoryKey: string,+ columns: string[],+ rows: Record<string, number[]>,+): HeatmapChartData =>+ columns.map((column, i) => {+ const entry: Record<string, string | number> = { [categoryKey]: column };+ for (const [rowKey, values] of Object.entries(rows)) entry[rowKey] = values[i] ?? "";+ return entry;+ });++// Pearson correlation between product KPIs (−1…1) — a symmetric matrix whose+// columns and rows are the same metrics.+const KPIS = ["Revenue", "Ad Spend", "Sessions", "Churn", "NPS", "Tickets"];+const correlationData = fromRowTable("metric", KPIS, {+ Revenue: [1, 0.72, 0.81, -0.64, 0.48, -0.22],+ "Ad Spend": [0.72, 1, 0.86, -0.18, 0.12, 0.09],+ Sessions: [0.81, 0.86, 1, -0.35, 0.27, 0.31],+ Churn: [-0.64, -0.18, -0.35, 1, -0.77, 0.58],+ NPS: [0.48, 0.12, 0.27, -0.77, 1, -0.69],+ Tickets: [-0.22, 0.09, 0.31, 0.58, -0.69, 1],+});++// Deterministic pseudo-random generator (mulberry32) so generated fixtures are+// stable across reloads and screenshots.+const seeded = (seed: number) => {+ let a = seed >>> 0;+ return () => {+ a = (a + 0x6d2b79f5) >>> 0;+ let t = a;+ t = Math.imul(t ^ (t >>> 15), t | 1);+ t ^= t + Math.imul(t ^ (t >>> 7), t | 61);+ return ((t ^ (t >>> 14)) >>> 0) / 4294967296;+ };+};++const HOSTS = [+ "api-01",+ "api-02",+ "api-03",+ "api-04",+ "db-primary",+ "db-replica",+ "cache-01",+ "worker-01",+];++// CPU utilisation (%) per host in 30-minute slots over one day: 48 columns × 8+// rows. Web/db hosts follow the daytime curve; the batch worker peaks overnight.+const denseCpuData: HeatmapChartData = (() => {+ const random = seeded(7);+ return Array.from({ length: 48 }, (_, i) => {+ const hour = Math.floor(i / 2);+ const time = `${String(hour).padStart(2, "0")}:${i % 2 === 0 ? "00" : "30"}`;+ const daytime = 0.5 - 0.5 * Math.cos(((hour - 3) / 24) * 2 * Math.PI);+ const row: Record<string, string | number> = { time };+ HOSTS.forEach((host) => {+ const load = host.startsWith("worker")+ ? 18 + (1 - daytime) * 64+ : (host.startsWith("db") ? 30 : 22) + daytime * 58;+ row[host] = Math.min(100, Math.max(0, Math.round(load + random() * 12 - 6)));+ });+ return row;+ });+})();++// Weekly survey response rate (%) per team. Empty strings are "no value" — the+// survey didn't run for that team that week — and render as muted cells.+const sparseSurveyData: HeatmapChartData = [+ { week: "Wk 1", Design: 82, Engineering: 64, Marketing: "", Sales: 41, Support: 77 },+ { week: "Wk 2", Design: "", Engineering: 71, Marketing: 58, Sales: "", Support: 80 },+ { week: "Wk 3", Design: 88, Engineering: "", Marketing: 62, Sales: 38, Support: "" },+ { week: "Wk 4", Design: "", Engineering: "", Marketing: 67, Sales: 45, Support: 84 },+ { week: "Wk 5", Design: 91, Engineering: 76, Marketing: "", Sales: "", Support: 79 },+ { week: "Wk 6", Design: 86, Engineering: 69, Marketing: 70, Sales: 52, Support: "" },+];++// Adoption (%) of cloud products (columns) per metro area (rows) — long labels+// on BOTH axes.+const longLabelData = fromRowTable(+ "product",+ [+ "Managed Kubernetes Service",+ "Serverless Functions Platform",+ "Enterprise Object Storage",+ "Real-time Analytics Warehouse",+ "Global Content Delivery Network",+ "Machine Learning Inference API",+ ],+ {+ "San Francisco–Oakland–Berkeley, CA Metro Area": [68, 74, 81, 57, 63, 49],+ "New York–Newark–Jersey City, NY-NJ-PA Metro Area": [54, 61, 77, 63, 70, 38],+ "Greater London Region": [49, 58, 72, 46, 66, 31],+ "Tokyo Metropolitan Area": [41, 36, 69, 32, 58, 27],+ "Mexico City Federal District": [23, 28, 44, 17, 35, 12],+ },+);++const dataVariations = {+ weeklyTraffic: weeklyTrafficData,+ regionalRevenue: regionalRevenueData,+ revenueChange: revenueChangeData,+ correlation: correlationData,+ denseCpu: denseCpuData,+ sparseSurvey: sparseSurveyData,+ longLabels: longLabelData,+} satisfies Record<string, HeatmapChartData>;++// Map data variations to their category keys+const categoryKeys: Record<keyof typeof dataVariations, string> = {+ weeklyTraffic: "slot",+ regionalRevenue: "month",+ revenueChange: "month",+ correlation: "metric",+ denseCpu: "time",+ sparseSurvey: "week",+ longLabels: "product",+};++// Ordered low → high ramp (a magma-style sequential palette).+const sunsetPalette = [+ "#0D0887",+ "#42049E",+ "#6A00A8",+ "#900DA4",+ "#B12A90",+ "#CC4678",+ "#E16462",+ "#F1844B",+ "#FCA636",+ "#FCCE25",+ "#FFE06E",+];++// Ordered low → neutral → high diverging ramp (purple ↔ green). Odd length, so+// zero lands on exactly one neutral middle color.+const purpleGreenPalette = [+ "#762A83",+ "#9970AB",+ "#C2A5CF",+ "#E7D4E8",+ "#F7F7F7",+ "#D9F0D3",+ "#A6DBA0",+ "#5AAE61",+ "#1B7837",+];++const PaletteSwatches = ({ colors, label }: { colors: string[]; label: string }) => (+ <div+ style={{ display: "flex", alignItems: "center", gap: "8px", fontSize: "12px", color: "#666" }}+ >+ <strong style={{ minWidth: "90px" }}>{label}</strong>+ <div+ style={{ display: "flex", borderRadius: "4px", overflow: "hidden", border: "1px solid #ddd" }}+ >+ {colors.map((color) => (+ <span+ key={color}+ title={color}+ style={{ width: "18px", height: "14px", backgroundColor: color }}+ />+ ))}+ </div>+ </div>+);++const meta: Meta<HeatmapChartProps<HeatmapChartData>> = {+ title: "Components/Charts/HeatmapChart",+ component: HeatmapChart,+ parameters: {+ layout: "centered",+ docs: {+ description: {+ component: `+## Installation and Basic Usage++\`\`\`tsx+import { HeatmapChart } from '@openuidev/react-ui/Charts/HeatmapChart';++// Basic implementation+<HeatmapChart+ data={yourData}+ categoryKey="slot"+/>++// Signed data (profit/loss, deltas, correlation) — zero sits on the neutral middle color+<HeatmapChart+ data={yourData}+ categoryKey="month"+ rampMode="diverging"+ showCellLabels+/>+\`\`\`++## Data Structure Requirements++Heatmap data uses the same row-shaped contract as the other charts:+- The **category field** (\`categoryKey\`) of each object is a **column** label (x-axis).+- Every other key of the **first** object becomes a **row** (y-axis) and a legend item.+- \`object[rowKey]\` is the **cell value**. Non-numeric, empty (\`""\`) or missing values render as muted "no value" cells.++\`\`\`tsx+const trafficData = [+ { slot: "8 AM", Mon: 410, Tue: 438, Wed: 425 },+ { slot: "10 AM", Mon: 690, Tue: 712, Wed: 705 },+ { slot: "12 PM", Mon: 585, Tue: 604, Wed: 612 },+];+// → 3 columns (8 AM, 10 AM, 12 PM) × 3 rows (Mon, Tue, Wed)+\`\`\`++## Key Features++- **Color Encodes Value**: Cells are colored by quantizing each value onto an ordered ramp (one bucket per palette color).+- **Two Ramp Modes**: \`sequential\` spreads the ramp over min→max; \`diverging\` forces a symmetric ±max domain so zero always sits on the neutral middle color.+- **Color Scale Key**: A bucket strip under the grid labelled with the domain endpoints (hover a bucket for its exact range) — the only value readout on touch and in print.+- **Cell Labels**: Optional in-cell values that auto-hide when they don't fit and auto-contrast against each cell's color.+- **Interactive Legend**: One item per row (swatch = the color of the row's mean); click to hide/show a row — the color domain re-fits to the visible rows.+- **Rich Tooltip**: Hovering a cell shows its value plus the row and column averages.+- **Theming**: Sequential mode uses \`customPalette\`, else the ThemeProvider's \`defaultChartPalette\`, else the built-in ocean ramp. Diverging mode without a \`customPalette\` uses a built-in blue ↔ orange ramp tuned for light and dark mode.++## When to Use++- Two categorical dimensions × one numeric measure (activity by weekday × hour, revenue by region × month).+- Matrices such as correlation tables, where the sign matters as much as the size.+- Spotting patterns, hot spots and gaps across many cells at once.++Prefer a line or bar chart when exact values or trends of a few series matter more than the overall pattern.++## Performance Considerations++- **Data Size**: Comfortably renders hundreds of cells; x-axis labels thin out automatically once columns get narrow.+- **Responsive**: Width follows the container; the default height is 296px, or pass \`height\`.+- **Animation**: The entrance animation is **off by default** (streaming-safe).+ `,+ },+ },+ },+ tags: ["dev", "autodocs"],+ argTypes: {+ data: {+ description: `+**Required.** An array of data objects. Each object is one **column** of the grid and should contain:+- The column label under \`categoryKey\` (string).+- One numeric value per **row** — every non-category key of the first object becomes a row.++**Best Practices:**+- Keep the same keys on every object; use \`""\` for a cell with no value.+- 3–12 rows and up to a few dozen columns read best.+`,+ control: false,+ table: {+ type: { summary: "Array<Record<string, string | number>>" },+ defaultValue: { summary: "[]" },+ category: "📊 Data Configuration",+ },+ },+ categoryKey: {+ description: `+**Required.** The key in your data objects that holds the **column** (x-axis) label.++**Examples:**+- "slot" for a weekday × time-of-day activity grid.+- "month" for a region × month revenue grid.+`,+ control: false,+ table: {+ type: { summary: "string" },+ category: "📊 Data Configuration",+ },+ },+ customPalette: {+ description: `+**Custom Color Ramp.** An **ordered** array of colors, low → high, that replaces the ThemeProvider's \`defaultChartPalette\` (and the built-in ocean ramp).++- Each color is one bucket of the value scale — more colors means finer steps.+- In \`diverging\` mode it is read as the full low → neutral → high ramp; use an **odd** length so zero lands on one exact middle color.+`,+ control: "object",+ table: {+ type: { summary: "string[]" },+ defaultValue: { summary: "undefined" },+ category: "🎨 Visual Styling",+ },+ },+ rampMode: {+ description: `+**How values map onto the ramp:**++- **sequential**: spreads the ramp over the plain min → max extent of the visible values.+- **diverging**: forces a symmetric domain (±max absolute value) so zero sits on the neutral middle color and the two signs get opposing hues. Use for profit/loss, deltas and correlations.+`,+ control: "radio",+ options: ["sequential", "diverging"],+ table: {+ type: { summary: '"sequential" | "diverging"' },+ defaultValue: { summary: "sequential" },+ category: "🎨 Visual Styling",+ },+ },+ cellGap: {+ description: "Gap between cells in px. Never allowed to eat more than half a cell.",+ control: { type: "number", min: 0, max: 12 },+ table: {+ type: { summary: "number" },+ defaultValue: { summary: "2" },+ category: "🎨 Visual Styling",+ },+ },+ cellRadius: {+ description: "Corner radius of each cell in px.",+ control: { type: "number", min: 0, max: 12 },+ table: {+ type: { summary: "number" },+ defaultValue: { summary: "2" },+ category: "🎨 Visual Styling",+ },+ },+ className: {+ description: "Extra class name added to the chart's root container.",+ control: "text",+ table: {+ type: { summary: "string" },+ category: "🎨 Visual Styling",+ },+ },+ legend: {+ description: `+**Legend Visibility.** The legend lists one item per **row**; its swatch is the color of the row's mean value. Clicking an item hides/shows that row.+`,+ control: "boolean",+ table: {+ type: { summary: "boolean" },+ defaultValue: { summary: "true" },+ category: "📱 Display Options",+ },+ },+ showColorScale: {+ description: `+**Color Scale Key.** Shows the value → color bucket strip under the grid, labelled with the domain's endpoints (diverging ramps get a zero notch at the center).++**Keep it on** unless an outer surface provides its own key — the tooltip is mouse-only, so on touch or in print this strip is the only way to read color as magnitude.+`,+ control: "boolean",+ table: {+ type: { summary: "boolean" },+ defaultValue: { summary: "true" },+ category: "📱 Display Options",+ },+ },+ showCellLabels: {+ description: `+**In-cell Values.** Draws each cell's (compactly formatted) value inside the cell.++Safe on any data: a label auto-hides when it doesn't fit its cell, and its text color auto-contrasts with the cell color. Off by default because dense matrices read better through color alone.+`,+ control: "boolean",+ table: {+ type: { summary: "boolean" },+ defaultValue: { summary: "false" },+ category: "📱 Display Options",+ },+ },+ showYAxis: {+ description:+ "Shows the row labels on the left. Long labels are truncated (max 200px) with a tooltip carrying the full text.",+ control: "boolean",+ table: {+ type: { summary: "boolean" },+ defaultValue: { summary: "true" },+ category: "📱 Display Options",+ },+ },+ height: {+ description:+ 'The height of the chart. A number is in px; a CSS string (e.g. `"100%"`) sizes the container and is measured. When omitted, the grid area is 296px tall and the color scale and legend sit below it.',+ control: "number",+ table: {+ type: { summary: "string | number" },+ category: "📱 Display Options",+ },+ },+ width: {+ description:+ 'The width of the chart: a number in px or a CSS string (e.g. `"100%"`). Defaults to the container\'s width.',+ control: "number",+ table: {+ type: { summary: "string | number" },+ category: "📱 Display Options",+ },+ },+ fitLegendInHeight: {+ description: `+Whether the legend and color scale are laid out **inside** \`height\` (the grid shrinks to make room) or placed **below** the chart.++Defaults to \`true\` when a \`height\` is set, otherwise \`false\`.+`,+ control: "boolean",+ table: {+ type: { summary: "boolean" },+ defaultValue: { summary: "height !== undefined" },+ category: "📱 Display Options",+ },+ },+ isAnimationActive: {+ description: `+**Entrance Animation.** A left-to-right column fade-in wave. Only the entrance is gated — recolors on data updates always tween, and printing always disables it.++**Default is false** (unlike most charts) so cells mounted while data streams in don't replay staggered entrances.+`,+ control: "boolean",+ table: {+ type: { summary: "boolean" },+ defaultValue: { summary: "false" },+ category: "🎬 Animation & Interaction",+ },+ },+ onClick: {+ description:+ "Called when a cell is clicked with the original data object (the column), its column index, and the row key. Cells show a pointer cursor when set.",+ control: false,+ table: {+ type: { summary: "(row: T[number], columnIndex: number, rowKey: string) => void" },+ category: "🎬 Animation & Interaction",+ },+ },+ },+} satisfies Meta<typeof HeatmapChart>;++export default meta;+type Story = StoryObj<typeof meta>;++/**+ * ## Interactive Playground+ *+ * Switch datasets with the buttons and use the Controls panel to try every prop.+ * Click a cell to see the `onClick` payload.+ */+export const InteractivePlayground: Story = {+ name: "🎮 Interactive Playground",+ args: {+ rampMode: "sequential",+ legend: true,+ showColorScale: true,+ showCellLabels: false,+ showYAxis: true,+ cellGap: 2,+ cellRadius: 2,+ isAnimationActive: false,+ height: undefined,+ width: undefined,+ },+ render: (args: any) => {+ const [selectedDataType, setSelectedDataType] =+ useState<keyof typeof dataVariations>("weeklyTraffic");+ const [lastClick, setLastClick] = useState<string | null>(null);++ const currentData: HeatmapChartData = dataVariations[selectedDataType];+ const currentCategoryKey = categoryKeys[selectedDataType];++ const buttonStyle: React.CSSProperties = {+ margin: "2px",+ padding: "6px 12px",+ fontSize: "12px",+ border: "1px solid #ddd",+ borderRadius: "4px",+ cursor: "pointer",+ background: "#fff",+ color: "#333",+ fontFamily: "monospace",+ transition: "all 0.2s",+ };++ const activeButtonStyle: React.CSSProperties = {+ ...buttonStyle,+ background: "#3b82f6",+ color: "white",+ border: "1px solid #3b82f6",+ fontWeight: 600,+ };++ return (+ <div style={{ width: "760px" }}>+ <Card style={{ width: "100%", padding: "20px", marginBottom: "20px" }}>+ <h3 style={{ margin: "0 0 12px 0", fontSize: "16px", fontWeight: "600" }}>+ 🟪 Heatmap Chart Test Suite+ </h3>+ <div style={{ display: "flex", flexWrap: "wrap", gap: "6px" }}>+ {(Object.keys(dataVariations) as Array<keyof typeof dataVariations>).map((key) => (+ <button+ key={key}+ onClick={() => {+ setSelectedDataType(key);+ setLastClick(null);+ }}+ style={selectedDataType === key ? activeButtonStyle : buttonStyle}+ >+ {key.replace(/([A-Z])/g, " $1").replace(/^./, (str) => str.toUpperCase())}+ </button>+ ))}+ </div>+ <div style={{ marginTop: "12px", fontSize: "12px", color: "#666" }}>+ <strong>Current Dataset:</strong> {selectedDataType} | <strong>Columns:</strong>{" "}+ {currentData.length} | <strong>Rows:</strong>{" "}+ {Object.keys(currentData[0] ?? {}).length - 1} | <strong>Category Key:</strong>{" "}+ {currentCategoryKey}+ </div>+ <div style={{ marginTop: "6px", fontSize: "12px", color: "#666" }}>+ <strong>Last clicked cell:</strong> {lastClick ?? "— click any cell"}+ </div>+ </Card>+ <Card+ style={{+ width: "100%",+ padding: "24px",+ resize: "horizontal",+ overflow: "hidden",+ minWidth: "320px",+ }}+ >+ <HeatmapChart+ {...args}+ data={currentData}+ categoryKey={currentCategoryKey}+ onClick={(row, columnIndex, rowKey) =>+ setLastClick(+ `${rowKey} × ${String(row[currentCategoryKey])} (column ${columnIndex}) = ${+ row[rowKey] === "" ? "no value" : String(row[rowKey])+ }`,+ )+ }+ />+ </Card>+ </div>+ );+ },+ parameters: {+ docs: {+ description: {+ story: `+Use the buttons to switch between datasets (sequential, signed, correlation, dense, sparse and long-label data) and the Controls panel to change every prop in real time.+Try switching **Revenue Change** or **Correlation** to \`rampMode: "diverging"\`, and click legend items to hide rows — the color domain re-fits to what's visible.+The card is horizontally resizable (drag its bottom-right corner).+`,+ },+ },+ },+};++/**+ * ## Default Configuration+ *+ * The HeatmapChart with its default settings: sequential ramp, color scale key,+ * row labels and row legend.+ */+export const DefaultConfiguration: Story = {+ name: "📊 Default Configuration",+ args: {+ data: weeklyTrafficData,+ categoryKey: "slot",+ },+ render: (args: any) => (+ <Card style={{ width: "720px", height: "auto", padding: "24px" }}>+ <div style={{ marginBottom: "16px" }}>+ <h3 style={{ margin: "0 0 8px 0", fontSize: "18px", fontWeight: "600" }}>+ Website Traffic by Day and Time+ </h3>+ <p style={{ margin: 0, color: "#666", fontSize: "14px" }}>+ Sessions per 2-hour slot — weekday peaks mid-morning and mid-afternoon, weekends in the+ evening.+ </p>+ </div>+ <HeatmapChart {...args} />+ </Card>+ ),+ parameters: {+ docs: {+ description: {+ story: `+The recommended starting configuration: pass \`data\` and \`categoryKey\`, everything else uses its default.++**Configuration Details:**+- **Data**: 8 time slots (columns) × 7 weekdays (rows).+- **Ramp**: \`sequential\` over the ThemeProvider's \`defaultChartPalette\` (the built-in ocean ramp when the theme has none); low values take the first color.+- **Color Scale**: On — the strip below the grid maps colors back to values.+- **Legend**: One item per weekday; click one to hide that row.+- **Tooltip**: Hover a cell for its value plus the row and column averages.+ `,+ },+ source: {+ code: `<HeatmapChart data={weeklyTrafficData} categoryKey="slot" />`,+ },+ },+ },+};++/**+ * ## Ramp Modes: Sequential vs Diverging+ *+ * The same signed dataset rendered with both ramp modes.+ */+export const RampModes: Story = {+ name: "⚖️ Ramp Modes: Sequential vs Diverging",+ args: {+ data: revenueChangeData,+ categoryKey: "month",+ showCellLabels: true,+ },+ render: (args: any) => (+ <div style={{ display: "flex", flexDirection: "column", gap: "24px", width: "760px" }}>+ <Card style={{ width: "100%", padding: "24px" }}>+ <h3 style={{ margin: "0 0 4px 0", fontSize: "16px", fontWeight: "600" }}>+ rampMode="sequential"+ </h3>+ <p style={{ margin: "0 0 16px 0", color: "#666", fontSize: "14px" }}>+ The ramp spans min → max (−14% … +32%): small losses and small gains look alike.+ </p>+ <HeatmapChart {...args} rampMode="sequential" />+ </Card>+ <Card style={{ width: "100%", padding: "24px" }}>+ <h3 style={{ margin: "0 0 4px 0", fontSize: "16px", fontWeight: "600" }}>+ rampMode="diverging"+ </h3>+ <p style={{ margin: "0 0 16px 0", color: "#666", fontSize: "14px" }}>+ The domain is forced symmetric (±32%): zero is the neutral middle, losses are blue and+ gains are orange.+ </p>+ <HeatmapChart {...args} rampMode="diverging" />+ </Card>+ </div>+ ),+ parameters: {+ docs: {+ description: {+ story: `+Month-over-month revenue change per product line is **signed**, and zero is meaningful.++- **sequential** (default) quantizes the plain min → max extent, so the ramp's middle falls at +9% — not at zero.+- **diverging** makes the domain symmetric around zero (\`±max(|min|, |max|)\`), so zero always lands on the neutral middle bucket and the color scale shows a zero notch at its center. Without a \`customPalette\` it uses a built-in blue ↔ orange ramp (colorblind-safer than red/green) with separate light- and dark-mode variants.+ `,+ },+ source: {+ code: `<HeatmapChart data={revenueChangeData} categoryKey="month" rampMode="diverging" showCellLabels />`,+ },+ },+ },+};++/**+ * ## Cell Value Labels+ *+ * In-cell values on a correlation matrix, and their auto-hiding on a dense grid.+ */+export const CellValueLabels: Story = {+ name: "🔢 Cell Value Labels",+ args: {+ data: correlationData,+ categoryKey: "metric",+ rampMode: "diverging",+ showCellLabels: true,+ legend: false,+ height: 380,+ },+ render: (args: any) => (+ <div style={{ display: "flex", flexDirection: "column", gap: "24px", width: "760px" }}>+ <Card style={{ width: "100%", padding: "24px" }}>+ <div style={{ marginBottom: "16px" }}>+ <h3 style={{ margin: "0 0 8px 0", fontSize: "18px", fontWeight: "600" }}>+ KPI Correlation Matrix+ </h3>+ <p style={{ margin: 0, color: "#666", fontSize: "14px" }}>+ Pearson correlation between product KPIs — values in every cell, zero on the neutral+ middle.+ </p>+ </div>+ <HeatmapChart {...args} />+ </Card>+ <Card style={{ width: "100%", padding: "24px" }}>+ <div style={{ marginBottom: "16px" }}>+ <h3 style={{ margin: "0 0 8px 0", fontSize: "18px", fontWeight: "600" }}>+ Labels auto-hide when they don't fit+ </h3>+ <p style={{ margin: 0, color: "#666", fontSize: "14px" }}>+ The same <code>showCellLabels</code> on a 48-column grid: cells too narrow for their+ value simply show color.+ </p>+ </div>+ <HeatmapChart data={denseCpuData} categoryKey="time" showCellLabels legend={false} />+ </Card>+ </div>+ ),+ parameters: {+ docs: {+ description: {+ story: `+\`showCellLabels\` draws each value inside its cell using the chart's compact number format (\`0.72\`, \`1.3K\`, \`2.4M\`).++- **Auto-contrast**: each label picks dark or light text against its own cell color.+- **Auto-hide**: a label that doesn't fit its cell (width or height) is skipped, so the prop is safe to enable on any data.+- **Diverging + labels** is the natural fit for correlation tables, where both sign and size matter.+ `,+ },+ source: {+ code: `<HeatmapChart+ data={correlationData}+ categoryKey="metric"+ rampMode="diverging"+ showCellLabels+ legend={false}+ height={380}+/>`,+ },+ },+ },+};++/**+ * ## Display & Shape Options+ *+ * Toggling the color scale, legend and row labels, and changing cell gap and radius.+ */+export const DisplayOptions: Story = {+ name: "🧩 Display & Shape Options",+ args: {+ data: regionalRevenueData,+ categoryKey: "month",+ },+ render: (args: any) => {+ const variants: Array<{+ title: string;+ note: string;+ props: Partial<HeatmapChartProps<HeatmapChartData>>;+ }> = [+ { title: "Defaults", note: "Color scale, legend and row labels on", props: {} },+ {+ title: "showColorScale={false}",+ note: "Relies on the tooltip for values",+ props: { showColorScale: false },+ },+ { title: "legend={false}", note: "No row legend or row toggling", props: { legend: false } },+ {+ title: "showYAxis={false}",+ note: "Row labels hidden — grid takes the width",+ props: { showYAxis: false },+ },+ {+ title: "cellGap={0} cellRadius={0}",+ note: "A continuous, seamless surface",+ props: { cellGap: 0, cellRadius: 0 },+ },+ {+ title: "cellGap={6} cellRadius={8}",+ note: "Rounded, tile-like cells",+ props: { cellGap: 6, cellRadius: 8 },+ },+ ];++ return (+ <div style={{ display: "grid", gridTemplateColumns: "1fr 1fr", gap: "24px", width: "960px" }}>+ {variants.map((variant) => (+ <Card key={variant.title} style={{ width: "100%", padding: "20px" }}>+ <h4+ style={{+ margin: "0 0 4px 0",+ fontSize: "14px",+ fontWeight: 600,+ fontFamily: "monospace",+ }}+ >+ {variant.title}+ </h4>+ <p style={{ margin: "0 0 12px 0", color: "#666", fontSize: "12px" }}>{variant.note}</p>+ <HeatmapChart {...args} {...variant.props} height={260} />+ </Card>+ ))}+ </div>+ );+ },+ parameters: {+ docs: {+ description: {+ story: `+Monthly revenue per region, rendered with the display and shape props that change the chart's chrome.++- **\`showColorScale\`**: the value key under the grid. Keep it unless the surrounding UI provides its own — without it, touch and print readers can't decode color.+- **\`legend\`**: the row legend; each swatch is the color of that row's average.+- **\`showYAxis\`**: the row labels; hiding them gives the grid the full width.+- **\`cellGap\` / \`cellRadius\`**: pixel gap and corner radius of every cell.++All panels pass \`height={260}\`, so the legend and color scale fit inside that height (\`fitLegendInHeight\` defaults to \`true\` when \`height\` is set).+ `,+ },+ },+ },+};++/**+ * ## Custom Palette+ *+ * Custom sequential and diverging ramps via `customPalette`.+ */+export const CustomPalette: Story = {+ name: "🎨 Custom Palette",+ args: {+ data: regionalRevenueData,+ categoryKey: "month",+ },+ render: (args: any) => (+ <div style={{ display: "flex", flexDirection: "column", gap: "24px", width: "760px" }}>+ <Card style={{ width: "100%", padding: "24px" }}>+ <div style={{ marginBottom: "16px" }}>+ <h3 style={{ margin: "0 0 8px 0", fontSize: "18px", fontWeight: "600" }}>+ Sequential ramp: Regional Revenue ($K)+ </h3>+ <PaletteSwatches colors={sunsetPalette} label="low → high" />+ </div>+ <HeatmapChart {...args} customPalette={sunsetPalette} />+ </Card>+ <Card style={{ width: "100%", padding: "24px" }}>+ <div style={{ marginBottom: "16px" }}>+ <h3 style={{ margin: "0 0 8px 0", fontSize: "18px", fontWeight: "600" }}>+ Diverging ramp: Revenue Change (%)+ </h3>+ <PaletteSwatches colors={purpleGreenPalette} label="− → 0 → +" />+ </div>+ <HeatmapChart+ data={revenueChangeData}+ categoryKey="month"+ rampMode="diverging"+ customPalette={purpleGreenPalette}+ showCellLabels+ />+ </Card>+ </div>+ ),+ parameters: {+ docs: {+ description: {+ story: `+\`customPalette\` is an **ordered ramp** (low → high), not a list of series colors: each color becomes one bucket of the value scale, so more colors means finer steps.++- **Sequential**: the ramp spans min → max of the visible values.+- **Diverging**: the ramp is read as low → neutral → high. Use an **odd** number of colors so zero lands on one exact middle color.++A \`customPalette\` always wins over the ThemeProvider's \`defaultChartPalette\` and over the built-in diverging ramp.+ `,+ },+ source: {+ code: `const sunset = ["#0D0887", "#42049E", "#6A00A8", /* … */ "#FCCE25", "#FFE06E"];+const purpleGreen = ["#762A83", "#9970AB", "#C2A5CF", "#E7D4E8", "#F7F7F7", "#D9F0D3", "#A6DBA0", "#5AAE61", "#1B7837"];++<HeatmapChart data={regionalRevenueData} categoryKey="month" customPalette={sunset} />++<HeatmapChart+ data={revenueChangeData}+ categoryKey="month"+ rampMode="diverging"+ customPalette={purpleGreen}+ showCellLabels+/>`,+ },+ },+ },+};++/**+ * ## Data Edge Cases+ *+ * A dense grid, a sparse grid with missing values, and long labels on both axes.+ */+export const DataEdgeCases: Story = {+ name: "📈 Dense, Sparse & Long-Label Data",+ args: {+ data: denseCpuData,+ categoryKey: "time",+ },+ render: (args: any) => (+ <div style={{ display: "flex", flexDirection: "column", gap: "24px", width: "860px" }}>+ <Card style={{ width: "100%", padding: "24px" }}>+ <div style={{ marginBottom: "16px" }}>+ <h3 style={{ margin: "0 0 8px 0", fontSize: "18px", fontWeight: "600" }}>+ Dense: CPU Utilisation (%) — 48 columns × 8 hosts+ </h3>+ <p style={{ margin: 0, color: "#666", fontSize: "14px" }}>+ X-axis labels thin out to every n-th column once bands get too narrow to read.+ </p>+ </div>+ <HeatmapChart {...args} cellGap={1} customPalette={sunsetPalette} />+ </Card>+ <Card style={{ width: "100%", padding: "24px" }}>+ <div style={{ marginBottom: "16px" }}>+ <h3 style={{ margin: "0 0 8px 0", fontSize: "18px", fontWeight: "600" }}>+ Sparse: Survey Response Rate (%)+ </h3>+ <p style={{ margin: 0, color: "#666", fontSize: "14px" }}>+ Empty values render as muted cells; hovering one shows "No value".+ </p>+ </div>+ <HeatmapChart data={sparseSurveyData} categoryKey="week" showCellLabels />+ </Card>+ <Card style={{ width: "100%", padding: "24px" }}>+ <div style={{ marginBottom: "16px" }}>+ <h3 style={{ margin: "0 0 8px 0", fontSize: "18px", fontWeight: "600" }}>+ Long Labels: Product Adoption (%) by Metro Area+ </h3>+ <p style={{ margin: 0, color: "#666", fontSize: "14px" }}>+ Row labels wider than 200px are truncated (hover one for the full name); column labels+ truncate to their band.+ </p>+ </div>+ <HeatmapChart data={longLabelData} categoryKey="product" customPalette={sunsetPalette} />+ </Card>+ </div>+ ),+ parameters: {+ docs: {+ description: {+ story: `+**Dense grids** — 48 half-hour columns × 8 hosts. Once a column is narrower than a readable tick, the x-axis shows every n-th label instead of an ellipsis per column; the cell gap is capped at half a cell so the grid never disappears.++**Sparse grids** — cells whose value is \`""\`, missing or non-numeric are drawn as muted "no value" cells. They are excluded from the color domain and the row/column averages, and their tooltip reads **No value**.++**Long labels** — row labels get up to 200px and are truncated with a hover tooltip carrying the full text; column labels are truncated to their band width.+ `,+ },+ source: {+ code: `// "" marks a cell with no value+const survey = [+ { week: "Wk 1", Design: 82, Engineering: 64, Marketing: "", Sales: 41, Support: 77 },+ { week: "Wk 2", Design: "", Engineering: 71, Marketing: 58, Sales: "", Support: 80 },+ // …+];++<HeatmapChart data={survey} categoryKey="week" showCellLabels />`,+ },+ },+ },+};++/**+ * ## Responsive Widths+ *+ * The same chart in containers of different widths.+ */+export const ResponsiveWidths: Story = {+ name: "📱 Responsive Behavior Demo",+ args: {+ data: weeklyTrafficData,+ categoryKey: "slot",+ showCellLabels: true,+ },+ render: (args: any) => (+ <div+ style={{ display: "flex", flexDirection: "column", gap: "24px", alignItems: "flex-start" }}+ >+ {[340, 560, 860].map((containerWidth) => (+ <div key={containerWidth}>+ <div+ style={{+ marginBottom: "8px",+ fontSize: "12px",+ color: "#666",+ fontFamily: "monospace",+ }}+ >+ container: {containerWidth}px+ </div>+ <Card style={{ width: `${containerWidth}px`, padding: "20px", boxSizing: "border-box" }}>+ <HeatmapChart {...args} />+ </Card>+ </div>+ ))}+ <div+ style={{+ padding: "12px",+ backgroundColor: "#f8f9fa",+ borderRadius: "6px",+ fontSize: "12px",+ color: "#666",+ maxWidth: "860px",+ }}+ >+ <strong>📊 Responsive Features Demonstrated:</strong>+ <ul style={{ margin: "8px 0 0 0", paddingLeft: "16px" }}>+ <li>The grid fills the container width; row labels keep their measured width</li>+ <li>Cell labels appear only where the value fits inside the cell</li>+ <li>X-axis labels truncate, then thin out as columns get narrower</li>+ <li>The legend wraps and collapses behind an expand toggle when space runs out</li>+ </ul>+ </div>+ </div>+ ),+ parameters: {+ docs: {+ description: {+ story: `+**Responsive Design:**++- The chart measures its container with a ResizeObserver; width always follows the container unless \`width\` is set.+- Height stays at the 296px default (or your \`height\`), so narrow containers get narrower — not shorter — cells.+- Cell labels (\`showCellLabels\` is on here) hide per cell as cells shrink, and x-axis labels thin out below ~28px per column.+ `,+ },+ },+ },+};diff --git a/packages/react-ui/src/components/D3Charts/HeatmapChart/types.ts b/packages/react-ui/src/components/Charts/HeatmapChart/types.tssimilarity index 100%rename from packages/react-ui/src/components/D3Charts/HeatmapChart/types.tsrename to packages/react-ui/src/components/Charts/HeatmapChart/types.tsdiff --git a/packages/react-ui/src/components/Charts/HorizontalBarChart/HorizontalBarChart.tsx b/packages/react-ui/src/components/Charts/HorizontalBarChart/HorizontalBarChart.tsxdeleted file mode 100644index 568279e19..000000000--- a/packages/react-ui/src/components/Charts/HorizontalBarChart/HorizontalBarChart.tsx+++ /dev/null@@ -1,512 +0,0 @@-import clsx from "clsx";-import React, { useCallback, useEffect, useId, useMemo, useRef, useState } from "react";-import { Bar, BarChart as RechartsBarChart, XAxis, YAxis } from "recharts";-import { usePrintContext } from "../../../context/PrintContext";-import { useTheme } from "../../ThemeProvider";-import { ChartConfig, ChartContainer, ChartTooltip } from "../Charts";-import { SideBarChartData, SideBarTooltipProvider } from "../context/SideBarTooltipContext";-import { useExportChartData, useTransformedKeys } from "../hooks";-import { useHorizontalBarLabelHeight } from "../hooks/useMaxLabelHeight";-import {- CustomTooltipContent,- DefaultLegend,- SideBarTooltip,- SVGXAxisTick,- verticalCartesianGrid,- YAxisTick,-} from "../shared";-import { ScrollButtonsVertical } from "../shared/ScrollButtonsVertical";--import { type LegendItem } from "../types/Legend";-import { useChartPalette, type PaletteName } from "../utils/PalletUtils";--import { LabelTooltipProvider } from "../shared/LabelTooltip/LabelTooltip";-import {- findNearestSnapPosition,- getBarStackInfo,- getRadiusArray,-} from "../utils/BarCharts/BarChartsUtils";-import {- get2dChartConfig,- getColorForDataKey,- getDataKeys,- getLegendItems,-} from "../utils/dataUtils";-import { numberTickFormatter } from "../utils/styleUtils";-import { CustomBarShape } from "./components/CustomBarShape";-import { useMaxCategoryLabelWidth } from "./hooks/useMaxCategoryLabelWidth";-import { HorizontalBarChartData, HorizontalBarChartVariant } from "./types";-import {- BAR_GAP,- BAR_HEIGHT,- getHeightOfData,- getPadding,- getSnapPositions,-} from "./utils/HorizontalBarChartUtils";--// Type for onClick event-type HorizontalBarChartOnClick = React.ComponentProps<typeof RechartsBarChart>["onClick"];-type HorizontalBarClickData = Parameters<NonNullable<HorizontalBarChartOnClick>>[0];--export interface HorizontalBarChartProps<T extends HorizontalBarChartData> {- data: T;- categoryKey: keyof T[number];- theme?: PaletteName;- customPalette?: string[];- variant?: HorizontalBarChartVariant;- grid?: boolean;- radius?: number;- icons?: Partial<Record<keyof T[number], React.ComponentType>>;- isAnimationActive?: boolean;- showXAxis?: boolean;- xAxisLabel?: React.ReactNode;- yAxisLabel?: React.ReactNode;- legend?: boolean;- className?: string;- height?: number;- width?: number;-}--const X_AXIS_HEIGHT = 40; // Height of X-axis chart when shown-const BAR_CATEGORY_GAP = "20%"; // Gap between categories-const BAR_INTERNAL_LINE_WIDTH = 1;-const BAR_RADIUS = 4;--const HorizontalBarChartComponent = <T extends HorizontalBarChartData>({- data,- categoryKey,- theme = "ocean",- customPalette,- variant = "grouped",- grid = true,- icons = {},- radius = BAR_RADIUS,- isAnimationActive = false,- showXAxis = true,- xAxisLabel,- yAxisLabel,- legend = true,- className,- height,- width,-}: HorizontalBarChartProps<T>) => {- const printContext = usePrintContext();- isAnimationActive = printContext ? false : isAnimationActive;-- const maxCategoryLabelWidth = useMaxCategoryLabelWidth(data, categoryKey as string);-- const chartContainerRef = useRef<HTMLDivElement>(null);- const mainContainerRef = useRef<HTMLDivElement>(null);- const [containerWidth, setContainerWidth] = useState<number>(0);- const [canScrollUp, setCanScrollUp] = useState(false);- const [canScrollDown, setCanScrollDown] = useState(false);- const [hoveredCategory, setHoveredCategory] = useState<string | number | null>(null);- const [isLegendExpanded, setIsLegendExpanded] = useState(false);- const [isSideBarTooltipOpen, setIsSideBarTooltipOpen] = useState(false);- const [sideBarTooltipData, setSideBarTooltipData] = useState<SideBarChartData>({- title: "",- values: [],- });-- // Calculate chart width for internal calculations (legend, xAxis, etc.)- const effectiveWidth = useMemo(() => {- return width ?? containerWidth;- }, [width, containerWidth]);-- // Calculate label height for better group height calculation- // Use chart width for label height calculation since labels span full width- const labelHeight = useHorizontalBarLabelHeight(data, categoryKey as string, effectiveWidth);-- const dataKeys = useMemo(() => {- return getDataKeys(data, categoryKey as string);- }, [data, categoryKey]);-- 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]);-- // Use provided height or observed height- const effectiveHeight = useMemo(() => {- return height ?? 296 + X_AXIS_HEIGHT;- }, [height]);-- // Calculate effective container height (excluding X-axis)- const effectiveContainerHeight = useMemo(() => {- const xAxisHeight = showXAxis ? X_AXIS_HEIGHT : 0;- return Math.max(0, effectiveHeight - xAxisHeight);- }, [effectiveHeight, showXAxis]);-- const padding = useMemo(() => {- return getPadding(data, categoryKey as string, effectiveContainerHeight, variant, labelHeight);- }, [data, categoryKey, effectiveContainerHeight, variant, labelHeight]);-- const dataHeight = useMemo(() => {- return getHeightOfData(data, categoryKey as string, variant, labelHeight);- }, [data, categoryKey, variant, labelHeight]);-- // Calculate snap positions for proper group alignment- const snapPositions = useMemo(() => {- return getSnapPositions(data, categoryKey as string, variant, labelHeight);- }, [data, categoryKey, variant, labelHeight]);-- // Check scroll boundaries- const updateScrollState = useCallback(() => {- if (mainContainerRef.current) {- const { scrollTop, scrollHeight, clientHeight } = mainContainerRef.current;- setCanScrollUp(scrollTop > 0);- setCanScrollDown(scrollTop < scrollHeight - clientHeight - 1);- }- }, []);-- const scrollUp = useCallback(() => {- if (mainContainerRef.current) {- const currentScroll = mainContainerRef.current.scrollTop;- const targetIndex = findNearestSnapPosition(snapPositions, currentScroll, "up");- const targetPosition = snapPositions[targetIndex] ?? 0;-- mainContainerRef.current.scrollTo({- top: targetPosition,- behavior: "smooth",- });- }- }, [snapPositions]);-- const scrollDown = useCallback(() => {- if (mainContainerRef.current) {- const currentScroll = mainContainerRef.current.scrollTop;- const targetIndex = findNearestSnapPosition(snapPositions, currentScroll, "down");- const targetPosition = snapPositions[targetIndex] ?? 0;-- mainContainerRef.current.scrollTo({- top: targetPosition,- behavior: "smooth",- });- }- }, [snapPositions]);-- useEffect(() => {- // Set up ResizeObserver if height or width is not provided- if (!chartContainerRef.current) {- return () => {};- }-- const resizeObserver = new ResizeObserver((entries) => {- for (const entry of entries) {- if (!width) {- setContainerWidth(entry.contentRect.width);- }- }- });-- resizeObserver.observe(chartContainerRef.current);-- return () => {- resizeObserver.disconnect();- };- }, [height, width]);-- // Update scroll state when container dimensions or data height changes- useEffect(() => {- updateScrollState();- }, [effectiveContainerHeight, dataHeight, containerWidth, updateScrollState]);-- useEffect(() => {- setIsSideBarTooltipOpen(false);- setIsLegendExpanded(false);- }, [dataKeys]);-- // Add scroll event listener to update button states- useEffect(() => {- const mainContainer = mainContainerRef.current;- if (!mainContainer) return;-- const handleScroll = () => {- updateScrollState();- };-- mainContainer.addEventListener("scroll", handleScroll);- return () => {- mainContainer.removeEventListener("scroll", handleScroll);- };- }, [updateScrollState]);-- // Memoize legend items creation- const legendItems: LegendItem[] = useMemo(() => {- return getLegendItems(dataKeys, colors, icons);- }, [dataKeys, colors, icons]);-- const exportData = useExportChartData({- type: "bar",- data,- categoryKey: categoryKey as string,- dataKeys,- colors,- legend,- xAxisLabel,- yAxisLabel,- extraOptions: {- barDir: "bar",- },- });-- const id = useId();-- const xAxis = useMemo(() => {- if (!showXAxis) {- return null;- }- return (- <div className="openui-horizontal-bar-chart-x-axis-container">- {/* X-axis only chart - synchronized with main chart */}- <ChartContainer- config={chartConfig}- style={{ width: "100%", height: X_AXIS_HEIGHT }}- rechartsProps={{- height: X_AXIS_HEIGHT,- }}- >- <RechartsBarChart- key={`x-axis-horizontal-bar-chart-${id}`}- data={data}- layout="vertical"- margin={{- top: 0,- bottom: 0,- left: 5,- right: 2,- }}- stackOffset="sign"- >- <XAxis- type="number"- height={X_AXIS_HEIGHT}- tickLine={false}- axisLine={false}- tickFormatter={numberTickFormatter}- tick={<SVGXAxisTick />}- />- {/* Invisible bars to maintain scale synchronization */}- {dataKeys.map((key) => {- return (- <Bar- key={`x-axis-horizontal-bar-chart-${key}`}- dataKey={key}- fill="transparent"- stackId={variant === "stacked" ? "a" : undefined}- isAnimationActive={false}- maxBarSize={0}- />- );- })}- </RechartsBarChart>- </ChartContainer>- </div>- );- }, [showXAxis, chartConfig, data, dataKeys, variant, id]);-- // Handle mouse events for group hovering- const handleChartMouseMove = useCallback((state: any) => {- if (state && state.activeLabel !== undefined) {- setHoveredCategory(state.activeLabel);- }- }, []);-- const handleChartMouseLeave = useCallback(() => {- setHoveredCategory(null);- }, []);-- 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 onBarsClick = useCallback(- (data: HorizontalBarClickData) => {- if (data?.activePayload?.length && data.activePayload.length > 10) {- setIsSideBarTooltipOpen(true);- setSideBarTooltipData({- title: data.activeLabel as string,- values: data.activePayload.map((payload) => ({- value: payload.value as number,- label: payload.name || payload.dataKey,- color: getColorForDataKey(payload.dataKey, dataKeys, colors),- })),- });- }- },- [dataKeys, colors],- );-- const setLabelWidth = useCallback(() => {}, []);-- return (- <LabelTooltipProvider>- <SideBarTooltipProvider- isSideBarTooltipOpen={isSideBarTooltipOpen}- setIsSideBarTooltipOpen={setIsSideBarTooltipOpen}- data={sideBarTooltipData}- setData={setSideBarTooltipData}- >- <div- className={clsx("openui-horizontal-bar-chart-container", className)}- data-openui-chart={exportData}- >- <div- className="openui-horizontal-bar-chart-container-inner-wrapper"- style={{- height: height ? `${height}px` : effectiveHeight,- }}- >- <div className="openui-horizontal-bar-chart-container-inner" ref={chartContainerRef}>- <div className="openui-horizontal-bar-chart-main-container" ref={mainContainerRef}>- <ChartContainer- config={chartConfig}- style={{ height: dataHeight, minHeight: "100%", width: "100%" }}- >- <RechartsBarChart- accessibilityLayer- key={`horizontal-bar-chart-${id}`}- data={data}- layout="vertical"- onClick={onBarsClick}- onMouseMove={handleChartMouseMove}- onMouseLeave={handleChartMouseLeave}- barGap={BAR_GAP}- barCategoryGap={BAR_CATEGORY_GAP}- margin={{- top: 0,- bottom: 0,- left: 2,- right: 2,- }}- stackOffset="sign"- >- {grid && verticalCartesianGrid()}- {/* this x axis is not visible but is needed for the chart to work */}- <XAxis type="number" tickLine={false} axisLine={false} hide />- <YAxis- type="category"- dataKey={categoryKey as string}- tickLine={false}- axisLine={false}- width={maxCategoryLabelWidth}- tick={<YAxisTick setLabelWidth={setLabelWidth} />}- interval={0}- // gives the padding on the 2 sides see the function for reference- padding={padding}- hide- />-- <ChartTooltip- cursor={{- fill: "var(--openui-highlight)",- stroke: "var(--openui-stroke-default)",- opacity: 1,- strokeWidth: 1,- }}- content={<CustomTooltipContent parentRef={mainContainerRef} />}- offset={15}- />-- {dataKeys.map((key, index) => {- const transformedKey = transformedKeys[key];- const color = `var(--color-${transformedKey})`;-- return (- <Bar- key={`main-${key}`}- dataKey={key}- fill={color}- stackId={variant === "stacked" ? "a" : undefined}- isAnimationActive={isAnimationActive}- maxBarSize={BAR_HEIGHT}- barSize={BAR_HEIGHT}- shape={(props: any) => {- const { payload, value, dataKey } = props;-- const { isNegative, isFirstInStack, isLastInStack } = getBarStackInfo(- variant,- value,- dataKey,- payload,- dataKeys,- );-- const customRadius = getRadiusArray(- variant,- radius,- "horizontal",- isFirstInStack,- isLastInStack,- isNegative,- );-- return (- <CustomBarShape- {...props}- radius={customRadius}- index={index}- categoryKey={categoryKey as string}- effectiveWidth={effectiveWidth}- labelHeight={labelHeight}- barInternalLineColor={barInternalLineColor}- internalLineWidth={BAR_INTERNAL_LINE_WIDTH}- hoveredCategory={hoveredCategory}- variant={variant}- />- );- }}- />- );- })}- </RechartsBarChart>- </ChartContainer>- </div>- {/* X-axis of the chart */}- {xAxis}- </div>- {/* if the data height is greater than the effective height, then show the scroll buttons */}- <ScrollButtonsVertical- dataHeight={dataHeight}- effectiveHeight={effectiveContainerHeight}- canScrollUp={canScrollUp}- canScrollDown={canScrollDown}- isSideBarTooltipOpen={isSideBarTooltipOpen}- onScrollUp={scrollUp}- onScrollDown={scrollDown}- />- {isSideBarTooltipOpen && <SideBarTooltip height={effectiveHeight} />}- </div>- {legend && (- <DefaultLegend- items={legendItems}- yAxisLabel={yAxisLabel}- xAxisLabel={xAxisLabel}- containerWidth={effectiveWidth}- isExpanded={isLegendExpanded}- setIsExpanded={setIsLegendExpanded}- />- )}- </div>- </SideBarTooltipProvider>- </LabelTooltipProvider>- );-};--// Added React.memo for performance optimization to avoid unnecessary re-renders-export const HorizontalBarChart = React.memo(- HorizontalBarChartComponent,-) as typeof HorizontalBarChartComponent;diff --git a/packages/react-ui/src/components/Charts/HorizontalBarChart/components/CustomBarShape.tsx b/packages/react-ui/src/components/Charts/HorizontalBarChart/components/CustomBarShape.tsxdeleted file mode 100644index 0e5c20f11..000000000--- a/packages/react-ui/src/components/Charts/HorizontalBarChart/components/CustomBarShape.tsx+++ /dev/null@@ -1,87 +0,0 @@-import React from "react";--import { LineInBarShape } from "../../shared";-import { type HorizontalBarChartVariant } from "../types";--interface CustomBarShapeProps {- // from recharts (can be more)- x?: number;- y?: number;- width?: number;- height?: number;- payload?: any;- // from parent scope- index: number;- categoryKey: string;- effectiveWidth: number;- labelHeight: number;- barInternalLineColor: string;- internalLineWidth: number;- hoveredCategory: string | number | null;- variant: HorizontalBarChartVariant;-}--const CustomBarShapeComponent = (props: CustomBarShapeProps) => {- const {- // recharts props- y,- payload,- // my props- index,- categoryKey,- effectiveWidth,- labelHeight,- barInternalLineColor,- internalLineWidth,- hoveredCategory,- variant,- // rest of recharts props to pass down- ...rest- } = props;-- // y might be undefined if not passed by recharts, but it's used.- // The original code has `let { y } = barProps;`. If `barProps.y` is undefined, `y` is undefined.- // The same for `payload`.- if (y === undefined || !payload) {- return null; // Or some fallback- }-- let label = null;- if (index === 0 && payload[categoryKey]) {- const labelX = 0;- const labelWidth = effectiveWidth;- const labelY = y - labelHeight / 2;- label = (- <foreignObject- x={labelX}- y={labelY}- width={labelWidth}- height={labelHeight}- style={{ pointerEvents: "none" }}- xmlns="http://www.w3.org/1999/xhtml"- >- <div className="openui-horizontal-bar-chart-category-label">{payload[categoryKey]}</div>- </foreignObject>- );- }-- return (- <g>- {label}- <LineInBarShape- {...rest}- payload={payload}- y={y + labelHeight / 2}- internalLineColor={barInternalLineColor}- internalLineWidth={internalLineWidth}- isHovered={hoveredCategory !== null}- hoveredCategory={hoveredCategory}- categoryKey={categoryKey as string}- variant={variant}- orientation="horizontal"- />- </g>- );-};--export const CustomBarShape = React.memo(CustomBarShapeComponent);diff --git a/packages/react-ui/src/components/Charts/HorizontalBarChart/dependencies.ts b/packages/react-ui/src/components/Charts/HorizontalBarChart/dependencies.tsdeleted file mode 100644index e69de29bb..000000000diff --git a/packages/react-ui/src/components/Charts/HorizontalBarChart/hooks/useMaxCategoryLabelWidth.tsx b/packages/react-ui/src/components/Charts/HorizontalBarChart/hooks/useMaxCategoryLabelWidth.tsxdeleted file mode 100644index b2dd1f19b..000000000--- a/packages/react-ui/src/components/Charts/HorizontalBarChart/hooks/useMaxCategoryLabelWidth.tsx+++ /dev/null@@ -1,29 +0,0 @@-import { useMemo } from "react";--import { useCanvasContextForLabelSize } from "../../hooks/useCanvasContextForLabelSize";--export const useMaxCategoryLabelWidth = (- data: Array<Record<string, string | number>>,- categoryKey: string,-): number => {- const context = useCanvasContextForLabelSize();-- return useMemo(() => {- if (data.length === 0) {- return 100; // Default fallback- }-- if (!context) {- // Fallback if canvas is not available- return Math.max(...data.map((item) => String(item[categoryKey] || "").length * 8), 100);- }-- return Math.max(- ...data.map((item) => {- const text = String(item[categoryKey] || "");- return context.measureText(text).width;- }),- 100,- );- }, [data, categoryKey, context]);-};diff --git a/packages/react-ui/src/components/Charts/HorizontalBarChart/horizontalBarChart.scss b/packages/react-ui/src/components/Charts/HorizontalBarChart/horizontalBarChart.scssdeleted file mode 100644index 4f6354437..000000000--- a/packages/react-ui/src/components/Charts/HorizontalBarChart/horizontalBarChart.scss+++ /dev/null@@ -1,62 +0,0 @@-@use "../../../cssUtils" as cssUtils;--.openui-horizontal-bar-chart-container {- position: relative;- width: 100%;- height: auto;- display: flex;- flex-direction: column;-- .openui-horizontal-bar-chart-container-inner {- position: relative;- display: flex;- flex-direction: column;- width: 100%;- flex: 1;- min-width: 0;- }-- .openui-horizontal-bar-chart-x-axis-container {- flex-shrink: 0;- width: 100%;- box-sizing: border-box;- border-top: 1px solid cssUtils.$border-default;- padding-top: cssUtils.$space-2xs;- }-- .openui-horizontal-bar-chart-container-inner-wrapper {- width: 100%;- display: flex;- flex-direction: row;- width: 100%;- overflow: hidden;- }-- .openui-horizontal-bar-chart-main-container {- height: 100%;- overflow-y: auto;- /* Hide scrollbar for Chrome, Safari and Opera */- &::-webkit-scrollbar {- display: none;- }-- /* Hide scrollbar for Firefox */- scrollbar-width: none;-- /* Hide scrollbar for IE and Edge */- -ms-overflow-style: none;- }-- .openui-horizontal-bar-chart-category-label {- display: flex;- align-items: center;- color: cssUtils.$text-neutral-secondary;- @include cssUtils.typography(label, extra-small);- overflow: hidden;- white-space: nowrap;- text-overflow: ellipsis;- width: 100%;- padding-left: cssUtils.$space-m;- box-sizing: border-box;- }-}diff --git a/packages/react-ui/src/components/Charts/HorizontalBarChart/index.ts b/packages/react-ui/src/components/Charts/HorizontalBarChart/index.tsdeleted file mode 100644index e45239e58..000000000--- a/packages/react-ui/src/components/Charts/HorizontalBarChart/index.ts+++ /dev/null@@ -1,2 +0,0 @@-export * from "./HorizontalBarChart";-export * from "./types";diff --git a/packages/react-ui/src/components/Charts/HorizontalBarChart/types/index.ts b/packages/react-ui/src/components/Charts/HorizontalBarChart/types/index.tsdeleted file mode 100644index c1d14df8c..000000000--- a/packages/react-ui/src/components/Charts/HorizontalBarChart/types/index.ts+++ /dev/null@@ -1,3 +0,0 @@-export type HorizontalBarChartVariant = "grouped" | "stacked";--export type HorizontalBarChartData = Array<Record<string, string | number>>;diff --git a/packages/react-ui/src/components/Charts/HorizontalBarChart/utils/HorizontalBarChartUtils.ts b/packages/react-ui/src/components/Charts/HorizontalBarChart/utils/HorizontalBarChartUtils.tsdeleted file mode 100644index a429e030a..000000000--- a/packages/react-ui/src/components/Charts/HorizontalBarChart/utils/HorizontalBarChartUtils.ts+++ /dev/null@@ -1,122 +0,0 @@-import { getDataKeys } from "../../utils/dataUtils";-import { HorizontalBarChartVariant } from "../types";--export const BAR_HEIGHT = 16;-export const BAR_GAP = 10;--/**- * This function returns the height of the data in the chart, used for padding calculation, scroll amount calculation, and- * for the height of the chart container.- * @param data - The data to be displayed in the chart.- * @param categoryKey - The key of the category to be displayed in the chart.- * @param variant - The variant of the chart.- * @param labelHeight - The height of the category label.- */-const getHeightOfData = (- data: Array<Record<string, string | number>>,- categoryKey: string,- variant: HorizontalBarChartVariant,- labelHeight: number,-) => {- if (data.length === 0) {- return 0;- }-- const height = data.length * getHeightOfGroup(data, categoryKey, variant, labelHeight);-- if (data.length === 1) {- const minSingleDataHeight = 80; // Minimum height for single data points- return Math.max(height, minSingleDataHeight);- }- return height;-};--/**- * This function returns the padding for the chart, used for the padding of the chart container.- * @param data - The data to be displayed in the chart.- * @param categoryKey - The key of the category to be displayed in the chart.- * @param containerHeight - The height of the container of the chart.- * @param variant - The variant of the chart.- * @param labelHeight - The height of the category label.- */-const getPadding = (- data: Array<Record<string, string | number>>,- categoryKey: string,- containerHeight: number,- variant: HorizontalBarChartVariant,- labelHeight: number,-) => {- const chartHeight = getHeightOfData(data, categoryKey, variant, labelHeight);- const paddingValue = containerHeight - chartHeight;-- if (paddingValue < 0) {- // If chart content is taller than container, no padding- return {- top: 10,- bottom: 10,- };- } else {- return {- top: paddingValue / 2,- bottom: paddingValue / 2,- };- }-};--/**- * This function returns the height of each group/category.- * @param data - The data to be displayed in the chart.- * @param categoryKey - The key of the category to be displayed in the chart.- * @param variant - The variant of the chart.- * @param labelHeight - The height of the category label.- */-const getHeightOfGroup = (- data: Array<Record<string, string | number>>,- categoryKey: string,- variant: HorizontalBarChartVariant,- labelHeight: number,-) => {- if (data.length === 0) return 200; // Fallback-- // Get the number of data keys (excluding categoryKey)- const dataKeys = getDataKeys(data, categoryKey);- const PADDING = 16;-- if (variant === "stacked") {- // For stacked: each category is one stack- return BAR_HEIGHT + labelHeight + PADDING;- } else {- // For grouped: each category contains multiple bars- const seriesPerCategory = dataKeys.length;- return seriesPerCategory * (BAR_HEIGHT + BAR_GAP) - BAR_GAP + labelHeight + PADDING;- }-};--/**- * This function returns the snap positions for the chart, used for the snap positions of the chart.- * @param data - The data to be displayed in the chart.- * @param categoryKey - The key of the category to be displayed in the chart.- * @param variant - The variant of the chart.- * @param labelHeight - The height of the category label.- * @returns The snap positions for the chart.- */-const getSnapPositions = (- data: Array<Record<string, string | number>>,- categoryKey: string,- variant: HorizontalBarChartVariant,- labelHeight: number,-): number[] => {- if (data.length === 0) return [0];-- const positions = [0]; // Start position- const groupHeightValue = getHeightOfGroup(data, categoryKey, variant, labelHeight);-- // Calculate all valid snap positions based on groups- for (let i = 1; i < data.length; i++) {- positions.push(i * groupHeightValue);- }-- return positions;-};--export { getHeightOfData, getHeightOfGroup, getPadding, getSnapPositions };diff --git a/packages/react-ui/src/components/Charts/LineChart/LineChart.tsx b/packages/react-ui/src/components/Charts/LineChart/LineChart.tsxindex 292dc584c..a694fabda 100644--- a/packages/react-ui/src/components/Charts/LineChart/LineChart.tsx+++ b/packages/react-ui/src/components/Charts/LineChart/LineChart.tsx@@ -1,437 +1,198 @@import clsx from "clsx";-import React, { useCallback, useEffect, useId, useMemo, useRef, useState } from "react";-import { Line, LineChart as RechartsLineChart, XAxis, YAxis } from "recharts";-import { usePrintContext } from "../../../context/PrintContext";-import { ChartConfig, ChartContainer, ChartTooltip } from "../Charts";-import { SideBarChartData, SideBarTooltipProvider } from "../context/SideBarTooltipContext";+import { useCallback } from "react";+import {+ useCartesianChartOrchestrator,+ useEffectiveAnimation,useExportChartData,- useMaxLabelHeight,- useTransformedKeys,- useYAxisLabelWidth,+ useXScale,+ useYScale,} from "../hooks";-import {- ActiveDot,- cartesianGrid,- CustomTooltipContent,- DefaultLegend,- ScrollButtonsHorizontal,- SideBarTooltip,- XAxisTick,- YAxisTick,-} from "../shared";-import { LabelTooltipProvider } from "../shared/LabelTooltip/LabelTooltip";-import { LegendItem, XAxisTickVariant } from "../types";-import {- findNearestSnapPosition,- getSnapPositions,- getWidthOfData,- getWidthOfGroup,-} from "../utils/AreaAndLine/AreaAndLineUtils";-import { getLineType } from "../utils/AreaAndLine/common";-import { PaletteName, useChartPalette } from "../utils/PalletUtils";-import {- get2dChartConfig,- getColorForDataKey,- getDataKeys,- getLegendItems,-} from "../utils/dataUtils";-import { LineChartData, LineChartVariant } from "./types";--type LineChartOnClick = React.ComponentProps<typeof RechartsLineChart>["onClick"];-type LineClickData = Parameters<NonNullable<LineChartOnClick>>[0];--export interface LineChartProps<T extends LineChartData> {- data: T;- categoryKey: keyof T[number];- theme?: PaletteName;- customPalette?: string[];- variant?: LineChartVariant;- tickVariant?: XAxisTickVariant;- grid?: boolean;- legend?: boolean;- icons?: Partial<Record<keyof T[number], React.ComponentType>>;- isAnimationActive?: boolean;- showYAxis?: boolean;- xAxisLabel?: React.ReactNode;- yAxisLabel?: React.ReactNode;- className?: string;- height?: number;- width?: number;- strokeWidth?: number;+import { CartesianXAxis } from "../shared/cartesian/axes/CartesianXAxis";+import { ClipDefs } from "../shared/cartesian/ClipDefs";+import { CartesianChartLayout } from "../shared/cartesian/layouts/CartesianChartLayout";+import { LineDotCrosshair } from "../shared/cartesian/LineDotCrosshair";+import { findNearestDataIndex } from "../utils/mouseUtils";+import { LineSeries } from "./parts/LineSeries";++import { CHART_CLASS_PREFIX } from "../utils/constants";+import type { LineChartData, LineChartProps } from "./types";++/**+ * Empty-data guard lives here, in a hook-free dispatcher: the chart impl below+ * calls hooks unconditionally, so the "no data" branch must short-circuit+ * *before* any hook runs (a count → 0 transition on a mounted chart would+ * otherwise break the Rules of Hooks).+ */+export function LineChart<T extends LineChartData>(props: LineChartProps<T>) {+ if (!props.data || props.data.length === 0) {+ return (+ <div+ className={clsx(+ `${CHART_CLASS_PREFIX}-line-chart-container ${CHART_CLASS_PREFIX}-chart-empty`,+ props.className,+ )}+ >+ <span className={`${CHART_CLASS_PREFIX}-chart-empty-text`}>No data available</span>+ </div>+ );+ }+ return <LineChartImpl {...props} />;}-const X_AXIS_PADDING = 36;-const CHART_CONTAINER_BOTTOM_MARGIN = 10;--export const LineChart = <T extends LineChartData>({+function LineChartImpl<T extends LineChartData>({data,categoryKey,- theme = "ocean",customPalette,- variant: lineChartVariant = "natural",- tickVariant = "multiLine",+ variant = "natural",+ tickVariant: tickVariantProp,+ showDots = false,+ dotRadius = 3,grid = true,- icons = {},+ legend: showLegend = true,+ icons,isAnimationActive = false,showYAxis = true,xAxisLabel,yAxisLabel,- legend = true,className,height,- width,- strokeWidth = 2,-}: LineChartProps<T>) => {- const printContext = usePrintContext();- isAnimationActive = printContext ? false : isAnimationActive;-- const dataKeys = useMemo(() => {- return getDataKeys(data, categoryKey as string);- }, [data, categoryKey]);-- const variant = getLineType(lineChartVariant);-- const { yAxisWidth, setLabelWidth } = useYAxisLabelWidth(data, dataKeys);-- const widthOfGroup = useMemo(() => {- return getWidthOfGroup(data);- }, [data]);-- const maxLabelHeight = useMaxLabelHeight(data, categoryKey as string, tickVariant, widthOfGroup);-- const transformedKeys = useTransformedKeys(dataKeys);-- const colors = useChartPalette({- chartThemeName: theme,- customPalette,+ width: fixedWidth,+ fitLegendInHeight,+ condensed = false,+ density,+ onClick,+ crosshair = false,+ highlight = false,+ activeDots = true,+ yTickCount,+}: LineChartProps<T>) {+ const animate = useEffectiveAnimation(isAnimationActive);+ const mode = condensed ? "fit" : "scroll";++ const orch = useCartesianChartOrchestrator({+ layout: mode,+ data,+ categoryKey,themePaletteName: "lineChartPalette",- dataLength: dataKeys.length,- });-- const chartConfig: ChartConfig = useMemo(() => {- return get2dChartConfig(dataKeys, colors, transformedKeys, undefined, icons);- }, [dataKeys, icons, colors, transformedKeys]);-- const chartContainerRef = useRef<HTMLDivElement>(null);- const mainContainerRef = useRef<HTMLDivElement>(null);- const [containerWidth, setContainerWidth] = useState<number>(0);- const [canScrollLeft, setCanScrollLeft] = useState(false);- const [canScrollRight, setCanScrollRight] = useState(false);- const [isSideBarTooltipOpen, setIsSideBarTooltipOpen] = useState(false);- const [isLegendExpanded, setIsLegendExpanded] = useState(false);- const [sideBarTooltipData, setSideBarTooltipData] = useState<SideBarChartData>({- title: "",- values: [],+ customPalette,+ showLegend,+ showYAxis,+ height,+ fixedWidth,+ fitLegendInHeight,+ tickVariantProp: tickVariantProp ?? (condensed ? "singleLine" : "multiLine"),+ chartIdPrefix: "d3lc",+ icons,+ onClick,+ density,+ yTickCount,});- // Use provided width or observed width- const effectiveWidth = useMemo(() => {- return width ?? containerWidth;- }, [width, containerWidth]);-- const effectiveContainerWidth = useMemo(() => {- const dynamicYAxisWidth = showYAxis ? yAxisWidth : 0;- return Math.max(0, effectiveWidth - dynamicYAxisWidth - 40); // -40 because we are giving 20px padding in xAxis on each side- }, [effectiveWidth, showYAxis, yAxisWidth]);-- const dataWidth = useMemo(() => {- return getWidthOfData(data, effectiveContainerWidth);- }, [data, effectiveContainerWidth]);-- // Calculate snap positions for proper scrolling alignment- const snapPositions = useMemo(() => {- return getSnapPositions(data);- }, [data]);-- const chartHeight = useMemo(() => {- return height ?? 296 + maxLabelHeight;- }, [height, maxLabelHeight]);-- // Check scroll boundaries- const updateScrollState = useCallback(() => {- if (mainContainerRef.current) {- const { scrollLeft, scrollWidth, clientWidth } = mainContainerRef.current;- setCanScrollLeft(scrollLeft > 0);- setCanScrollRight(scrollLeft < scrollWidth - clientWidth - 1); // -1 for floating point precision- }- }, []);-- const scrollLeft = useCallback(() => {- if (mainContainerRef.current) {- const currentScroll = mainContainerRef.current.scrollLeft;- const targetIndex = findNearestSnapPosition(snapPositions, currentScroll, "left");- const targetPosition = snapPositions[targetIndex] ?? 0;-- mainContainerRef.current.scrollTo({- left: targetPosition,- behavior: "smooth",- });- }- }, [snapPositions]);-- const scrollRight = useCallback(() => {- if (mainContainerRef.current) {- const currentScroll = mainContainerRef.current.scrollLeft;- const targetIndex = findNearestSnapPosition(snapPositions, currentScroll, "right");- const targetPosition = snapPositions[targetIndex] ?? 0;-- mainContainerRef.current.scrollTo({- left: targetPosition,- behavior: "smooth",- });- }- }, [snapPositions]);-- useEffect(() => {- // Only set up ResizeObserver if width is not provided- if (width || !chartContainerRef.current) {- return () => {};- }-- const resizeObserver = new ResizeObserver((entries) => {- // there is only one entry in the entries array because we are observing the chart container- for (const entry of entries) {- setContainerWidth(entry.contentRect.width);- }- });-- resizeObserver.observe(chartContainerRef.current);-- return () => {- resizeObserver.disconnect();- };- }, [width]);-- // Update scroll state when container width or data width changes- useEffect(() => {- updateScrollState();- }, [effectiveWidth, dataWidth, updateScrollState]);-- useEffect(() => {- setIsSideBarTooltipOpen(false);- setIsLegendExpanded(false);- }, [dataKeys]);-- // Add scroll event listener to update button states- useEffect(() => {- const mainContainer = mainContainerRef.current;- if (!mainContainer) return;-- const handleScroll = () => {- updateScrollState();- };+ const xScale = useXScale(+ data,+ orch.data.catKey,+ orch.dimensions.chartAreaWidth,+ orch.dimensions.widthOfGroup,+ );+ const yScale = useYScale(data, orch.data.dataKeys, orch.dimensions.chartInnerHeight, false);- mainContainer.addEventListener("scroll", handleScroll);- return () => {- mainContainer.removeEventListener("scroll", handleScroll);- };- }, [updateScrollState]);+ const getYValue = useCallback(+ (row: Record<string, string | number>, key: string) => Number(row[key]) || 0,+ [],+ );- const legendItems: LegendItem[] = useMemo(() => {- return getLegendItems(dataKeys, colors, icons);- }, [dataKeys, colors, icons]);+ const findIndex = useCallback((mouseX: number) => findNearestDataIndex(xScale, mouseX), [xScale]);+ const mouseHandlers = orch.hover.createMouseHandlers(findIndex);+ // PPTX print-export JSON — mirrors react-ui's LineChart call (type:'line').+ // react-ui also passes `extraOptions: { lineSize: strokeWidth }`, but viz's+ // LineChart exposes no stroke-width prop (stroke is CSS-driven), so there is+ // no real value to emit — the field is omitted rather than faked. Undefined+ // off the print path.const exportData = useExportChartData({type: "line",data,- categoryKey: categoryKey as string,- dataKeys,- colors,- legend,+ categoryKey: orch.data.catKey,+ dataKeys: orch.data.dataKeys,+ colors: orch.data.colors,+ legend: showLegend,xAxisLabel,yAxisLabel,- extraOptions: {- lineSize: strokeWidth,- },});- const id = useId();-- const onLineClick = useCallback(- (data: LineClickData) => {- if (data?.activePayload?.length && data.activePayload.length > 10) {- setIsSideBarTooltipOpen(true);- setSideBarTooltipData({- title: data.activeLabel as string,- values: data.activePayload.map((payload) => ({- value: payload.value as number,- label: payload.name || payload.dataKey,- color: getColorForDataKey(payload.dataKey, dataKeys, colors),- })),- });+ return (+ <CartesianChartLayout+ orch={orch}+ yScale={yScale}+ mouseHandlers={mouseHandlers}+ classPrefix="line-chart"+ chartType="line"+ exportData={exportData}+ ariaLabel="Line chart"+ showYAxis={showYAxis}+ grid={grid}+ showLegend={showLegend}+ xAxisLabel={xAxisLabel}+ yAxisLabel={yAxisLabel}+ yTickCount={yTickCount}+ className={className}+ defs={+ <defs>+ <ClipDefs+ chartId={orch.identity.chartId}+ chartWidth={orch.dimensions.chartAreaWidth}+ chartHeight={orch.dimensions.chartInnerHeight}+ />+ </defs>}- },- [dataKeys, colors],- );-- const yAxis = useMemo(() => {- if (!showYAxis) {- return null;- }- return (- <div className="openui-line-chart-y-axis-container">- {/* Y-axis only chart - synchronized with main chart */}- <RechartsLineChart- key={`y-axis-chart-${id}`}- width={yAxisWidth}- height={chartHeight}- data={data}- margin={{- top: 20,- bottom: maxLabelHeight + CHART_CONTAINER_BOTTOM_MARGIN, // this is required for to give space for x-axis- left: 0,- right: 0,- }}- onClick={onLineClick}- >- <YAxis- width={yAxisWidth}- tickLine={false}- axisLine={false}- tick={<YAxisTick setLabelWidth={setLabelWidth} />}+ series={+ <>+ <LineSeries+ data={data}+ dataKeys={orch.data.dataKeys}+ xScale={xScale}+ yScale={yScale}+ variant={variant}+ categoryKey={orch.data.catKey}+ colors={orch.data.colorMap}+ showDots={showDots}+ dotRadius={dotRadius}+ isAnimationActive={animate}/>- {/* Invisible lines to maintain scale synchronization */}- {dataKeys.map((key) => {- return (- <Line- key={`y-axis-${key}`}- dataKey={key}- type={variant}- stroke="transparent"- strokeWidth={0}- dot={false}- activeDot={false}- isAnimationActive={isAnimationActive}- />- );- })}- </RechartsLineChart>- </div>- );- }, [- showYAxis,- id,- chartHeight,- data,- onLineClick,- dataKeys,- variant,- isAnimationActive,- maxLabelHeight,- yAxisWidth,- ]);-- return (- <LabelTooltipProvider>- <SideBarTooltipProvider- isSideBarTooltipOpen={isSideBarTooltipOpen}- setIsSideBarTooltipOpen={setIsSideBarTooltipOpen}- data={sideBarTooltipData}- setData={setSideBarTooltipData}- >- <div- className={clsx("openui-line-chart-container", className)}- data-openui-chart={exportData}- style={{- width: width ? `${width}px` : undefined,- }}- >- <div className="openui-line-chart-container-inner" ref={chartContainerRef}>- {/* Y-axis of the chart */}- {yAxis}- <div className="openui-line-chart-main-container" ref={mainContainerRef}>- <ChartContainer- config={chartConfig}- style={{ width: dataWidth, minWidth: "100%", height: chartHeight }}- rechartsProps={{- width: "100%",- height: "100%",- minHeight: 1,- minWidth: 1,- initialDimension: { width: 1, height: 1 },- }}- >- <RechartsLineChart- accessibilityLayer- key={`line-chart-${id}`}- data={data}- margin={{- top: 20,- bottom: CHART_CONTAINER_BOTTOM_MARGIN,- }}- onClick={onLineClick}- >- {grid && cartesianGrid()}- <XAxis- dataKey={categoryKey as string}- tickLine={false}- axisLine={false}- height={maxLabelHeight}- textAnchor="middle"- interval={0}- tick={- <XAxisTick- variant={tickVariant}- widthOfGroup={widthOfGroup}- labelHeight={maxLabelHeight}- />- }- orientation="bottom"- padding={{- left: X_AXIS_PADDING,- right: X_AXIS_PADDING,- }}- />-- <ChartTooltip- content={<CustomTooltipContent parentRef={mainContainerRef} />}- offset={15}- />-- {dataKeys.map((key) => {- const transformedKey = transformedKeys[key];- const color = `var(--color-${transformedKey})`;- return (- <Line- key={`main-${key}`}- dataKey={key}- type={variant}- stroke={color}- strokeWidth={strokeWidth}- dot={false}- activeDot={<ActiveDot key={`active-dot-${key}-${id}`} />}- isAnimationActive={isAnimationActive}- />- );- })}- </RechartsLineChart>- </ChartContainer>- </div>- {isSideBarTooltipOpen && <SideBarTooltip height={chartHeight} />}- </div>- {/* if the data width is greater than the effective width, then show the scroll buttons */}- <ScrollButtonsHorizontal- dataWidth={dataWidth}- effectiveWidth={effectiveWidth}- canScrollLeft={canScrollLeft}- canScrollRight={canScrollRight}- isSideBarTooltipOpen={isSideBarTooltipOpen}- onScrollLeft={scrollLeft}- onScrollRight={scrollRight}+ <LineDotCrosshair+ hoveredIndex={orch.hover.hoveredIndex}+ xScale={xScale}+ yScale={yScale}+ data={data}+ dataKeys={orch.data.dataKeys}+ categoryKey={orch.data.catKey}+ colors={orch.data.colorMap}+ chartHeight={orch.dimensions.chartInnerHeight}+ getYValue={getYValue}+ classPrefix={`${CHART_CLASS_PREFIX}-line-chart`}+ crosshair={crosshair}+ highlight={highlight}+ activeDots={activeDots}/>- {legend && (- <DefaultLegend- items={legendItems}- yAxisLabel={yAxisLabel}- xAxisLabel={xAxisLabel}- containerWidth={effectiveWidth}- isExpanded={isLegendExpanded}- setIsExpanded={setIsLegendExpanded}- />- )}- </div>- </SideBarTooltipProvider>- </LabelTooltipProvider>+ </>+ }+ xAxis={+ <CartesianXAxis+ mode={mode}+ scale={xScale}+ classPrefix={`${CHART_CLASS_PREFIX}-line-chart`}+ tickVariant={orch.dimensions.tickVariant}+ widthOfGroup={orch.dimensions.widthOfGroup}+ labelHeight={orch.xAxis.xAxisHeight}+ labelWidth={orch.xAxis.labelWidth}+ maxLines={orch.xAxis.maxLines}+ labelInterval={orch.dimensions.labelInterval}+ angle={orch.xAxis.angle}+ chartWidth={orch.dimensions.chartAreaWidth}+ yAxisWidth={orch.dimensions.effectiveYAxisWidth}+ />+ }+ />);-};+}diff --git a/packages/react-ui/src/components/Charts/LineChart/LineChartCondensed.tsx b/packages/react-ui/src/components/Charts/LineChart/LineChartCondensed.tsxnew file mode 100644index 000000000..309a6bf44--- /dev/null+++ b/packages/react-ui/src/components/Charts/LineChart/LineChartCondensed.tsx@@ -0,0 +1,9 @@+import { LineChart } from "./LineChart";+import type { LineChartData, LineChartProps } from "./types";++export type LineChartCondensedProps<T extends LineChartData> = Omit<LineChartProps<T>, "condensed">;++/** A `LineChart` that fits its container's width instead of scrolling. */+export const LineChartCondensed = <T extends LineChartData>(props: LineChartCondensedProps<T>) => (+ <LineChart {...props} condensed />+);diff --git a/packages/react-ui/src/components/Charts/LineChart/dependencies.ts b/packages/react-ui/src/components/Charts/LineChart/dependencies.tsdeleted file mode 100644index e9ef0ced9..000000000--- a/packages/react-ui/src/components/Charts/LineChart/dependencies.ts+++ /dev/null@@ -1,2 +0,0 @@-const dependencies = ["LineChart", "IconButton"];-export default dependencies;diff --git a/packages/react-ui/src/components/Charts/LineChart/index.ts b/packages/react-ui/src/components/Charts/LineChart/index.tsindex 3f293679e..f41e11b54 100644--- a/packages/react-ui/src/components/Charts/LineChart/index.ts+++ b/packages/react-ui/src/components/Charts/LineChart/index.ts@@ -1,2 +1,4 @@-export * from "./LineChart";-export * from "./types";+export { LineChart } from "./LineChart";+export { LineChartCondensed } from "./LineChartCondensed";+export type { LineChartCondensedProps } from "./LineChartCondensed";+export type { LineChartData, LineChartProps, LineChartVariant } from "./types";diff --git a/packages/react-ui/src/components/Charts/LineChart/lineChart.scss b/packages/react-ui/src/components/Charts/LineChart/lineChart.scssindex 77aa73fe2..2b7609de7 100644--- a/packages/react-ui/src/components/Charts/LineChart/lineChart.scss+++ b/packages/react-ui/src/components/Charts/LineChart/lineChart.scss@@ -1,25 +1,31 @@@use "../../../cssUtils" as cssUtils;+@use "../shared/cartesian/chartBase" as base;+@use "../prefix" as brand;-.openui-line-chart-container-inner {- display: flex;- width: 100%;+@include base.chart-base("line-chart");+@include base.crosshair-styles("line-chart");++// No `transition: d/cx/cy` here: data-change motion is the spring data morph+// in LineSeries (gated on isAnimationActive). A CSS transition restarted from+// progress 0 on every attribute write, so per-frame streaming rewrites pinned+// the rendered geometry (and would fight the morph's per-tick writes).+.#{brand.$prefix}-line-chart-line {+ fill: none;+ stroke-width: 2;}-.openui-line-chart-y-axis-container {- flex-shrink: 0;+.#{brand.$prefix}-line-chart-dot {+ stroke: cssUtils.$foreground;+ stroke-width: 1;}-.openui-line-chart-main-container {- width: 100%;- overflow-x: auto;- /* Hide scrollbar for Chrome, Safari and Opera */- &::-webkit-scrollbar {- display: none;+// Entrances are decorative: gate the whole rule (pre-state included) behind+// reduced-motion so users who opt out get the natural static state immediately+// — gating only the animation would strand elements at the opacity: 0 start.+@media (prefers-reduced-motion: no-preference) {+ .#{brand.$prefix}-line-chart-line--animated {+ stroke-dasharray: var(--path-length);+ stroke-dashoffset: var(--path-length);+ animation: #{brand.$prefix}-draw-line 1s ease-out forwards;}-- /* Hide scrollbar for Firefox */- scrollbar-width: none;-- /* Hide scrollbar for IE and Edge */- -ms-overflow-style: none;}diff --git a/packages/react-ui/src/components/D3Charts/LineChart/parts/LineSeries.tsx b/packages/react-ui/src/components/Charts/LineChart/parts/LineSeries.tsxsimilarity index 100%rename from packages/react-ui/src/components/D3Charts/LineChart/parts/LineSeries.tsxrename to packages/react-ui/src/components/Charts/LineChart/parts/LineSeries.tsxdiff --git a/packages/react-ui/src/components/Charts/LineChart/stories/lineChart.stories.tsx b/packages/react-ui/src/components/Charts/LineChart/stories/lineChart.stories.tsxindex 4590e03b8..c03941cf7 100644--- a/packages/react-ui/src/components/Charts/LineChart/stories/lineChart.stories.tsx+++ b/packages/react-ui/src/components/Charts/LineChart/stories/lineChart.stories.tsx@@ -10,8 +10,8 @@ import {Watch,} from "lucide-react";import { useState } from "react";+import { LineChart, LineChartProps } from "../..";import { Card } from "../../../Card";-import { LineChart, LineChartProps } from "../LineChart";const customColorPalette = ["#0A0E60",@@ -481,9 +481,9 @@ const icons = {* - **Responsive Design**: Fluidly adjusts to any container size, from small widgets to large dashboards.** ### Customization- * - **Theming**: Six pre-built color palettes to fit your application's design, or use custom colors with `customPalette`.+ * - **Colors**: Uses the ThemeProvider's chart palette, or custom colors with `customPalette`.* - **Line Styles**: Supports `linear`, `natural` (smooth), and `step` variants.- * - **Styling Options**: Control stroke width, grid visibility, and more.+ * - **Styling Options**: Control grid visibility, axes, and more.*/const meta: Meta<LineChartProps<typeof lineChartV2Data>> = {title: "Components/Charts/ScrollableLineChart",@@ -508,7 +508,6 @@ const timeSeriesData = [<ScrollableLineChartdata={timeSeriesData}categoryKey="month"- theme="ocean"/>// With custom colors@@ -568,19 +567,8 @@ const salesData = [category: "📊 Data Configuration",},},- theme: {- description:- "Specifies the color palette for the chart's lines, tooltips, and legend. Ignored when customPalette is provided.",- control: "select",- options: ["ocean", "orchid", "emerald", "sunset", "spectrum", "vivid"],- table: {- defaultValue: { summary: "ocean" },- category: "🎨 Visual Styling",- },- },customPalette: {- description:- "Custom array of colors to use instead of the theme palette. Overrides the theme prop when provided.",+ description: "Custom array of colors to use instead of the ThemeProvider's chart palette.",control: "object",table: {type: { summary: "string[]" },@@ -596,14 +584,6 @@ const salesData = [category: "🎨 Visual Styling",},},- strokeWidth: {- description: "Controls the thickness of the lines in pixels.",- control: { type: "number", min: 1, max: 10, step: 1 },- table: {- defaultValue: { summary: "2" },- category: "🎨 Visual Styling",- },- },grid: {description: "Toggles the visibility of the background grid lines.",control: "boolean",@@ -708,13 +688,11 @@ export const DataExplorer: Story = {args: {data: lineChartV2Data,categoryKey: "month",- theme: "ocean",variant: "natural",grid: true,legend: true,isAnimationActive: true,showYAxis: true,- strokeWidth: 2,},render: (args: any) => {const [selectedDataType, setSelectedDataType] =@@ -839,12 +817,10 @@ export const BigLabelsStory: Story = {args: {data: dataVariations.bigLabels as any,categoryKey: "category" as any,- theme: "emerald",variant: "natural",grid: true,legend: true,showYAxis: true,- strokeWidth: 3,},render: (args: any) => (<Card style={{ width: "600px" }}>@@ -865,13 +841,11 @@ export const DenseTimelineStory: Story = {args: {data: dataVariations.denseTimeline as any,categoryKey: "period" as any,- theme: "sunset",variant: "natural",grid: true,legend: true,isAnimationActive: true,showYAxis: true,- strokeWidth: 2,},render: (args: any) => (<Card style={{ width: "500px" }}>@@ -888,41 +862,6 @@ export const DenseTimelineStory: Story = {},};-/**- * ## Stroke and Style Customization- *- * This story showcases how to customize the appearance of the lines.- * You can adjust properties like `strokeWidth` to create different visual effects.- */-export const StrokeCustomizationStory: Story = {- name: "🎨 Stroke Customization",- args: {- data: dataVariations.default as any,- categoryKey: "month" as any,- theme: "vivid",- variant: "natural",- grid: true,- legend: true,- showYAxis: true,- },- render: (args: any) => (- <div style={{ display: "flex", flexDirection: "column", gap: "20px" }}>- <div>- <h4>Default Lines (strokeWidth: 2)</h4>- <Card style={{ width: "500px" }}>- <LineChart {...args} strokeWidth={2} />- </Card>- </div>- <div>- <h4>Thick Lines (strokeWidth: 4)</h4>- <Card style={{ width: "500px" }}>- <LineChart {...args} strokeWidth={4} />- </Card>- </div>- </div>- ),-};-/*** ## Line Variants*@@ -936,12 +875,10 @@ export const VariantComparisonStory: Story = {args: {data: dataVariations.minimal as any,categoryKey: "category" as any,- theme: "orchid",grid: true,legend: true,isAnimationActive: true,showYAxis: true,- strokeWidth: 3,},render: (args: any) => (<div style={{ display: "flex", flexDirection: "column", gap: "20px" }}>@@ -990,13 +927,11 @@ export const CustomPaletteStory: Story = {data: dataVariations.default as any,categoryKey: "month" as any,customPalette: customColorPalette,- theme: "ocean", // This will be overridden by customPalettevariant: "natural",grid: true,legend: true,isAnimationActive: true,showYAxis: true,- strokeWidth: 2,xAxisLabel: "Month",yAxisLabel: "Traffic",},@@ -1053,7 +988,7 @@ export const CustomPaletteStory: Story = {docs: {description: {story:- 'Demonstrates how to use the `customPalette` prop to provide your own color scheme for the chart. When `customPalette` is provided, it overrides the `theme` prop and uses your specified colors instead of the predefined theme palettes.\n\n**Key Features:**\n- 🎨 **Custom Colors**: Override default theme colors with your own palette\n- 🔄 **Theme Override**: The `theme` prop is ignored when `customPalette` is provided\n- 📊 **Consistent Distribution**: Colors are distributed evenly across data series\n- 🎯 **Brand Matching**: Perfect for matching your application\'s brand colors\n\n**Usage:**\n```tsx\n<LineChart\n data={data}\n categoryKey="month"\n customPalette={["#FF6B6B", "#4ECDC4", "#45B7D1"]}\n // theme prop is ignored when customPalette is provided\n/>\n```',+ 'Demonstrates how to use the `customPalette` prop to provide your own color scheme for the chart. When `customPalette` is provided, it overrides the ThemeProvider\'s chart palette and uses your specified colors instead.\n\n**Key Features:**\n- 🎨 **Custom Colors**: Override the default chart colors with your own palette\n- 📊 **Consistent Distribution**: Colors are distributed evenly across data series\n- 🎯 **Brand Matching**: Perfect for matching your application\'s brand colors\n\n**Usage:**\n```tsx\n<LineChart\n data={data}\n categoryKey="month"\n customPalette={["#FF6B6B", "#4ECDC4", "#45B7D1"]}\n/>\n```',},},},@@ -1071,13 +1006,11 @@ export const ExpandCollapseMarketingStory: Story = {args: {data: dataVariations.expandCollapseMarketing as any,categoryKey: "channel" as any,- theme: "spectrum",variant: "natural",grid: true,legend: true,isAnimationActive: true,showYAxis: true,- strokeWidth: 2,},render: (args: any) => (<Card style={{ width: "600px" }}>@@ -1110,13 +1043,11 @@ export const ResponsiveBehaviorDemo: Story = {args: {data: dataVariations.bigLabels as any,categoryKey: "category" as any,- theme: "sunset",variant: "natural",grid: true,legend: true,isAnimationActive: false,showYAxis: true,- strokeWidth: 2,},render: (args: any) => {const [dimensions, setDimensions] = useState<{ width: number; height: number | string }>({diff --git a/packages/react-ui/src/components/Charts/LineChartCondensed/stories/lineChartCondensed.stories.tsx b/packages/react-ui/src/components/Charts/LineChart/stories/lineChartCondensed.stories.tsxsimilarity index 88%rename from packages/react-ui/src/components/Charts/LineChartCondensed/stories/lineChartCondensed.stories.tsxrename to packages/react-ui/src/components/Charts/LineChart/stories/lineChartCondensed.stories.tsxindex 854a88beb..27b302b5e 100644--- a/packages/react-ui/src/components/Charts/LineChartCondensed/stories/lineChartCondensed.stories.tsx+++ b/packages/react-ui/src/components/Charts/LineChart/stories/lineChartCondensed.stories.tsx@@ -10,8 +10,8 @@ import {Watch,} from "lucide-react";import { useState } from "react";+import { LineChartCondensed, LineChartCondensedProps } from "../..";import { Card } from "../../../Card";-import { LineChartCondensed, LineChartCondensedProps } from "../LineChartCondensed";// 🔥 COMPREHENSIVE DATA VARIATIONS - Designed to test various scenariosconst dataVariations = {@@ -257,12 +257,11 @@ const icons = {* ### Interactive & Responsive* - **Hover Tooltips**: Standard tooltip showing all data series* - **Responsive Design**: Adapts fluidly to its container's size- * - **Line Customization**: Control line thickness with strokeWidth prop** ### Customization- * - **Theming**: Comes with six pre-built color palettes+ * - **Colors**: Uses the ThemeProvider's chart palette, or custom colors with `customPalette`* - **Line Styles**: Supports `linear`, `natural` (smooth), and `step` interpolation- * - **Styling Options**: Control grid visibility, axes, stroke width, and more+ * - **Styling Options**: Control grid visibility, axes, and more*/const meta: Meta<LineChartCondensedProps<typeof lineChartCondensedData>> = {title: "Components/Charts/LineChart",@@ -287,7 +286,6 @@ const trafficData = [<LineChartdata={trafficData}categoryKey="date"- theme="ocean"height={200}/>\`\`\`@@ -312,7 +310,6 @@ const salesData = [- **No Interactive Legend**: Legend is simplified and non-interactive- **Tick Variants**: Supports both horizontal (singleLine) and angled labels- **Performance**: Optimized for quick rendering in dashboards-- **Stroke Width Control**: Customize line thickness with strokeWidth prop## Performance Considerations- **Data Density**: For very large datasets, consider disabling animations@@ -345,19 +342,8 @@ const salesData = [category: "📊 Data Configuration",},},- theme: {- description:- "Specifies the color palette for the chart's lines and tooltips. Ignored when customPalette is provided.",- control: "select",- options: ["ocean", "orchid", "emerald", "sunset", "spectrum", "vivid"],- table: {- defaultValue: { summary: "ocean" },- category: "🎨 Visual Styling",- },- },customPalette: {- description:- "Custom array of colors to use instead of the theme palette. Overrides the theme prop when provided.",+ description: "Custom array of colors to use instead of the ThemeProvider's chart palette.",control: "object",table: {type: { summary: "string[]" },@@ -375,7 +361,7 @@ const salesData = [},tickVariant: {description:- "X-axis tick label style. Choose between 'singleLine' (horizontal) or 'angled' (rotated at optimal angle).",+ "X-axis tick label style. Choose between 'singleLine' (horizontal) or 'angled' (rotated 45° when they don't fit).",control: "radio",options: ["singleLine", "angled"],table: {@@ -383,14 +369,6 @@ const salesData = [category: "🎨 Visual Styling",},},- strokeWidth: {- description: "Line thickness in pixels. Controls the width of the line strokes.",- control: { type: "number", min: 1, max: 10, step: 0.5 },- table: {- defaultValue: { summary: "2" },- category: "🎨 Visual Styling",- },- },icons: {description:"An object mapping data series keys to React components to be used as icons in the legend.",@@ -488,10 +466,8 @@ export const DataExplorer: Story = {args: {data: lineChartCondensedData,categoryKey: "month",- theme: "ocean",variant: "natural",tickVariant: "singleLine",- strokeWidth: 2,grid: true,isAnimationActive: false,showYAxis: true,@@ -873,10 +849,8 @@ export const LargeDatasetWithSidebarTooltip: Story = {},] as any,categoryKey: "month" as any,- theme: "ocean",variant: "natural",tickVariant: "singleLine",- strokeWidth: 2,grid: true,isAnimationActive: false,showYAxis: true,@@ -938,10 +912,8 @@ export const BigLabelsStory: Story = {args: {data: dataVariations.bigLabels as any,categoryKey: "category" as any,- theme: "emerald",variant: "natural",tickVariant: "angled",- strokeWidth: 2,grid: true,isAnimationActive: false,showYAxis: true,@@ -956,7 +928,7 @@ export const BigLabelsStory: Story = {docs: {description: {story:- "Tests the chart with extremely long category names. The angled tick variant automatically rotates labels at an optimal angle to prevent overlapping and maximize readability.",+ "Tests the chart with extremely long category names. The angled tick variant rotates labels 45° to prevent overlapping and maximize readability.",},},},@@ -973,10 +945,8 @@ export const DenseTimelineStory: Story = {args: {data: dataVariations.denseTimeline as any,categoryKey: "period" as any,- theme: "sunset",variant: "natural",tickVariant: "angled",- strokeWidth: 2,grid: true,isAnimationActive: false,showYAxis: true,@@ -1008,10 +978,8 @@ export const CompanyNamesStory: Story = {args: {data: dataVariations.companyNames as any,categoryKey: "company" as any,- theme: "vivid",variant: "natural",tickVariant: "angled",- strokeWidth: 2,grid: true,isAnimationActive: false,showYAxis: true,@@ -1043,10 +1011,8 @@ export const CountryDataStory: Story = {args: {data: dataVariations.countryData as any,categoryKey: "country" as any,- theme: "orchid",variant: "natural",tickVariant: "angled",- strokeWidth: 2,grid: true,isAnimationActive: false,showYAxis: true,@@ -1078,10 +1044,8 @@ export const MixedLengthsStory: Story = {args: {data: dataVariations.mixedLengths as any,categoryKey: "item" as any,- theme: "spectrum",variant: "linear",tickVariant: "singleLine",- strokeWidth: 2,grid: true,isAnimationActive: false,showYAxis: true,@@ -1112,10 +1076,8 @@ export const EdgeCasesStory: Story = {args: {data: dataVariations.edgeCases as any,categoryKey: "name" as any,- theme: "ocean",variant: "step",tickVariant: "angled",- strokeWidth: 2,grid: true,isAnimationActive: false,showYAxis: true,@@ -1147,10 +1109,8 @@ export const MinimalDataStory: Story = {args: {data: dataVariations.minimal as any,categoryKey: "category" as any,- theme: "emerald",variant: "natural",tickVariant: "singleLine",- strokeWidth: 2,grid: true,isAnimationActive: false,showYAxis: true,@@ -1182,10 +1142,8 @@ export const CustomPaletteStory: Story = {args: {data: dataVariations.default as any,categoryKey: "month" as any,- theme: "ocean", // This will be overridden by customPalettevariant: "natural",tickVariant: "singleLine",- strokeWidth: 2,grid: true,isAnimationActive: false,showYAxis: true,@@ -1248,73 +1206,7 @@ export const CustomPaletteStory: Story = {docs: {description: {story:- 'Demonstrates how to use the `customPalette` prop to provide your own color scheme. When `customPalette` is provided, it overrides the `theme` prop.\n\n**Usage:**\n```tsx\n<LineChartCondensed\n data={data}\n categoryKey="month"\n customPalette={["#FF6B6B", "#4ECDC4", "#45B7D1"]}\n/>\n```',- },- },- },-};--/**- * ## Stroke Width Comparison- *- * Compare different line thickness options to find the right visual weight for your data.- */-export const StrokeWidthComparison: Story = {- name: "📏 Stroke Width Comparison",- render: () => (- <div style={{ display: "flex", flexDirection: "column", gap: "24px" }}>- <Card style={{ width: "700px", padding: "16px" }}>- <div style={{ marginBottom: "12px" }}>- <div style={{ fontSize: "16px", fontWeight: "600", marginBottom: "4px" }}>- Thin Lines (1px)- </div>- <div style={{ fontSize: "13px", color: "#666" }}>Subtle, minimal visual weight</div>- </div>- <LineChartCondensed- data={dataVariations.default as any}- categoryKey="month"- theme="ocean"- strokeWidth={1}- height={180}- />- </Card>- <Card style={{ width: "700px", padding: "16px" }}>- <div style={{ marginBottom: "12px" }}>- <div style={{ fontSize: "16px", fontWeight: "600", marginBottom: "4px" }}>- Default Lines (2px)- </div>- <div style={{ fontSize: "13px", color: "#666" }}>Balanced, standard weight</div>- </div>- <LineChartCondensed- data={dataVariations.default as any}- categoryKey="month"- theme="emerald"- strokeWidth={2}- height={180}- />- </Card>- <Card style={{ width: "700px", padding: "16px" }}>- <div style={{ marginBottom: "12px" }}>- <div style={{ fontSize: "16px", fontWeight: "600", marginBottom: "4px" }}>- Thick Lines (4px)- </div>- <div style={{ fontSize: "13px", color: "#666" }}>Bold, high emphasis</div>- </div>- <LineChartCondensed- data={dataVariations.default as any}- categoryKey="month"- theme="sunset"- strokeWidth={4}- height={180}- />- </Card>- </div>- ),- parameters: {- docs: {- description: {- story:- "**Side-by-side comparison** of stroke widths:\n\n- **1px**: Thin, subtle lines perfect for dense data or multiple overlapping series\n- **2px**: Default weight, balanced for most use cases\n- **4px**: Thick, bold lines for high emphasis or presentations\n\n**When to use each:**\n- Use **1px** for many overlapping series or subtle trends\n- Use **2px** (default) for general purpose visualization\n- Use **4px** for presentations or when emphasizing specific trends",+ 'Demonstrates how to use the `customPalette` prop to provide your own color scheme. When `customPalette` is provided, it overrides the ThemeProvider\'s chart palette.\n\n**Usage:**\n```tsx\n<LineChartCondensed\n data={data}\n categoryKey="month"\n customPalette={["#FF6B6B", "#4ECDC4", "#45B7D1"]}\n/>\n```',},},},@@ -1336,15 +1228,13 @@ export const TickVariantComparison: Story = {Single Line Variant (Horizontal)</div><div style={{ fontSize: "13px", color: "#666" }}>- Standard horizontal labels. Recharts automatically hides overlapping labels.+ Standard horizontal labels, truncated with an ellipsis when they don't fit.</div></div><LineChartCondenseddata={dataVariations.bigLabels as any}categoryKey="category"tickVariant="singleLine"- theme="ocean"- strokeWidth={2}height={200}/></Card>@@ -1354,15 +1244,13 @@ export const TickVariantComparison: Story = {Angled Variant (Rotated)</div><div style={{ fontSize: "13px", color: "#666" }}>- Automatically rotates labels at an optimal angle. Shows more labels without collision.+ Rotates labels 45° when they don't fit horizontally.</div></div><LineChartCondenseddata={dataVariations.bigLabels as any}categoryKey="category"tickVariant="angled"- theme="emerald"- strokeWidth={2}height={260}/></Card>@@ -1372,7 +1260,7 @@ export const TickVariantComparison: Story = {docs: {description: {story:- "**Side-by-side comparison** of tick variants:\n\n- **Single Line**: Standard horizontal labels with automatic collision detection. Recharts hides overlapping labels.\n- **Angled**: Rotates labels at an optimal angle calculated based on label width and available space. Shows more labels without collision.\n\n**When to use each:**\n- Use **singleLine** for short labels or when you have few data points\n- Use **angled** for long labels or many data points where horizontal labels would overlap",+ "**Side-by-side comparison** of tick variants:\n\n- **Single Line**: Standard horizontal labels, truncated with an ellipsis when they don't fit.\n- **Angled**: Rotates labels 45° when they don't fit horizontally.\n\n**When to use each:**\n- Use **singleLine** for short labels or when you have few data points\n- Use **angled** for long labels or many data points where horizontal labels would overlap",},},},@@ -1389,10 +1277,8 @@ export const ResponsiveBehaviorDemo: Story = {args: {data: dataVariations.bigLabels as any,categoryKey: "category" as any,- theme: "sunset",variant: "natural",tickVariant: "angled",- strokeWidth: 2,grid: true,isAnimationActive: false,showYAxis: true,diff --git a/packages/react-ui/src/components/D3Charts/LineChart/types.ts b/packages/react-ui/src/components/Charts/LineChart/types.tssimilarity index 100%rename from packages/react-ui/src/components/D3Charts/LineChart/types.tsrename to packages/react-ui/src/components/Charts/LineChart/types.tsdiff --git a/packages/react-ui/src/components/Charts/LineChart/types/index.ts b/packages/react-ui/src/components/Charts/LineChart/types/index.tsdeleted file mode 100644index 083280dd2..000000000--- a/packages/react-ui/src/components/Charts/LineChart/types/index.ts+++ /dev/null@@ -1,3 +0,0 @@-export type LineChartData = Array<Record<string, string | number>>;--export type LineChartVariant = "linear" | "natural" | "step";diff --git a/packages/react-ui/src/components/Charts/LineChartCondensed/LineChartCondensed.tsx b/packages/react-ui/src/components/Charts/LineChartCondensed/LineChartCondensed.tsxdeleted file mode 100644index 33fdbfb8e..000000000--- a/packages/react-ui/src/components/Charts/LineChartCondensed/LineChartCondensed.tsx+++ /dev/null@@ -1,391 +0,0 @@-import clsx from "clsx";-import React, { useCallback, useEffect, useId, useMemo, useRef, useState } from "react";-import { Line, LineChart as RechartsLineChart, XAxis, YAxis } from "recharts";-import { usePrintContext } from "../../../context/PrintContext";-import { ChartConfig, ChartContainer, ChartTooltip } from "../Charts";-import { DEFAULT_X_AXIS_HEIGHT, X_AXIS_PADDING } from "../constants";-import { SideBarChartData, SideBarTooltipProvider } from "../context/SideBarTooltipContext";-import {- useAutoAngleCalculation,- useExportChartData,- useMaxLabelWidth,- useTransformedKeys,- useYAxisLabelWidth,-} from "../hooks";-import { LineChartData, LineChartVariant } from "../LineChart/types";-import {- ActiveDot,- cartesianGrid,- CustomTooltipContent,- DefaultLegend,- SideBarTooltip,- SVGXAxisTick,- SVGXAxisTickVariant,- YAxisTick,-} from "../shared";-import { LabelTooltipProvider } from "../shared/LabelTooltip/LabelTooltip";-import { LegendItem } from "../types";-import { getLineType } from "../utils/AreaAndLine/common";-import {- get2dChartConfig,- getColorForDataKey,- getDataKeys,- getLegendItems,-} from "../utils/dataUtils";-import { PaletteName, useChartPalette } from "../utils/PalletUtils";--// this a technic to get the type of the onClick event of the line chart-// we need to do this because the onClick event type is not exported by recharts-type LineChartOnClick = React.ComponentProps<typeof RechartsLineChart>["onClick"];-type LineClickData = Parameters<NonNullable<LineChartOnClick>>[0];--export interface LineChartCondensedProps<T extends LineChartData> {- data: T;- categoryKey: keyof T[number];- theme?: PaletteName;- customPalette?: string[];- variant?: LineChartVariant;- tickVariant?: SVGXAxisTickVariant;- grid?: boolean;- icons?: Partial<Record<keyof T[number], React.ComponentType>>;- isAnimationActive?: boolean;- showYAxis?: boolean;- xAxisLabel?: React.ReactNode;- yAxisLabel?: React.ReactNode;- legend?: boolean;- className?: string;- height?: number;- width?: number;- strokeWidth?: number;-}--const CHART_HEIGHT = 296;-const CHART_CONTAINER_BOTTOM_MARGIN = 10;--const LineChartCondensedComponent = <T extends LineChartData>({- data,- categoryKey,- theme = "ocean",- customPalette,- variant: lineChartVariant = "natural",- tickVariant = "singleLine",- grid = true,- icons = {},- isAnimationActive = false,- showYAxis = true,- xAxisLabel,- yAxisLabel,- legend = true,- className,- height = CHART_HEIGHT,- width,- strokeWidth = 2,-}: LineChartCondensedProps<T>) => {- const printContext = usePrintContext();- isAnimationActive = printContext ? false : isAnimationActive;-- const dataKeys = useMemo(() => {- return getDataKeys(data, categoryKey as string);- }, [data, categoryKey]);-- const variant = getLineType(lineChartVariant);-- const { yAxisWidth, setLabelWidth } = useYAxisLabelWidth(data, dataKeys);-- const maxLabelWidth = useMaxLabelWidth(data, categoryKey as string);-- const chartContainerRef = useRef<HTMLDivElement>(null);- const [chartContainerWidth, setChartContainerWidth] = useState<number>(0);-- const widthOfData = useMemo(() => {- if (data.length === 0) {- return 0;- }- // Use passed width if available, otherwise use observed chartContainerWidth- const chartWidth = width ?? chartContainerWidth;- return chartWidth / data.length;- }, [width, chartContainerWidth, data]);-- const { angle: calculatedAngle, height: xAxisHeight } = useAutoAngleCalculation(- maxLabelWidth,- tickVariant === "angled",- maxLabelWidth < 100 ? widthOfData : undefined,- );-- const isAngled = useMemo(() => {- return calculatedAngle !== 0;- }, [calculatedAngle]);-- const effectiveHeight = useMemo(() => {- if (tickVariant === "angled") {- return xAxisHeight + height;- }- return height + DEFAULT_X_AXIS_HEIGHT;- }, [height, xAxisHeight, tickVariant]);-- 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 exportData = useExportChartData({- type: "line",- data,- categoryKey: categoryKey as string,- dataKeys,- colors,- legend,- xAxisLabel,- yAxisLabel,- extraOptions: {- lineSize: strokeWidth,- },- });-- const chartMargin = useMemo(- () => ({- top: 10,- right: 10,- bottom: CHART_CONTAINER_BOTTOM_MARGIN,- left: showYAxis ? 10 : 0,- }),- [showYAxis],- );-- const onLineClick = useCallback(- (data: LineClickData) => {- if (data?.activePayload?.length && data.activePayload.length > 10) {- setIsSideBarTooltipOpen(true);- setSideBarTooltipData({- title: data.activeLabel as string,- values: data.activePayload.map((payload) => ({- value: payload.value as number,- label: payload.name || payload.dataKey,- color: getColorForDataKey(payload.dataKey, dataKeys, colors),- })),- });- }- },- [dataKeys, colors],- );-- const containerRef = useRef<HTMLDivElement>(null);- const [containerWidth, setContainerWidth] = useState<number>(0);- const [isSideBarTooltipOpen, setIsSideBarTooltipOpen] = useState(false);- const [sideBarTooltipData, setSideBarTooltipData] = useState<SideBarChartData>({- title: "",- values: [],- });- const [isLegendExpanded, setIsLegendExpanded] = useState(false);-- // Use provided width or observed width- const effectiveWidth = useMemo(() => {- return width ?? containerWidth;- }, [width, containerWidth]);-- // Observe container width for legend- useEffect(() => {- // Only set up ResizeObserver if width is not provided- if (width || !containerRef.current || !chartContainerRef.current) {- return () => {};- }-- const resizeObserver = new ResizeObserver((entries) => {- // there is only one entry in the entries array because we are observing the chart container- for (const entry of entries) {- if (entry.target === containerRef.current) {- setContainerWidth(entry.contentRect.width);- }- if (entry.target === chartContainerRef.current) {- setChartContainerWidth(entry.contentRect.width);- }- }- });-- resizeObserver.observe(containerRef.current);- resizeObserver.observe(chartContainerRef.current);-- return () => {- resizeObserver.disconnect();- };- }, [width]);-- useEffect(() => {- setIsLegendExpanded(false);- }, [dataKeys]);-- // Memoize legend items creation- const legendItems: LegendItem[] = useMemo(() => {- if (!legend) {- return [];- }- return getLegendItems(dataKeys, colors, icons);- }, [dataKeys, colors, icons, legend]);-- const yAxis = useMemo(() => {- if (!showYAxis) {- return null;- }- return (- <div className="openui-line-chart-condensed-y-axis-container">- {/* Y-axis only chart - synchronized with main chart */}- <RechartsLineChart- key={`y-axis-line-chart-condensed-${id}`}- width={yAxisWidth}- height={effectiveHeight}- data={data}- margin={{- top: chartMargin.top,- bottom: xAxisHeight + chartMargin.bottom, // this is required to give space for x-axis- left: 0,- right: 0,- }}- >- <YAxis- width={yAxisWidth}- tickLine={false}- axisLine={false}- tick={<YAxisTick setLabelWidth={setLabelWidth} />}- />- {/* Invisible lines to maintain scale synchronization */}- {dataKeys.map((key) => {- return (- <Line- key={`yaxis-line-chart-condensed-${key}`}- dataKey={key}- stroke="transparent"- strokeWidth={0}- dot={false}- isAnimationActive={false}- />- );- })}- </RechartsLineChart>- </div>- );- }, [- showYAxis,- effectiveHeight,- data,- dataKeys,- id,- yAxisWidth,- chartMargin,- xAxisHeight,- setLabelWidth,- ]);-- return (- <LabelTooltipProvider>- <SideBarTooltipProvider- isSideBarTooltipOpen={isSideBarTooltipOpen}- setIsSideBarTooltipOpen={setIsSideBarTooltipOpen}- data={sideBarTooltipData}- setData={setSideBarTooltipData}- >- <div- className={clsx("openui-line-chart-condensed-container", className)}- data-openui-chart={exportData}- style={{- width: width ? `${width}px` : undefined,- }}- >- {yAxisLabel && (- <div className="openui-line-chart-condensed-y-axis-label">{yAxisLabel}</div>- )}- <div className="openui-line-chart-condensed-container-inner" ref={containerRef}>- {/* Y-axis of the chart */}- {yAxis}- <div className="openui-line-chart-condensed" ref={chartContainerRef}>- <ChartContainer- config={chartConfig}- style={{ width: "100%", height: effectiveHeight }}- rechartsProps={{- width: "100%",- height: "100%",- }}- >- <RechartsLineChart- accessibilityLayer- key={`line-chart-condensed-${id}`}- data={data}- margin={chartMargin}- onClick={onLineClick}- >- {grid && cartesianGrid()}-- <XAxis- dataKey={categoryKey as string}- tickLine={false}- axisLine={false}- textAnchor={isAngled ? "end" : "middle"}- interval="preserveStartEnd"- minTickGap={5}- height={xAxisHeight}- tick={<SVGXAxisTick />}- angle={calculatedAngle}- orientation="bottom"- padding={{- left: X_AXIS_PADDING,- right: X_AXIS_PADDING,- }}- />- {/* Y-axis is rendered in the separate synchronized chart */}-- <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>- {isSideBarTooltipOpen && <SideBarTooltip height={effectiveHeight} />}- </div>- {xAxisLabel && (- <div className="openui-line-chart-condensed-x-axis-label">{xAxisLabel}</div>- )}- {legend && (- <DefaultLegend- items={legendItems}- containerWidth={effectiveWidth}- isExpanded={isLegendExpanded}- setIsExpanded={setIsLegendExpanded}- />- )}- </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/packages/react-ui/src/components/Charts/LineChartCondensed/dependencies.ts b/packages/react-ui/src/components/Charts/LineChartCondensed/dependencies.tsdeleted file mode 100644index 815367b8c..000000000--- a/packages/react-ui/src/components/Charts/LineChartCondensed/dependencies.ts+++ /dev/null@@ -1,2 +0,0 @@-const dependencies = ["LineChartCondensed"];-export default dependencies;diff --git a/packages/react-ui/src/components/Charts/LineChartCondensed/index.ts b/packages/react-ui/src/components/Charts/LineChartCondensed/index.tsdeleted file mode 100644index 767111dfa..000000000--- a/packages/react-ui/src/components/Charts/LineChartCondensed/index.ts+++ /dev/null@@ -1,2 +0,0 @@-export * from "../LineChart/types";-export * from "./LineChartCondensed";diff --git a/packages/react-ui/src/components/Charts/LineChartCondensed/lineChartCondensed.scss b/packages/react-ui/src/components/Charts/LineChartCondensed/lineChartCondensed.scssdeleted file mode 100644index 0b621c2cb..000000000--- a/packages/react-ui/src/components/Charts/LineChartCondensed/lineChartCondensed.scss+++ /dev/null@@ -1,32 +0,0 @@-@use "../../../cssUtils" as cssUtils;--.openui-line-chart-condensed-container {- display: flex;- flex-direction: column;-}--.openui-line-chart-condensed-container-inner {- display: flex;- width: 100%;-}--.openui-line-chart-condensed-y-axis-container {- flex-shrink: 0;-}--.openui-line-chart-condensed {- width: 100%;- height: 100%;-- &-x-axis-label {- @include cssUtils.typography(label, extra-small);- color: cssUtils.$text-neutral-secondary;- text-align: center;- }-- &-y-axis-label {- @include cssUtils.typography(label, extra-small);- color: cssUtils.$text-neutral-secondary;- padding-bottom: cssUtils.$space-s;- }-}diff --git a/packages/react-ui/src/components/Charts/MiniAreaChart/MiniAreaChart.tsx b/packages/react-ui/src/components/Charts/MiniAreaChart/MiniAreaChart.tsxindex 7168615ec..9080d46e5 100644--- a/packages/react-ui/src/components/Charts/MiniAreaChart/MiniAreaChart.tsx+++ b/packages/react-ui/src/components/Charts/MiniAreaChart/MiniAreaChart.tsx@@ -1,38 +1,27 @@-import clsx from "clsx";-import { useEffect, useId, useMemo, useRef, useState } from "react";-import { Area, AreaChart as RechartsAreaChart, XAxis } from "recharts";-import { usePrintContext } from "../../../context/PrintContext";-import { AreaChartVariant } from "../AreaChart/types";-import { ChartConfig, ChartContainer } from "../Charts";+import { area, line } from "d3-shape";+import { useId } from "react";+import { useEffectiveAnimation } from "../hooks/core/useEffectiveAnimation";+import { MiniChartFrame } from "../shared/mini/MiniChartFrame";import {- DATA_KEY,- getRecentDataThatFits,- transformDataForChart,-} from "../utils/AreaAndLine/MiniAreaAndLineUtils";-import { getLineType } from "../utils/AreaAndLine/common";-import { useChartPalette, type PaletteName } from "../utils/PalletUtils";-import { get2dChartConfig } from "../utils/dataUtils";-import { MiniAreaChartData } from "./types";--export interface MiniAreaChartProps {- data: MiniAreaChartData;- theme?: PaletteName;- customPalette?: string[];- variant?: AreaChartVariant;- opacity?: number;- isAnimationActive?: boolean;- onAreaClick?: (data: any) => void;- size?: number | string;- className?: string;- areaColor?: string;- useGradient?: boolean;-}--export const MiniAreaChart = ({+ MINI_POINT_RADIUS,+ type MiniChartPoint,+ miniCurves,+ miniLineGeometry,+} from "../shared/mini/miniChartUtils";+import { CHART_CLASS_PREFIX } from "../utils/constants";+import { useChartPalette } from "../utils/paletteUtils";+import type { MiniAreaChartProps } from "./types";++const CLASS = `${CHART_CLASS_PREFIX}-mini-area-chart`;++/**+ * A compact, axis-free area sparkline: the most recent values that fit, one series, a gradient fill under a 1.5px+ * line.+ */+export function MiniAreaChart({data,- theme = "ocean",customPalette,- variant: areaChartVariant = "natural",+ variant = "natural",opacity = 0.5,isAnimationActive = false,onAreaClick,@@ -40,108 +29,71 @@ export const MiniAreaChart = ({className,areaColor,useGradient = true,-}: MiniAreaChartProps) => {- const printContext = usePrintContext();- isAnimationActive = printContext ? false : isAnimationActive;-- const containerRef = useRef<HTMLDivElement>(null);- const [containerWidth, setContainerWidth] = useState<number>(0);-- const variant = getLineType(areaChartVariant);-- useEffect(() => {- if (!containerRef.current) {- return () => {};- }-- const resizeObserver = new ResizeObserver((entries) => {- // there is only one entry in the entries array because we are only observing the chart container- for (const entry of entries) {- setContainerWidth(entry.contentRect.width);- }- });-- resizeObserver.observe(containerRef.current);-- return () => {- resizeObserver.disconnect();- };- }, []);-- // Get the most recent data that fits in the container- const filteredData = useMemo(() => {- return getRecentDataThatFits(data, containerWidth);- }, [data, containerWidth]);-- // Transform the filtered data to a consistent format for recharts- const chartData = useMemo(() => {- return transformDataForChart(filteredData);- }, [filteredData]);-- const colors = useChartPalette({- chartThemeName: theme,- customPalette: customPalette || (areaColor ? [areaColor] : undefined),+}: MiniAreaChartProps) {+ const animate = useEffectiveAnimation(isAnimationActive);+ const [color = ""] = useChartPalette({+ customPalette: customPalette ?? (areaColor ? [areaColor] : undefined),themePaletteName: "areaChartPalette",dataLength: 1,});-- const transformedKeys = useMemo(() => ({ [DATA_KEY]: DATA_KEY }), []);-- const chartConfig: ChartConfig = useMemo(() => {- return get2dChartConfig([DATA_KEY], colors, transformedKeys);- }, [colors, transformedKeys]);-- const id = useId();-- // Generate unique gradient ID to avoid conflicts when multiple charts are on the same page- const gradientId = useMemo(() => `miniAreaGradient-${id}`, [id]);- const color = `var(--color-${DATA_KEY})`;+ const gradientId = `${CLASS}-gradient-${useId().replace(/:/g, "")}`;+ const curve = miniCurves[variant] ?? miniCurves.natural;+ const animated = animate ? ` ${CHART_CLASS_PREFIX}-mini-chart-mark--animated` : "";return (- <ChartContainer- config={chartConfig}- style={{- width: size,- height: size,- aspectRatio: 1 / 1,- minHeight: 100,- minWidth: 100,- }}- rechartsProps={{- aspect: 1 / 1,+ <MiniChartFrame chart="area" size={size} className={className} onClick={onAreaClick}>+ {(width, height) => {+ const { points, x, y } = miniLineGeometry(data, width, height);+ const areaD =+ area<MiniChartPoint>()+ .x((_, i) => x(i))+ .y0(y(0))+ .y1((p) => y(p.value))+ .curve(curve)(points) ?? "";+ const lineD =+ line<MiniChartPoint>()+ .x((_, i) => x(i))+ .y((p) => y(p.value))+ .curve(curve)(points) ?? "";+ return (+ <>+ {useGradient && (+ <defs>+ <linearGradient id={gradientId} 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>+ )}+ <path+ className={`${CLASS}-area${animated}`}+ d={areaD}+ fill={useGradient ? `url(#${gradientId})` : color}+ fillOpacity={useGradient ? 1 : opacity}+ />+ <path+ className={`${CLASS}-line${animated}`}+ d={lineD}+ fill="none"+ stroke={color}+ strokeWidth={1.5}+ />+ {/* A single value has no area to draw: it's marked with a dot. */}+ {points.length === 1 && (+ <circle+ className={`${CLASS}-point${animated}`}+ cx={x(0)}+ cy={y(points[0]!.value)}+ r={MINI_POINT_RADIUS}+ fill={useGradient ? `url(#${gradientId})` : color}+ fillOpacity={useGradient ? 1 : opacity}+ stroke={color}+ strokeWidth={1.5}+ />+ )}+ </>+ );}}- onClick={onAreaClick}- ref={containerRef}- className={clsx("openui-charts-mini-area-chart-container", className)}- >- <RechartsAreaChart- accessibilityLayer- data={chartData}- margin={{- top: 10,- }}- >- {useGradient && (- <defs>- <linearGradient id={gradientId} 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>- )}-- <XAxis dataKey="label" hide={true} />-- <Area- dataKey={DATA_KEY}- type={variant}- stroke={color}- fill={useGradient ? `url(#${gradientId})` : color}- fillOpacity={useGradient ? 1 : opacity}- isAnimationActive={isAnimationActive}- strokeWidth={1.5}- />- </RechartsAreaChart>- </ChartContainer>+ </MiniChartFrame>);-};+}diff --git a/packages/react-ui/src/components/Charts/MiniAreaChart/dependencies.ts b/packages/react-ui/src/components/Charts/MiniAreaChart/dependencies.tsdeleted file mode 100644index 3b1962326..000000000--- a/packages/react-ui/src/components/Charts/MiniAreaChart/dependencies.ts+++ /dev/null@@ -1,2 +0,0 @@-const dependencies = ["MiniAreaChart"];-export default dependencies;diff --git a/packages/react-ui/src/components/Charts/MiniAreaChart/index.ts b/packages/react-ui/src/components/Charts/MiniAreaChart/index.tsindex 02e709aa0..bacf1d659 100644--- a/packages/react-ui/src/components/Charts/MiniAreaChart/index.ts+++ b/packages/react-ui/src/components/Charts/MiniAreaChart/index.ts@@ -1,2 +1,2 @@-export * from "./MiniAreaChart";-export * from "./types";+export { MiniAreaChart } from "./MiniAreaChart";+export type { MiniAreaChartData, MiniAreaChartProps } from "./types";diff --git a/packages/react-ui/src/components/Charts/MiniAreaChart/stories/MiniAreaChart.stories.tsx b/packages/react-ui/src/components/Charts/MiniAreaChart/stories/MiniAreaChart.stories.tsxindex 2f50bd5a6..8bf4661e3 100644--- a/packages/react-ui/src/components/Charts/MiniAreaChart/stories/MiniAreaChart.stories.tsx+++ b/packages/react-ui/src/components/Charts/MiniAreaChart/stories/MiniAreaChart.stories.tsx@@ -1,6 +1,6 @@import type { Meta, StoryObj } from "@storybook/react";+import { MiniAreaChart } from "../..";import { Card } from "../../../Card";-import { MiniAreaChart } from "../MiniAreaChart";// Simple array of numbers for 1D area chartconst simpleAreaChartData = [@@ -50,16 +50,6 @@ const meta: Meta<typeof MiniAreaChart> = {category: "Data",},},- theme: {- description:- "The color palette theme for the chart. Each theme provides a different color for the area.",- control: "select",- options: ["ocean", "orchid", "emerald", "sunset", "spectrum", "vivid"],- table: {- defaultValue: { summary: "ocean" },- category: "Appearance",- },- },variant: {description:"The interpolation method used to create the area curves. 'linear' creates straight lines between points, 'natural' creates smooth curves, and 'step' creates a stepped area.",@@ -126,7 +116,6 @@ export const SimpleNumberArray: Story = {name: "Simple Number Array (With Gradient)",args: {data: simpleAreaChartData,- theme: "ocean",variant: "natural",opacity: 0.5,useGradient: true,@@ -147,7 +136,6 @@ const activityData = [12, 45, 78, 32, 67, 89, 23, 56, 91, 34];<MiniAreaChartdata={activityData}- theme="ocean"variant="natural"useGradient={true}isAnimationActive={true}@@ -163,7 +151,6 @@ export const LabeledData: Story = {name: "Labeled Data (With Gradient)",args: {data: labeledAreaChartData,- theme: "emerald",variant: "natural",opacity: 0.6,useGradient: true,@@ -189,7 +176,6 @@ const revenueData = [<MiniAreaChartdata={revenueData}- theme="emerald"variant="natural"useGradient={true}size="100%"@@ -204,7 +190,6 @@ export const WithoutGradient: Story = {name: "Solid Fill (Without Gradient)",args: {data: simpleAreaChartData.slice(0, 15),- theme: "sunset",variant: "natural",opacity: 0.4,useGradient: false,@@ -223,7 +208,6 @@ export const WithoutGradient: Story = {code: `<MiniAreaChartdata={data}- theme="sunset"variant="natural"opacity={0.4}useGradient={false}@@ -245,7 +229,6 @@ export const GradientComparison: Story = {</h4><MiniAreaChartdata={[20, 45, 35, 80, 60, 90, 45, 70, 85, 30]}- theme="orchid"variant="natural"useGradient={true}size={200}@@ -255,7 +238,6 @@ export const GradientComparison: Story = {<h4 style={{ marginBottom: "12px", fontSize: "14px", fontWeight: "600" }}>Solid Fill</h4><MiniAreaChartdata={[20, 45, 35, 80, 60, 90, 45, 70, 85, 30]}- theme="orchid"variant="natural"useGradient={false}opacity={0.3}@@ -270,7 +252,6 @@ export const ResponsiveData: Story = {name: "Responsive Data Filtering",args: {data: simpleAreaChartData,- theme: "orchid",variant: "natural",opacity: 0.4,useGradient: true,@@ -303,49 +284,20 @@ export const DifferentSizes: Story = {<div style={{ display: "flex", gap: "20px", alignItems: "center" }}><Card style={{ width: "120px", padding: "12px" }}><h4 style={{ marginBottom: "8px", fontSize: "12px", fontWeight: "600" }}>Small</h4>- <MiniAreaChart data={[15, 25, 20, 35, 30, 18, 22]} theme="sunset" size={80} />+ <MiniAreaChart data={[15, 25, 20, 35, 30, 18, 22]} size={80} /></Card><Card style={{ width: "200px", padding: "16px" }}><h4 style={{ marginBottom: "12px", fontSize: "14px", fontWeight: "600" }}>Medium</h4>- <MiniAreaChart data={simpleAreaChartData.slice(0, 10)} theme="spectrum" size={160} />+ <MiniAreaChart data={simpleAreaChartData.slice(0, 10)} size={160} /></Card><Card style={{ width: "280px", padding: "20px" }}><h4 style={{ marginBottom: "16px", fontSize: "16px", fontWeight: "600" }}>Large</h4>- <MiniAreaChart data={simpleAreaChartData} theme="vivid" size={240} />+ <MiniAreaChart data={simpleAreaChartData} size={240} /></Card></div>),};-export const DifferentThemes: Story = {- name: "Different Themes (All With Gradients)",- render: () => (- <div style={{ display: "flex", gap: "20px", flexWrap: "wrap" }}>- {(["ocean", "orchid", "emerald", "sunset", "spectrum", "vivid"] as const).map((theme) => (- <Card key={theme} style={{ width: "200px", padding: "16px" }}>- <h4- style={{- marginBottom: "12px",- fontSize: "14px",- fontWeight: "600",- textTransform: "capitalize",- }}- >- {theme} Theme- </h4>- <MiniAreaChart- data={[15, 25, 20, 35, 30, 18, 22, 28, 33, 19]}- theme={theme}- variant="natural"- useGradient={true}- size={160}- />- </Card>- ))}- </div>- ),-};-export const DifferentVariants: Story = {name: "Different Variants",render: () => (@@ -364,7 +316,6 @@ export const DifferentVariants: Story = {</h4><MiniAreaChartdata={[15, 35, 25, 45, 30, 50, 28, 42, 38, 29]}- theme="spectrum"variant={variant}useGradient={true}size={180}@@ -379,7 +330,6 @@ export const CustomColor: Story = {name: "Custom Color with Gradient",args: {data: [20, 45, 28, 80, 99, 43, 67, 23, 89, 56],- theme: "ocean",variant: "natural",opacity: 0.7,areaColor: "#ff6b6b",diff --git a/packages/react-ui/src/components/D3Charts/MiniAreaChart/types.ts b/packages/react-ui/src/components/Charts/MiniAreaChart/types.tssimilarity index 100%rename from packages/react-ui/src/components/D3Charts/MiniAreaChart/types.tsrename to packages/react-ui/src/components/Charts/MiniAreaChart/types.tsdiff --git a/packages/react-ui/src/components/Charts/MiniAreaChart/types/index.ts b/packages/react-ui/src/components/Charts/MiniAreaChart/types/index.tsdeleted file mode 100644index 9a51c7451..000000000--- a/packages/react-ui/src/components/Charts/MiniAreaChart/types/index.ts+++ /dev/null@@ -1 +0,0 @@-export type MiniAreaChartData = Array<number> | Array<{ value: number; label?: string }>;diff --git a/packages/react-ui/src/components/Charts/MiniBarChart/MiniBarChart.tsx b/packages/react-ui/src/components/Charts/MiniBarChart/MiniBarChart.tsxindex ad7105c39..1fcd7baa3 100644--- a/packages/react-ui/src/components/Charts/MiniBarChart/MiniBarChart.tsx+++ b/packages/react-ui/src/components/Charts/MiniBarChart/MiniBarChart.tsx@@ -1,38 +1,24 @@-import clsx from "clsx";-import { useEffect, useMemo, useRef, useState } from "react";-import { Bar, BarChart, XAxis } from "recharts";-import { usePrintContext } from "../../../context/PrintContext";import { useTheme } from "../../ThemeProvider";-import { ChartConfig, ChartContainer } from "../Charts";-import { LineInBarShape } from "../shared";-import { useChartPalette, type PaletteName } from "../utils/PalletUtils";-import { get2dChartConfig } from "../utils/dataUtils";-import { type MiniBarChartData } from "./types";-import {- DATA_KEY,- getPadding,- getRecentDataThatFits,- MINI_BAR_WIDTH,- transformDataForChart,-} from "./utils/miniBarChartUtils";--export interface MiniBarChartProps {- data: MiniBarChartData;- theme?: PaletteName;- customPalette?: string[];- radius?: number;- isAnimationActive?: boolean;- onBarsClick?: (data: any) => void;- size?: number | string;- className?: string;- barColor?: string;-}--const MINI_BAR_CHART_INNER_LINE_WIDTH = 1;--export const MiniBarChart = ({+import { useEffectiveAnimation } from "../hooks/core/useEffectiveAnimation";+import { roundedBarPath } from "../shared/cartesian/roundedBarPath";+import { MiniChartFrame } from "../shared/mini/MiniChartFrame";+import { MINI_BAR_WIDTH, miniBarGeometry } from "../shared/mini/miniChartUtils";+import { CHART_CLASS_PREFIX } from "../utils/constants";+import { useChartPalette } from "../utils/paletteUtils";+import type { MiniBarChartProps } from "./types";++const CLASS = `${CHART_CLASS_PREFIX}-mini-bar-chart`;+// The thin line down each bar's middle, inset from both ends — shown only on+// bars tall enough to hold it.+const INNER_LINE_INSET = 6;+const INNER_LINE_MIN_HEIGHT = 8;++/**+ * Compact, axis-free bars: the most recent values that fit, 8px bars right-aligned, rounded outer corners, and+ * a thin inner line.+ */+export function MiniBarChart({data,- theme = "ocean",customPalette,radius = 1,isAnimationActive = false,@@ -40,98 +26,50 @@ export const MiniBarChart = ({size = "100%",className,barColor,-}: MiniBarChartProps) => {- const printContext = usePrintContext();- isAnimationActive = printContext ? false : isAnimationActive;-- const containerRef = useRef<HTMLDivElement>(null);- const [containerWidth, setContainerWidth] = useState<number>(0);-- useEffect(() => {- if (!containerRef.current) {- return () => {};- }-- const resizeObserver = new ResizeObserver((entries) => {- // there is only one entry in the entries array because we are only observing the chart container- for (const entry of entries) {- setContainerWidth(entry.contentRect.width);- }- });-- resizeObserver.observe(containerRef.current);-- return () => {- resizeObserver.disconnect();- };- }, []);-- // Get the most recent data that fits in the container- const filteredData = useMemo(() => {- return getRecentDataThatFits(data, containerWidth);- }, [data, containerWidth]);-- // Transform the filtered data to a consistent format for recharts- const chartData = useMemo(() => {- return transformDataForChart(filteredData);- }, [filteredData]);-- const colors = useChartPalette({- chartThemeName: theme,- customPalette: customPalette || (barColor ? [barColor] : undefined),+}: MiniBarChartProps) {+ const animate = useEffectiveAnimation(isAnimationActive);+ const [color = ""] = useChartPalette({+ customPalette: customPalette ?? (barColor ? [barColor] : undefined),themePaletteName: "barChartPalette",dataLength: 1,});-- const transformedKeys = useMemo(() => ({ [DATA_KEY]: DATA_KEY }), []);-- const chartConfig: ChartConfig = useMemo(() => {- return get2dChartConfig([DATA_KEY], colors, transformedKeys);- }, [colors, transformedKeys]);-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 innerLineColor = mode === "light" ? "rgba(255, 255, 255, 0.3)" : "rgba(0, 0, 0, 0.3)";+ const animated = animate ? ` ${CHART_CLASS_PREFIX}-mini-chart-mark--animated` : "";return (- <ChartContainer- config={chartConfig}- style={{- width: size,- height: size,- aspectRatio: 1 / 1,- minHeight: 100,- minWidth: 100,- }}- rechartsProps={{- aspect: 1 / 1,- }}- onClick={onBarsClick}- ref={containerRef}- className={clsx("openui-charts-mini-bar-chart-container", className)}- >- <BarChart accessibilityLayer data={chartData}>- <XAxis hide={true} padding={getPadding(filteredData, containerWidth)} />- <Bar- dataKey={DATA_KEY}- fill={`var(--color-${DATA_KEY})`}- radius={[radius, radius, 0, 0]}- isAnimationActive={isAnimationActive}- maxBarSize={MINI_BAR_WIDTH}- barSize={MINI_BAR_WIDTH}- shape={- <LineInBarShape- internalLineWidth={MINI_BAR_CHART_INNER_LINE_WIDTH}- internalLineColor={barInternalLineColor}- />- }- />- </BarChart>- </ChartContainer>+ <MiniChartFrame chart="bar" size={size} className={className} onClick={onBarsClick}>+ {(width, height) =>+ miniBarGeometry(data, width, height).map((bar, i) =>+ bar.height > 0 ? (+ <g key={i} className={`${CLASS}-bar-group${animated}`}>+ <path+ className={`${CLASS}-bar`}+ d={roundedBarPath(+ bar.x,+ bar.y,+ MINI_BAR_WIDTH,+ bar.height,+ bar.negative ? [0, 0, radius, radius] : [radius, radius, 0, 0],+ )}+ fill={color}+ />+ {bar.height >= INNER_LINE_MIN_HEIGHT && (+ <line+ className={`${CLASS}-inner-line`}+ x1={bar.x + MINI_BAR_WIDTH / 2}+ y1={bar.y + INNER_LINE_INSET}+ x2={bar.x + MINI_BAR_WIDTH / 2}+ y2={bar.y + bar.height - INNER_LINE_INSET}+ stroke={innerLineColor}+ strokeWidth={1}+ strokeLinecap="round"+ />+ )}+ </g>+ ) : null,+ )+ }+ </MiniChartFrame>);-};+}diff --git a/packages/react-ui/src/components/Charts/MiniBarChart/dependencies.ts b/packages/react-ui/src/components/Charts/MiniBarChart/dependencies.tsdeleted file mode 100644index ea021d98a..000000000--- a/packages/react-ui/src/components/Charts/MiniBarChart/dependencies.ts+++ /dev/null@@ -1,2 +0,0 @@-const dependencies = ["MiniBarChart"];-export default dependencies;diff --git a/packages/react-ui/src/components/Charts/MiniBarChart/index.ts b/packages/react-ui/src/components/Charts/MiniBarChart/index.tsindex 02620bc68..02c487261 100644--- a/packages/react-ui/src/components/Charts/MiniBarChart/index.ts+++ b/packages/react-ui/src/components/Charts/MiniBarChart/index.ts@@ -1,2 +1,2 @@-export * from "./MiniBarChart";-export * from "./types";+export { MiniBarChart } from "./MiniBarChart";+export type { MiniBarChartData, MiniBarChartProps } from "./types";diff --git a/packages/react-ui/src/components/Charts/MiniBarChart/stories/MiniBarChart.stories.tsx b/packages/react-ui/src/components/Charts/MiniBarChart/stories/MiniBarChart.stories.tsxindex 22e02ee31..93aa699cc 100644--- a/packages/react-ui/src/components/Charts/MiniBarChart/stories/MiniBarChart.stories.tsx+++ b/packages/react-ui/src/components/Charts/MiniBarChart/stories/MiniBarChart.stories.tsx@@ -1,7 +1,7 @@import type { Meta, StoryObj } from "@storybook/react";import { Monitor } from "lucide-react";+import { MiniBarChart, MiniBarChartProps } from "../..";import { Card } from "../../../Card";-import { MiniBarChart, MiniBarChartProps } from "../MiniBarChart";// Simple array of numbers for 1D bar chartconst simpleBarChartData = [@@ -56,16 +56,6 @@ const meta: Meta<MiniBarChartProps> = {category: "Data",},},- theme: {- description:- "The color palette theme for the chart. Each theme provides a different set of colors for the bars.",- control: "select",- options: ["ocean", "orchid", "emerald", "sunset", "spectrum", "vivid"],- table: {- defaultValue: { summary: "ocean" },- category: "Appearance",- },- },radius: {description: "The radius of the rounded corners of the bars",control: "number",@@ -103,7 +93,6 @@ export const SimpleNumberArray: Story = {name: "Simple Number Array",args: {data: simpleBarChartData,- theme: "ocean",radius: 2,isAnimationActive: true,size: "100%",@@ -124,7 +113,6 @@ const salesData = [2347891, 1893456, 3456789, 2987654, 1765432, 4321098];<MiniBarChartdata={salesData}- theme="ocean"radius={2}isAnimationActive={true}size={200}@@ -139,7 +127,6 @@ export const LabeledData: Story = {name: "Labeled Data",args: {data: labeledBarChartData,- theme: "emerald",radius: 1,isAnimationActive: true,size: 200,@@ -163,7 +150,6 @@ const revenueData = [<MiniBarChartdata={revenueData}- theme="emerald"radius={1}isAnimationActive={true}size={200}@@ -178,7 +164,6 @@ export const SmallSize: Story = {name: "Small Size",args: {data: [10, 20, 15, 30, 25, 35, 18],- theme: "sunset",radius: 1,isAnimationActive: true,size: 120,@@ -190,26 +175,3 @@ export const SmallSize: Story = {</Card>),};--export const DifferentThemes: Story = {- name: "Different Themes",- render: () => (- <div style={{ display: "flex", gap: "20px", flexWrap: "wrap" }}>- {(["ocean", "orchid", "emerald", "sunset", "spectrum", "vivid"] as const).map((theme) => (- <Card key={theme} style={{ width: "200px", padding: "16px" }}>- <h4- style={{- marginBottom: "12px",- fontSize: "14px",- fontWeight: "600",- textTransform: "capitalize",- }}- >- {theme} Theme- </h4>- <MiniBarChart data={[15, 25, 20, 35, 30, 18, 22]} theme={theme} radius={2} size={160} />- </Card>- ))}- </div>- ),-};diff --git a/packages/react-ui/src/components/D3Charts/MiniBarChart/types.ts b/packages/react-ui/src/components/Charts/MiniBarChart/types.tssimilarity index 100%rename from packages/react-ui/src/components/D3Charts/MiniBarChart/types.tsrename to packages/react-ui/src/components/Charts/MiniBarChart/types.tsdiff --git a/packages/react-ui/src/components/Charts/MiniBarChart/types/index.ts b/packages/react-ui/src/components/Charts/MiniBarChart/types/index.tsdeleted file mode 100644index 51f9a0492..000000000--- a/packages/react-ui/src/components/Charts/MiniBarChart/types/index.ts+++ /dev/null@@ -1 +0,0 @@-export type MiniBarChartData = Array<number> | Array<{ value: number; label?: string }>;diff --git a/packages/react-ui/src/components/Charts/MiniBarChart/utils/miniBarChartUtils.ts b/packages/react-ui/src/components/Charts/MiniBarChart/utils/miniBarChartUtils.tsdeleted file mode 100644index e93b6fcd6..000000000--- a/packages/react-ui/src/components/Charts/MiniBarChart/utils/miniBarChartUtils.ts+++ /dev/null@@ -1,97 +0,0 @@-import { type MiniBarChartData } from "../types";--export const MINI_BAR_WIDTH: number = 8;-export const MINI_ELEMENT_SPACING: number = 10;--const CONTAINER_HORIZONTAL_PADDING: number = 8; // 4px left + 4px right--/**- * Calculates the total width of the data.- *- * @param data - The mini bar chart data array- * @returns The total width needed in pixels to display all data items- */-const getWidthOfData = (data: MiniBarChartData) => {- return data.length * (MINI_ELEMENT_SPACING + MINI_BAR_WIDTH);-};--/**- * Calculates the left and right padding for the chart container based on available space.- * If the chart data exceeds the container width, no padding is applied.- *- * @param data - The mini bar chart data array- * @param containerWidth - The total width of the container in pixels- * @returns An object with left and right padding values in pixels- */-export const getPadding = (data: MiniBarChartData, containerWidth: number) => {- const availableWidth = containerWidth - CONTAINER_HORIZONTAL_PADDING;- const chartWidth = getWidthOfData(data);- const paddingValue = availableWidth - chartWidth;-- if (paddingValue < 0) {- return {- left: 0,- right: 0,- };- }- return {- left: paddingValue,- right: 0,- };-};--/**- * Filters the data to include only the most recent items that can fit within the container width.- * This function ensures the chart displays the latest data when space is limited.- *- * @param data - The complete mini bar chart data array- * @param containerWidth - The total width of the container in pixels- * @returns A filtered array containing only the most recent data items that fit in the container- */-export const getRecentDataThatFits = (- data: MiniBarChartData,- containerWidth: number,-): MiniBarChartData => {- if (containerWidth <= 0 || data.length === 0) {- return data;- }-- // Subtract padding to get actual available width for chart content- const availableWidth = containerWidth - CONTAINER_HORIZONTAL_PADDING;-- // Calculate how many items can fit in the available space- const itemWidth = MINI_BAR_WIDTH + MINI_ELEMENT_SPACING;- const maxItems = Math.floor(availableWidth / itemWidth);-- // If all items fit, return all data- if (maxItems >= data.length) {- return data;- }-- // Return the most recent items that fit- return data.slice(-maxItems);-};--type ChartData = Array<{- value: number;- label: string;-}>;--/**- * Transforms the mini bar chart data into a standardized format for rendering.- * Handles both numeric values and objects with value/label properties.- *- * @param data - The mini bar chart data array (can contain numbers or objects with value/label)- * @returns An array of chart data objects with value and label properties- */-export const transformDataForChart = (data: MiniBarChartData): ChartData => {- return data.map((item, index) => {- if (typeof item === "number") {- return { value: item, label: `Item ${index + 1}` };- } else {- return { value: item.value, label: item.label || `Item ${index + 1}` };- }- });-};--export const DATA_KEY = "value";diff --git a/packages/react-ui/src/components/Charts/MiniLineChart/MiniLineChart.tsx b/packages/react-ui/src/components/Charts/MiniLineChart/MiniLineChart.tsxindex c56025d89..eb7a1ec91 100644--- a/packages/react-ui/src/components/Charts/MiniLineChart/MiniLineChart.tsx+++ b/packages/react-ui/src/components/Charts/MiniLineChart/MiniLineChart.tsx@@ -1,128 +1,74 @@-import clsx from "clsx";-import { useEffect, useMemo, useRef, useState } from "react";-import { Line, LineChart as RechartsLineChart, XAxis } from "recharts";-import { usePrintContext } from "../../../context/PrintContext";-import { ChartConfig, ChartContainer } from "../Charts";-import { LineChartVariant } from "../LineChart/types";+import { line } from "d3-shape";+import { useEffectiveAnimation } from "../hooks/core/useEffectiveAnimation";+import { MiniChartFrame } from "../shared/mini/MiniChartFrame";import {- DATA_KEY,- getRecentDataThatFits,- transformDataForChart,-} from "../utils/AreaAndLine/MiniAreaAndLineUtils";-import { getLineType } from "../utils/AreaAndLine/common";-import { useChartPalette, type PaletteName } from "../utils/PalletUtils";-import { get2dChartConfig } from "../utils/dataUtils";-import { MiniLineChartData } from "./types";+ MINI_POINT_RADIUS,+ type MiniChartPoint,+ miniCurves,+ miniLineGeometry,+} from "../shared/mini/miniChartUtils";+import { CHART_CLASS_PREFIX } from "../utils/constants";+import { useChartPalette } from "../utils/paletteUtils";+import type { MiniLineChartProps } from "./types";-export interface MiniLineChartProps {- data: MiniLineChartData;- theme?: PaletteName;- customPalette?: string[];- variant?: LineChartVariant;- strokeWidth?: number;- isAnimationActive?: boolean;- onLineClick?: (data: any) => void;- size?: number | string;- className?: string;- lineColor?: string;-}+const CLASS = `${CHART_CLASS_PREFIX}-mini-line-chart`;-export const MiniLineChart = ({+/**+ * A compact, axis-free line sparkline: the most recent values that fit, one series, no dots.+ */+export function MiniLineChart({data,- theme = "ocean",customPalette,- variant: lineChartVariant = "natural",+ variant = "natural",strokeWidth = 2,- isAnimationActive = true,+ isAnimationActive = false,onLineClick,size = "100%",className,lineColor,-}: MiniLineChartProps) => {- const printContext = usePrintContext();- isAnimationActive = printContext ? false : isAnimationActive;-- const containerRef = useRef<HTMLDivElement>(null);- const [containerWidth, setContainerWidth] = useState<number>(0);-- const variant = getLineType(lineChartVariant);-- useEffect(() => {- if (!containerRef.current) {- return () => {};- }-- const resizeObserver = new ResizeObserver((entries) => {- for (const entry of entries) {- setContainerWidth(entry.contentRect.width);- }- });-- resizeObserver.observe(containerRef.current);-- return () => {- resizeObserver.disconnect();- };- }, []);-- // Get the most recent data that fits in the container- const filteredData = useMemo(() => {- return getRecentDataThatFits(data, containerWidth);- }, [data, containerWidth]);-- // Transform the filtered data to a consistent format for recharts- const chartData = useMemo(() => {- return transformDataForChart(filteredData);- }, [filteredData]);-- const colors = useChartPalette({- chartThemeName: theme,- customPalette: customPalette || (lineColor ? [lineColor] : undefined),+}: MiniLineChartProps) {+ const animate = useEffectiveAnimation(isAnimationActive);+ const [color = ""] = useChartPalette({+ customPalette: customPalette ?? (lineColor ? [lineColor] : undefined),themePaletteName: "lineChartPalette",dataLength: 1,});-- const transformedKeys = useMemo(() => ({ [DATA_KEY]: DATA_KEY }), []);-- const chartConfig: ChartConfig = useMemo(() => {- return get2dChartConfig([DATA_KEY], colors, transformedKeys);- }, [colors, transformedKeys]);+ const curve = miniCurves[variant] ?? miniCurves.natural;+ const animated = animate ? ` ${CHART_CLASS_PREFIX}-mini-chart-mark--animated` : "";return (- <ChartContainer- config={chartConfig}- style={{- width: size,- height: size,- aspectRatio: 1 / 1,- minHeight: 100,- minWidth: 100,+ <MiniChartFrame chart="line" size={size} className={className} onClick={onLineClick}>+ {(width, height) => {+ const { points, x, y } = miniLineGeometry(data, width, height);+ const lineD =+ line<MiniChartPoint>()+ .x((_, i) => x(i))+ .y((p) => y(p.value))+ .curve(curve)(points) ?? "";+ // A single value has no line to draw: it's marked with a dot.+ const single = points.length === 1 ? points[0] : undefined;+ return (+ <>+ <path+ className={`${CLASS}-line${animated}`}+ d={lineD}+ fill="none"+ stroke={color}+ strokeWidth={strokeWidth}+ />+ {single && (+ <circle+ className={`${CLASS}-point${animated}`}+ cx={x(0)}+ cy={y(single.value)}+ r={MINI_POINT_RADIUS}+ stroke={color}+ strokeWidth={strokeWidth}+ />+ )}+ </>+ );}}- rechartsProps={{- aspect: 1 / 1,- }}- onClick={onLineClick}- ref={containerRef}- className={clsx("openui-charts-mini-line-chart-container", className)}- >- <RechartsLineChart- accessibilityLayer- data={chartData}- margin={{- top: 10,- }}- >- <XAxis dataKey="label" hide={true} />-- <Line- dataKey={DATA_KEY}- type={variant}- stroke={`var(--color-${DATA_KEY})`}- strokeWidth={strokeWidth}- dot={false}- isAnimationActive={isAnimationActive}- />- </RechartsLineChart>- </ChartContainer>+ </MiniChartFrame>);-};+}diff --git a/packages/react-ui/src/components/Charts/MiniLineChart/dependencies.ts b/packages/react-ui/src/components/Charts/MiniLineChart/dependencies.tsdeleted file mode 100644index 573358a14..000000000--- a/packages/react-ui/src/components/Charts/MiniLineChart/dependencies.ts+++ /dev/null@@ -1,2 +0,0 @@-const dependencies = ["MiniLineChart"];-export default dependencies;diff --git a/packages/react-ui/src/components/Charts/MiniLineChart/index.ts b/packages/react-ui/src/components/Charts/MiniLineChart/index.tsindex c489b3a1b..7faf3a5cb 100644--- a/packages/react-ui/src/components/Charts/MiniLineChart/index.ts+++ b/packages/react-ui/src/components/Charts/MiniLineChart/index.ts@@ -1,2 +1,2 @@-export * from "./MiniLineChart";-export * from "./types";+export { MiniLineChart } from "./MiniLineChart";+export type { MiniLineChartData, MiniLineChartProps } from "./types";diff --git a/packages/react-ui/src/components/Charts/MiniLineChart/stories/MiniLineChart.stories.tsx b/packages/react-ui/src/components/Charts/MiniLineChart/stories/MiniLineChart.stories.tsxindex 67ee48e1b..5090664ce 100644--- a/packages/react-ui/src/components/Charts/MiniLineChart/stories/MiniLineChart.stories.tsx+++ b/packages/react-ui/src/components/Charts/MiniLineChart/stories/MiniLineChart.stories.tsx@@ -1,6 +1,6 @@import type { Meta, StoryObj } from "@storybook/react";+import { MiniLineChart } from "../..";import { Card } from "../../../Card";-import { MiniLineChart } from "../MiniLineChart";// Simple array of numbers for 1D line chartconst simpleLineChartData = [@@ -48,16 +48,6 @@ const meta: Meta<typeof MiniLineChart> = {category: "Data",},},- theme: {- description:- "The color palette theme for the chart. Each theme provides a different color for the line.",- control: "select",- options: ["ocean", "orchid", "emerald", "sunset", "spectrum", "vivid"],- table: {- defaultValue: { summary: "ocean" },- category: "Appearance",- },- },variant: {description:"The interpolation method used to create the line curves. 'linear' creates straight lines between points, 'natural' creates smooth curves, and 'step' creates a stepped line.",@@ -113,7 +103,6 @@ export const SimpleNumberArray: Story = {name: "Simple Number Array",args: {data: simpleLineChartData,- theme: "ocean",variant: "natural",strokeWidth: 2,isAnimationActive: true,@@ -133,7 +122,6 @@ const activityData = [12, 45, 78, 32, 67, 89, 23, 56, 91, 34];<MiniLineChartdata={activityData}- theme="ocean"variant="natural"strokeWidth={2}isAnimationActive={true}@@ -149,7 +137,6 @@ export const LabeledData: Story = {name: "Labeled Data",args: {data: labeledLineChartData,- theme: "emerald",variant: "natural",strokeWidth: 2,isAnimationActive: true,@@ -174,7 +161,6 @@ const revenueData = [<MiniLineChartdata={revenueData}- theme="emerald"variant="natural"strokeWidth={2}size="100%"diff --git a/packages/react-ui/src/components/D3Charts/MiniLineChart/types.ts b/packages/react-ui/src/components/Charts/MiniLineChart/types.tssimilarity index 100%rename from packages/react-ui/src/components/D3Charts/MiniLineChart/types.tsrename to packages/react-ui/src/components/Charts/MiniLineChart/types.tsdiff --git a/packages/react-ui/src/components/Charts/MiniLineChart/types/index.ts b/packages/react-ui/src/components/Charts/MiniLineChart/types/index.tsdeleted file mode 100644index 59487ff9f..000000000--- a/packages/react-ui/src/components/Charts/MiniLineChart/types/index.ts+++ /dev/null@@ -1 +0,0 @@-export type MiniLineChartData = Array<number> | Array<{ value: number; label?: string }>;diff --git a/packages/react-ui/src/components/Charts/PieChart/PieChart.tsx b/packages/react-ui/src/components/Charts/PieChart/PieChart.tsxindex da669c8a6..70c40ed54 100644--- a/packages/react-ui/src/components/Charts/PieChart/PieChart.tsx+++ b/packages/react-ui/src/components/Charts/PieChart/PieChart.tsx@@ -1,504 +1,185 @@-import clsx from "clsx";-import { memo, useCallback, useLayoutEffect, useMemo, useRef, useState } from "react";-import { Cell, Pie, PieChart as RechartsPieChart } from "recharts";-import { usePrintContext } from "../../../context/PrintContext.js";-import { useTheme } from "../../ThemeProvider/ThemeProvider.js";-import { ChartContainer, ChartTooltip, ChartTooltipContent } from "../Charts.js";-import { useExportChartData, useTransformedKeys } from "../hooks/index.js";-import { DefaultLegend } from "../shared/DefaultLegend/DefaultLegend.js";-import { StackedLegend } from "../shared/StackedLegend/StackedLegend.js";-import { LegendItem } from "../types/Legend.js";-import { getCategoricalChartConfig } from "../utils/dataUtils.js";-import { PaletteName, useChartPalette } from "../utils/PalletUtils.js";-import { PieChartData } from "./types/index.js";-import {- calculateChartDimensions,- calculateTwoLevelChartDimensions,- createAnimationConfig,- createEventHandlers,- getHoverStyles,- transformDataWithPercentages,- useChartHover,-} from "./utils/PieChartUtils.js";+import { arc, pie, type PieArcDatum } from "d3-shape";+import { useMemo } from "react";-export interface PieChartProps<T extends PieChartData> {- data: T;- categoryKey: keyof T[number];- dataKey: keyof T[number];- theme?: PaletteName;- customPalette?: string[];- variant?: "pie" | "donut";- format?: "percentage" | "number";- legend?: boolean;- legendVariant?: "default" | "stacked";- isAnimationActive?: boolean;- appearance?: "circular" | "semiCircular";- cornerRadius?: number;- paddingAngle?: number;- onMouseEnter?: (data: any, index: number) => void;- onMouseLeave?: () => void;- onClick?: (data: any, index: number) => void;- className?: string;- maxChartSize?: number;- minChartSize?: number;- // Add height and width props- height?: number | string;- width?: number | string;+import {+ type CategoricalSlice,+ useCategoricalChartOrchestrator,+ useEffectiveAnimation,+ useExportChartData,+} from "../hooks";+import { ChartShell } from "../shared/core/ChartShell";+import { DefaultLegend } from "../shared/core/DefaultLegend/DefaultLegend";+import { useResolvedLegendKey } from "../shared/core/legend/LegendStoreProvider";+import { ChartTooltip } from "../shared/core/PortalTooltip/ChartTooltip";+import { ChartWithStackedLegend } from "../shared/core/StackedLegend/ChartWithStackedLegend";+import { CHART_CLASS_PREFIX } from "../utils/constants";+import { PieSlices } from "./parts/PieSlices";+import type { PieChartData, PieChartProps } from "./types";++/**+ * `legendVariant="stacked"` (the default) lays the chart out with its built-in stacked legend. The inline legend is+ * used for `"default"`, and none when the chart publishes to an external+ * legend (`legendKey`, or a surrounding `LegendStoreProvider`'s key).+ */+export function PieChart<T extends PieChartData>(props: PieChartProps<T>) {+ const { legend = true, legendVariant = "stacked", legendKey, width, height, className } = props;+ const externalLegendKey = useResolvedLegendKey(legendKey);++ if (legend && legendVariant === "stacked" && externalLegendKey === undefined) {+ return (+ <ChartWithStackedLegend width={width} height={height} className={className}>+ <PieChartImpl {...props} width={undefined} height={undefined} className={undefined} />+ </ChartWithStackedLegend>+ );+ }+ return <PieChartImpl {...props} />;}-const STACKED_LEGEND_BREAKPOINT = 400;-const MIN_CHART_SIZE = 150;-const MAX_CHART_SIZE = 500;-const CORNER_RADIUS = 0;--const PieChartComponent = <T extends PieChartData>({- data,- categoryKey,- dataKey,- theme = "ocean",- customPalette,- variant = "pie",- format = "number",- legend = true,- legendVariant = "stacked",- isAnimationActive = true,- appearance = "circular",- cornerRadius,- paddingAngle = 0,- onMouseEnter,- onMouseLeave,- onClick,- className,- maxChartSize = MAX_CHART_SIZE,- minChartSize = MIN_CHART_SIZE,- height,- width,-}: PieChartProps<T>) => {- const printContext = usePrintContext();- isAnimationActive = printContext ? false : isAnimationActive;-- const wrapperRef = useRef<HTMLDivElement>(null);- const [wrapperRect, setWrapperRect] = useState({ width: 0, height: 0 });- const [hoveredLegendKey, setHoveredLegendKey] = useState<string | null>(null);- const [isLegendExpanded, setIsLegendExpanded] = useState(false);- const { activeIndex, handleMouseEnter, handleMouseLeave } = useChartHover();- const { theme: userTheme } = useTheme();-- // Determine layout mode based on container width- const isRowLayout =- legend && legendVariant === "stacked" && wrapperRect.width >= STACKED_LEGEND_BREAKPOINT;-- // Sort data by value (highest to lowest) for pie chart rendering- const sortedProcessedData = useMemo(- () => [...data].sort((a, b) => Number(b[dataKey]) - Number(a[dataKey])),- [data, dataKey],- );-- const categories = useMemo(- () => sortedProcessedData.map((item) => String(item[categoryKey])),- [sortedProcessedData, categoryKey],- );- const transformedKeys = useTransformedKeys(categories);-- // Memoize string conversions to avoid repeated calls- const categoryKeyString = useMemo(() => String(categoryKey), [categoryKey]);- const dataKeyString = useMemo(() => String(dataKey), [dataKey]);- const formatKey = useMemo(- () => (format === "percentage" ? "percentage" : dataKeyString),- [format, dataKeyString],- );-- // Use provided dimensions or observed dimensions from the wrapper- const effectiveWidth = wrapperRect.width;- const effectiveHeight = wrapperRect.height;-- // Calculate chart dimensions based on the smaller dimension of the container- const chartSize = useMemo(() => {- // Compute the available width for the chart. In row layout, chart and legend are side-by-side.- // Subtract the 20px gap defined in CSS to avoid over-estimating available width.- const containerWidth = isRowLayout ? Math.max(0, (effectiveWidth - 20) / 2) : effectiveWidth;-- // If wrapper height isn't explicitly provided (or is very small), it will be driven by the- // chart's own content, creating a feedback loop that pins the size to the minimum.- // Prefer width in that case to size the chart sensibly.- const heightIsUsable = effectiveHeight >= minChartSize;-- let size = heightIsUsable ? Math.min(containerWidth, effectiveHeight) : containerWidth;- size = Math.min(size, maxChartSize);- return Math.max(minChartSize, size);- }, [effectiveWidth, effectiveHeight, isRowLayout]);+function PieChartImpl<T extends PieChartData>(props: PieChartProps<T>) {+ const {+ data,+ categoryKey,+ dataKey,+ customPalette,+ variant = "pie",+ appearance = "circular",+ format = "number",+ legend: showLegend = true,+ isAnimationActive = false,+ cornerRadius = 0,+ paddingAngle = 0,+ maxChartSize = 500,+ minChartSize = 150,+ height,+ width,+ fitLegendInHeight,+ className,+ onClick,+ legendKey,+ } = props;const isSemiCircular = appearance === "semiCircular";- const chartViewportHeight = useMemo(- () => (isSemiCircular ? Math.max(1, Math.ceil(chartSize / 2)) : chartSize),- [chartSize, isSemiCircular],- );- const chartSizeStyle = useMemo(- () => ({ width: chartSize, height: chartViewportHeight }),- [chartSize, chartViewportHeight],- );- const rechartsProps = useMemo(- () => ({- width: "100%",- height: "100%",- minWidth: 1,- minHeight: 1,- initialDimension: { width: 1, height: 1 },- }),- [],- );- const colors = useChartPalette({- chartThemeName: theme,- customPalette,+ const orch = useCategoricalChartOrchestrator({+ data,+ categoryKey,+ dataKey,themePaletteName: "pieChartPalette",- dataLength: sortedProcessedData.length,- });-- const exportData = useExportChartData({- type: "pie",- data: sortedProcessedData,- categoryKey: categoryKey as string,- dataKeys: [dataKey as string],- colors,- legend,+ customPalette,+ format,+ showLegend,+ isSemiCircular,+ maxChartSize,+ minChartSize,+ height,+ width,+ fitLegendInHeight,+ legendKey,});- // Memoize expensive data transformations and configurations- const transformedData = useMemo(- () => transformDataWithPercentages(sortedProcessedData as T, dataKey),- [sortedProcessedData, dataKey],- );+ const animate = useEffectiveAnimation(isAnimationActive);- const chartConfig = useMemo(- () => getCategoricalChartConfig(sortedProcessedData as T, categoryKey, colors, transformedKeys),- [sortedProcessedData, categoryKey, colors, transformedKeys],- );+ // Pie-specific geometry+ const outerRadius = orch.dimensions.chartSize * 0.45;+ const innerRadius = variant === "donut" ? outerRadius * 0.6 : 0;- const animationConfig = useMemo(- () => createAnimationConfig({ isAnimationActive }),- [isAnimationActive],- );+ const startAngle = isSemiCircular ? -Math.PI / 2 : 0;+ const endAngle = isSemiCircular ? Math.PI / 2 : 2 * Math.PI;- const eventHandlers = useMemo(- () => createEventHandlers(onMouseEnter, onMouseLeave, onClick),- [onMouseEnter, onMouseLeave, onClick],- );-- const sectorStyle = useMemo(() => {- let cornerRadiusValue: number = CORNER_RADIUS;-- if (typeof cornerRadius === "number") {- cornerRadiusValue = cornerRadius;- } else {- const cornerRadiusTheme = userTheme.radius2xs;- if (cornerRadiusTheme) {- cornerRadiusValue =- typeof cornerRadiusTheme === "string" ? parseInt(cornerRadiusTheme) : cornerRadiusTheme;- }- }-- return {- cornerRadius: cornerRadiusValue,- paddingAngle: variant === "donut" ? 0.5 : paddingAngle,- };- }, [cornerRadius, variant, paddingAngle, userTheme.radius2xs]);-- const legendItems = useMemo(+ const pieGenerator = useMemo(() =>- sortedProcessedData.map((item, index) => ({- key: String(item[categoryKey]),- label: String(item[categoryKey]),- value: Number(item[dataKey]),- color: colors[index] || "#000000",- })),- [sortedProcessedData, categoryKey, dataKey, colors],- );-- const defaultLegendItems = useMemo((): LegendItem[] => {- return legendItems.map(({ key, label, color }) => ({ key, label, color }));- }, [legendItems]);-- const handleLegendItemHover = useCallback(- (index: number | null) => {- if (legendVariant !== "stacked") return;- if (index !== null) {- const item = sortedProcessedData[index];- if (item) {- const categoryValue = String(item[categoryKey]);- setHoveredLegendKey(categoryValue);- const transformedIndex = transformedData.findIndex(- (d) => String((d as any)[categoryKey]) === categoryValue,- );- if (transformedIndex !== -1) {- handleMouseEnter(transformedData[transformedIndex], transformedIndex);- }- }- } else {- setHoveredLegendKey(null);- handleMouseLeave();- }- },- [- sortedProcessedData,- categoryKey,- transformedData,- handleMouseEnter,- handleMouseLeave,- legendVariant,- ],- );-- const handleChartMouseEnter = useCallback(- (entry: any, index: number) => {- handleMouseEnter(entry, index);- if (legend && legendVariant === "stacked") {- setHoveredLegendKey(String(entry[categoryKey]));- }- eventHandlers.onMouseEnter?.(entry, index);- },- [handleMouseEnter, categoryKey, legend, legendVariant, eventHandlers.onMouseEnter],- );-- const handleChartMouseLeave = useCallback(() => {- handleMouseLeave();- if (legend && legendVariant === "stacked") {- setHoveredLegendKey(null);- }- eventHandlers.onMouseLeave?.();- }, [handleMouseLeave, legend, legendVariant, eventHandlers.onMouseLeave]);-- const dimensions = useMemo(() => {- if (variant === "donut") {- return calculateTwoLevelChartDimensions(chartSize);- }- if (isSemiCircular) {- return { ...calculateChartDimensions(chartSize, variant), middleRadius: 0 };- }- return { outerRadius: "90%", innerRadius: 0, middleRadius: 0 };- }, [variant, chartSize, isSemiCircular]);-- const startAngle = useMemo(() => (appearance === "semiCircular" ? 180 : 0), [appearance]);- const endAngle = useMemo(() => (appearance === "semiCircular" ? 0 : 360), [appearance]);-- const commonPieProps = useMemo(- () => ({- data: transformedData,- dataKey: formatKey,- nameKey: categoryKeyString,- labelLine: false,- label: false,- ...animationConfig,- ...eventHandlers,- ...sectorStyle,- startAngle,- endAngle,- cx: "50%",- cy: isSemiCircular ? chartViewportHeight : "50%",- onMouseEnter: handleChartMouseEnter,- onMouseLeave: handleChartMouseLeave,- }),- [- transformedData,- formatKey,- categoryKeyString,- animationConfig,- eventHandlers,- sectorStyle,- startAngle,- endAngle,- isSemiCircular,- chartViewportHeight,- handleChartMouseEnter,- handleChartMouseLeave,- ],+ pie<CategoricalSlice>()+ .value((d) => d.value)+ .sort(null)+ .startAngle(startAngle)+ .endAngle(endAngle)+ .padAngle((paddingAngle * Math.PI) / 180),+ [startAngle, endAngle, paddingAngle],);- // Use ResizeObserver for subsequent size changes- useLayoutEffect(() => {- const wrapper = wrapperRef.current;- if (!wrapper) return;-- const observer = new ResizeObserver((entries) => {- const entry = entries[0];- if (entry) {- setWrapperRect({- width: entry.contentRect.width,- height: entry.contentRect.height,- });- }- });- observer.observe(wrapper);-- // Read initial dimensions synchronously before first paint to avoid size jump- const rect = wrapper.getBoundingClientRect();- setWrapperRect({ width: rect.width, height: rect.height });- return () => observer.disconnect();- }, []);-- const renderPieCharts = useCallback(() => {- if (variant === "donut") {- return [- <Pie- key="inner-pie"- {...commonPieProps}- innerRadius={dimensions.innerRadius}- outerRadius={dimensions.middleRadius}- >- {transformedData.map((entry, index: number) => {- const categoryValue = String(entry[categoryKey as keyof typeof entry] || "");- const transformedKey = transformedKeys[categoryValue] ?? categoryValue;- const config = chartConfig[transformedKey];- const hoverStyles = getHoverStyles(index, activeIndex);- const fill = config?.color || colors[index];- return (- <Cell- key={`inner-cell-${index}`}- fill={fill}- {...hoverStyles}- stroke="none"- className="openui-pie-chart__inner-cell"- />- );- })}- </Pie>,- <Pie- key="outer-pie"- {...commonPieProps}- innerRadius={dimensions.middleRadius}- outerRadius={dimensions.outerRadius}- >- {transformedData.map((entry, index: number) => {- const categoryValue = String(entry[categoryKey as keyof typeof entry] || "");- const transformedKey = transformedKeys[categoryValue] ?? categoryValue;- const config = chartConfig[transformedKey];- const hoverStyles = getHoverStyles(index, activeIndex);- const fill = config?.color || colors[index];- return <Cell key={`outer-cell-${index}`} fill={fill} {...hoverStyles} stroke="none" />;- })}- </Pie>,- ];- }- return (- <Pie- {...commonPieProps}- outerRadius={dimensions.outerRadius}- innerRadius={dimensions.innerRadius}- activeIndex={activeIndex ?? undefined}- >- {transformedData.map((entry, index: number) => {- const categoryValue = String(entry[categoryKey as keyof typeof entry] || "");- const transformedKey = transformedKeys[categoryValue] ?? categoryValue;- const config = chartConfig[transformedKey];- const hoverStyles = getHoverStyles(index, activeIndex);- const fill = config?.color || colors[index];- return <Cell key={`cell-${index}`} fill={fill} {...hoverStyles} stroke="none" />;- })}- </Pie>- );- }, [- variant,- commonPieProps,- dimensions,- transformedData,- categoryKey,- chartConfig,- activeIndex,- colors,- transformedKeys,- ]);-- const renderLegend = useCallback(() => {- if (!legend) return null;- if (legendVariant === "stacked") {- return (- <div className="openui-pie-chart-legend-container">- <StackedLegend- items={legendItems}- onItemHover={setHoveredLegendKey}- activeKey={hoveredLegendKey}- onLegendItemHover={handleLegendItemHover}- containerWidth={isRowLayout ? undefined : wrapperRect.width}- />- </div>- );- }- return (- <DefaultLegend- items={defaultLegendItems}- containerWidth={wrapperRect.width}- isExpanded={isLegendExpanded}- setIsExpanded={setIsLegendExpanded}- />- );- }, [- legend,- legendVariant,- legendItems,- hoveredLegendKey,- handleLegendItemHover,- wrapperRect.width,- isRowLayout,- defaultLegendItems,- isLegendExpanded,- ]);-- const wrapperClassName = useMemo(+ const arcGenerator = useMemo(() =>- clsx("openui-pie-chart-container-wrapper", className, {- "layout-row": isRowLayout,- "layout-column": !isRowLayout,- "legend-default": legend && legendVariant === "default",- "legend-stacked": legend && legendVariant === "stacked",- }),- [className, legend, legendVariant, isRowLayout],+ arc<unknown, PieArcDatum<CategoricalSlice>>()+ .innerRadius(innerRadius)+ .outerRadius(outerRadius)+ .cornerRadius(cornerRadius),+ [innerRadius, outerRadius, cornerRadius],);- const wrapperStyle = useMemo(() => {- const formatDimension = (value: number | string | undefined) => {- if (typeof value === "number") {- return `${value}px`;- }- return value;- };- const dimensions = {- width: formatDimension(width),- height: formatDimension(height),- };+ const arcs = useMemo(+ () => pieGenerator(orch.data.visibleSlices),+ [pieGenerator, orch.data.visibleSlices],+ );- return dimensions;- }, [width, height]);+ // PPTX print-export JSON — mirrors react-ui's PieChart call (type:'pie',+ // single series = [dataKey], no extraOptions). Colors are the resolved slice+ // palette in sorted-data order. Undefined off the print path.+ const exportData = useExportChartData({+ type: "pie",+ data: orch.data.sortedData,+ categoryKey: orch.data.catKey,+ dataKeys: [orch.data.valKey],+ colors: orch.data.slices.map((s) => s.color),+ legend: showLegend,+ });return (- <div- ref={wrapperRef}- className={wrapperClassName}- style={wrapperStyle}- data-openui-chart={exportData}+ <ChartShell+ containerRef={orch.refs.containerRef}+ classPrefix={`${CHART_CLASS_PREFIX}-pie-chart`}+ className={className}+ style={orch.style.containerStyle}+ isEmpty={orch.isEmpty}+ exportData={exportData}>- <div className="openui-pie-chart-container">- <div className="openui-pie-chart-container-inner">- <div style={chartSizeStyle}>- <ChartContainer- config={chartConfig}- className="openui-pie-chart"- rechartsProps={rechartsProps}+ {() => (+ <>+ <div className={`${CHART_CLASS_PREFIX}-pie-chart-svg-wrapper`}>+ <svg+ width={orch.dimensions.svgWidth}+ height={orch.dimensions.svgHeight}+ viewBox={`0 0 ${orch.dimensions.svgWidth} ${orch.dimensions.svgHeight}`}+ role="img"+ aria-label="Pie chart">- <RechartsPieChart>- <ChartTooltip- content={<ChartTooltipContent showPercentage={format === "percentage"} />}+ <g transform={`translate(${orch.dimensions.centerX}, ${orch.dimensions.centerY})`}>+ <PieSlices+ arcs={arcs}+ arcGenerator={arcGenerator}+ slices={orch.data.visibleSlices}+ hoveredIndex={orch.hover.hoveredIndex}+ entrance={animate}+ staticRender={orch.isPrinting}+ data={orch.data.visibleRows}+ onMouseMove={orch.hover.handleMouseMove}+ onMouseLeave={orch.hover.handleMouseLeave}+ onClick={onClick}/>- {renderPieCharts()}- </RechartsPieChart>- </ChartContainer>+ </g>+ </svg></div>- </div>- </div>- {renderLegend()}- </div>- );-};--export const PieChart = memo(PieChartComponent);-PieChart.displayName = "PieChart";+ {showLegend && !orch.usesRemoteLegend && (+ <DefaultLegend+ ref={orch.refs.legendRef}+ items={orch.data.legendItems}+ containerWidth={orch.dimensions.containerWidth}+ isExpanded={orch.legend.isLegendExpanded}+ setIsExpanded={orch.legend.setIsLegendExpanded}+ onItemClick={orch.data.toggleSlice}+ hiddenSeries={orch.data.hiddenSlices}+ />+ )}++ {orch.tooltip.tooltipPayload && orch.hover.mousePos && (+ <ChartTooltip+ label={orch.tooltip.tooltipPayload.label}+ items={orch.tooltip.tooltipPayload.items}+ viewportPosition={orch.hover.mousePos}+ />+ )}+ </>+ )}+ </ChartShell>+ );+}diff --git a/packages/react-ui/src/components/Charts/PieChart/index.ts b/packages/react-ui/src/components/Charts/PieChart/index.tsindex d4a4262d5..713249dea 100644--- a/packages/react-ui/src/components/Charts/PieChart/index.ts+++ b/packages/react-ui/src/components/Charts/PieChart/index.ts@@ -1,2 +1,2 @@-export * from "./PieChart";-export * from "./types";+export { PieChart } from "./PieChart";+export type { PieChartData, PieChartProps } from "./types";diff --git a/packages/react-ui/src/components/D3Charts/PieChart/parts/PieSlices.tsx b/packages/react-ui/src/components/Charts/PieChart/parts/PieSlices.tsxsimilarity index 100%rename from packages/react-ui/src/components/D3Charts/PieChart/parts/PieSlices.tsxrename to packages/react-ui/src/components/Charts/PieChart/parts/PieSlices.tsxdiff --git a/packages/react-ui/src/components/Charts/PieChart/pieChart.scss b/packages/react-ui/src/components/Charts/PieChart/pieChart.scssindex 27b276bd4..8fac0e63a 100644--- a/packages/react-ui/src/components/Charts/PieChart/pieChart.scss+++ b/packages/react-ui/src/components/Charts/PieChart/pieChart.scss@@ -1,94 +1,27 @@-@use "../../../cssUtils" as cssUtils;+@use "../shared/cartesian/chartBase" as base;+@use "../prefix" as brand;-// Main wrapper for the entire chart component-.openui-pie-chart-container-wrapper {- display: flex;- position: relative;- gap: 20px;+@include base.centered-container("pie-chart");+@include base.centered-svg-wrapper("pie-chart");- // Default legend is always a column layout- &.legend-default {- flex-direction: column;- align-items: center;- }-- // Stacked legend uses a column layout by default (mobile-first)- &.legend-stacked.layout-column {- flex-direction: column;- align-items: center;- }-- // Switches to a row layout on wider containers- &.legend-stacked.layout-row {- flex-direction: row;- align-items: center;- min-height: 296px;-- .openui-pie-chart-legend-container {- height: 296px;-- // Vertically center stacked legend content alongside the pie.- .openui-stacked-legend-container {- justify-content: center;- }-- .openui-stacked-legend {- height: auto;- max-height: 100%;- }- }+// Entrances are decorative: gate the whole rule (pre-state included) behind+// reduced-motion so users who opt out get the natural static state immediately+// — gating only the animation would strand elements at the opacity: 0 start.+@media (prefers-reduced-motion: no-preference) {+ .#{brand.$prefix}-pie-chart-slice--animated {+ opacity: 0;+ transform-origin: center center;+ animation: #{brand.$prefix}-pie-appear 0.6s ease-out forwards;}}-// Container for the chart itself-.openui-pie-chart-container {- display: flex;- align-items: center;- justify-content: center;- width: 100%;- height: 100%;- position: relative;-- // When in a row layout, the chart container should be flexible- .layout-row & {- flex: 1;- min-width: 0;+@keyframes #{brand.$prefix}-pie-appear {+ from {+ opacity: 0;+ transform: scale(0.8);}-}--// Recharts chart styles-.openui-pie-chart {- display: flex;- align-items: center;- justify-content: center;-- .openui-pie-chart__inner-cell {- fill: cssUtils.$sunk;- }-}--// Container for the legend component-.openui-pie-chart-legend-container {- display: flex;- justify-content: center;-- // Default legend is centered at the bottom- .legend-default & {- width: 100%;- align-items: center;- }-- // Stacked legend in column layout- .layout-column.legend-stacked & {- width: 100%;- align-items: flex-start;- }-- // Stacked legend in row layout- .layout-row.legend-stacked & {- flex: 1;- min-width: 0;- height: 100%;- align-items: center;+ to {+ opacity: 1;+ transform: scale(1);}}diff --git a/packages/react-ui/src/components/Charts/PieChart/stories/PieChart.stories.tsx b/packages/react-ui/src/components/Charts/PieChart/stories/PieChart.stories.tsxindex 86f2acefd..d4821142e 100644--- a/packages/react-ui/src/components/Charts/PieChart/stories/PieChart.stories.tsx+++ b/packages/react-ui/src/components/Charts/PieChart/stories/PieChart.stories.tsx@@ -1,7 +1,7 @@import type { Meta, StoryObj } from "@storybook/react";import { useState } from "react";+import { PieChart, PieChartProps } from "../..";import { Card } from "../../../Card";-import { PieChart, PieChartProps } from "../PieChart";const monthlySalesData = [{ month: "January", value: 1250 },@@ -58,7 +58,7 @@ const comprehensiveData = [* - **Responsive Design**: Fluidly adjusts to the size of its container** ### Customization- * - **Theming**: Six pre-built color palettes to match your application's design+ * - **Colors**: Uses the ThemeProvider's chart palette, or custom colors with `customPalette`* - **Styling Options**: Control corner radius, padding between slices, and more*/@@ -81,7 +81,6 @@ import { PieChart } from '@openuidev/react-ui/Charts/PieChart';data={yourData}categoryKey="category"dataKey="value"- theme="ocean"/>\`\`\`@@ -144,19 +143,9 @@ const salesData = [category: "📊 Data Configuration",},},- theme: {- description:- "The color palette for the chart. Provides a set of aesthetically pleasing colors.",- control: "select",- options: ["ocean", "orchid", "emerald", "sunset", "spectrum", "vivid"],- table: {- defaultValue: { summary: "ocean" },- category: "🎨 Visual Styling",- },- },customPalette: {description:- "An array of color strings to use as a custom palette for the chart. This overrides the `theme` prop.",+ "An array of color strings to use as a custom palette for the chart. This overrides the ThemeProvider's chart palette.",control: "object",table: {type: { summary: "string[]" },@@ -276,7 +265,6 @@ export const InteractivePlayground: Story = {data: monthlySalesData,categoryKey: "month",dataKey: "value",- theme: "ocean",variant: "pie",format: "number",legend: true,@@ -299,7 +287,7 @@ export const InteractivePlayground: Story = {** **Key Features Shown:*** - Standard circular pie layout- * - Professional 'ocean' color theme+ * - Chart palette from the ThemeProvider* - Responsive stacked legend for clarity* - Smooth animations on load*/@@ -309,7 +297,6 @@ export const DefaultConfiguration: Story = {data: monthlySalesData,categoryKey: "month",dataKey: "value",- theme: "ocean",variant: "pie",format: "number",legend: true,@@ -345,7 +332,6 @@ export const LayoutAndVariantOptions: Story = {data: monthlySalesData.slice(0, 4),categoryKey: "month",dataKey: "value",- theme: "emerald",legend: true,legendVariant: "stacked",isAnimationActive: false,@@ -427,7 +413,6 @@ export const LargeDatasetWithCarousel: Story = {data: comprehensiveData,categoryKey: "category",dataKey: "sales",- theme: "spectrum",variant: "donut",legend: true,legendVariant: "stacked",@@ -447,7 +432,6 @@ export const ResponsiveDemo: Story = {data: comprehensiveData,categoryKey: "category",dataKey: "sales",- theme: "spectrum",variant: "circular",format: "number",legend: true,diff --git a/packages/react-ui/src/components/D3Charts/PieChart/types.ts b/packages/react-ui/src/components/Charts/PieChart/types.tssimilarity index 93%rename from packages/react-ui/src/components/D3Charts/PieChart/types.tsrename to packages/react-ui/src/components/Charts/PieChart/types.tsindex 159c8da46..b6cbafcb1 100644--- a/packages/react-ui/src/components/D3Charts/PieChart/types.ts+++ b/packages/react-ui/src/components/Charts/PieChart/types.ts@@ -14,8 +14,7 @@ export interface PieChartProps<T extends PieChartData> {/*** `"stacked"` (default): the chart with a stacked legend listing each item's* share — side by side from 400px wide, below the chart when narrower.- * `"default"`: the compact legend under the chart. Matches react-ui's- * Recharts PieChart.+ * `"default"`: the compact legend under the chart.*/legendVariant?: "default" | "stacked";/** When set, this chart publishes its legend to the shared legend store underdiff --git a/packages/react-ui/src/components/Charts/PieChart/types/index.ts b/packages/react-ui/src/components/Charts/PieChart/types/index.tsdeleted file mode 100644index 44e9afb30..000000000--- a/packages/react-ui/src/components/Charts/PieChart/types/index.ts+++ /dev/null@@ -1 +0,0 @@-export type PieChartData = Array<Record<string, string | number>>;diff --git a/packages/react-ui/src/components/Charts/PieChart/utils/PieChartUtils.ts b/packages/react-ui/src/components/Charts/PieChart/utils/PieChartUtils.tsdeleted file mode 100644index 67d31dfc2..000000000--- a/packages/react-ui/src/components/Charts/PieChart/utils/PieChartUtils.ts+++ /dev/null@@ -1,221 +0,0 @@-/**- * Utility functions for pie charts- */-import { useState } from "react";-import { PieChartData } from "../types";--export interface ChartDimensions {- outerRadius: number;- innerRadius: number;-}--export interface TwoLevelChartDimensions extends ChartDimensions {- middleRadius: number;-}--export interface HoverStyles {- opacity: number;- stroke: string;- strokeWidth: number;-}--export interface ChartHoverHook {- activeIndex: number | null;- handleMouseEnter: (event: any, index: number) => void;- handleMouseLeave: () => void;-}--export interface AnimationConfig {- isAnimationActive: boolean;- animationBegin: number;- animationDuration: number;- animationEasing: "ease" | "ease-in" | "ease-out" | "ease-in-out" | "linear";-}--// ==========================================-// Core Calculation Utilities-// ==========================================--/**- * Calculates the percentage value of a number relative to a total- * @param value - The value to calculate percentage for- * @param total - The total value to calculate percentage against- * @returns The calculated percentage rounded to 2 decimal places- */-const calculatePercentage = (value: number, total: number): number => {- if (total === 0) {- return 0;- }- return Number(((value / total) * 100).toFixed(2));-};--// ==========================================-// Chart Dimension Calculations-// ==========================================--/**- * Calculates dimensions for standard pie/donut charts- * @param width - The container width- * @param variant - The chart variant ('pie' or 'donut')- * @returns Object containing outer and inner radius values- */-const calculateChartDimensions = (width: number, variant: string): ChartDimensions => {- const baseRadiusPercentage = 0.45; // Prefer a larger base to better utilize available width- let outerRadius = Math.round(width * baseRadiusPercentage);-- // Set minimum and maximum bounds for radius- outerRadius = Math.max(50, Math.min(outerRadius, width / 2 - 10)); // Ensure radius isn't too small or too large-- // Calculate inner radius for donut variant - consistent ratio regardless of layout- let innerRadius = 0;- if (variant === "donut") {- innerRadius = Math.round(outerRadius * 0.6);- }-- return { outerRadius, innerRadius };-};--/**- * Calculates dimensions for two-level pie charts- * @param width - The container width- * @returns Object containing outer, middle, and inner radius values- */-const calculateTwoLevelChartDimensions = (width: number): TwoLevelChartDimensions => {- const baseRadiusPercentage = 0.45; // Prefer a larger base to better utilize available width- let outerRadius = Math.round(width * baseRadiusPercentage);-- // Set minimum and maximum bounds for radius- outerRadius = Math.max(50, Math.min(outerRadius, width / 2 - 10));-- // Calculate middle radius (inner ring's outer boundary)- const middleRadius = Math.round(outerRadius * 0.9);-- // Calculate inner radius - always has a value in two-level chart- const innerRadius = Math.round(middleRadius * 0.28);-- return { outerRadius, middleRadius, innerRadius };-};--// ==========================================-// Layout and Styling Utilities-// ==========================================--/**- * Generates hover style properties for chart cells- * @param index - The index of the current cell- * @param activeIndex - The index of the currently hovered cell- * @returns Object containing hover style properties- */-const getHoverStyles = (index: number, activeIndex: number | null): HoverStyles => {- return {- opacity: activeIndex === null || activeIndex === index ? 1 : 0.5,- stroke: activeIndex === index ? "#fff" : "none",- strokeWidth: activeIndex === index ? 2 : 0,- };-};--// ==========================================-// Data Transformation Utilities-// ==========================================--/**- * Transforms data by adding percentage calculations- * @param data - The input data array- * @param dataKey - The key to use for value calculations- * @returns Transformed data with added percentage and original value- */-const transformDataWithPercentages = <T extends PieChartData>(- data: T,- dataKey: keyof T[number],-) => {- const total = data.reduce((sum, item) => sum + Number(item[dataKey]), 0);- return data.map((item) => ({- ...item,- percentage: calculatePercentage(Number(item[dataKey as string]), total),- originalValue: item[dataKey as string],- }));-};--// ==========================================-// Hover Effect Utilities-// ==========================================--/**- * Custom hook for managing chart hover effects- * @returns Object containing hover state and handlers- */-const useChartHover = (): ChartHoverHook => {- const [activeIndex, setActiveIndex] = useState<number | null>(null);-- const handleMouseEnter = (_: any, index: number) => {- setActiveIndex(index);- };-- const handleMouseLeave = () => {- setActiveIndex(null);- };-- return {- activeIndex,- handleMouseEnter,- handleMouseLeave,- };-};--// ==========================================-// Animation Utilities-// ==========================================--/**- * Creates animation configuration for pie chart- * @param config - Animation configuration options- * @returns Animation configuration object- */-const createAnimationConfig = (config: Partial<AnimationConfig> = {}): AnimationConfig => {- return {- isAnimationActive: config.isAnimationActive ?? true,- animationBegin: config.animationBegin ?? 0,- animationDuration: config.animationDuration ?? 1500,- animationEasing: config.animationEasing ?? "ease",- };-};--// ==========================================-// Event Handler Utilities-// ==========================================--/**- * Creates event handlers for pie chart- * @param onMouseEnter - Mouse enter handler- * @param onMouseLeave - Mouse leave handler- * @param onClick - Click handler- * @returns Object containing event handlers- */-const createEventHandlers = (- onMouseEnter?: (data: any, index: number) => void,- onMouseLeave?: () => void,- onClick?: (data: any, index: number) => void,-) => {- return {- onMouseEnter: onMouseEnter- ? (data: any, index: number) => onMouseEnter(data, index)- : undefined,- onMouseLeave: onMouseLeave ? () => onMouseLeave() : undefined,- onClick: onClick ? (data: any, index: number) => onClick(data, index) : undefined,- };-};--// ==========================================-// Export all utility functions-// ==========================================--export {- calculateChartDimensions,- calculatePercentage,- calculateTwoLevelChartDimensions,- createAnimationConfig,- createEventHandlers,- getHoverStyles,- transformDataWithPercentages,- useChartHover,-};diff --git a/packages/react-ui/src/components/Charts/RadarChart/RadarChart.tsx b/packages/react-ui/src/components/Charts/RadarChart/RadarChart.tsxindex 3eef96795..a5787d554 100644--- a/packages/react-ui/src/components/Charts/RadarChart/RadarChart.tsx+++ b/packages/react-ui/src/components/Charts/RadarChart/RadarChart.tsx@@ -1,263 +1,157 @@-import clsx from "clsx";-import React, { memo, useLayoutEffect, useMemo, useRef, useState } from "react";-import {- PolarAngleAxis,- PolarGrid,- Radar,- RadarChart as RechartsRadarChart,- ResponsiveContainer,-} from "recharts";-import { usePrintContext } from "../../../context/PrintContext";-import { ChartConfig, ChartContainer, ChartTooltip } from "../Charts";-import { SideBarTooltipProvider } from "../context/SideBarTooltipContext";-import { useExportChartData, useTransformedKeys } from "../hooks";-import { ActiveDot, CustomTooltipContent, DefaultLegend } from "../shared";-import { LegendItem } from "../types";-import { useChartPalette } from "../utils/PalletUtils";-import { get2dChartConfig, getDataKeys, getLegendItems } from "../utils/dataUtils";-import { AxisLabel } from "./components/AxisLabel";-import { RadarChartData } from "./types";--const MIN_CHART_SIZE = 150;-const MAX_CHART_SIZE = 296;--export interface RadarChartProps<T extends RadarChartData> {- data: T;- categoryKey: keyof T[number];- theme?: "ocean" | "orchid" | "emerald" | "sunset" | "spectrum" | "vivid";- customPalette?: string[];- variant?: "line" | "area";- grid?: boolean;- legend?: boolean;- strokeWidth?: number;- areaOpacity?: number;- icons?: Partial<Record<keyof T[number], React.ComponentType>>;- isAnimationActive?: boolean;- height?: number;- width?: number;-}--const RadarChartComponent = <T extends RadarChartData>({- data,- categoryKey,- theme = "ocean",- customPalette,- variant = "line",- grid = true,- legend = true,- strokeWidth = 2,- areaOpacity = 0.2,- icons = {},- isAnimationActive = false,- height,- width,-}: RadarChartProps<T>) => {- const printContext = usePrintContext();- isAnimationActive = printContext ? false : isAnimationActive;-- const dataKeys = useMemo(() => {- return getDataKeys(data, categoryKey as string);- }, [data, categoryKey]);-- const transformedKeys = useTransformedKeys(dataKeys);-- const colors = useChartPalette({- chartThemeName: theme,+import { useCallback, useMemo } from "react";++import { useEffectiveAnimation, useRadarChartOrchestrator } from "../hooks";+import { ChartShell } from "../shared/core/ChartShell";+import { DefaultLegend } from "../shared/core/DefaultLegend/DefaultLegend";+import { ChartTooltip } from "../shared/core/PortalTooltip/ChartTooltip";+import { CHART_CLASS_PREFIX } from "../utils/constants";+import { RadarAxisLabels } from "./parts/RadarAxisLabels";+import { RadarGrid } from "./parts/RadarGrid";+import { RadarSeries } from "./parts/RadarSeries";+import type { RadarChartData, RadarChartProps } from "./types";++export function RadarChart<T extends RadarChartData>(props: RadarChartProps<T>) {+ const {+ data,+ categoryKey,customPalette,- themePaletteName: "radarChartPalette",- dataLength: dataKeys.length,- });-- // Create Config- const chartConfig: ChartConfig = useMemo(() => {- return get2dChartConfig(dataKeys, colors, transformedKeys, undefined, icons);- }, [dataKeys, icons, colors, transformedKeys]);-- const legendItems: LegendItem[] = useMemo(() => {- return getLegendItems(dataKeys, colors, icons);- }, [dataKeys, colors, icons]);-- const exportData = useExportChartData({- type: "radar",+ gridShape = "polygon",+ gridLevels = 5,+ grid: showGrid = true,+ legend: showLegend = true,+ icons,+ isAnimationActive = false,+ variant = "line",+ areaOpacity = 0.2,+ showDots = false,+ dotRadius = 4,+ fillOpacity,+ maxChartSize = 500,+ minChartSize = 150,+ height,+ width,+ fitLegendInHeight,+ className,+ onClick,+ } = props;++ const orch = useRadarChartOrchestrator({data,- categoryKey: categoryKey as string,- dataKeys,- colors,- legend,+ categoryKey,+ themePaletteName: "radarChartPalette",+ customPalette,+ icons,+ showLegend,+ maxChartSize,+ minChartSize,+ height,+ width,+ fitLegendInHeight,+ onClick,});- const [isLegendExpanded, setIsLegendExpanded] = useState(false);- const wrapperRef = useRef<HTMLDivElement>(null);- const [wrapperRect, setWrapperRect] = useState({ width: 0, height: 0 });-- useLayoutEffect(() => {- const wrapper = wrapperRef.current;- if (!wrapper) return;-- const observer = new ResizeObserver((entries) => {- const entry = entries[0];- if (entry) {- setWrapperRect({- width: entry.contentRect.width,- height: entry.contentRect.height,- });- }- });+ const animate = useEffectiveAnimation(isAnimationActive);- // Read initial dimensions synchronously before first paint to avoid size jump- const rect = wrapper.getBoundingClientRect();- setWrapperRect({ width: rect.width, height: rect.height });+ const numAxes = data.length;- observer.observe(wrapper);- return () => observer.disconnect();- }, []);-- const chartSize = useMemo(() => {- const effectiveWidth = wrapperRect.width;- const effectiveHeight = wrapperRect.height;- let charts = Math.min(effectiveWidth, effectiveHeight);- charts = Math.min(charts, MAX_CHART_SIZE);- return Math.max(MIN_CHART_SIZE, charts);- }, [wrapperRect]);-- const chartSizeStyle = useMemo(() => ({ width: chartSize, height: chartSize }), [chartSize]);- const rechartsProps: Omit<React.ComponentProps<typeof ResponsiveContainer>, "children"> = useMemo(- () => ({- width: "100%",- height: "100%",- minWidth: 1,- minHeight: 1,- initialDimension: { width: 1, height: 1 },- }),- [],+ const findIndex = useCallback(+ (mouseX: number, mouseY: number) => {+ if (numAxes === 0) return -1;+ let angle = Math.atan2(mouseY, mouseX) + Math.PI / 2;+ if (angle < 0) angle += 2 * Math.PI;+ return Math.round(angle / ((2 * Math.PI) / numAxes)) % numAxes;+ },+ [numAxes],);- const radars = useMemo(() => {- return dataKeys.map((key) => {- const transformedKey = transformedKeys[key];- const color = `var(--color-${transformedKey})`;- if (variant === "line") {- return (- <Radar- key={key}- dataKey={key}- fill={color}- fillOpacity={0}- stroke={color}- strokeWidth={strokeWidth}- isAnimationActive={isAnimationActive}- activeDot={<ActiveDot />}- />- );- } else {- return (- <Radar- key={key}- dataKey={key}- fill={color}- stroke={color}- strokeWidth={strokeWidth}- fillOpacity={areaOpacity}- isAnimationActive={isAnimationActive}- activeDot={<ActiveDot />}- />- );- }- });- }, [dataKeys, transformedKeys, variant, strokeWidth, areaOpacity, isAnimationActive]);-- const wrapperClassName = useMemo(- () =>- clsx("openui-radar-chart-container-wrapper", {- "layout-column": true,- }),- [],+ // Destructured so the memo depends on the callback identity itself (a+ // stable useCallback), not the whole orch.hover object.+ const { createMouseHandlers } = orch.hover;+ const mouseHandlers = useMemo(+ () => createMouseHandlers(findIndex),+ [createMouseHandlers, findIndex],);- const wrapperStyle = useMemo(() => {- const formatDimension = (value: number | string | undefined) => {- if (typeof value === "number") {- return `${value}px`;- }- return value;- };- const dimensions = {- width: formatDimension(width),- height: formatDimension(height),- };-- if (dimensions.width === undefined) {- delete dimensions.width;- }-- if (dimensions.height === undefined) {- delete dimensions.height;- }-- return dimensions;- }, [width, height]);-return (- <SideBarTooltipProvider- isSideBarTooltipOpen={false}- setIsSideBarTooltipOpen={() => {}}- data={undefined}- setData={() => {}}+ <ChartShell+ containerRef={orch.refs.containerRef}+ classPrefix={`${CHART_CLASS_PREFIX}-radar-chart`}+ className={className}+ style={orch.style.containerStyle}+ isEmpty={orch.isEmpty}>- <div- ref={wrapperRef}- className={wrapperClassName}- style={wrapperStyle}- data-openui-chart={exportData}- >- <div className="openui-radar-chart-container">- <div className="openui-radar-chart-container-inner">- <div style={chartSizeStyle}>- <ChartContainer- config={chartConfig}- className="openui-radar-chart"- rechartsProps={rechartsProps}+ {() => (+ <>+ <div className={`${CHART_CLASS_PREFIX}-radar-chart-svg-wrapper`}>+ <svg+ width={orch.dimensions.svgWidth}+ height={orch.dimensions.svgHeight}+ viewBox={`0 0 ${orch.dimensions.svgWidth} ${orch.dimensions.svgHeight}`}+ role="img"+ aria-label="Radar chart"+ >+ <g+ transform={`translate(${orch.dimensions.centerX}, ${orch.dimensions.centerY})`}+ onMouseMove={mouseHandlers.handleMouseMove}+ onMouseLeave={mouseHandlers.handleMouseLeave}+ onTouchMove={mouseHandlers.handleTouchMove}+ onTouchEnd={mouseHandlers.handleTouchEnd}+ onClick={mouseHandlers.handleClick}>- <RechartsRadarChart- data={data}- margin={{- left: 10,- right: 10,- top: 10,- bottom: 10,- }}- >- {grid && <PolarGrid className="openui-chart-polar-grid" stroke="currentColor" />}- <PolarAngleAxis- dataKey={categoryKey as string}- tick={<AxisLabel portalContainerRef={wrapperRef} />}+ {showGrid && (+ <RadarGrid+ maxRadius={orch.dimensions.maxRadius}+ gridLevels={gridLevels}+ gridShape={gridShape}+ numAxes={numAxes}/>-- <ChartTooltip- cursor={false}- content={<CustomTooltipContent parentRef={wrapperRef} />}- />- {/* rendering the radars here */}- {radars}- </RechartsRadarChart>- </ChartContainer>- </div>+ )}+ <RadarSeries+ data={data}+ dataKeys={orch.data.dataKeys}+ catKey={orch.data.catKey}+ radialScale={orch.dimensions.radialScale}+ numAxes={numAxes}+ colorMap={orch.data.colorMap}+ fillOpacity={fillOpacity ?? (variant === "area" ? areaOpacity : 0)}+ showDots={showDots}+ dotRadius={dotRadius}+ hoveredIndex={orch.hover.hoveredIndex}+ animate={animate}+ />+ <RadarAxisLabels+ data={data}+ catKey={orch.data.catKey}+ numAxes={numAxes}+ maxRadius={orch.dimensions.maxRadius}+ chartSize={orch.dimensions.chartSize}+ containerWidth={orch.dimensions.containerWidth}+ />+ </g>+ </svg></div>- </div>- {legend && (- <DefaultLegend- items={legendItems}- containerWidth={wrapperRect.width}- isExpanded={isLegendExpanded}- setIsExpanded={setIsLegendExpanded}- style={{ paddingTop: 0 }}- />- )}- </div>- </SideBarTooltipProvider>- );-};--export const RadarChart = memo(RadarChartComponent);-RadarChart.displayName = "RadarChart";+ {showLegend && (+ <DefaultLegend+ ref={orch.refs.legendRef}+ items={orch.legend.legendItems}+ containerWidth={orch.dimensions.containerWidth}+ isExpanded={orch.legend.isLegendExpanded}+ setIsExpanded={orch.legend.setIsLegendExpanded}+ onItemClick={orch.legend.toggleSeries}+ hiddenSeries={orch.legend.hiddenSeries}+ />+ )}++ {orch.tooltip.tooltipPayload && orch.hover.mousePos && (+ <ChartTooltip+ label={orch.tooltip.tooltipPayload.label}+ items={orch.tooltip.tooltipPayload.items}+ viewportPosition={orch.hover.mousePos}+ />+ )}+ </>+ )}+ </ChartShell>+ );+}diff --git a/packages/react-ui/src/components/Charts/RadarChart/components/AxisLabel.tsx b/packages/react-ui/src/components/Charts/RadarChart/components/AxisLabel.tsxdeleted file mode 100644index d7e2abfcb..000000000--- a/packages/react-ui/src/components/Charts/RadarChart/components/AxisLabel.tsx+++ /dev/null@@ -1,130 +0,0 @@-import clsx from "clsx";-import React, { useLayoutEffect, useMemo, useRef } from "react";-import { calculateAvailableWidth, truncateText } from "../utils";--// This is the props that are passed by recharts to the custom tick component-interface AxisLabelProps {- x?: number;- y?: number;- textAnchor?: string;- payload?: {- value: string;- };- className?: string;- portalContainerRef?: React.RefObject<HTMLDivElement | null>;-- [key: string]: any; // To allow other props from recharts-}--export const AxisLabel: React.FC<AxisLabelProps> = (props) => {- const { x, y, payload, textAnchor, portalContainerRef, className } = props;- const anchorRef = useRef<SVGGElement>(null);-- /**- * Memoizes the calculation of truncated text for axis labels- *- * This hook handles text truncation based on available space in the chart container:- * 1. Returns empty string or original value if payload/container is missing- * 2. Calculates container width and available space based on text anchor position- * 3. Truncates text to fit within available width using specified font size- *- * @returns {string} Truncated text that fits within available space- *- * Dependencies:- * - payload?.value: The text content to truncate- * - x: X-coordinate of the label- * - textAnchor: Text anchor position ('start', 'middle', 'end')- * - portalContainerRef: Reference to container element- */- const truncatedText = useMemo(() => {- if (!payload?.value || !portalContainerRef?.current) {- return payload?.value || "";- }-- const container = portalContainerRef.current;- // Get the width of the container- const containerWidth = container.getBoundingClientRect().width;- // Get the padding of the container- const padding = 0;- // Get the font size of the text- const fontSize = 10;-- // Calculate available width based on text anchor and position, and padding- const availableWidth = calculateAvailableWidth(- x || 0,- containerWidth,- textAnchor || "middle",- padding,- );-- return truncateText(payload.value, availableWidth, fontSize);- }, [payload?.value, x, textAnchor, portalContainerRef]);-- useLayoutEffect(() => {- const container = portalContainerRef?.current;- const anchor = anchorRef.current;-- if (!container || !anchor || !truncatedText) {- return;- }-- // Create the label element- const labelEl = document.createElement("div");- labelEl.textContent = truncatedText;- container.appendChild(labelEl);-- // Function to calculate and apply styles- const updatePosition = () => {- const anchorRect = anchor.getBoundingClientRect();- const containerRect = container.getBoundingClientRect();- const left = anchorRect.left - containerRect.left;- const top = anchorRect.top - containerRect.top;-- const padding = 0;- let transform = "";- if (textAnchor === "end") {- transform = `translate(calc(-100% - ${padding}px), -50%)`;- } else if (textAnchor === "start") {- transform = `translate(${padding}px, -50%)`;- } else {- transform = "translate(-50%, -50%)";- }-- labelEl.style.position = "absolute";- labelEl.style.left = `${left}px`;- labelEl.style.top = `${top}px`;- labelEl.style.transform = transform;- labelEl.style.pointerEvents = "none";- labelEl.style.zIndex = "0";- labelEl.className = clsx("openui-chart-polar-angle-axis-label", className);-- // Update text content if it has changed due to container resize- const containerWidth = containerRect.width;- const availableWidth = calculateAvailableWidth(- left,- containerWidth,- textAnchor ?? "middle",- 0,- );- const newTruncatedText = truncateText(payload?.value ?? "", availableWidth, 10);- if (labelEl.textContent !== newTruncatedText) {- labelEl.textContent = newTruncatedText;- }- };-- updatePosition();-- const resizeObserver = new ResizeObserver(updatePosition);- resizeObserver.observe(container);-- // Cleanup function to run when the component unmounts or deps change- return () => {- resizeObserver.disconnect();- if (container.contains(labelEl)) {- container.removeChild(labelEl);- }- };- }, [x, y, textAnchor, truncatedText, portalContainerRef, className, payload?.value]);-- return <g ref={anchorRef} transform={`translate(${x || 0}, ${y || 0})`} />;-};diff --git a/packages/react-ui/src/components/Charts/RadarChart/index.ts b/packages/react-ui/src/components/Charts/RadarChart/index.tsindex ba0fe04a9..ffed6f64a 100644--- a/packages/react-ui/src/components/Charts/RadarChart/index.ts+++ b/packages/react-ui/src/components/Charts/RadarChart/index.ts@@ -1,2 +1,2 @@-export * from "./RadarChart";-export * from "./types";+export { RadarChart } from "./RadarChart";+export type { RadarChartData, RadarChartProps } from "./types";diff --git a/packages/react-ui/src/components/D3Charts/RadarChart/parts/RadarAxisLabels.tsx b/packages/react-ui/src/components/Charts/RadarChart/parts/RadarAxisLabels.tsxsimilarity index 100%rename from packages/react-ui/src/components/D3Charts/RadarChart/parts/RadarAxisLabels.tsxrename to packages/react-ui/src/components/Charts/RadarChart/parts/RadarAxisLabels.tsxdiff --git a/packages/react-ui/src/components/D3Charts/RadarChart/parts/RadarGrid.tsx b/packages/react-ui/src/components/Charts/RadarChart/parts/RadarGrid.tsxsimilarity index 100%rename from packages/react-ui/src/components/D3Charts/RadarChart/parts/RadarGrid.tsxrename to packages/react-ui/src/components/Charts/RadarChart/parts/RadarGrid.tsxdiff --git a/packages/react-ui/src/components/D3Charts/RadarChart/parts/RadarSeries.tsx b/packages/react-ui/src/components/Charts/RadarChart/parts/RadarSeries.tsxsimilarity index 100%rename from packages/react-ui/src/components/D3Charts/RadarChart/parts/RadarSeries.tsxrename to packages/react-ui/src/components/Charts/RadarChart/parts/RadarSeries.tsxdiff --git a/packages/react-ui/src/components/Charts/RadarChart/radarChart.scss b/packages/react-ui/src/components/Charts/RadarChart/radarChart.scssindex b3d1a5483..f63a12f19 100644--- a/packages/react-ui/src/components/Charts/RadarChart/radarChart.scss+++ b/packages/react-ui/src/components/Charts/RadarChart/radarChart.scss@@ -1,49 +1,68 @@@use "../../../cssUtils" as cssUtils;+@use "../shared/cartesian/chartBase" as base;+@use "../prefix" as brand;-.openui-radar-chart-container-wrapper {- display: flex;- position: relative;- gap: 20px;- &.layout-column {- flex-direction: column;- align-items: center;- }+@include base.centered-container("radar-chart");+@include base.centered-svg-wrapper("radar-chart");++// Labels are budgeted against the CONTAINER width (radarLabelLayout.ts) and+// legitimately paint outside the square svg viewport; the polar container+// column deliberately does not clip (chartBase.scss centered-container).+// Vertical extent stays inside the svg via radarLabelPadding + line caps.+.#{brand.$prefix}-radar-chart-svg-wrapper > svg {+ overflow: visible;}-.openui-radar-chart-container {- display: flex;- align-items: center;- justify-content: center;- position: relative;- width: 100%;- .layout-column & {- flex: 1;- min-height: 0;- }+// Solid rings and spokes in the interactive border tone.+.#{brand.$prefix}-radar-chart-grid-ring {+ stroke: cssUtils.$border-interactive;+ stroke-width: 1;}-.openui-radar-chart-container-inner {- width: 100%;- height: 100%;- display: flex;- align-items: center;- justify-content: center;+.#{brand.$prefix}-radar-chart-grid-spoke {+ stroke: cssUtils.$border-interactive;+ stroke-width: 1;}-.openui-radar-chart {- .recharts-polar-grid-concentric-polygon {- stroke-width: 1;- stroke: cssUtils.$border-interactive;- }+.#{brand.$prefix}-radar-chart-polygon-area {+ transition: opacity 0.2s ease;+}++.#{brand.$prefix}-radar-chart-polygon-stroke {+ fill: none;+ stroke-width: 2;+}- .recharts-polar-grid-angle line {- stroke: cssUtils.$border-interactive;+.#{brand.$prefix}-radar-chart-dot {+ stroke: cssUtils.$foreground;+ stroke-width: 1.5;+ transition:+ r 0.15s ease,+ opacity 0.15s ease;+}++.#{brand.$prefix}-radar-chart-axis-label {+ @include base.svg-tick-label;+}++// Entrances are decorative: gate the whole rule (pre-state included) behind+// reduced-motion so users who opt out get the natural static state immediately+// — gating only the animation would strand elements at the opacity: 0 start.+@media (prefers-reduced-motion: no-preference) {+ .#{brand.$prefix}-radar-chart-polygon--animated {+ opacity: 0;+ transform-origin: center center;+ animation: #{brand.$prefix}-radar-polygon-appear 0.5s ease-out forwards;}}-.openui-chart-polar-angle-axis-label {- pointer-events: none;- @include cssUtils.typography(label, 2-extra-small);- color: cssUtils.$text-neutral-secondary;- white-space: nowrap;+@keyframes #{brand.$prefix}-radar-polygon-appear {+ from {+ opacity: 0;+ transform: scale(0.3);+ }+ to {+ opacity: 1;+ transform: scale(1);+ }}diff --git a/packages/react-ui/src/components/Charts/RadarChart/stories/RadarChart.stories.tsx b/packages/react-ui/src/components/Charts/RadarChart/stories/RadarChart.stories.tsxindex 2d5cddc3a..314713d6a 100644--- a/packages/react-ui/src/components/Charts/RadarChart/stories/RadarChart.stories.tsx+++ b/packages/react-ui/src/components/Charts/RadarChart/stories/RadarChart.stories.tsx@@ -1,8 +1,8 @@import type { Meta, StoryObj } from "@storybook/react";import { Shield, Star, Target } from "lucide-react";import { useState } from "react";+import { RadarChart, RadarChartProps } from "../..";import { Card } from "../../../Card";-import { RadarChart, RadarChartProps } from "../RadarChart";// 📊 COMPREHENSIVE DATA VARIATIONS - Designed to test various radar chart scenariosconst dataVariations = {@@ -101,7 +101,6 @@ import { RadarChart } from '@openuidev/react-ui/Charts/RadarChart';<RadarChartdata={yourData}categoryKey="category"- theme="ocean"variant="line"/>@@ -132,8 +131,8 @@ const exampleData = [- **Multiple Data Series**: Compare several datasets on the same chart.- **Two Visual Variants**: Choose between 'line' and 'area' styles.-- **Customizable Appearance**: Control colors, stroke width, and area opacity.-- **Custom Color Palettes**: Use predefined themes or provide your own custom colors.+- **Customizable Appearance**: Control colors and area opacity.+- **Custom Color Palettes**: Use the ThemeProvider's chart palette or provide your own custom colors.- **Interactive Legend**: Toggle visibility of data series.- **Icon Support**: Add custom icons to legend items for better visual identification.- **Animation**: Smooth animations for loading and data transitions.@@ -174,27 +173,8 @@ const exampleData = [category: "📊 Data Configuration",},},- theme: {- description: `-**Color Theme Selection.** Choose from professionally designed color palettes. Ignored when customPalette is provided.--- **ocean**: Cool blues and teals (professional, corporate)-- **orchid**: Purple and pink tones (creative, modern)-- **emerald**: Green variations (nature, growth, finance)-- **sunset**: Warm oranges and reds (energy, attention-grabbing)-- **spectrum**: Full color range (diverse, comprehensive)-- **vivid**: High-contrast colors (accessibility, clarity)-`,- control: "select",- options: ["ocean", "orchid", "emerald", "sunset", "spectrum", "vivid"],- table: {- defaultValue: { summary: "ocean" },- category: "🎨 Visual Styling",- },- },customPalette: {- description:- "Custom array of colors to use instead of the theme palette. Overrides the theme prop when provided.",+ description: "Custom array of colors to use instead of the ThemeProvider's chart palette.",control: "object",table: {type: { summary: "string[]" },@@ -245,17 +225,6 @@ const exampleData = [category: "📱 Display Options",},},- strokeWidth: {- description: `-**Line Thickness.** Sets the width of the radar lines for the 'line' variant and the border for the 'area' variant.-`,- control: { type: "number", min: 1, max: 10 },- table: {- type: { summary: "number" },- defaultValue: { summary: "2" },- category: "🎨 Visual Styling",- },- },areaOpacity: {description: `**Area Fill Opacity.** Controls the transparency of the filled areas when \`variant\` is 'area'.@@ -330,11 +299,9 @@ export const DefaultConfiguration: Story = {args: {data: dataVariations.performance,categoryKey: "metric",- theme: "ocean",variant: "line",grid: true,legend: true,- strokeWidth: 2,isAnimationActive: true,},render: (args: any) => (@@ -359,7 +326,7 @@ This is the recommended starting configuration for most use cases. The chart dis**Configuration Details:**- **Data**: Team performance metrics.- **Variant**: 'line' for clear comparison between series.-- **Colors**: 'ocean' theme (blues and teals).+- **Colors**: The ThemeProvider's chart palette.- **Legend**: Enabled to identify data series.- **Animations**: Enabled for smooth interactions.`,@@ -373,11 +340,9 @@ export const SkillsAssessment: Story = {args: {data: dataVariations.default,categoryKey: "skill",- theme: "orchid",variant: "area",grid: true,legend: true,- strokeWidth: 2,areaOpacity: 0.4,isAnimationActive: true,},@@ -409,11 +374,9 @@ export const TeamPerformance: Story = {args: {data: dataVariations.performance,categoryKey: "metric",- theme: "emerald",variant: "line",grid: true,legend: true,- strokeWidth: 3,isAnimationActive: true,icons: {team_a: Shield,@@ -438,7 +401,7 @@ export const TeamPerformance: Story = {docs: {description: {story:- "This chart demonstrates how to enhance the legend with custom icons. It's an effective way to visually associate data series with specific entities, like teams or products. The thicker stroke width also improves line visibility.",+ "This chart demonstrates how to enhance the legend with custom icons. It's an effective way to visually associate data series with specific entities, like teams or products.",},},},@@ -449,11 +412,9 @@ export const BusinessMetrics: Story = {args: {data: dataVariations.businessMetrics,categoryKey: "department",- theme: "sunset",variant: "area",grid: true,legend: true,- strokeWidth: 2,areaOpacity: 0.4,isAnimationActive: true,},@@ -483,11 +444,9 @@ export const BusinessMetrics: Story = {export const InteractivePlayground: Story = {name: "🧪 Interactive Playground",args: {- theme: "ocean",variant: "line",grid: true,legend: true,- strokeWidth: 2,areaOpacity: 0.5,isAnimationActive: true,},@@ -561,7 +520,7 @@ export const InteractivePlayground: Story = {description: {story: `Use the buttons to switch between different datasets and explore how the RadarChart adapts.-You can also use the Storybook controls to change theme, variant, and other properties in real-time.+You can also use the Storybook controls to change variant and other properties in real-time.This playground is designed for testing various configurations and edge cases.`,},@@ -569,57 +528,6 @@ This playground is designed for testing various configurations and edge cases.},};-export const ThemeShowcase: Story = {- name: "🎨 Theme Showcase",- args: {- data: dataVariations.productFeatures,- categoryKey: "feature",- variant: "area",- grid: true,- legend: true,- strokeWidth: 2,- areaOpacity: 0.6,- isAnimationActive: false,- },- render: (args: any) => (- <div- style={{- display: "grid",- gridTemplateColumns: "repeat(3, 1fr)",- gap: "24px",- width: "900px",- }}- >- {(["ocean", "orchid", "emerald", "sunset", "spectrum", "vivid"] as const).map((theme) => (- <div key={theme}>- <h4- style={{- textAlign: "center",- marginBottom: "12px",- textTransform: "capitalize",- fontSize: "14px",- fontWeight: 600,- }}- >- {theme}- </h4>- <Card style={{ height: "fit-content", padding: "12px" }}>- <RadarChart {...args} theme={theme} />- </Card>- </div>- ))}- </div>- ),- parameters: {- docs: {- description: {- story:- "This story showcases all available color themes. Each theme provides a professionally curated palette suitable for different branding and data contexts. Animations are disabled for quicker comparison.",- },- },- },-};-/*** ## Custom Palette*@@ -644,11 +552,9 @@ export const CustomPaletteStory: Story = {"#B4C6FF","#CBD7FF",],- theme: "ocean", // This will be overridden by customPalettevariant: "area",grid: true,legend: true,- strokeWidth: 3,isAnimationActive: true,},render: (args: any) => (@@ -712,7 +618,7 @@ export const CustomPaletteStory: Story = {docs: {description: {story:- 'Demonstrates how to use the `customPalette` prop to provide your own color scheme for the radar chart. When `customPalette` is provided, it overrides the `theme` prop and uses your specified colors instead of the predefined theme palettes.\n\n**Key Features:**\n- 🎨 **Custom Colors**: Override default theme colors with your own palette\n- 🔄 **Theme Override**: The `theme` prop is ignored when `customPalette` is provided\n- 📊 **Consistent Distribution**: Colors are distributed evenly across data series\n- 🎯 **Brand Matching**: Perfect for matching your application\'s brand colors\n\n**Usage:**\n```tsx\n<RadarChart\n data={data}\n categoryKey="metric"\n customPalette={["#FF6B6B", "#4ECDC4", "#45B7D1"]}\n // theme prop is ignored when customPalette is provided\n/>\n```',+ 'Demonstrates how to use the `customPalette` prop to provide your own color scheme for the radar chart. When `customPalette` is provided, it overrides the ThemeProvider\'s chart palette and uses your specified colors instead.\n\n**Key Features:**\n- 🎨 **Custom Colors**: Override the default chart colors with your own palette\n- 📊 **Consistent Distribution**: Colors are distributed evenly across data series\n- 🎯 **Brand Matching**: Perfect for matching your application\'s brand colors\n\n**Usage:**\n```tsx\n<RadarChart\n data={data}\n categoryKey="metric"\n customPalette={["#FF6B6B", "#4ECDC4", "#45B7D1"]}\n/>\n```',},},},diff --git a/packages/react-ui/src/components/D3Charts/RadarChart/types.ts b/packages/react-ui/src/components/Charts/RadarChart/types.tssimilarity index 95%rename from packages/react-ui/src/components/D3Charts/RadarChart/types.tsrename to packages/react-ui/src/components/Charts/RadarChart/types.tsindex 4b4393fdb..afb2658b9 100644--- a/packages/react-ui/src/components/D3Charts/RadarChart/types.ts+++ b/packages/react-ui/src/components/Charts/RadarChart/types.ts@@ -21,7 +21,7 @@ export interface RadarChartProps<T extends RadarChartData> {isAnimationActive?: boolean;/*** `"line"` (default): series outlines only. `"area"`: outlines filled at- * `areaOpacity`. Matches react-ui's Recharts RadarChart.+ * `areaOpacity`.*/variant?: "line" | "area";/** Fill opacity of the `"area"` variant. Default 0.2. */diff --git a/packages/react-ui/src/components/Charts/RadarChart/types/index.ts b/packages/react-ui/src/components/Charts/RadarChart/types/index.tsdeleted file mode 100644index 1639bd74b..000000000--- a/packages/react-ui/src/components/Charts/RadarChart/types/index.ts+++ /dev/null@@ -1 +0,0 @@-export type RadarChartData = Array<Record<string, string | number>>;diff --git a/packages/react-ui/src/components/Charts/RadarChart/utils/index.ts b/packages/react-ui/src/components/Charts/RadarChart/utils/index.tsdeleted file mode 100644index a2780afb6..000000000--- a/packages/react-ui/src/components/Charts/RadarChart/utils/index.ts+++ /dev/null@@ -1,83 +0,0 @@-/**- * Truncates text to fit within specified width bounds- * @param text - The original text- * @param maxWidth - Maximum width in pixels- * @param fontSize - Font size for measurement- * @returns Truncated text with ellipsis if needed- */-const truncateText = (text: string, maxWidth: number, fontSize = 10): string => {- if (maxWidth <= 0) return text;-- // Create a temporary canvas to measure text width- const canvas = document.createElement("canvas");- const context = canvas.getContext("2d");- if (!context) return text;-- context.font = `${fontSize}px Inter`;-- // If text fits, return as is- if (context.measureText(text).width <= maxWidth) {- return text;- }-- // Binary search for the longest text that fits- let low = 0;- let high = text.length;- let result = text;-- while (low <= high) {- const mid = Math.floor((low + high) / 2);- const truncated = text.substring(0, mid) + "...";- const width = context.measureText(truncated).width;-- if (width <= maxWidth) {- result = truncated;- low = mid + 1;- } else {- high = mid - 1;- }- }-- return result;-};--/**- * Calculates the available width for a text label based on its position and anchor point- *- * This function determines how much horizontal space is available for a text label- * by checking its position relative to the container bounds. The calculation varies- * based on the text anchor position:- *- * - For "start" anchored text: Available space is from labelX to container right edge- * - For "end" anchored text: Available space is from container left edge to labelX- * - For "middle" anchored text: Takes minimum of left/right space and doubles it- *- * @param labelX - X coordinate of the label position- * @param containerWidth - Total width of the container- * @param textAnchor - How text is anchored ("start", "end", or "middle")- * @param padding - Optional padding to maintain from container edges (default 10px)- * @returns The maximum width available for the label in pixels- */-const calculateAvailableWidth = (- labelX: number,- containerWidth: number,- textAnchor: string,- padding = 0,-): number => {- switch (textAnchor) {- case "start":- // Text starts at labelX, extends to the right- return Math.max(0, containerWidth - labelX - padding);- case "end":- // Text ends at labelX, extends to the left- return Math.max(0, labelX - padding);- case "middle":- default:- // Text is centered at labelX- const leftSpace = labelX - padding;- const rightSpace = containerWidth - labelX - padding;- return Math.max(0, Math.min(leftSpace, rightSpace) * 2);- }-};--export { calculateAvailableWidth, truncateText };diff --git a/packages/react-ui/src/components/Charts/RadialChart/RadialChart.tsx b/packages/react-ui/src/components/Charts/RadialChart/RadialChart.tsxindex 7e17dffbc..40d016db3 100644--- a/packages/react-ui/src/components/Charts/RadialChart/RadialChart.tsx+++ b/packages/react-ui/src/components/Charts/RadialChart/RadialChart.tsx@@ -1,399 +1,180 @@-import clsx from "clsx";-import { useCallback, useEffect, useMemo, useRef, useState } from "react";-import { Cell, PolarGrid, RadialBar, RadialBarChart, ResponsiveContainer } from "recharts";-import { usePrintContext } from "../../../context/PrintContext";-import { ChartContainer, ChartTooltip, ChartTooltipContent } from "../Charts";-import { useExportChartData, useTransformedKeys } from "../hooks";-import { DefaultLegend } from "../shared/DefaultLegend/DefaultLegend";-import { StackedLegend } from "../shared/StackedLegend/StackedLegend";-import { LegendItem } from "../types/Legend";-import { getCategoricalChartConfig } from "../utils/dataUtils";-import { PaletteName, useChartPalette } from "../utils/PalletUtils";-import { RadialChartData } from "./types";-import {- calculateRadialChartDimensions,- createRadialAnimationConfig,- createRadialEventHandlers,- getRadialHoverStyles,- transformRadialDataWithPercentages,- useRadialChartHover,-} from "./utils/RadialChartUtils";+import { useMemo } from "react";-export interface RadialChartProps<T extends RadialChartData> {- data: T;- categoryKey: keyof T[number];- dataKey: keyof T[number];- theme?: PaletteName;- customPalette?: string[];- variant?: "semicircle" | "circular";- format?: "percentage" | "number";- legend?: boolean;- legendVariant?: "default" | "stacked";- grid?: boolean;- isAnimationActive?: boolean;- cornerRadius?: number;- onMouseEnter?: (data: any, index: number) => void;- onMouseLeave?: () => void;- onClick?: (data: any, index: number) => void;- className?: string;- maxChartSize?: number;- minChartSize?: number;- height?: number | string;- width?: number | string;+import {+ useCategoricalChartOrchestrator,+ useEffectiveAnimation,+ useExportChartData,+} from "../hooks";+import { ChartShell } from "../shared/core/ChartShell";+import { DefaultLegend } from "../shared/core/DefaultLegend/DefaultLegend";+import { useResolvedLegendKey } from "../shared/core/legend/LegendStoreProvider";+import { ChartTooltip } from "../shared/core/PortalTooltip/ChartTooltip";+import { ChartWithStackedLegend } from "../shared/core/StackedLegend/ChartWithStackedLegend";+import { CHART_CLASS_PREFIX } from "../utils/constants";+import { RadialBars } from "./parts/RadialBars";+import { RadialGrid } from "./parts/RadialGrid";+import type { RadialChartData, RadialChartProps } from "./types";++const BAR_GAP = 2;++/**+ * `legendVariant="stacked"` (the default) lays the chart out with its built-in stacked legend. The inline legend is+ * used for `"default"`, and none when the chart publishes to an external+ * legend (`legendKey`, or a surrounding `LegendStoreProvider`'s key).+ */+export function RadialChart<T extends RadialChartData>(props: RadialChartProps<T>) {+ const { legend = true, legendVariant = "stacked", legendKey, width, height, className } = props;+ const externalLegendKey = useResolvedLegendKey(legendKey);++ if (legend && legendVariant === "stacked" && externalLegendKey === undefined) {+ return (+ <ChartWithStackedLegend width={width} height={height} className={className}>+ <RadialChartImpl {...props} width={undefined} height={undefined} className={undefined} />+ </ChartWithStackedLegend>+ );+ }+ return <RadialChartImpl {...props} />;}-const STACKED_LEGEND_BREAKPOINT = 400;-const MIN_CHART_SIZE = 150;-const MAX_CHART_SIZE = 500;--export const RadialChart = <T extends RadialChartData>({- data,- categoryKey,- dataKey,- theme = "ocean",- customPalette,- variant = "circular",- format = "number",- legend = true,- legendVariant = "stacked",- grid = false,- isAnimationActive = false,- cornerRadius = 10,- onMouseEnter,- onMouseLeave,- onClick,- className,- maxChartSize = MAX_CHART_SIZE,- minChartSize = MIN_CHART_SIZE,- height,- width,-}: RadialChartProps<T>) => {- const printContext = usePrintContext();- isAnimationActive = printContext ? false : isAnimationActive;-- const wrapperRef = useRef<HTMLDivElement>(null);- const [wrapperRect, setWrapperRect] = useState({ width: 0, height: 0 });- const [hoveredLegendKey, setHoveredLegendKey] = useState<string | null>(null);- const [isLegendExpanded, setIsLegendExpanded] = useState(false);- const { activeIndex, handleMouseEnter, handleMouseLeave } = useRadialChartHover();-- // Determine layout mode based on container width- const isRowLayout =- legend && legendVariant === "stacked" && wrapperRect.width >= STACKED_LEGEND_BREAKPOINT;-- // Sort data by value (highest to lowest) for radial chart rendering- const sortedProcessedData = useMemo(- () => [...data].sort((a, b) => Number(b[dataKey]) - Number(a[dataKey])),- [data, dataKey],- );-- const categories = useMemo(- () => sortedProcessedData.map((item) => String(item[categoryKey])),- [sortedProcessedData, categoryKey],- );- const transformedKeys = useTransformedKeys(categories);-- // Memoize string conversions to avoid repeated calls- const categoryKeyString = useMemo(() => String(categoryKey), [categoryKey]);- const dataKeyString = useMemo(() => String(dataKey), [dataKey]);- const formatKey = useMemo(- () => (format === "percentage" ? "percentage" : dataKeyString),- [format, dataKeyString],- );-- // Use provided dimensions or observed dimensions from the wrapper- const effectiveWidth = wrapperRect.width;- const effectiveHeight = wrapperRect.height;-- // Calculate chart dimensions based on the smaller dimension of the container- const chartSize = useMemo(() => {- // Compute the available width for the chart. In row layout, chart and legend sit side-by-side.- // Subtract the 20px gap defined in CSS to avoid over-estimating available width.- const containerWidth = isRowLayout ? Math.max(0, (effectiveWidth - 20) / 2) : effectiveWidth;-- // If wrapper height isn't explicitly provided (or is very small), prefer sizing by width to- // avoid a feedback loop where height depends on the chart, which then clamps the size.- const heightIsUsable = effectiveHeight >= minChartSize;-- let size = heightIsUsable ? Math.min(containerWidth, effectiveHeight) : containerWidth;- size = Math.min(size, maxChartSize);- return Math.max(minChartSize, size);- }, [effectiveWidth, effectiveHeight, isRowLayout]);-- const chartSizeStyle = useMemo(- () => ({- width: chartSize,- height: chartSize,- }),- [chartSize],- );-- const rechartsProps: Omit<React.ComponentProps<typeof ResponsiveContainer>, "children"> = useMemo(- () => ({- width: "100%",- height: "100%",- minWidth: 1,- minHeight: 1,- initialDimension: { width: 1, height: 1 },- }),- [],- );-- // Calculate chart radii- const dimensions = useMemo(() => calculateRadialChartDimensions(chartSize), [chartSize]);-- // Get color palette and distribute colors- const colors = useChartPalette({- chartThemeName: theme,+function RadialChartImpl<T extends RadialChartData>(props: RadialChartProps<T>) {+ const {+ data,+ categoryKey,+ dataKey,customPalette,+ variant = "circular",+ format = "number",+ legend: showLegend = true,+ grid: showGrid = false,+ isAnimationActive = false,+ cornerRadius = 10,+ maxChartSize = 500,+ minChartSize = 150,+ height,+ width,+ fitLegendInHeight,+ className,+ onClick,+ legendKey,+ } = props;++ const isSemiCircular = variant === "semiCircular";++ const orch = useCategoricalChartOrchestrator({+ data,+ categoryKey,+ dataKey,themePaletteName: "radialChartPalette",- dataLength: sortedProcessedData.length,+ customPalette,+ format,+ showLegend,+ isSemiCircular,+ maxChartSize,+ minChartSize,+ height,+ width,+ fitLegendInHeight,+ legendKey,});- const exportData = useExportChartData({- type: "pie",- data: sortedProcessedData,- categoryKey: categoryKey as string,- dataKeys: [dataKey as string],- colors,- legend,- });+ const animate = useEffectiveAnimation(isAnimationActive);- // Memoize expensive data transformations and configurations- const transformedData = useMemo(- () => transformRadialDataWithPercentages(sortedProcessedData as T, dataKey, colors),- [sortedProcessedData, dataKey, colors],- );+ // Radial-specific geometry+ const maxRadius = orch.dimensions.chartSize * 0.45;+ const minRadius = maxRadius * 0.25;+ // semiCircular viewport shows the TOP half-plane (centerY sits at the bottom+ // edge), so the sweep must run 9→12→3 o'clock (d3 angles: 0 = 12 o'clock,+ // clockwise) — same convention as PieChart's semiCircular.+ const startAngle = isSemiCircular ? -Math.PI / 2 : 0;+ const endAngle = isSemiCircular ? Math.PI / 2 : 2 * Math.PI;- const chartConfig = useMemo(- () => getCategoricalChartConfig(sortedProcessedData as T, categoryKey, colors, transformedKeys),- [sortedProcessedData, categoryKey, colors, transformedKeys],+ const maxValue = useMemo(+ () => Math.max(...orch.data.visibleSlices.map((s) => s.value), 0),+ [orch.data.visibleSlices],);- const animationConfig = useMemo(- () => createRadialAnimationConfig({ isAnimationActive }),- [isAnimationActive],- );-- const eventHandlers = useMemo(- () => createRadialEventHandlers(onMouseEnter, onMouseLeave, onClick),- [onMouseEnter, onMouseLeave, onClick],- );-- // Create legend items for both variants- const legendItems = useMemo(- () =>- sortedProcessedData.map((item, index) => ({- key: String(item[categoryKey]),- label: String(item[categoryKey]),- value: Number(item[dataKey]),- color: colors[index] || "#000000",- })),- [sortedProcessedData, categoryKey, dataKey, colors],- );-- const defaultLegendItems = useMemo((): LegendItem[] => {- return legendItems.map(({ key, label, color }) => ({ key, label, color }));- }, [legendItems]);-- // Handle legend item hover to highlight radial bar- const handleLegendItemHover = useCallback(- (index: number | null) => {- if (legendVariant !== "stacked") return;- if (index !== null) {- const item = sortedProcessedData[index];- if (item) {- const categoryValue = String(item[categoryKey]);- setHoveredLegendKey(categoryValue);- // Find the index in the transformed data (which is also sorted)- const transformedIndex = transformedData.findIndex(- (d) => String((d as any)[categoryKey]) === categoryValue,- );- if (transformedIndex !== -1) {- handleMouseEnter(transformedData[transformedIndex], transformedIndex);- }- }- } else {- setHoveredLegendKey(null);- handleMouseLeave();- }- },- [- sortedProcessedData,- categoryKey,- transformedData,- handleMouseEnter,- handleMouseLeave,- legendVariant,- ],- );-- // Enhanced chart hover handlers- const handleChartMouseEnter = useCallback(- (entry: any, index: number) => {- handleMouseEnter(entry, index);- if (legend && legendVariant === "stacked") {- setHoveredLegendKey(String(entry[categoryKey]));- }- eventHandlers.onMouseEnter?.(entry, index);- },- [handleMouseEnter, categoryKey, legend, legendVariant, eventHandlers.onMouseEnter],- );-- const handleChartMouseLeave = useCallback(() => {- handleMouseLeave();- if (legend && legendVariant === "stacked") {- setHoveredLegendKey(null);- }- eventHandlers.onMouseLeave?.();- }, [handleMouseLeave, legend, legendVariant, eventHandlers.onMouseLeave]);-- // Setup ResizeObserver to watch the wrapper element- useEffect(() => {- const wrapper = wrapperRef.current;- if (!wrapper) return;-- // Use ResizeObserver if component is in responsive mode (no fixed width/height)- const observer = new ResizeObserver((entries) => {- const entry = entries[0];- if (entry) {- setWrapperRect({- width: entry.contentRect.width,- height: entry.contentRect.height,- });- }- });- observer.observe(wrapper);- return () => observer.disconnect();- }, []);-- const renderLegend = useCallback(() => {- if (!legend) return null;- if (legendVariant === "stacked") {- return (- <div className="openui-radial-chart-legend-container">- <StackedLegend- items={legendItems}- onItemHover={setHoveredLegendKey}- activeKey={hoveredLegendKey}- onLegendItemHover={handleLegendItemHover}- containerWidth={isRowLayout ? undefined : wrapperRect.width}- />- </div>- );- }- return (- <DefaultLegend- items={defaultLegendItems}- containerWidth={wrapperRect.width}- isExpanded={isLegendExpanded}- setIsExpanded={setIsLegendExpanded}- />- );- }, [- legend,- legendVariant,- legendItems,- hoveredLegendKey,- handleLegendItemHover,- wrapperRect.width,- isRowLayout,- defaultLegendItems,- isLegendExpanded,- ]);-- const wrapperClassName = clsx("openui-radial-chart-container-wrapper", className, {- "layout-row": isRowLayout,- "layout-column": !isRowLayout,- "legend-default": legend && legendVariant === "default",- "legend-stacked": legend && legendVariant === "stacked",+ // PPTX print-export JSON — mirrors react-ui's RadialChart call, which (like+ // its PieChart) emits type:'pie' with a single series = [dataKey] and no+ // extraOptions. Colors are the resolved slice palette in sorted-data order.+ // Undefined off the print path.+ const exportData = useExportChartData({+ type: "pie",+ data: orch.data.sortedData,+ categoryKey: orch.data.catKey,+ dataKeys: [orch.data.valKey],+ colors: orch.data.slices.map((s) => s.color),+ legend: showLegend,});- // Correct angles for semicircle (top half)- const startAngle = variant === "semicircle" ? 180 : 0;- const endAngle = variant === "semicircle" ? 0 : 360;-- const wrapperStyle = useMemo(() => {- const formatDimension = (value: number | string | undefined) => {- if (typeof value === "number") {- return `${value}px`;- }- return value;- };- const dimensions = {- width: formatDimension(width),- height: formatDimension(height),- };-- if (dimensions.width === undefined) {- delete dimensions.width;- }-- if (dimensions.height === undefined) {- delete dimensions.height;- }- return dimensions;- }, [width, height]);-return (- <div- ref={wrapperRef}- className={wrapperClassName}- style={wrapperStyle}- aria-description="radial-chart-wrapper"- data-openui-chart={exportData}+ <ChartShell+ containerRef={orch.refs.containerRef}+ classPrefix={`${CHART_CLASS_PREFIX}-radial-chart`}+ className={className}+ style={orch.style.containerStyle}+ isEmpty={orch.isEmpty}+ exportData={exportData}>- <div className="openui-radial-chart-container">- <div className="openui-radial-chart-container-inner">- <div style={chartSizeStyle}>- <ChartContainer- config={chartConfig}- className="openui-radial-chart"- rechartsProps={rechartsProps}+ {() => (+ <>+ <div className={`${CHART_CLASS_PREFIX}-radial-chart-svg-wrapper`}>+ <svg+ width={orch.dimensions.svgWidth}+ height={orch.dimensions.svgHeight}+ viewBox={`0 0 ${orch.dimensions.svgWidth} ${orch.dimensions.svgHeight}`}+ role="img"+ aria-label="Radial chart">- <RadialBarChart- data={transformedData}- startAngle={startAngle}- endAngle={endAngle}- innerRadius={dimensions.innerRadius}- outerRadius={dimensions.outerRadius}- >- {grid && <PolarGrid gridType="circle" />}- <ChartTooltip- cursor={false}- content={- <ChartTooltipContent- showPercentage={format === "percentage"}- nameKey={categoryKeyString}- />- }- />- <RadialBar- dataKey={formatKey}- background={!grid}+ <g transform={`translate(${orch.dimensions.centerX}, ${orch.dimensions.centerY})`}>+ {showGrid && (+ <RadialGrid+ maxRadius={maxRadius}+ minRadius={minRadius}+ startAngle={startAngle}+ endAngle={endAngle}+ />+ )}+ <RadialBars+ slices={orch.data.visibleSlices}+ maxValue={maxValue}+ maxRadius={maxRadius}+ minRadius={minRadius}+ startAngle={startAngle}+ endAngle={endAngle}cornerRadius={cornerRadius}- {...animationConfig}- activeIndex={activeIndex ?? undefined}- onMouseEnter={handleChartMouseEnter}- onMouseLeave={handleChartMouseLeave}- onClick={eventHandlers.onClick}- >- {transformedData.map((entry, index) => {- const categoryValue = String(entry[categoryKey as keyof typeof entry] || "");- const config = chartConfig[categoryValue];- const hoverStyles = getRadialHoverStyles(index, activeIndex);- const fill = config?.color || colors[index];- return (- <Cell key={`cell-${index}`} fill={fill} {...hoverStyles} stroke="none" />- );- })}- </RadialBar>- </RadialBarChart>- </ChartContainer>+ barGap={BAR_GAP}+ hoveredIndex={orch.hover.hoveredIndex}+ animate={animate}+ data={orch.data.visibleRows}+ onMouseMove={orch.hover.handleMouseMove}+ onMouseLeave={orch.hover.handleMouseLeave}+ onClick={onClick}+ />+ </g>+ </svg></div>- </div>- </div>- {renderLegend()}- </div>++ {showLegend && !orch.usesRemoteLegend && (+ <DefaultLegend+ ref={orch.refs.legendRef}+ items={orch.data.legendItems}+ containerWidth={orch.dimensions.containerWidth}+ isExpanded={orch.legend.isLegendExpanded}+ setIsExpanded={orch.legend.setIsLegendExpanded}+ onItemClick={orch.data.toggleSlice}+ hiddenSeries={orch.data.hiddenSlices}+ />+ )}++ {orch.tooltip.tooltipPayload && orch.hover.mousePos && (+ <ChartTooltip+ label={orch.tooltip.tooltipPayload.label}+ items={orch.tooltip.tooltipPayload.items}+ viewportPosition={orch.hover.mousePos}+ />+ )}+ </>+ )}+ </ChartShell>);-};+}diff --git a/packages/react-ui/src/components/Charts/RadialChart/index.ts b/packages/react-ui/src/components/Charts/RadialChart/index.tsindex 2f12d30de..d4da77b01 100644--- a/packages/react-ui/src/components/Charts/RadialChart/index.ts+++ b/packages/react-ui/src/components/Charts/RadialChart/index.ts@@ -1,2 +1,2 @@-export * from "./RadialChart";-export * from "./types";+export { RadialChart } from "./RadialChart";+export type { RadialChartData, RadialChartProps } from "./types";diff --git a/packages/react-ui/src/components/D3Charts/RadialChart/parts/RadialBars.tsx b/packages/react-ui/src/components/Charts/RadialChart/parts/RadialBars.tsxsimilarity index 100%rename from packages/react-ui/src/components/D3Charts/RadialChart/parts/RadialBars.tsxrename to packages/react-ui/src/components/Charts/RadialChart/parts/RadialBars.tsxdiff --git a/packages/react-ui/src/components/D3Charts/RadialChart/parts/RadialGrid.tsx b/packages/react-ui/src/components/Charts/RadialChart/parts/RadialGrid.tsxsimilarity index 100%rename from packages/react-ui/src/components/D3Charts/RadialChart/parts/RadialGrid.tsxrename to packages/react-ui/src/components/Charts/RadialChart/parts/RadialGrid.tsxdiff --git a/packages/react-ui/src/components/Charts/RadialChart/radialChart.scss b/packages/react-ui/src/components/Charts/RadialChart/radialChart.scssindex 6c113bdbd..29489faaf 100644--- a/packages/react-ui/src/components/Charts/RadialChart/radialChart.scss+++ b/packages/react-ui/src/components/Charts/RadialChart/radialChart.scss@@ -1,84 +1,22 @@@use "../../../cssUtils" as cssUtils;+@use "../shared/cartesian/chartBase" as base;+@use "../prefix" as brand;-// Main wrapper for the entire chart component-.openui-radial-chart-container-wrapper {- display: flex;- position: relative;- gap: 20px;+@include base.centered-container("radial-chart");+@include base.centered-svg-wrapper("radial-chart");- // Default legend is always a column layout- &.legend-default {- flex-direction: column;- align-items: center;- }-- // Stacked legend uses a column layout by default (mobile-first)- &.legend-stacked.layout-column {- flex-direction: column;- align-items: center;- }-- // Switches to a row layout on wider containers- &.legend-stacked.layout-row {- flex-direction: row;- align-items: center; // Vertically center chart and legend- max-height: 296px;-- .openui-radial-chart-legend-container {- height: 296px;- }- }-}--// Container for the chart itself-.openui-radial-chart-container {- display: flex;- align-items: center;- justify-content: center;- position: relative;- width: 100%;- height: 100%;-- // When in a row layout, the chart container should be flexible- .layout-row & {- flex: 1;- min-width: 0; // Prevent flexbox overflow issues- }+.#{brand.$prefix}-radial-chart-grid-circle {+ stroke: cssUtils.$border-default;+ stroke-width: 1;+ stroke-dasharray: 4 4;}-// Recharts chart styles-.openui-radial-chart {- display: flex;- align-items: center;- justify-content: center;-- .recharts-polar-grid {- opacity: 0.3;- }-}--// Container for the legend component-.openui-radial-chart-legend-container {- display: flex;- justify-content: center;-- // Default legend is centered at the bottom- .legend-default & {- width: 100%;- align-items: center;- }-- // Stacked legend in column layout- .layout-column.legend-stacked & {- width: 100%;- align-items: flex-start;- }-- // Stacked legend in row layout- .layout-row.legend-stacked & {- flex: 1;- min-width: 0; // Prevent flexbox overflow- height: 100%;- align-items: center; // Vertically center legend content+// Entrances are decorative: gate the whole rule (pre-state included) behind+// reduced-motion so users who opt out get the natural static state immediately+// — gating only the animation would strand elements at the opacity: 0 start.+@media (prefers-reduced-motion: no-preference) {+ .#{brand.$prefix}-radial-chart-bar--animated {+ opacity: 0;+ animation: #{brand.$prefix}-fade-appear 0.5s ease-out forwards;}}diff --git a/packages/react-ui/src/components/Charts/RadialChart/stories/RadialChart.stories.tsx b/packages/react-ui/src/components/Charts/RadialChart/stories/RadialChart.stories.tsxindex 78da99c4a..c40da0323 100644--- a/packages/react-ui/src/components/Charts/RadialChart/stories/RadialChart.stories.tsx+++ b/packages/react-ui/src/components/Charts/RadialChart/stories/RadialChart.stories.tsx@@ -1,7 +1,7 @@import type { Meta, StoryObj } from "@storybook/react";import { useState } from "react";+import { RadialChart, RadialChartProps } from "../..";import { Card } from "../../../Card";-import { RadialChart, RadialChartProps } from "../RadialChart";/*** Sample data sets for demonstrating various RadialChart configurations@@ -85,7 +85,7 @@ const customColorPalette = [* - **Animation Support**: Smooth transitions and loading animations** ### Customization Options- * - **Theme System**: Pre-built color palettes (ocean, orchid, emerald, sunset, spectrum, vivid)+ * - **Colors**: Uses the ThemeProvider's chart palette, or custom colors with `customPalette`* - **Layout Flexibility**: Responsive design that adapts to container dimensions*/@@ -108,7 +108,6 @@ import { RadialChart } from '@openuidev/react-ui/Charts/RadialChart';data={yourData}categoryKey="category"dataKey="value"- theme="ocean"variant="circular"/>\`\`\`@@ -187,32 +186,14 @@ const exampleData = [category: "📊 Data Configuration",},},- theme: {- description: `-**Color Theme Selection.** Choose from professionally designed color palettes:--- **ocean**: Cool blues and teals (professional, corporate)-- **orchid**: Purple and pink tones (creative, modern)-- **emerald**: Green variations (nature, growth, finance)-- **sunset**: Warm oranges and reds (energy, attention-grabbing)-- **spectrum**: Full color range (diverse, comprehensive)-- **vivid**: High-contrast colors (accessibility, clarity)- `,- control: "select",- options: ["ocean", "orchid", "emerald", "sunset", "spectrum", "vivid"],- table: {- defaultValue: { summary: "ocean" },- category: "🎨 Visual Styling",- },- },customPalette: {description: `-**Custom Color Palette.** Override the theme colors with your own color array.+**Custom Color Palette.** Override the ThemeProvider's chart palette with your own color array.**Usage:**- Provide an array of hex color strings- Colors will be applied in order to chart segments-- Takes precedence over theme colors when provided+- Takes precedence over the ThemeProvider's chart palette when provided- Useful for brand-specific color requirements**Example:**@@ -358,7 +339,7 @@ type Story = StoryObj<typeof meta>;** **Key Features Shown:*** - Standard circular layout with full 360° display- * - Professional ocean color theme+ * - Chart palette from the ThemeProvider* - Stacked legend for optimal space utilization* - Smooth animations for polished user experience* - Number format for clear value display@@ -369,7 +350,6 @@ export const DefaultConfiguration: Story = {data: monthlyRevenueData,categoryKey: "month",dataKey: "value",- theme: "ocean",variant: "circular",format: "number",legend: true,@@ -401,7 +381,7 @@ in a clear, professional manner with optimal default settings for readability an**Configuration Details:**- **Data**: 12 months of revenue data- **Layout**: Full circular display-- **Colors**: Ocean theme (blues and teals)+- **Colors**: The ThemeProvider's chart palette- **Legend**: Stacked layout for space efficiency- **Animations**: Enabled for smooth interactions`,@@ -410,60 +390,6 @@ in a clear, professional manner with optimal default settings for readability an},};-/**- * ## Theme Showcase- *- * RadialChart includes six professionally designed color themes, each optimized- * for different contexts and brand requirements.- */-export const ThemeShowcase: Story = {- name: "🎨 Theme Variations",- args: {- data: monthlyRevenueData.slice(0, 6),- categoryKey: "month",- dataKey: "value",- theme: "emerald",- variant: "circular",- format: "number",- legend: true,- legendVariant: "stacked",- grid: false,- isAnimationActive: true,- cornerRadius: 10,- },- render: (args: any) => (- <Card style={{ width: "600px", height: "auto", padding: "24px" }}>- <div style={{ marginBottom: "20px" }}>- <h3 style={{ margin: "0 0 8px 0", fontSize: "18px", fontWeight: "600" }}>- Financial Growth Metrics- </h3>- <p style={{ margin: 0, color: "#666", fontSize: "14px" }}>- Using the emerald theme for finance-related data visualization- </p>- </div>- <RadialChart {...args} />- </Card>- ),- parameters: {- docs: {- description: {- story: `-**Theme Selection Guide:**--- **Ocean** 🌊: Corporate, professional, trustworthy (recommended for business)-- **Orchid** 🌸: Creative, modern, innovative (great for design/marketing)-- **Emerald** 🍃: Growth, finance, nature (perfect for financial data)-- **Sunset** 🌅: Energy, attention, warmth (ideal for alerts/important metrics)-- **Spectrum** 🌈: Diverse, comprehensive (when you need many distinct colors)-- **Vivid** ⚡: High contrast, accessible (optimized for accessibility requirements)--**Best Practice:** Choose themes that align with your brand colors and data context.- `,- },- },- },-};-/*** ## Advanced Visual Enhancement*@@ -475,7 +401,6 @@ export const VisualEnhancement: Story = {data: monthlyRevenueData.slice(0, 6),categoryKey: "month",dataKey: "value",- theme: "sunset",variant: "circular",format: "percentage",legend: true,@@ -591,7 +516,7 @@ export const CustomPalette: Story = {**Custom Palette Features:**- **Brand Alignment**: Use your exact brand colors for consistent visual identity-- **Override Themes**: Takes precedence over theme-based color selection+- **Palette Override**: Takes precedence over the ThemeProvider's chart palette- **Flexible Array**: Provide any number of colors - they'll cycle automatically for larger datasets- **Hex Color Support**: Standard hex color format (#RRGGBB)@@ -640,7 +565,6 @@ export const LargeDatasetDemo: Story = {data: comprehensiveFinancialData,categoryKey: "category",dataKey: "amount",- theme: "spectrum",variant: "circular",format: "number",legend: true,@@ -720,7 +644,6 @@ export const ResponsiveDemo: Story = {data: monthlyRevenueData,categoryKey: "month",dataKey: "value",- theme: "spectrum",variant: "circular",format: "number",legend: true,diff --git a/packages/react-ui/src/components/D3Charts/RadialChart/types.ts b/packages/react-ui/src/components/Charts/RadialChart/types.tssimilarity index 93%rename from packages/react-ui/src/components/D3Charts/RadialChart/types.tsrename to packages/react-ui/src/components/Charts/RadialChart/types.tsindex 6b5c2eb0b..6ccac43e0 100644--- a/packages/react-ui/src/components/D3Charts/RadialChart/types.ts+++ b/packages/react-ui/src/components/Charts/RadialChart/types.ts@@ -13,8 +13,7 @@ export interface RadialChartProps<T extends RadialChartData> {/*** `"stacked"` (default): the chart with a stacked legend listing each item's* share — side by side from 400px wide, below the chart when narrower.- * `"default"`: the compact legend under the chart. Matches react-ui's- * Recharts RadialChart.+ * `"default"`: the compact legend under the chart.*/legendVariant?: "default" | "stacked";grid?: boolean;diff --git a/packages/react-ui/src/components/Charts/RadialChart/types/index.ts b/packages/react-ui/src/components/Charts/RadialChart/types/index.tsdeleted file mode 100644index 498dd6e66..000000000--- a/packages/react-ui/src/components/Charts/RadialChart/types/index.ts+++ /dev/null@@ -1 +0,0 @@-export type RadialChartData = Array<Record<string, string | number>>;diff --git a/packages/react-ui/src/components/Charts/RadialChart/utils/RadialChartUtils.ts b/packages/react-ui/src/components/Charts/RadialChart/utils/RadialChartUtils.tsdeleted file mode 100644index 0d601baeb..000000000--- a/packages/react-ui/src/components/Charts/RadialChart/utils/RadialChartUtils.ts+++ /dev/null@@ -1,199 +0,0 @@-/**- * Utility functions for radial charts- */-import { useState } from "react";-import { RadialChartData } from "../types";--// ==========================================--export interface RadialChartDimensions {- outerRadius: number;- innerRadius: number;-}--export interface RadialHoverStyles {- opacity: number;- stroke: string;- strokeWidth: number;-}--export interface RadialChartHoverHook {- activeIndex: number | null;- handleMouseEnter: (event: any, index: number) => void;- handleMouseLeave: () => void;-}--export interface RadialAnimationConfig {- isAnimationActive: boolean;- animationBegin: number;- animationDuration: number;- animationEasing: "ease" | "ease-in" | "ease-out" | "ease-in-out" | "linear";-}--// ==========================================-// Core Calculation Utilities-// ==========================================--/**- * Calculates the percentage value of a number relative to a total- * @param value - The value to calculate percentage for- * @param total - The total value to calculate percentage against- * @returns The calculated percentage rounded to 2 decimal places- */-export const calculatePercentage = (value: number, total: number): number => {- if (total === 0) {- return 0;- }- return Number(((value / total) * 100).toFixed(2));-};--// ==========================================-// Chart Dimension Calculations-// ==========================================--/**- * Calculates dimensions for radial charts based on container size- * @param width - The container width- * @param variant - The chart variant ('semicircle' or 'circular')- * @returns Object containing outer and inner radius values- */-export const calculateRadialChartDimensions = (width: number): RadialChartDimensions => {- // Prefer a base that better utilizes width while leaving a small margin to prevent clipping- const baseRadiusPercentage = 0.45;- let outerRadius = Math.round(width * baseRadiusPercentage);-- // Clamp radius within sensible bounds and leave ~10px margin from the edge- outerRadius = Math.max(50, Math.min(outerRadius, Math.round(width / 2) - 10));-- // The inner radius is 30% of the outer radius- const innerRadius = Math.round(outerRadius * 0.3);-- return { outerRadius, innerRadius };-};--// ==========================================-// Layout and Styling Utilities-// ==========================================--/**- * Generates hover style properties for radial chart cells- * @param index - The index of the current cell- * @param activeIndex - The index of the currently hovered cell- * @returns Object containing hover style properties- */-export const getRadialHoverStyles = (- index: number,- activeIndex: number | null,-): RadialHoverStyles => {- return {- opacity: activeIndex === null || activeIndex === index ? 1 : 0.6,- stroke: activeIndex === index ? "#fff" : "none",- strokeWidth: activeIndex === index ? 2 : 0,- };-};--// ==========================================-// Data Transformation Utilities-// ==========================================--/**- * Transforms data by adding percentage calculations and colors- * @param data - The input data array- * @param dataKey - The key to use for value calculations- * @param theme - The color theme to use- * @returns Transformed data with added percentage, original value, and fill color- */-export const transformRadialDataWithPercentages = <T extends RadialChartData>(- data: T,- dataKey: keyof T[number],- colors: string[], // Change this from 'theme: string' to 'colors: string[]'-) => {- const total = data.reduce((sum, item) => sum + Number(item[dataKey]), 0);-- return data.map((item, index) => ({- ...item,- percentage: calculatePercentage(Number(item[dataKey as string]), total),- originalValue: item[dataKey as string],- fill: colors[index],- }));-};--// ==========================================-// Hover Effect Utilities-// ==========================================--/**- * Custom hook for managing radial chart hover effects- * @returns Object containing hover state and handlers- */-export const useRadialChartHover = (): RadialChartHoverHook => {- const [activeIndex, setActiveIndex] = useState<number | null>(null);-- const handleMouseEnter = (_: any, index: number) => {- setActiveIndex(index);- };-- const handleMouseLeave = () => {- setActiveIndex(null);- };-- return {- activeIndex,- handleMouseEnter,- handleMouseLeave,- };-};--// ==========================================-// Animation Utilities-// ==========================================--/**- * Creates animation configuration for radial chart- * @param config - Animation configuration options- * @returns Animation configuration object- */-export const createRadialAnimationConfig = (- config: Partial<RadialAnimationConfig> = {},-): RadialAnimationConfig => {- return {- isAnimationActive: config.isAnimationActive ?? true,- animationBegin: config.animationBegin ?? 0,- animationDuration: config.animationDuration ?? 1500,- animationEasing: config.animationEasing ?? "ease",- };-};--// ==========================================-// Event Handler Utilities-// ==========================================--/**- * Creates event handlers for radial chart- * @param onMouseEnter - Mouse enter handler- * @param onMouseLeave - Mouse leave handler- * @param onClick - Click handler- * @returns Object containing event handlers- */-export const createRadialEventHandlers = (- onMouseEnter?: (data: any, index: number) => void,- onMouseLeave?: () => void,- onClick?: (data: any, index: number) => void,-) => {- return {- onMouseEnter: onMouseEnter- ? (data: any, index: number) => onMouseEnter(data, index)- : undefined,- onMouseLeave: onMouseLeave ? () => onMouseLeave() : undefined,- onClick: onClick ? (data: any, index: number) => onClick(data, index) : undefined,- };-};--// ==========================================-// Backward compatibility - keeping old function names-// ==========================================--// Keep old function names for backward compatibility-export const transformRadialData = transformRadialDataWithPercentages;-export const useChartHover = useRadialChartHover;-export const getHoverStyles = getRadialHoverStyles;diff --git a/packages/react-ui/src/components/Charts/ScatterChart/ScatterChart.tsx b/packages/react-ui/src/components/Charts/ScatterChart/ScatterChart.tsxindex eb4ad70ea..42817ae0d 100644--- a/packages/react-ui/src/components/Charts/ScatterChart/ScatterChart.tsx+++ b/packages/react-ui/src/components/Charts/ScatterChart/ScatterChart.tsx@@ -1,414 +1,185 @@-import clsx from "clsx";-import React, { useEffect, useId, useMemo, useRef, useState } from "react";-import { Cell, ScatterChart as RechartsScatterChart, Scatter, XAxis, YAxis } from "recharts";-import { usePrintContext } from "../../../context/PrintContext";-import { ChartConfig, ChartContainer, ChartTooltip } from "../Charts";-import { SideBarChartData, SideBarTooltipProvider } from "../context/SideBarTooltipContext";-import { useExportChartData, useYAxisLabelWidth } from "../hooks";-import {- CustomTooltipContent,- DefaultLegend,- gridCartesianGrid,- SideBarTooltip,- SVGXAxisTick,- YAxisTick,-} from "../shared";-import { LegendItem } from "../types";-import { get2dChartConfig, getLegendItems } from "../utils/dataUtils";-import { PaletteName, useChartPalette } from "../utils/PalletUtils";-import { numberTickFormatter } from "../utils/styleUtils";-import ScatterDot from "./components/ScatterDot";-import { ScatterChartData, ScatterPoint } from "./types";-import {- calculateScatterDomain,- getScatterDatasets,- transformScatterData,-} from "./utils/ScatterChartUtils";--export interface ScatterChartProps {- data: ScatterChartData;- xAxisDataKey?: string;- yAxisDataKey?: string;- theme?: PaletteName;- customPalette?: string[];- grid?: boolean;- legend?: boolean;- isAnimationActive?: boolean;- xAxisLabel?: React.ReactNode;- yAxisLabel?: React.ReactNode;- className?: string;- height?: number | string;- width?: number | string;- shape?: "circle" | "square";-}--const DEFAULT_CHART_HEIGHT = 296;-const X_AXIS_HEIGHT = 40;--export const ScatterChart = ({- data,- xAxisDataKey = "x",- yAxisDataKey = "y",- theme = "ocean",- customPalette,- grid = true,- xAxisLabel,- yAxisLabel,- legend = true,- isAnimationActive = false,- className,- height,- width,- shape = "circle",-}: ScatterChartProps) => {- const printContext = usePrintContext();- isAnimationActive = printContext ? false : isAnimationActive;-- const datasets = useMemo(() => {- return getScatterDatasets(data);- }, [data]);-- const colors = useChartPalette({- chartThemeName: theme,- customPalette,- themePaletteName: "lineChartPalette",- dataLength: datasets.length,- });-- const transformedData: ScatterPoint[] = useMemo(() => {- if (!data || !Array.isArray(data)) {- return [];- }- return transformScatterData(data, datasets, colors);- }, [data, datasets, colors]);-- const { yAxisWidth, setLabelWidth } = useYAxisLabelWidth(transformedData, [yAxisDataKey]);-- const chartConfig: ChartConfig = useMemo(() => {- return get2dChartConfig(- datasets,- colors,- datasets.reduce((acc, key) => ({ ...acc, [key]: key }), {}),- undefined,- );- }, [datasets, colors]);-- const chartWrapperRef = useRef<HTMLDivElement>(null);- const legendContainerRef = useRef<HTMLDivElement>(null);- const xAxisContainerRef = useRef<HTMLDivElement>(null);- const [containerWidth, setContainerWidth] = useState<number>(0);- const [isSideBarTooltipOpen, setIsSideBarTooltipOpen] = useState(false);- const [isLegendExpanded, setIsLegendExpanded] = useState(false);- const [sideBarTooltipData, setSideBarTooltipData] = useState<SideBarChartData>({- title: "",- values: [],- });-- const chartWidth = useMemo(() => {- if (!containerWidth) {- return undefined;- }- return containerWidth - yAxisWidth;- }, [containerWidth, yAxisWidth]);-- const chartHeight = useMemo(() => {- const legendHeight = legendContainerRef.current?.offsetHeight ?? 0;- const xAxisHeight = xAxisContainerRef.current?.offsetHeight ?? 0;-- if (typeof height === "number") {- return height - legendHeight - xAxisHeight;- }-- if (typeof height === "string" && height.endsWith("px")) {- const numericHeight = parseInt(height, 10);- if (!isNaN(numericHeight)) {- return numericHeight - legendHeight - xAxisHeight;- }- }-- if (!height || !chartWrapperRef.current) {- return DEFAULT_CHART_HEIGHT;- }-- return chartWrapperRef.current.offsetHeight - legendHeight - xAxisHeight;- }, [containerWidth, height]);-- const isFixedNumericHeight = useMemo(() => {- if (typeof height === "number") return true;- if (typeof height === "string" && height.endsWith("px")) return true;- return false;- }, [height]);-- // Calculate domains for x and y axes- const xDomain = useMemo(() => {- return calculateScatterDomain(data, xAxisDataKey as "x" | "y");- }, [data, xAxisDataKey]);-- const yDomain = useMemo(() => {- return calculateScatterDomain(data, yAxisDataKey as "x" | "y");- }, [data, yAxisDataKey]);-- const renderDotShape = useMemo(() => {- return (props: unknown) => {- return <ScatterDot {...(props as object)} variant={shape} />;- };- }, [shape]);-- useEffect(() => {- const chartElement = chartWrapperRef.current;-- if (!chartElement) {- return;- }-- const resizeObserver = new ResizeObserver((entries) => {- for (const entry of entries) {- if (entry.target === chartElement) {- setContainerWidth(entry.contentRect.width);- }- }- });-- resizeObserver.observe(chartElement);-- return () => {- resizeObserver.disconnect();- };- }, []);-- useEffect(() => {- setIsSideBarTooltipOpen(false);- setIsLegendExpanded(false);- }, [datasets]);-- const legendItems: LegendItem[] = useMemo(() => {- return getLegendItems(datasets, colors);- }, [datasets, colors]);-- const exportData = useExportChartData({- type: "scatter",+import { useMemo } from "react";++import { useEffectiveAnimation, useScatterChartOrchestrator } from "../hooks";+import { NumericXAxis } from "../shared/cartesian/axes/NumericXAxis";+import { YAxis } from "../shared/cartesian/axes/YAxis";+import { Grid } from "../shared/cartesian/Grid";+import { VerticalGrid } from "../shared/cartesian/VerticalGrid";+import { ChartShell } from "../shared/core/ChartShell";+import { DefaultLegend } from "../shared/core/DefaultLegend/DefaultLegend";+import { ChartTooltip } from "../shared/core/PortalTooltip/ChartTooltip";+import { CHART_CLASS_PREFIX } from "../utils/constants";+import { ScatterDots } from "./parts/ScatterDots";+import type { ScatterChartProps } from "./types";++export function ScatterChart(props: ScatterChartProps) {+ const {data,- colors,- legend,+ xAxisDataKey = "x",+ yAxisDataKey = "y",+ customPalette,+ grid: showGrid = true,+ verticalGrid: showVerticalGrid = true,+ legend: showLegend = true,+ showYAxis = true,xAxisLabel,yAxisLabel,- customDataTransform: () =>- data.map((dataset) => ({- name: dataset.name,- x: dataset.data.map((p) => p[xAxisDataKey] as number),- y: dataset.data.map((p) => p[yAxisDataKey] as number),- })),+ isAnimationActive = false,+ dotRadius = 4,+ className,+ height,+ width,+ fitLegendInHeight,+ onClick,+ } = props;++ // Points are placed by their `x` / `y`; other data keys are read into them.+ const points = useMemo(+ () =>+ !Array.isArray(data) || (xAxisDataKey === "x" && yAxisDataKey === "y")+ ? data+ : data.map((dataset) => ({+ ...dataset,+ data: dataset.data.map((point) => ({+ ...point,+ x: Number(point[xAxisDataKey]),+ y: Number(point[yAxisDataKey]),+ })),+ })),+ [data, xAxisDataKey, yAxisDataKey],+ );++ const orch = useScatterChartOrchestrator({+ data: points,+ themePaletteName: "defaultChartPalette",+ customPalette,+ showLegend,+ showYAxis,+ height,+ width,+ fitLegendInHeight,+ xAxisLabel: typeof xAxisLabel === "string" ? xAxisLabel : undefined,+ yAxisLabel: typeof yAxisLabel === "string" ? yAxisLabel : undefined,+ onClick,});- const id = useId();+ const animate = useEffectiveAnimation(isAnimationActive);++ const {+ dimensions: {+ effectiveYAxisWidth,+ chartAreaWidth,+ chartInnerHeight,+ totalSvgWidth,+ totalSvgHeight,+ xAxisHeight,+ CHART_MARGIN_TOP: marginTop,+ },+ scales: { xScale, yScale },+ } = orch;- const xAxis = useMemo(() => {- return (- <div className="openui-scatter-chart-x-axis-container" ref={xAxisContainerRef}>- <ChartContainer- config={chartConfig}- style={{ width: "100%", height: X_AXIS_HEIGHT }}- rechartsProps={{- height: X_AXIS_HEIGHT,- }}- >- <RechartsScatterChart- key={`x-axis-scatter-chart-${id}`}- data={transformedData}- margin={{- top: 10,- bottom: 0,- left: yAxisWidth,- right: 0,- }}- >- <XAxis- type="number"- height={X_AXIS_HEIGHT}- name={xAxisLabel as string}- tickLine={false}- axisLine={false}- tickFormatter={numberTickFormatter}- tick={<SVGXAxisTick dy={10} />}- domain={xDomain}- dataKey={xAxisDataKey}- />- {/* Invisible scatter to maintain scale synchronization */}- <Scatter- data={transformedData}- fill="transparent"- isAnimationActive={isAnimationActive}- shape="circle"- />- </RechartsScatterChart>- </ChartContainer>- </div>- );- }, [- chartConfig,- transformedData,- id,- xDomain,- xAxisDataKey,- isAnimationActive,- xAxisLabel,- yAxisWidth,- ]);- const yAxis = useMemo(() => {- return (- <div className="openui-scatter-chart-y-axis-container" style={{ height: chartHeight + 20 }}>- <RechartsScatterChart- key={`y-axis-scatter-chart-${id}`}- width={yAxisWidth}- height={chartHeight + 10}- data={transformedData}- margin={{- top: 10,- bottom: 12,- left: 0,- right: 0,- }}- >- <YAxis- type="number"- width={yAxisWidth}- dataKey={yAxisDataKey}- name={yAxisLabel as string}- domain={yDomain}- tickLine={false}- axisLine={false}- tick={<YAxisTick setLabelWidth={setLabelWidth} />}- tickFormatter={numberTickFormatter}- />- {/* Invisible scatter to maintain scale synchronization */}- <Scatter- data={transformedData}- fill="transparent"- isAnimationActive={isAnimationActive}- shape="circle"- />- </RechartsScatterChart>- </div>- );- }, [- transformedData,- id,- yAxisWidth,- chartHeight,- yDomain,- yAxisDataKey,- yAxisLabel,- isAnimationActive,- setLabelWidth,- ]);return (- <SideBarTooltipProvider- isSideBarTooltipOpen={isSideBarTooltipOpen}- setIsSideBarTooltipOpen={setIsSideBarTooltipOpen}- data={sideBarTooltipData}- setData={setSideBarTooltipData}+ <ChartShell+ containerRef={orch.refs.containerRef}+ classPrefix={`${CHART_CLASS_PREFIX}-scatter-chart`}+ className={className}+ style={orch.style.containerStyle}+ isEmpty={orch.isEmpty}>- <div- className={clsx("openui-scatter-chart-container", className)}- data-openui-chart={exportData}- style={{- width: typeof width === "number" ? `${width}px` : width || "100%",- height: isFixedNumericHeight ? "auto" : (height ?? "auto"),- }}- ref={chartWrapperRef}- >- <div className="openui-scatter-chart-container-inner">- {yAxis}- <div- className="openui-scatter-chart-main-and-x-axis-container"- style={{ width: chartWidth }}+ {() => (+ <>+ <svg+ width={totalSvgWidth}+ height={totalSvgHeight}+ style={{ overflow: "visible" }}+ role="img"+ aria-label="Scatter chart">- <div- className="openui-scatter-chart-main-container"- style={{- width: "100%",- height: chartHeight,- }}+ {showYAxis && (+ <g transform={`translate(0, ${marginTop})`}>+ <YAxis+ scale={yScale}+ width={effectiveYAxisWidth}+ chartHeight={chartInnerHeight}+ className={`${CHART_CLASS_PREFIX}-scatter-chart-y-axis`}+ tickClassName={`${CHART_CLASS_PREFIX}-scatter-chart-y-tick`}+ />+ </g>+ )}++ <g+ transform={`translate(${effectiveYAxisWidth}, ${marginTop})`}+ onMouseMove={orch.hover.handleMouseMove}+ onMouseLeave={orch.hover.handleMouseLeave}+ onTouchMove={orch.hover.handleTouchMove}+ onTouchEnd={orch.hover.handleTouchEnd}+ onClick={orch.hover.handleClick}>- <ChartContainer- config={chartConfig}- style={{- width: "100%",- height: "100%",- aspectRatio: 0,- }}- rechartsProps={{- width: "100%",- height: "100%",- }}- >- <RechartsScatterChart- key={`scatter-chart-${id}`}- margin={{- top: 10,- right: 2,- bottom: 2,- left: 2,- }}- >- {grid && gridCartesianGrid({ horizontal: true, vertical: true })}- <XAxis- type="number"- name={xAxisLabel as string}- domain={xDomain}- dataKey={xAxisDataKey}- hide- />-- <YAxis- type="number"- dataKey={yAxisDataKey}- name={yAxisLabel as string}- domain={yDomain}- hide- />-- <ChartTooltip- content={- <CustomTooltipContent- parentRef={chartWrapperRef}- hideIndicator- labelKey="dataset"- />- }- offset={15}- />-- <Scatter- key={`scatter-${id}`}- data={transformedData}- shape={renderDotShape}- isAnimationActive={isAnimationActive}- >- {transformedData.map((entry, index) => (- <Cell key={`cell-${index}`} fill={entry["color"] as string} />- ))}- </Scatter>- </RechartsScatterChart>- </ChartContainer>- </div>- </div>- {xAxis}- {isSideBarTooltipOpen && chartHeight > 0 && <SideBarTooltip height={chartHeight} />}- </div>- <div className="openui-scatter-chart-legend-container" ref={legendContainerRef}>- {legend && (+ <rect width={chartAreaWidth} height={chartInnerHeight} fill="transparent" />++ {showGrid && (+ <Grid+ yScale={yScale}+ chartWidth={chartAreaWidth}+ chartHeight={chartInnerHeight}+ className={`${CHART_CLASS_PREFIX}-scatter-chart-grid`}+ />+ )}++ {showVerticalGrid && (+ <VerticalGrid+ xScale={xScale}+ chartWidth={chartAreaWidth}+ chartHeight={chartInnerHeight}+ className={`${CHART_CLASS_PREFIX}-scatter-chart-grid-vertical`}+ />+ )}++ <ScatterDots+ datasets={orch.data.visibleDatasets}+ xScale={xScale}+ yScale={yScale}+ colorMap={orch.data.colorMap}+ dotRadius={dotRadius}+ hoveredPoint={orch.hover.hoveredPoint}+ animate={animate}+ />+ </g>++ <g transform={`translate(${effectiveYAxisWidth}, ${chartInnerHeight + marginTop})`}>+ <NumericXAxis+ scale={xScale}+ chartWidth={chartAreaWidth}+ height={xAxisHeight}+ className={`${CHART_CLASS_PREFIX}-scatter-chart-x-axis`}+ tickClassName={`${CHART_CLASS_PREFIX}-scatter-chart-x-tick`}+ />+ </g>+ </svg>++ {showLegend && (<DefaultLegend- items={legendItems}- yAxisLabel={yAxisLabel}+ ref={orch.refs.legendRef}+ items={orch.legend.legendItems}+ containerWidth={orch.dimensions.containerWidth}+ isExpanded={orch.legend.isLegendExpanded}+ setIsExpanded={orch.legend.setIsLegendExpanded}+ onItemClick={orch.legend.toggleSeries}+ hiddenSeries={orch.legend.hiddenSeries}xAxisLabel={xAxisLabel}- containerWidth={containerWidth}- isExpanded={isLegendExpanded}- setIsExpanded={setIsLegendExpanded}+ yAxisLabel={yAxisLabel}+ />+ )}++ {orch.tooltip.tooltipPayload && orch.hover.mousePos && (+ <ChartTooltip+ label={orch.tooltip.tooltipPayload.label}+ items={orch.tooltip.tooltipPayload.items}+ viewportPosition={orch.hover.mousePos}/>)}- </div>- </div>- </SideBarTooltipProvider>+ </>+ )}+ </ChartShell>);-};+}diff --git a/packages/react-ui/src/components/Charts/ScatterChart/components/ScatterDot.tsx b/packages/react-ui/src/components/Charts/ScatterChart/components/ScatterDot.tsxdeleted file mode 100644index 75624f37b..000000000--- a/packages/react-ui/src/components/Charts/ScatterChart/components/ScatterDot.tsx+++ /dev/null@@ -1,64 +0,0 @@-import React, { useState } from "react";--export interface ScatterDotProps {- cx?: number;- cy?: number;- fill?: string;- radius?: number;- variant?: "circle" | "square";-}--const ScatterDot: React.FC<ScatterDotProps> = ({ cx, cy, fill, variant = "circle" }) => {- const [active, setActive] = useState(false);- if (typeof cx !== "number" || typeof cy !== "number") {- return null;- }-- const OUTLINE_COLOR = "var(--openui-highlight)";- const OUTLINE_WIDTH = 2;- const displayRadius = active ? 5 : 3;-- if (variant === "square") {- const sideLength = displayRadius * 2;- return (- <rect- x={cx - displayRadius}- y={cy - displayRadius}- width={sideLength}- height={sideLength}- fill={fill}- stroke={active ? OUTLINE_COLOR : "none"}- strokeWidth={OUTLINE_WIDTH}- strokeLinejoin="round"- vectorEffect="non-scaling-stroke"- rx={2}- onPointerEnter={() => {- setActive(true);- }}- onPointerLeave={() => {- setActive(false);- }}- />- );- }-- return (- <circle- cx={cx}- cy={cy}- r={displayRadius}- fill={fill}- stroke={active ? OUTLINE_COLOR : "none"}- strokeWidth={OUTLINE_WIDTH}- vectorEffect="non-scaling-stroke"- onPointerEnter={() => {- setActive(true);- }}- onPointerLeave={() => {- setActive(false);- }}- />- );-};--export default ScatterDot;diff --git a/packages/react-ui/src/components/Charts/ScatterChart/index.ts b/packages/react-ui/src/components/Charts/ScatterChart/index.tsindex 055cba60e..a04176e3f 100644--- a/packages/react-ui/src/components/Charts/ScatterChart/index.ts+++ b/packages/react-ui/src/components/Charts/ScatterChart/index.ts@@ -1,4 +1,3 @@export { ScatterChart } from "./ScatterChart";-export type { ScatterChartProps } from "./ScatterChart";-export type * from "./types";-export * from "./utils/ScatterChartUtils";+export type { ScatterChartData, ScatterChartProps } from "./types";+export * from "./utils/scatterChartUtils";diff --git a/packages/react-ui/src/components/D3Charts/ScatterChart/parts/ScatterDots.tsx b/packages/react-ui/src/components/Charts/ScatterChart/parts/ScatterDots.tsxsimilarity index 100%rename from packages/react-ui/src/components/D3Charts/ScatterChart/parts/ScatterDots.tsxrename to packages/react-ui/src/components/Charts/ScatterChart/parts/ScatterDots.tsxdiff --git a/packages/react-ui/src/components/Charts/ScatterChart/scatterChart.scss b/packages/react-ui/src/components/Charts/ScatterChart/scatterChart.scssindex 765b4ad09..b4c959bc4 100644--- a/packages/react-ui/src/components/Charts/ScatterChart/scatterChart.scss+++ b/packages/react-ui/src/components/Charts/ScatterChart/scatterChart.scss@@ -1,42 +1,56 @@@use "../../../cssUtils" as cssUtils;+@use "../shared/cartesian/chartBase" as base;+@use "../prefix" as brand;-.openui-scatter-chart-container {- position: relative;- width: 100%;- height: auto;- display: flex;- flex-direction: column;+@include base.centered-container("scatter-chart");++.#{brand.$prefix}-scatter-chart-grid line {+ stroke: cssUtils.$border-default;+ stroke-dasharray: 3 3;+}++.#{brand.$prefix}-scatter-chart-grid line.#{brand.$prefix}-grid-zero-line {+ stroke-dasharray: none;}-.openui-scatter-chart-container-inner {- position: relative;- display: flex;- width: 100%;- flex: 1 1 auto;- min-width: 0;++.#{brand.$prefix}-scatter-chart-grid-vertical line {+ stroke: cssUtils.$border-default;+ stroke-dasharray: 3 3;}-.openui-scatter-chart-x-axis-container {- position: absolute;- bottom: 0;- left: 0;- flex-shrink: 0;- width: 100%;++.#{brand.$prefix}-scatter-chart-y-tick {+ @include base.svg-tick-label;}-.openui-scatter-chart-y-axis-container {- flex-shrink: 0;++.#{brand.$prefix}-scatter-chart-x-tick {+ @include base.svg-tick-label;}-.openui-scatter-chart-main-and-x-axis-container {- display: flex;- flex-direction: column;- width: 100%;+.#{brand.$prefix}-scatter-chart-dot {+ stroke: cssUtils.$foreground;+ stroke-width: 1.5;+ transition:+ r 0.15s ease,+ fill-opacity 0.15s ease,+ stroke-opacity 0.15s ease;}-.openui-scatter-chart-main-container {- width: 100%;- overflow: hidden;- margin-bottom: 45px;+// Entrances are decorative: gate the whole rule (pre-state included) behind+// reduced-motion so users who opt out get the natural static state immediately+// — gating only the animation would strand elements at the opacity: 0 start.+@media (prefers-reduced-motion: no-preference) {+ .#{brand.$prefix}-scatter-chart-dot--animated {+ opacity: 0;+ animation: #{brand.$prefix}-scatter-dot-appear 0.4s ease-out forwards;+ }}-.openui-scatter-chart-legend-container {- border-top: 1px solid cssUtils.$border-default;+@keyframes #{brand.$prefix}-scatter-dot-appear {+ from {+ opacity: 0;+ r: 0;+ }+ to {+ opacity: 1;+ }}diff --git a/packages/react-ui/src/components/Charts/ScatterChart/stories/ScatterChart.stories.tsx b/packages/react-ui/src/components/Charts/ScatterChart/stories/ScatterChart.stories.tsxindex b2ebff20f..7e1be1e78 100644--- a/packages/react-ui/src/components/Charts/ScatterChart/stories/ScatterChart.stories.tsx+++ b/packages/react-ui/src/components/Charts/ScatterChart/stories/ScatterChart.stories.tsx@@ -10,8 +10,8 @@ import {Watch,} from "lucide-react";import { useState } from "react";+import { ScatterChart, ScatterChartProps } from "../..";import { Card } from "../../../Card";-import { ScatterChart, ScatterChartProps } from "../ScatterChart";const customColorPalette = ["#0A0E60",@@ -439,9 +439,8 @@ const icons = {* - **Responsive Design**: Adapts to any container size.** ### Customization- * - **Theming**: Six pre-built color palettes or custom colors.- * - **Shape Options**: Multiple point shapes (circle, diamond, square, etc.).- * - **Axis Configuration**: Customizable axis labels, units, and domains.+ * - **Colors**: Uses the ThemeProvider's chart palette, or custom colors with `customPalette`.+ * - **Axis Configuration**: Customizable axis labels.*/const meta: Meta<ScatterChartProps> = {title: "Components/Charts/ScatterChart",@@ -465,20 +464,13 @@ const scatterData = [// Basic implementation<ScatterChartdata={scatterData}- xAxisDataKey="x"- yAxisDataKey="y"- theme="ocean"/>-// With custom labels and units+// With custom axis labels<ScatterChartdata={scatterData}- xAxisDataKey="x"- yAxisDataKey="y"xAxisLabel="Temperature (°C)"yAxisLabel="Sales ($)"- xAxisUnit="°C"- yAxisUnit="$"/>\`\`\`@@ -515,48 +507,14 @@ const scatterData = [category: "📊 Data Configuration",},},- xAxisDataKey: {- description: "The key in your data object that represents the X-axis values.",- control: "text",- table: {- defaultValue: { summary: "x" },- category: "📊 Data Configuration",- },- },- yAxisDataKey: {- description: "The key in your data object that represents the Y-axis values.",- control: "text",- table: {- defaultValue: { summary: "y" },- category: "📊 Data Configuration",- },- },- theme: {- description: "Specifies the color palette for the chart points and legend.",- control: "select",- options: ["ocean", "orchid", "emerald", "sunset", "spectrum", "vivid"],- table: {- defaultValue: { summary: "ocean" },- category: "🎨 Visual Styling",- },- },customPalette: {- description: "Custom array of colors to use instead of the theme palette.",+ description: "Custom array of colors to use instead of the ThemeProvider's chart palette.",control: "object",table: {type: { summary: "string[]" },category: "🎨 Visual Styling",},},- shape: {- description: "The shape of the scatter points.",- control: "select",- options: ["circle", "square"],- table: {- defaultValue: { summary: "circle" },- category: "🎨 Visual Styling",- },- },grid: {description: "Toggles the visibility of the background grid lines.",control: "boolean",@@ -637,15 +595,10 @@ export const BasicScatter: Story = {name: "📈 Basic Scatter Chart",args: {data: dataVariations.default,- xAxisDataKey: "x",- yAxisDataKey: "y",- theme: "ocean",grid: true,legend: true,isAnimationActive: true,showYAxis: true,- showXAxis: true,- shape: "circle",width: 700,height: 400,},@@ -662,15 +615,11 @@ export const CorrelationAnalysis: Story = {name: "📊 Correlation Analysis",args: {data: dataVariations.correlation,- xAxisDataKey: "x",- yAxisDataKey: "y",- theme: "emerald",grid: true,legend: true,isAnimationActive: true,xAxisLabel: "Marketing Spend",yAxisLabel: "Sales Revenue",- shape: "circle",},render: (args: any) => (<Card style={{ width: "700px" }}>@@ -679,50 +628,6 @@ export const CorrelationAnalysis: Story = {),};-/**- * ## Shape Comparison- *- * Compare different point shapes available in the scatter chart.- * Each shape provides a different visual style for your data points.- */-export const ShapeComparison: Story = {- name: "🔷 Shape Comparison",- args: {- data: dataVariations.default as never,- xAxisDataKey: "x",- yAxisDataKey: "y",- theme: "sunset",- grid: true,- legend: true,- isAnimationActive: false,- },- render: (args: any) => {- const shapes = ["circle", "square"] as const;-- return (- <div style={{ display: "flex", flexDirection: "column", gap: "20px" }}>- {shapes.map((shape) => (- <div key={shape}>- <h4- style={{- margin: "0 0 8px 0",- fontSize: "14px",- fontWeight: "600",- textTransform: "capitalize",- }}- >- {shape} Shape- </h4>- <Card style={{ width: "500px", height: "600px" }}>- <ScatterChart {...args} shape={shape} height={"100%"} />- </Card>- </div>- ))}- </div>- );- },-};-/*** ## Data Explorer*@@ -733,13 +638,9 @@ export const DataExplorer: Story = {name: "🎛️ Data Explorer",args: {data: dataVariations.default as never,- xAxisDataKey: "x",- yAxisDataKey: "y",- theme: "ocean",grid: true,legend: true,isAnimationActive: true,- shape: "circle",},render: (args: any) => {const [selectedDataType, setSelectedDataType] =diff --git a/packages/react-ui/src/components/D3Charts/ScatterChart/types.ts b/packages/react-ui/src/components/Charts/ScatterChart/types.tssimilarity index 87%rename from packages/react-ui/src/components/D3Charts/ScatterChart/types.tsrename to packages/react-ui/src/components/Charts/ScatterChart/types.tsindex 80ddbfc3a..7c9790299 100644--- a/packages/react-ui/src/components/D3Charts/ScatterChart/types.ts+++ b/packages/react-ui/src/components/Charts/ScatterChart/types.ts@@ -20,6 +20,10 @@ export interface HoveredScatterPoint {export interface ScatterChartProps {data: ScatterChartData;+ /** Point field that sets the horizontal position. Default `"x"`. */+ xAxisDataKey?: string;+ /** Point field that sets the vertical position. Default `"y"`. */+ yAxisDataKey?: string;customPalette?: string[];grid?: boolean;verticalGrid?: boolean;diff --git a/packages/react-ui/src/components/Charts/ScatterChart/types/index.ts b/packages/react-ui/src/components/Charts/ScatterChart/types/index.tsdeleted file mode 100644index 025a36ea7..000000000--- a/packages/react-ui/src/components/Charts/ScatterChart/types/index.ts+++ /dev/null@@ -1,13 +0,0 @@-export interface ScatterPoint {- x: number;- y: number;- z?: number;- [key: string]: string | number | undefined;-}--export interface ScatterDataset {- name: string;- data: ScatterPoint[];-}--export type ScatterChartData = ScatterDataset[];diff --git a/packages/react-ui/src/components/Charts/ScatterChart/utils/ScatterChartUtils.ts b/packages/react-ui/src/components/Charts/ScatterChart/utils/scatterChartUtils.tssimilarity index 94%rename from packages/react-ui/src/components/Charts/ScatterChart/utils/ScatterChartUtils.tsrename to packages/react-ui/src/components/Charts/ScatterChart/utils/scatterChartUtils.tsindex d5f89fb7d..2d89ab8cd 100644--- a/packages/react-ui/src/components/Charts/ScatterChart/utils/ScatterChartUtils.ts+++ b/packages/react-ui/src/components/Charts/ScatterChart/utils/scatterChartUtils.ts@@ -1,4 +1,4 @@-import { ScatterChartData, ScatterPoint } from "../types";+import type { ScatterChartData, ScatterPoint } from "../types";/*** Extracts dataset names from scatter chart data@@ -13,7 +13,7 @@ export const getScatterDatasets = (data: ScatterChartData): string[] => {};/**- * Transforms scatter chart data for recharts consumption+ * Flattens scatter datasets into one list of points* @param data - The scatter chart data (array of datasets)* @param datasets - Array of dataset names to include* @param colors - Array of colors for datasets@@ -46,7 +46,7 @@ export const transformScatterData = (...point,x: Number(point.x),y: Number(point.y),- z: point.z ? Number(point.z) : undefined,+ z: point["z"] ? Number(point["z"]) : undefined,color,dataset: dataset.name,});diff --git a/packages/react-ui/src/components/D3Charts/SegmentedBar/SegmentedBar.tsx b/packages/react-ui/src/components/Charts/SegmentedBar/SegmentedBar.tsxsimilarity index 100%rename from packages/react-ui/src/components/D3Charts/SegmentedBar/SegmentedBar.tsxrename to packages/react-ui/src/components/Charts/SegmentedBar/SegmentedBar.tsxdiff --git a/packages/react-ui/src/components/Charts/SegmentedBar/SingleStackedBar.tsx b/packages/react-ui/src/components/Charts/SegmentedBar/SingleStackedBar.tsxnew file mode 100644index 000000000..106324ca3--- /dev/null+++ b/packages/react-ui/src/components/Charts/SegmentedBar/SingleStackedBar.tsx@@ -0,0 +1,8 @@+import { SegmentedBar } from "./SegmentedBar";+import type { SegmentedBarData, SegmentedBarProps } from "./types";++export type SingleStackedBarData = SegmentedBarData;+export type SingleStackedBarProps<T extends SingleStackedBarData> = SegmentedBarProps<T>;++/** `SegmentedBar` under its earlier name. */+export const SingleStackedBar = SegmentedBar;diff --git a/packages/react-ui/src/components/Charts/SegmentedBar/index.ts b/packages/react-ui/src/components/Charts/SegmentedBar/index.tsnew file mode 100644index 000000000..9bb08af35--- /dev/null+++ b/packages/react-ui/src/components/Charts/SegmentedBar/index.ts@@ -0,0 +1,4 @@+export { SegmentedBar } from "./SegmentedBar";+export { SingleStackedBar } from "./SingleStackedBar";+export type { SingleStackedBarData, SingleStackedBarProps } from "./SingleStackedBar";+export type { SegmentedBarData, SegmentedBarProps } from "./types";diff --git a/packages/react-ui/src/components/D3Charts/SegmentedBar/parts/segmentedBarGeometry.test.ts b/packages/react-ui/src/components/Charts/SegmentedBar/parts/segmentedBarGeometry.test.tssimilarity index 100%rename from packages/react-ui/src/components/D3Charts/SegmentedBar/parts/segmentedBarGeometry.test.tsrename to packages/react-ui/src/components/Charts/SegmentedBar/parts/segmentedBarGeometry.test.tsdiff --git a/packages/react-ui/src/components/D3Charts/SegmentedBar/parts/segmentedBarGeometry.ts b/packages/react-ui/src/components/Charts/SegmentedBar/parts/segmentedBarGeometry.tssimilarity index 100%rename from packages/react-ui/src/components/D3Charts/SegmentedBar/parts/segmentedBarGeometry.tsrename to packages/react-ui/src/components/Charts/SegmentedBar/parts/segmentedBarGeometry.tsdiff --git a/packages/react-ui/src/components/D3Charts/SegmentedBar/segmentedBar.scss b/packages/react-ui/src/components/Charts/SegmentedBar/segmentedBar.scsssimilarity index 96%rename from packages/react-ui/src/components/D3Charts/SegmentedBar/segmentedBar.scssrename to packages/react-ui/src/components/Charts/SegmentedBar/segmentedBar.scssindex 7a91b7b61..c47ab68de 100644--- a/packages/react-ui/src/components/D3Charts/SegmentedBar/segmentedBar.scss+++ b/packages/react-ui/src/components/Charts/SegmentedBar/segmentedBar.scss@@ -24,7 +24,9 @@// The thin bar track..#{brand.$prefix}-segmented-bar {+ // Padding inside the size, with or without a global box-sizing reset.width: 100%;+ box-sizing: border-box;height: 20px;font-family: inherit;background-color: cssUtils.$background;diff --git a/packages/react-ui/src/components/Charts/SingleStackedBarChart/stories/SingleStackedBarChart.stories.tsx b/packages/react-ui/src/components/Charts/SegmentedBar/stories/SingleStackedBarChart.stories.tsxsimilarity index 80%rename from packages/react-ui/src/components/Charts/SingleStackedBarChart/stories/SingleStackedBarChart.stories.tsxrename to packages/react-ui/src/components/Charts/SegmentedBar/stories/SingleStackedBarChart.stories.tsxindex 1ed366561..c42b92233 100644--- a/packages/react-ui/src/components/Charts/SingleStackedBarChart/stories/SingleStackedBarChart.stories.tsx+++ b/packages/react-ui/src/components/Charts/SegmentedBar/stories/SingleStackedBarChart.stories.tsx@@ -1,6 +1,6 @@import type { Meta, StoryObj } from "@storybook/react";+import { SingleStackedBar, SingleStackedBarProps } from "../..";import { Card } from "../../../Card";-import { SingleStackedBar, SingleStackedBarProps } from "../SingleStackedBarChart";const meta: Meta<SingleStackedBarProps<any>> = {title: "Components/Charts/SingleStackedBar",@@ -26,7 +26,6 @@ import { SingleStackedBar } from '@openuidev/react-ui/Charts/SingleStackedBar';]}categoryKey="category"dataKey="value"- theme="ocean"legend={true}/>\`\`\`@@ -54,7 +53,7 @@ const data = [## Key Features- **Segmented Display**: Visualize the composition of a whole.-- **Theming**: Six built-in color palettes.+- **Colors**: Uses the ThemeProvider's chart palette, or custom colors with \`customPalette\`.- **Animation**: Smoothly animates the bar segments.- **Legend Support**: Optional legend with category names and colors.- **Responsive**: Adapts to the width of its container.@@ -104,32 +103,14 @@ These values determine the proportional width of each segment.category: "📊 Data Configuration",},},- theme: {+ isAnimationActive: {description: `-**Color Theme Selection.** Choose from professionally designed color palettes:--- **ocean**: Cool blues and teals-- **orchid**: Purple and pink tones-- **emerald**: Green variations-- **sunset**: Warm oranges and reds-- **spectrum**: Full color range-- **vivid**: High-contrast colors-`,- control: "select",- options: ["ocean", "orchid", "emerald", "sunset", "spectrum", "vivid"],- table: {- defaultValue: { summary: "ocean" },- category: "🎨 Visual Styling",- },- },- animated: {- description: `-**Animation Control.** Enables or disables the fill animation on load.+**Animation Control.** Enables or disables the segment width animation.`,control: "boolean",table: {type: { summary: "boolean" },- defaultValue: { summary: "true" },+ defaultValue: { summary: "false" },category: "🎬 Animation & Interaction",},},@@ -194,8 +175,7 @@ export const DefaultConfiguration: Story = {data: sampleData.default,categoryKey: "category",dataKey: "value",- theme: "ocean",- animated: true,+ isAnimationActive: true,},render: (args: any) => (<Card style={{ width: "400px", padding: "24px" }}>@@ -214,49 +194,7 @@ export const DefaultConfiguration: Story = {docs: {description: {story:- "This is the standard appearance of the Single Stacked Bar. It shows multiple segments, each with a color from the selected theme, representing the proportional breakdown of a whole.",- },- },- },-};--export const ThemeShowcase: Story = {- name: "🎨 Theme Showcase",- args: {- data: [- { category: "Segment 1", value: 15 },- { category: "Segment 2", value: 20 },- { category: "Segment 3", value: 25 },- { category: "Segment 4", value: 15 },- ],- categoryKey: "category",- dataKey: "value",- animated: true,- },- render: (args: any) => (- <div style={{ width: "400px", display: "flex", flexDirection: "column", gap: "24px" }}>- {(["ocean", "orchid", "emerald", "sunset", "spectrum", "vivid"] as const).map((theme) => (- <div key={theme}>- <h4- style={{- marginBottom: "12px",- textTransform: "capitalize",- fontSize: "14px",- fontWeight: 600,- }}- >- {theme}- </h4>- <SingleStackedBar {...args} theme={theme} />- </div>- ))}- </div>- ),- parameters: {- docs: {- description: {- story:- "The Single Stacked Bar supports six different color themes. This allows it to fit seamlessly into various application designs and visual identities.",+ "This is the standard appearance of the Single Stacked Bar. It shows multiple segments, each with a color from the chart palette, representing the proportional breakdown of a whole.",},},},@@ -268,8 +206,7 @@ export const ManySegments: Story = {data: sampleData.many,categoryKey: "category",dataKey: "value",- theme: "vivid",- animated: true,+ isAnimationActive: true,},render: (args: any) => (<Card style={{ width: "500px", padding: "24px" }}>@@ -288,7 +225,7 @@ export const ManySegments: Story = {docs: {description: {story:- "The Single Stacked Bar can display many segments. The colors will cycle through the selected theme palette if the number of segments exceeds the number of available colors.",+ "The Single Stacked Bar can display many segments. The colors will cycle through the chart palette if the number of segments exceeds the number of available colors.",},},},@@ -300,8 +237,7 @@ export const FullComposition: Story = {data: sampleData.full,categoryKey: "category",dataKey: "value",- theme: "spectrum",- animated: false,+ isAnimationActive: false,},render: (args: any) => (<Card style={{ width: "400px", padding: "24px" }}>@@ -332,8 +268,7 @@ export const WithLegend: Story = {data: sampleData.default,categoryKey: "category",dataKey: "value",- theme: "ocean",- animated: true,+ isAnimationActive: true,legend: true,legendVariant: "default",},@@ -367,8 +302,7 @@ export const LegendWithManyItems: Story = {data: sampleData.many,categoryKey: "category",dataKey: "value",- theme: "vivid",- animated: true,+ isAnimationActive: true,legend: true,legendVariant: "default",},@@ -402,8 +336,7 @@ export const StackedLegendVariant: Story = {data: sampleData.many,categoryKey: "category",dataKey: "value",- theme: "ocean",- animated: true,+ isAnimationActive: true,legend: true,legendVariant: "stacked",},diff --git a/packages/react-ui/src/components/D3Charts/SegmentedBar/types.ts b/packages/react-ui/src/components/Charts/SegmentedBar/types.tssimilarity index 100%rename from packages/react-ui/src/components/D3Charts/SegmentedBar/types.tsrename to packages/react-ui/src/components/Charts/SegmentedBar/types.tsdiff --git a/packages/react-ui/src/components/Charts/SingleStackedBarChart/SingleStackedBarChart.tsx b/packages/react-ui/src/components/Charts/SingleStackedBarChart/SingleStackedBarChart.tsxdeleted file mode 100644index c06918548..000000000--- a/packages/react-ui/src/components/Charts/SingleStackedBarChart/SingleStackedBarChart.tsx+++ /dev/null@@ -1,241 +0,0 @@-import clsx from "clsx";-import { useCallback, useEffect, useMemo, useRef, useState } from "react";-import { usePrintContext } from "../../../context/PrintContext";-import { Separator } from "../../Separator";-import { useExportChartData } from "../hooks";-import { DefaultLegend } from "../shared/DefaultLegend/DefaultLegend";-import { FloatingUIPortal } from "../shared/PortalTooltip";-import { StackedLegend } from "../shared/StackedLegend/StackedLegend";-import { LegendItem, StackedLegendItem } from "../types";-import { PaletteName, useChartPalette } from "../utils/PalletUtils";-import { ToolTip } from "./components";-import { SingleStackedBarData } from "./types";--export interface SingleStackedBarProps<T extends SingleStackedBarData> {- data: T;- categoryKey: keyof T[number];- dataKey: keyof T[number];- theme?: PaletteName;- customPalette?: string[];- legend?: boolean;- legendVariant?: "default" | "stacked";- className?: string;- style?: React.CSSProperties;- animated?: boolean;-}--export const SingleStackedBar = <T extends SingleStackedBarData>({- data,- categoryKey,- dataKey,- theme = "ocean",- customPalette,- legend = true,- legendVariant = "default",- className,- style,- animated = true,-}: SingleStackedBarProps<T>) => {- const [isLegendExpanded, setIsLegendExpanded] = useState(false);- const [activeIndex, setActiveIndex] = useState<number | null>(null);- const [hoveredLegendKey, setHoveredLegendKey] = useState<string | null>(null);- const wrapperRef = useRef<HTMLDivElement>(null);- const [containerWidth, setContainerWidth] = useState(0);- const [tooltipPosition, setTooltipPosition] = useState<{ x: number; y: number } | null>(null);-- useEffect(() => {- const wrapper = wrapperRef.current;- if (!wrapper) return;-- const observer = new ResizeObserver((entries) => {- const entry = entries[0];- if (entry) {- setContainerWidth(entry.contentRect.width);- }- });-- observer.observe(wrapper);- return () => observer.disconnect();- }, []);- // Calculate percentages- const segments = useMemo(() => {- if (!data || data.length === 0) {- return [];- }-- const total = data.reduce((acc, item) => acc + Number(item[dataKey]), 0);-- return data.map((item, index) => ({- value: Number(item[dataKey]),- category: String(item[categoryKey]),- index,- percentage: total > 0 ? (Number(item[dataKey]) / total) * 100 : 0,- }));- }, [data, dataKey, categoryKey]);-- // Get theme colors for each segment- const colors = useChartPalette({- chartThemeName: theme,- customPalette,- themePaletteName: "barChartPalette",- dataLength: Math.max(segments.length, 1),- });-- // Create legend items- const legendItems = useMemo((): LegendItem[] => {- return segments.map((segment, index) => ({- key: `${segment.category}-${index}`,- label: segment.category,- color: colors[index % colors.length] || "",- percentage: segment.percentage,- }));- }, [segments, colors]);-- // Create stacked legend items with values- const stackedLegendItems = useMemo(- (): StackedLegendItem[] =>- segments.map((segment, index) => ({- key: `${segment.category}-${index}`,- label: segment.category,- value: segment.value,- color: colors[index % colors.length] || "",- })),- [segments, colors],- );-- const printContext = usePrintContext();- animated = printContext ? false : animated;-- const exportData = useExportChartData({- type: "bar",- data,- categoryKey: categoryKey as string,- dataKeys: [dataKey as string],- colors,- legend,- extraOptions: {- barDir: "bar",- barGrouping: "stacked",- },- });-- // Handle legend item hover with tooltip positioning- const handleLegendItemHover = useCallback(- (hoverIndex: number | null) => {- setActiveIndex(hoverIndex);- if (hoverIndex !== null) {- const segment = segments[hoverIndex];- if (segment) {- const legendKey = `${segment.category}-${hoverIndex}`;- setHoveredLegendKey(legendKey);- }- // Try to position tooltip above the hovered segment- const segmentEl = wrapperRef.current?.querySelectorAll(- ".openui-single-stacked-bar-chart-segment",- )?.[hoverIndex] as HTMLDivElement | undefined;- if (segmentEl) {- const rect = segmentEl.getBoundingClientRect();- const containerRect = wrapperRef.current?.getBoundingClientRect();- if (containerRect) {- const relativeX = rect.left + rect.width / 2 - containerRect.left;- const relativeY = rect.top - containerRect.top;- setTooltipPosition({ x: relativeX, y: relativeY });- } else {- setTooltipPosition({ x: rect.left + rect.width / 2, y: rect.top });- }- }- } else {- setHoveredLegendKey(null);- setTooltipPosition(null);- }- },- [segments],- );-- // Segmented progress bar- return (- <div- ref={wrapperRef}- className={clsx("openui-single-stacked-bar-chart-container", className, {- "openui-single-stacked-bar-chart-container-gap": legend && legendVariant === "default",- })}- style={style}- data-openui-chart={exportData}- >- <div className="openui-single-stacked-bar-chart">- {segments.map((segment, index) => {- const isActive = activeIndex === null || activeIndex === index;- return (- <div- key={`segment-${index}`}- className={clsx("openui-single-stacked-bar-chart-segment", {- "openui-single-stacked-bar-chart-animated": animated,- })}- style={{- width: `${segment.percentage}%`,- backgroundColor: colors[index % colors.length],- opacity: isActive ? 1 : 0.5,- }}- onMouseEnter={(e) => {- setActiveIndex(index);- const legendKey = `${segment.category}-${index}`;- setHoveredLegendKey(legendKey);- const rect = (e.currentTarget as HTMLDivElement).getBoundingClientRect();- const containerRect = wrapperRef.current?.getBoundingClientRect();- if (containerRect) {- // Position relative to container so FloatingUIPortal aligns correctly- const relativeX = rect.left + rect.width / 2 - containerRect.left;- const relativeY = rect.top - containerRect.top;- setTooltipPosition({ x: relativeX, y: relativeY });- } else {- setTooltipPosition({ x: rect.left + rect.width / 2, y: rect.top });- }- }}- onMouseLeave={() => {- setActiveIndex(null);- setHoveredLegendKey(null);- }}- >- <div className="openui-single-stacked-bar-chart-segment-line" />- </div>- );- })}- </div>- {activeIndex !== null && tooltipPosition && (- <FloatingUIPortal position={tooltipPosition} placement="top" offsetDistance={10}>- <ToolTip- label={legendItems[activeIndex]?.label ?? ""}- color={stackedLegendItems[activeIndex]?.color ?? "#000000"}- value={stackedLegendItems[activeIndex]?.value ?? 0}- percentage={segments[activeIndex]?.percentage ?? 0}- />- </FloatingUIPortal>- )}-- {legend && legendVariant === "default" && <Separator />}-- {legend && legendVariant === "default" && (- <DefaultLegend- items={legendItems}- isExpanded={isLegendExpanded}- setIsExpanded={setIsLegendExpanded}- containerWidth={containerWidth}- style={{ paddingTop: 0 }}- />- )}- {legend && legendVariant === "stacked" && (- <StackedLegend- items={stackedLegendItems}- containerWidth={containerWidth}- onItemHover={setHoveredLegendKey}- activeKey={hoveredLegendKey}- onLegendItemHover={handleLegendItemHover}- separator- showTitle={false}- layout="showMore"- className="openui-single-stacked-bar-chart-stacked-legend"- />- )}- </div>- );-};diff --git a/packages/react-ui/src/components/Charts/SingleStackedBarChart/components/ToolTip.tsx b/packages/react-ui/src/components/Charts/SingleStackedBarChart/components/ToolTip.tsxdeleted file mode 100644index 003309f32..000000000--- a/packages/react-ui/src/components/Charts/SingleStackedBarChart/components/ToolTip.tsx+++ /dev/null@@ -1,47 +0,0 @@-import React from "react";-import { numberTickFormatter } from "../../utils";--interface ToolTipProps {- label: string;- color: string;- value: number | string;- percentage?: number;-}--export const ToolTip: React.FC<ToolTipProps> = ({ label, color, value, percentage }) => {- return (- <div className="openui-chart-tooltip">- <div className="openui-chart-tooltip-label">{label}</div>- <div className="openui-chart-tooltip-content">- <div className="openui-chart-tooltip-content-item">- <div- className="openui-chart-tooltip-content-indicator openui-chart-tooltip-content-indicator--dot"- style={{- ["--color-bg" as any]: color,- ["--color-border" as any]: color,- }}- />- <div className="openui-chart-tooltip-content-value-wrapper">- <div className="openui-chart-tooltip-content-label">- <span>Value</span>- </div>- <span className="openui-chart-tooltip-content-value">- {typeof value === "number" ? numberTickFormatter(value) : value}- </span>- </div>- </div>- <div className="openui-chart-tooltip-content-item-separator" />- <div className="openui-chart-tooltip-content-item">- <div className="openui-chart-tooltip-content-value-wrapper">- <div className="openui-chart-tooltip-content-label">- <span>Percentage</span>- </div>- <span className="openui-chart-tooltip-content-value percentage">- {typeof percentage === "number" ? `${percentage.toFixed(1)}%` : "-"}- </span>- </div>- </div>- </div>- </div>- );-};diff --git a/packages/react-ui/src/components/Charts/SingleStackedBarChart/components/index.ts b/packages/react-ui/src/components/Charts/SingleStackedBarChart/components/index.tsdeleted file mode 100644index f06eadc00..000000000--- a/packages/react-ui/src/components/Charts/SingleStackedBarChart/components/index.ts+++ /dev/null@@ -1 +0,0 @@-export { ToolTip } from "./ToolTip";diff --git a/packages/react-ui/src/components/Charts/SingleStackedBarChart/index.ts b/packages/react-ui/src/components/Charts/SingleStackedBarChart/index.tsdeleted file mode 100644index 76025dbd6..000000000--- a/packages/react-ui/src/components/Charts/SingleStackedBarChart/index.ts+++ /dev/null@@ -1,3 +0,0 @@-export { SingleStackedBar } from "./SingleStackedBarChart";-export type { SingleStackedBarProps } from "./SingleStackedBarChart";-export type { SingleStackedBarData } from "./types";diff --git a/packages/react-ui/src/components/Charts/SingleStackedBarChart/singleStackedBarChart.scss b/packages/react-ui/src/components/Charts/SingleStackedBarChart/singleStackedBarChart.scssdeleted file mode 100644index 2b6ac25c6..000000000--- a/packages/react-ui/src/components/Charts/SingleStackedBarChart/singleStackedBarChart.scss+++ /dev/null@@ -1,69 +0,0 @@-@use "../../../cssUtils.scss" as cssUtils;--.openui-single-stacked-bar-chart-container {- display: flex;- flex-direction: column;- align-items: center;- justify-content: center;- position: relative;-- &-gap {- gap: cssUtils.$space-m;- }-}--.openui-single-stacked-bar-chart {- width: 100%;- height: 20px;- font-family: inherit;- background-color: cssUtils.$background;- border-radius: cssUtils.$radius-s;- overflow: hidden;- box-shadow: cssUtils.$shadow-s;- display: flex;- padding: cssUtils.$space-2xs;- gap: cssUtils.$space-3xs;-}--.openui-single-stacked-bar-chart-segment {- height: 100%;- display: flex;- align-items: center;- justify-content: center;- min-width: 2px;- box-shadow: cssUtils.$shadow-s;- // border-radius: cssUtils.$radius-xs;- position: relative;- overflow: hidden;- transition:- box-shadow 0.2s ease,- filter 0.2s ease,- opacity 0.2s ease;-- &:first-child {- border-radius: cssUtils.$radius-xs 0 0 cssUtils.$radius-xs;- }-- &:last-child {- border-radius: 0 cssUtils.$radius-xs cssUtils.$radius-xs 0;- }-- &-line {- position: absolute;- transform: translateY(-50%);- background-color: cssUtils.$border-accent-emphasis;- top: 50%;- left: 5px;- width: calc(100% - 10px);- height: 1px;- z-index: 1;- min-width: 2px;- }-}--.openui-single-stacked-bar-chart-animated {- transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);-}-.openui-single-stacked-bar-chart-stacked-legend {- margin-top: cssUtils.$space-s;-}diff --git a/packages/react-ui/src/components/Charts/SingleStackedBarChart/types/index.ts b/packages/react-ui/src/components/Charts/SingleStackedBarChart/types/index.tsdeleted file mode 100644index 6f8e60302..000000000--- a/packages/react-ui/src/components/Charts/SingleStackedBarChart/types/index.ts+++ /dev/null@@ -1 +0,0 @@-export type SingleStackedBarData = Array<Record<string, string | number>>;diff --git a/packages/react-ui/src/components/D3Charts/_prefix.scss b/packages/react-ui/src/components/Charts/_prefix.scsssimilarity index 93%rename from packages/react-ui/src/components/D3Charts/_prefix.scssrename to packages/react-ui/src/components/Charts/_prefix.scssindex 6e2bcbc6f..bcfc426f4 100644--- a/packages/react-ui/src/components/D3Charts/_prefix.scss+++ b/packages/react-ui/src/components/Charts/_prefix.scss@@ -2,4 +2,4 @@// mirror of `CHART_CLASS_PREFIX` in `utils/constants.ts` (SCSS can't read// TS constants). Change BOTH or the stylesheets stop matching the DOM.// Usage: `@use '<rel>/prefix' as brand;` then `.#{brand.$prefix}-bar-chart`.-$prefix: openui-d3;+$prefix: openui;diff --git a/packages/react-ui/src/components/Charts/charts.scss b/packages/react-ui/src/components/Charts/charts.scssindex 52fb1f27b..e2d074910 100644--- a/packages/react-ui/src/components/Charts/charts.scss+++ b/packages/react-ui/src/components/Charts/charts.scss@@ -1,93 +1,18 @@-@use "../../cssUtils.scss" as cssUtils;--// 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";--// radar chart css-@forward "./RadarChart/radarChart.scss";--// single stacked bar chart css-@forward "./SingleStackedBarChart/singleStackedBarChart.scss";--// pie chart css-@forward "./PieChart/pieChart.scss";--// radial chart css-@forward "./RadialChart/radialChart.scss";--// shared components css-@forward "./shared/XAxisTick/xAxisTick.scss";-@forward "./shared/SVGXAxisTick/svgXAxisTick.scss";-@forward "./shared/DefaultLegend/defaultLegend.scss";-@forward "./shared/StackedLegend/stackedLegend.scss";-@forward "./shared/YAxisTick/yAxisTick.scss";-@forward "./shared/ScrollButtonsHorizontal/scrollButtonsHorizontal.scss";-@forward "./shared/ScrollButtonsVertical/scrollButtonsVertical.scss";-@forward "./shared/LabelTooltip/labelTooltip.scss";--// portal tooltip css-@forward "./shared/PortalTooltip/portalTooltip.scss";--// side bar tooltip css-@forward "./shared/SideBarTooltip/sideBarTooltip.scss";--.openui-chart {- // Container styles- &-container {- display: flex;- aspect-ratio: 1/1;- justify-content: center;- font-size: 12px;- line-height: 16px;-- .recharts-radial-bar-background-sector {- fill: cssUtils.$background;- }-- // Strokes and borders- .recharts-cartesian-grid line[stroke="#ccc"],- .recharts-curve.recharts-tooltip-cursor,- .recharts-polar-grid[stroke="#ccc"],- .recharts-reference-line[stroke="#ccc"] {- stroke: cssUtils.$border-default;- }-- // Transparency settings- .recharts-dot[stroke="#fff"],- .recharts-sector[stroke="#fff"] {- stroke: transparent;- }-- // Outline resets- .recharts-layer,- .recharts-sector,- .recharts-surface {- outline: none;- }- }-}--.openui-chart-cartesian-grid {- stroke: cssUtils.$border-default;-}--.openui-chart-polar-grid {- stroke: cssUtils.$border-default;-}--.openui-chart-label-list {- fill: cssUtils.$text-neutral-secondary;-}+@forward "./AreaChart/areaChart";+@forward "./LineChart/lineChart";+@forward "./BarChart/barChart";+@forward "./BarChart/horizontalBarChart";+@forward "./PieChart/pieChart";+@forward "./RadialChart/radialChart";+@forward "./RadarChart/radarChart";+@forward "./ScatterChart/scatterChart";+@forward "./HeatmapChart/heatmapChart";+@forward "./FunnelChart/funnelChart";+@forward "./CalendarHeatmap/calendarHeatmap";+@forward "./SegmentedBar/segmentedBar";+@forward "./shared/mini/miniChart";+@forward "./shared/core/PortalTooltip/portalTooltip";+@forward "./shared/core/DefaultLegend/defaultLegend";+@forward "./shared/core/StackedLegend/stackedLegend";+@forward "./shared/cartesian/ScrollButtonsHorizontal/scrollButtonsHorizontal";+@forward "./shared/cartesian/ScrollButtonsVertical/scrollButtonsVertical";diff --git a/packages/react-ui/src/components/D3Charts/classPrefix.test.ts b/packages/react-ui/src/components/Charts/classPrefix.test.tssimilarity index 93%rename from packages/react-ui/src/components/D3Charts/classPrefix.test.tsrename to packages/react-ui/src/components/Charts/classPrefix.test.tsindex 1d34301fe..900019eec 100644--- a/packages/react-ui/src/components/D3Charts/classPrefix.test.ts+++ b/packages/react-ui/src/components/Charts/classPrefix.test.ts@@ -5,7 +5,7 @@ import { describe, expect, it } from "vitest";import { CHART_CLASS_PREFIX } from "./utils/constants";/**- * Self-audit: every chart class, keyframe, and CSS custom property D3Charts+ * Self-audit: every chart class, keyframe, and CSS custom property the charts* emits must be composed from CHART_CLASS_PREFIX (TS) / brand.$prefix (SCSS) —* never hardcoded — so the prefix stays a one-line rename. The only sanctioned* literal is the print/PPTX exporter data attribute (`data-openui-chart` — see@@ -61,7 +61,9 @@ const blankExportAttributes = (content: string): string =>content.replace(EXPORT_ATTRIBUTE_RE, (token) => " ".repeat(token.length));const BRANDS = CHART_CLASS_PREFIX.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");-const PREFIX_LITERAL_RE = new RegExp(`\\b${BRANDS}-[a-z0-9-]+\\b`, "g");+// react-ui's theme tokens share the brand (`--openui-foreground`); a literal+// right after `--` is a theme CSS variable, not a chart class.+const PREFIX_LITERAL_RE = new RegExp(`(?<!--)\\b${BRANDS}-[a-z0-9-]+\\b`, "g");const SCSS_LITERAL_SELECTOR_RE = new RegExp(`\\.${BRANDS}-[a-z0-9-]+`, "g");const SCSS_LITERAL_CUSTOM_PROP_RE = new RegExp(`--${BRANDS}-[a-z0-9-]+`, "g");const SCSS_LITERAL_KEYFRAMES_RE = new RegExp(`@keyframes\\s+${BRANDS}[-_][a-z0-9_-]+`, "g");@@ -89,12 +91,12 @@ const collectViolations = (sources: PrefixSource[], patterns: RegExp[]): string[return violations;};-describe("D3Charts class prefix self-audit", () => {+describe("Charts class prefix self-audit", () => {it("keeps the TS and SCSS prefix declarations mirrored", () => {const scss = fs.readFileSync(path.join(SRC_DIR, "_prefix.scss"), "utf8");const match = scss.match(/\$prefix:\s*([a-zA-Z0-9_-]+)\s*;/);expect(match?.[1]).toBe(CHART_CLASS_PREFIX);- expect(CHART_CLASS_PREFIX).toBe("openui-d3");+ expect(CHART_CLASS_PREFIX).toBe("openui");});it("bans hardcoded brand literals in TS/TSX sources", () => {@@ -124,7 +126,7 @@ describe("D3Charts class prefix self-audit", () => {it("requires every non-barrel stylesheet to compose from the prefix partial", () => {const failures: string[] = [];for (const { relativePath, content } of SCSS_SOURCES) {- if (relativePath === "_prefix.scss" || relativePath === "d3Charts.scss") {+ if (relativePath === "_prefix.scss" || relativePath === "charts.scss") {continue;}const stripped = stripSourceComments(content);diff --git a/packages/react-ui/src/components/Charts/constants/CondensedCharts.ts b/packages/react-ui/src/components/Charts/constants/CondensedCharts.tsdeleted file mode 100644index 377fc16c1..000000000--- a/packages/react-ui/src/components/Charts/constants/CondensedCharts.ts+++ /dev/null@@ -1,3 +0,0 @@-export const X_AXIS_PADDING = 20;-export const MIN_ROTATION_ANGLE = 0;-export const DEFAULT_X_AXIS_HEIGHT = 30;diff --git a/packages/react-ui/src/components/Charts/constants/index.ts b/packages/react-ui/src/components/Charts/constants/index.tsdeleted file mode 100644index 3b4637efd..000000000--- a/packages/react-ui/src/components/Charts/constants/index.ts+++ /dev/null@@ -1 +0,0 @@-export * from "./CondensedCharts";diff --git a/packages/react-ui/src/components/Charts/context/SideBarTooltipContext.tsx b/packages/react-ui/src/components/Charts/context/SideBarTooltipContext.tsxdeleted file mode 100644index 4fad8db27..000000000--- a/packages/react-ui/src/components/Charts/context/SideBarTooltipContext.tsx+++ /dev/null@@ -1,54 +0,0 @@-import React, { createContext, ReactNode, useContext } from "react";--export interface SideBarChartData {- title: string;- values: {- value: number;- label: string;- color: string;- }[];-}--interface SideBarTooltipContextType {- data: SideBarChartData | undefined;- isSideBarTooltipOpen: boolean;- setData: (data: SideBarChartData) => void;- setIsSideBarTooltipOpen: (isOpen: boolean) => void;-}--const SideBarTooltipContext = createContext<SideBarTooltipContextType | undefined>(undefined);--interface SideBarTooltipProviderProps {- children: ReactNode;- isSideBarTooltipOpen: boolean;- setIsSideBarTooltipOpen: (isOpen: boolean) => void;- data: SideBarChartData | undefined;- setData: (data: SideBarChartData) => void;-}--export const SideBarTooltipProvider: React.FC<SideBarTooltipProviderProps> = ({- children,- isSideBarTooltipOpen,- setIsSideBarTooltipOpen,- data,- setData,-}) => {- const value: SideBarTooltipContextType = {- data,- isSideBarTooltipOpen,- setData,- setIsSideBarTooltipOpen,- };-- return <SideBarTooltipContext.Provider value={value}>{children}</SideBarTooltipContext.Provider>;-};--export const useSideBarTooltip = (): SideBarTooltipContextType => {- const context = useContext(SideBarTooltipContext);- if (context === undefined) {- throw new Error("useSideBarTooltip must be used within a SideBarTooltipProvider");- }- return context;-};--export default SideBarTooltipContext;diff --git a/packages/react-ui/src/components/Charts/dependencies.ts b/packages/react-ui/src/components/Charts/dependencies.tsindex 39a26fb45..c8e92784b 100644--- a/packages/react-ui/src/components/Charts/dependencies.ts+++ b/packages/react-ui/src/components/Charts/dependencies.ts@@ -1,2 +1,6 @@-const dependencies = ["Charts", "IconButton"];+import buttonDeps from "../Button/dependencies";+import iconButtonDeps from "../IconButton/dependencies";+import separatorDeps from "../Separator/dependencies";++const dependencies = ["Charts", ...iconButtonDeps, ...buttonDeps, ...separatorDeps];export default dependencies;diff --git a/packages/react-ui/src/components/D3Charts/hooks/cartesian/index.ts b/packages/react-ui/src/components/Charts/hooks/cartesian/index.tssimilarity index 100%rename from packages/react-ui/src/components/D3Charts/hooks/cartesian/index.tsrename to packages/react-ui/src/components/Charts/hooks/cartesian/index.tsdiff --git a/packages/react-ui/src/components/D3Charts/hooks/cartesian/orchestratorTypes.ts b/packages/react-ui/src/components/Charts/hooks/cartesian/orchestratorTypes.tssimilarity index 100%rename from packages/react-ui/src/components/D3Charts/hooks/cartesian/orchestratorTypes.tsrename to packages/react-ui/src/components/Charts/hooks/cartesian/orchestratorTypes.tsdiff --git a/packages/react-ui/src/components/D3Charts/hooks/cartesian/useAutoAngleCalculation.ts b/packages/react-ui/src/components/Charts/hooks/cartesian/useAutoAngleCalculation.tssimilarity index 100%rename from packages/react-ui/src/components/D3Charts/hooks/cartesian/useAutoAngleCalculation.tsrename to packages/react-ui/src/components/Charts/hooks/cartesian/useAutoAngleCalculation.tsdiff --git a/packages/react-ui/src/components/D3Charts/hooks/cartesian/useCalendarHeatmapOrchestrator.ts b/packages/react-ui/src/components/Charts/hooks/cartesian/useCalendarHeatmapOrchestrator.tssimilarity index 91%rename from packages/react-ui/src/components/D3Charts/hooks/cartesian/useCalendarHeatmapOrchestrator.tsrename to packages/react-ui/src/components/Charts/hooks/cartesian/useCalendarHeatmapOrchestrator.tsindex 45ab0f80d..e3fbf3639 100644--- a/packages/react-ui/src/components/D3Charts/hooks/cartesian/useCalendarHeatmapOrchestrator.ts+++ b/packages/react-ui/src/components/Charts/hooks/cartesian/useCalendarHeatmapOrchestrator.ts@@ -18,7 +18,7 @@ import type { CalendarColumnSeparators, CalendarLevelStyle } from "../../Calendaimport { buildContainerStyle } from "../../utils/buildContainerStyle";import { CHART_CLASS_PREFIX, DEFAULT_CHART_HEIGHT } from "../../utils/constants";import { parseLineHeight } from "../../utils/labelWrap";-import { resolvePalette } from "../../utils/paletteUtils";+import { orientRampToSurface, resolvePalette } from "../../utils/paletteUtils";import { sampleRampStops } from "../../utils/rampUtils";import { useCanvasContextForLabelSize } from "../core/useCanvasContextForLabelSize";import { useChartShell } from "../core/useChartShell";@@ -93,6 +93,7 @@ export interface UseCalendarHeatmapOrchestratorParams {showMonthLabels: boolean;columnSeparators?: CalendarColumnSeparators;showLegend: boolean;+ valueLabel: string;formatTooltipLabel?: (value: number, date: Date) => string;width?: number | string;height?: number | string;@@ -132,6 +133,7 @@ export function useCalendarHeatmapOrchestrator({showMonthLabels,columnSeparators,showLegend,+ valueLabel,formatTooltipLabel,width,height,@@ -157,20 +159,22 @@ export function useCalendarHeatmapOrchestrator({height,});const context = useCanvasContextForLabelSize();- const { theme } = useTheme();+ const { theme, mode } = useTheme();const levelStyles = useMemo(() => normalizeLevelStyles(levelStylesProp), [levelStylesProp]);- // --- Level colors: five stops, either explicit or sampled from the ramp. The- // sampled ramp keeps HeatmapChart's low→high ordering, so stop 0 is the faint- // "empty" shade and stop 4 the most active. A per-level `levelStyles[i].color`+ // --- Level colors: five stops, either explicit or sampled from the ramp.+ // Stop 0 is the faint "empty" shade and stop 4 the most active: a+ // customPalette is read low → high as given, the theme's palette is oriented+ // to the surface (as in HeatmapChart). A per-level `levelStyles[i].color`// then supersedes the resolved stop. ---const levelColors = useMemo<string[]>(() => {- const base = levelColorsProp- ? [...levelColorsProp]- : sampleRampStops(resolvePalette(theme, themePaletteName, customPalette), LEVEL_COUNT);+ const ramp = customPalette+ ? resolvePalette(theme, themePaletteName, customPalette)+ : orientRampToSurface(resolvePalette(theme, themePaletteName), mode);+ const base = levelColorsProp ? [...levelColorsProp] : sampleRampStops(ramp, LEVEL_COUNT);return base.map((color, level) => levelStyles[level]?.color ?? color);- }, [levelColorsProp, theme, themePaletteName, customPalette, levelStyles]);+ }, [levelColorsProp, theme, mode, themePaletteName, customPalette, levelStyles]);// --- Grid + per-cell level ---const grid = useMemo(@@ -217,9 +221,10 @@ export function useCalendarHeatmapOrchestrator({return Math.max(WEEKDAY_GUTTER_MIN, Math.ceil(max) + WEEKDAY_LABEL_GAP * 2);}, [weekdayTicks, context]);- const gutterTop = showMonthLabels- ? Math.ceil(parseLineHeight(context.font)) + MONTH_LABEL_BOTTOM_GAP- : 0;+ // Quarter labels get their own row above the month labels.+ const labelRowHeight = Math.ceil(parseLineHeight(context.font)) + MONTH_LABEL_BOTTOM_GAP;+ const gutterTop =+ (separators.labels.length > 0 ? labelRowHeight : 0) + (showMonthLabels ? labelRowHeight : 0);// --- Cell geometry ---const weeks = grid.weeks;@@ -265,7 +270,7 @@ export function useCalendarHeatmapOrchestrator({label: formatCalendarTooltipDate(hoveredCell.date),items: [{- name: "contributions",+ name: valueLabel,value: formatTooltipLabel? formatTooltipLabel(hoveredCell.value, hoveredCell.date): hoveredCell.value,@@ -273,7 +278,7 @@ export function useCalendarHeatmapOrchestrator({},],};- }, [hoveredCell, levelColors, formatTooltipLabel]);+ }, [hoveredCell, levelColors, valueLabel, formatTooltipLabel]);// --- Bidirectional level highlight, in two scopes (bklit parity):// `hoveredLevel` (legend hover only) drives the GRID dim — hovering a celldiff --git a/packages/react-ui/src/components/D3Charts/hooks/cartesian/useCartesianChartOrchestrator.ts b/packages/react-ui/src/components/Charts/hooks/cartesian/useCartesianChartOrchestrator.tssimilarity index 100%rename from packages/react-ui/src/components/D3Charts/hooks/cartesian/useCartesianChartOrchestrator.tsrename to packages/react-ui/src/components/Charts/hooks/cartesian/useCartesianChartOrchestrator.tsdiff --git a/packages/react-ui/src/components/D3Charts/hooks/cartesian/useChartDimensions.ts b/packages/react-ui/src/components/Charts/hooks/cartesian/useChartDimensions.tssimilarity index 100%rename from packages/react-ui/src/components/D3Charts/hooks/cartesian/useChartDimensions.tsrename to packages/react-ui/src/components/Charts/hooks/cartesian/useChartDimensions.tsdiff --git a/packages/react-ui/src/components/D3Charts/hooks/cartesian/useChartScroll.ts b/packages/react-ui/src/components/Charts/hooks/cartesian/useChartScroll.tssimilarity index 100%rename from packages/react-ui/src/components/D3Charts/hooks/cartesian/useChartScroll.tsrename to packages/react-ui/src/components/Charts/hooks/cartesian/useChartScroll.tsdiff --git a/packages/react-ui/src/components/D3Charts/hooks/cartesian/useFunnelChartOrchestrator.ts b/packages/react-ui/src/components/Charts/hooks/cartesian/useFunnelChartOrchestrator.tssimilarity index 90%rename from packages/react-ui/src/components/D3Charts/hooks/cartesian/useFunnelChartOrchestrator.tsrename to packages/react-ui/src/components/Charts/hooks/cartesian/useFunnelChartOrchestrator.tsindex 45f9827c2..ba97fdefa 100644--- a/packages/react-ui/src/components/D3Charts/hooks/cartesian/useFunnelChartOrchestrator.ts+++ b/packages/react-ui/src/components/Charts/hooks/cartesian/useFunnelChartOrchestrator.ts@@ -3,7 +3,7 @@ import type { ChartColorPalette } from "../../../ThemeProvider";import { useTheme } from "../../../ThemeProvider";import type { FunnelOrientation } from "../../FunnelChart/parts/funnelGeometry";-import { funnelPercentage } from "../../FunnelChart/parts/funnelGeometry";+import { formatFunnelPercentage, funnelPercentage } from "../../FunnelChart/parts/funnelGeometry";import type { TooltipItem } from "../../shared/core/PortalTooltip/ChartTooltip";import type { ChartData, LegendItem } from "../../types";import { buildContainerStyle } from "../../utils/buildContainerStyle";@@ -11,6 +11,7 @@ import { DEFAULT_CHART_HEIGHT } from "../../utils/constants";import { buildColumnKeys } from "../../utils/heatmapUtils";import { parseLineHeight } from "../../utils/labelWrap";import { resolvePalette } from "../../utils/paletteUtils";+import { MAX_X_AXIS_HEIGHT_SHARE } from "../../utils/xAxisLabelLayout";import { useCanvasContextForLabelSize } from "../core/useCanvasContextForLabelSize";import { useChartShell } from "../core/useChartShell";import { usePerElementHover } from "../core/usePerElementHover";@@ -192,8 +193,8 @@ export function useFunnelChartOrchestrator<T extends ChartData>({const items: TooltipItem[] = [{ name: "Value", value: stage.value, color: stage.color },{- name: "of first stage",- value: `${Math.round(stage.pct)}%`,+ name: "Of first stage",+ value: formatFunnelPercentage(stage.pct),color: stage.color,},];@@ -236,11 +237,32 @@ export function useFunnelChartOrchestrator<T extends ChartData>({// Reserved label band (horizontal: bottom) / column (vertical: right). No// reservation when labels are hidden — the funnel reclaims the full area.+ // The band never takes more than half the height, so the funnel keeps the+ // rest; angled labels that don't fit it are truncated.+ const maxLabelBandHeight = Math.max(+ singleLineLabelHeight + LABEL_GAP,+ Math.floor(H * MAX_X_AXIS_HEIGHT_SHARE),+ );const labelBandHeight =!showLabels || !horizontal? 0- : (labelAngle !== 0 ? Math.max(angledHeight, singleLineLabelHeight) : singleLineLabelHeight) +- LABEL_GAP;+ : Math.min(+ maxLabelBandHeight,+ (labelAngle !== 0+ ? Math.max(angledHeight, singleLineLabelHeight)+ : singleLineLabelHeight) + LABEL_GAP,+ );+ // Longest angled label the band holds: text of width L rotated by the angle+ // spans L·sin + lineHeight·cos vertically.+ const angleRad = (Math.abs(labelAngle) * Math.PI) / 180;+ const angledLabelMaxWidth =+ labelAngle === 0+ ? Infinity+ : Math.max(+ 0,+ (labelBandHeight - LABEL_GAP - singleLineLabelHeight * Math.cos(angleRad)) /+ Math.sin(angleRad),+ );const labelColWidth =!showLabels || horizontal? 0@@ -275,6 +297,7 @@ export function useFunnelChartOrchestrator<T extends ChartData>({labelBandHeight,labelColWidth,labelAngle,+ angledLabelMaxWidth,},hover: { hoveredIndex, mousePos, handleMouseMove, handleMouseLeave },legend: { isLegendExpanded, setIsLegendExpanded },diff --git a/packages/react-ui/src/components/D3Charts/hooks/cartesian/useHeatmapChartOrchestrator.test.ts b/packages/react-ui/src/components/Charts/hooks/cartesian/useHeatmapChartOrchestrator.test.tssimilarity index 100%rename from packages/react-ui/src/components/D3Charts/hooks/cartesian/useHeatmapChartOrchestrator.test.tsrename to packages/react-ui/src/components/Charts/hooks/cartesian/useHeatmapChartOrchestrator.test.tsdiff --git a/packages/react-ui/src/components/D3Charts/hooks/cartesian/useHeatmapChartOrchestrator.ts b/packages/react-ui/src/components/Charts/hooks/cartesian/useHeatmapChartOrchestrator.tssimilarity index 91%rename from packages/react-ui/src/components/D3Charts/hooks/cartesian/useHeatmapChartOrchestrator.tsrename to packages/react-ui/src/components/Charts/hooks/cartesian/useHeatmapChartOrchestrator.tsindex 7ab5d1b31..db7752186 100644--- a/packages/react-ui/src/components/D3Charts/hooks/cartesian/useHeatmapChartOrchestrator.ts+++ b/packages/react-ui/src/components/Charts/hooks/cartesian/useHeatmapChartOrchestrator.ts@@ -16,6 +16,7 @@ import {import {DIVERGING_DEFAULT_DARK,DIVERGING_DEFAULT_LIGHT,+ orientRampToSurface,resolvePalette,} from "../../utils/paletteUtils";import { useCanvasContextForLabelSize } from "../core/useCanvasContextForLabelSize";@@ -31,9 +32,13 @@ const MIN_Y_AXIS_WIDTH = 20;const MAX_Y_AXIS_WIDTH = 200;const Y_AXIS_PADDING = 10;-// Below this band width, x labels thin out (every n-th) instead of rendering-// an ellipsis + tooltip wrapper per column. ~3 characters of the tick font.+// X labels thin out (every n-th) so each shown label gets room for the widest+// label text, between these bounds: at least ~3 characters of the tick font,+// and no more than this so one long label doesn't thin the whole axis (longer+// labels truncate). The gap keeps neighbouring labels apart.const MIN_X_LABEL_PX = 28;+const MAX_X_LABEL_PX = 64;+const X_LABEL_GAP = 8;export interface HoveredHeatmapCell {rowKey: string;@@ -165,7 +170,11 @@ export function useHeatmapChartOrchestrator<T extends Array<Record<string, strinif (rampMode === "diverging" && !customPalette) {return mode === "dark" ? DIVERGING_DEFAULT_DARK : DIVERGING_DEFAULT_LIGHT;}- return resolvePalette(theme, themePaletteName, customPalette);+ // A customPalette is used as given; the theme's palette is oriented so low+ // values sit nearest the surface.+ return customPalette+ ? resolvePalette(theme, themePaletteName, customPalette)+ : orientRampToSurface(resolvePalette(theme, themePaletteName), mode);}, [rampMode, customPalette, mode, theme, themePaletteName]);const [minValue, maxValue] = useMemo(() => {@@ -242,11 +251,18 @@ export function useHeatmapChartOrchestrator<T extends Array<Record<string, strin// x scale interns duplicates into one band, but React keys must be unique).const columnKeys = useMemo(() => buildColumnKeys(columns), [columns]);- // Thin the x labels once bands get narrower than a readable tick. The- // bandwidth comes from the SCALE: its domain interns duplicate labels, and- // XAxis thins over those unique bands — columns.length would over-count- // (and over-thin) whenever an LLM re-emits a category.- const labelInterval = computeLabelInterval(xScale.bandwidth(), MIN_X_LABEL_PX);+ // Thin the x labels once columns get narrower than their labels. The step+ // comes from the SCALE: its domain interns duplicate labels, and XAxis thins+ // over those unique bands — columns.length would over-count (and over-thin)+ // whenever an LLM re-emits a category.+ const widestColumnLabel = useMemo(+ () => columns.reduce((max, label) => Math.max(max, context.measureText(label).width), 0),+ [columns, context],+ );+ const labelInterval = computeLabelInterval(+ xScale.step(),+ Math.min(MAX_X_LABEL_PX, Math.max(MIN_X_LABEL_PX, widestColumnLabel)) + X_LABEL_GAP,+ );const yScale = useMemo(() =>scaleBand<string>()@@ -313,7 +329,7 @@ export function useHeatmapChartOrchestrator<T extends Array<Record<string, strinconst rowMean = rowMeans.get(rowKey);if (data.length > 1 && rowMean !== undefined) {items.push({- name: "row avg",+ name: "Row avg",value: roundMean(rowMean),color: colorScale(rowMean),});@@ -321,7 +337,7 @@ export function useHeatmapChartOrchestrator<T extends Array<Record<string, strinconst columnMean = columnMeans[columnIndex];if (visibleRowKeys.length > 1 && columnMean != null) {items.push({- name: "column avg",+ name: "Column avg",value: roundMean(columnMean),color: colorScale(columnMean),});diff --git a/packages/react-ui/src/components/D3Charts/hooks/cartesian/useHorizontalBarChartOrchestrator.ts b/packages/react-ui/src/components/Charts/hooks/cartesian/useHorizontalBarChartOrchestrator.tssimilarity index 100%rename from packages/react-ui/src/components/D3Charts/hooks/cartesian/useHorizontalBarChartOrchestrator.tsrename to packages/react-ui/src/components/Charts/hooks/cartesian/useHorizontalBarChartOrchestrator.tsdiff --git a/packages/react-ui/src/components/D3Charts/hooks/cartesian/useMaxLabelWidth.ts b/packages/react-ui/src/components/Charts/hooks/cartesian/useMaxLabelWidth.tssimilarity index 100%rename from packages/react-ui/src/components/D3Charts/hooks/cartesian/useMaxLabelWidth.tsrename to packages/react-ui/src/components/Charts/hooks/cartesian/useMaxLabelWidth.tsdiff --git a/packages/react-ui/src/components/D3Charts/hooks/cartesian/useScatterChartOrchestrator.ts b/packages/react-ui/src/components/Charts/hooks/cartesian/useScatterChartOrchestrator.tssimilarity index 100%rename from packages/react-ui/src/components/D3Charts/hooks/cartesian/useScatterChartOrchestrator.tsrename to packages/react-ui/src/components/Charts/hooks/cartesian/useScatterChartOrchestrator.tsdiff --git a/packages/react-ui/src/components/D3Charts/hooks/cartesian/useStackedData.ts b/packages/react-ui/src/components/Charts/hooks/cartesian/useStackedData.tssimilarity index 100%rename from packages/react-ui/src/components/D3Charts/hooks/cartesian/useStackedData.tsrename to packages/react-ui/src/components/Charts/hooks/cartesian/useStackedData.tsdiff --git a/packages/react-ui/src/components/D3Charts/hooks/cartesian/useXAxisHeight.ts b/packages/react-ui/src/components/Charts/hooks/cartesian/useXAxisHeight.tssimilarity index 100%rename from packages/react-ui/src/components/D3Charts/hooks/cartesian/useXAxisHeight.tsrename to packages/react-ui/src/components/Charts/hooks/cartesian/useXAxisHeight.tsdiff --git a/packages/react-ui/src/components/D3Charts/hooks/cartesian/useXAxisLabelLayout.ts b/packages/react-ui/src/components/Charts/hooks/cartesian/useXAxisLabelLayout.tssimilarity index 100%rename from packages/react-ui/src/components/D3Charts/hooks/cartesian/useXAxisLabelLayout.tsrename to packages/react-ui/src/components/Charts/hooks/cartesian/useXAxisLabelLayout.tsdiff --git a/packages/react-ui/src/components/D3Charts/hooks/cartesian/useXBandScale.ts b/packages/react-ui/src/components/Charts/hooks/cartesian/useXBandScale.tssimilarity index 100%rename from packages/react-ui/src/components/D3Charts/hooks/cartesian/useXBandScale.tsrename to packages/react-ui/src/components/Charts/hooks/cartesian/useXBandScale.tsdiff --git a/packages/react-ui/src/components/D3Charts/hooks/cartesian/useXScale.ts b/packages/react-ui/src/components/Charts/hooks/cartesian/useXScale.tssimilarity index 100%rename from packages/react-ui/src/components/D3Charts/hooks/cartesian/useXScale.tsrename to packages/react-ui/src/components/Charts/hooks/cartesian/useXScale.tsdiff --git a/packages/react-ui/src/components/D3Charts/hooks/cartesian/useYAxisWidth.ts b/packages/react-ui/src/components/Charts/hooks/cartesian/useYAxisWidth.tssimilarity index 100%rename from packages/react-ui/src/components/D3Charts/hooks/cartesian/useYAxisWidth.tsrename to packages/react-ui/src/components/Charts/hooks/cartesian/useYAxisWidth.tsdiff --git a/packages/react-ui/src/components/D3Charts/hooks/cartesian/useYScale.ts b/packages/react-ui/src/components/Charts/hooks/cartesian/useYScale.tssimilarity index 100%rename from packages/react-ui/src/components/D3Charts/hooks/cartesian/useYScale.tsrename to packages/react-ui/src/components/Charts/hooks/cartesian/useYScale.tsdiff --git a/packages/react-ui/src/components/D3Charts/hooks/core/index.ts b/packages/react-ui/src/components/Charts/hooks/core/index.tssimilarity index 100%rename from packages/react-ui/src/components/D3Charts/hooks/core/index.tsrename to packages/react-ui/src/components/Charts/hooks/core/index.tsdiff --git a/packages/react-ui/src/components/D3Charts/hooks/core/measureFontScope.test.ts b/packages/react-ui/src/components/Charts/hooks/core/measureFontScope.test.tssimilarity index 100%rename from packages/react-ui/src/components/D3Charts/hooks/core/measureFontScope.test.tsrename to packages/react-ui/src/components/Charts/hooks/core/measureFontScope.test.tsdiff --git a/packages/react-ui/src/components/D3Charts/hooks/core/measureFontScope.ts b/packages/react-ui/src/components/Charts/hooks/core/measureFontScope.tssimilarity index 100%rename from packages/react-ui/src/components/D3Charts/hooks/core/measureFontScope.tsrename to packages/react-ui/src/components/Charts/hooks/core/measureFontScope.tsdiff --git a/packages/react-ui/src/components/D3Charts/hooks/core/useCanvasContextForLabelSize.ts b/packages/react-ui/src/components/Charts/hooks/core/useCanvasContextForLabelSize.tssimilarity index 100%rename from packages/react-ui/src/components/D3Charts/hooks/core/useCanvasContextForLabelSize.tsrename to packages/react-ui/src/components/Charts/hooks/core/useCanvasContextForLabelSize.tsdiff --git a/packages/react-ui/src/components/D3Charts/hooks/core/useCategoricalChartData.ts b/packages/react-ui/src/components/Charts/hooks/core/useCategoricalChartData.tssimilarity index 100%rename from packages/react-ui/src/components/D3Charts/hooks/core/useCategoricalChartData.tsrename to packages/react-ui/src/components/Charts/hooks/core/useCategoricalChartData.tsdiff --git a/packages/react-ui/src/components/D3Charts/hooks/core/useChartData.ts b/packages/react-ui/src/components/Charts/hooks/core/useChartData.tssimilarity index 100%rename from packages/react-ui/src/components/D3Charts/hooks/core/useChartData.tsrename to packages/react-ui/src/components/Charts/hooks/core/useChartData.tsdiff --git a/packages/react-ui/src/components/D3Charts/hooks/core/useChartHover.ts b/packages/react-ui/src/components/Charts/hooks/core/useChartHover.tssimilarity index 100%rename from packages/react-ui/src/components/D3Charts/hooks/core/useChartHover.tsrename to packages/react-ui/src/components/Charts/hooks/core/useChartHover.tsdiff --git a/packages/react-ui/src/components/D3Charts/hooks/core/useChartShell.ts b/packages/react-ui/src/components/Charts/hooks/core/useChartShell.tssimilarity index 100%rename from packages/react-ui/src/components/D3Charts/hooks/core/useChartShell.tsrename to packages/react-ui/src/components/Charts/hooks/core/useChartShell.tsdiff --git a/packages/react-ui/src/components/D3Charts/hooks/core/useContainerSize.ts b/packages/react-ui/src/components/Charts/hooks/core/useContainerSize.tssimilarity index 100%rename from packages/react-ui/src/components/D3Charts/hooks/core/useContainerSize.tsrename to packages/react-ui/src/components/Charts/hooks/core/useContainerSize.tsdiff --git a/packages/react-ui/src/components/D3Charts/hooks/core/useEffectiveAnimation.ts b/packages/react-ui/src/components/Charts/hooks/core/useEffectiveAnimation.tssimilarity index 100%rename from packages/react-ui/src/components/D3Charts/hooks/core/useEffectiveAnimation.tsrename to packages/react-ui/src/components/Charts/hooks/core/useEffectiveAnimation.tsdiff --git a/packages/react-ui/src/components/D3Charts/hooks/core/useExportChartData.test.ts b/packages/react-ui/src/components/Charts/hooks/core/useExportChartData.test.tssimilarity index 100%rename from packages/react-ui/src/components/D3Charts/hooks/core/useExportChartData.test.tsrename to packages/react-ui/src/components/Charts/hooks/core/useExportChartData.test.tsdiff --git a/packages/react-ui/src/components/D3Charts/hooks/core/useExportChartData.ts b/packages/react-ui/src/components/Charts/hooks/core/useExportChartData.tssimilarity index 75%rename from packages/react-ui/src/components/D3Charts/hooks/core/useExportChartData.tsrename to packages/react-ui/src/components/Charts/hooks/core/useExportChartData.tsindex 7dac676e0..9376db985 100644--- a/packages/react-ui/src/components/D3Charts/hooks/core/useExportChartData.ts+++ b/packages/react-ui/src/components/Charts/hooks/core/useExportChartData.ts@@ -1,20 +1,14 @@import { useMemo } from "react";-import type { ExportChartData } from "../../../Charts/Charts";+import type { ExportChartData } from "../../types";// react-ui's PRINT CONTEXT (a React context; falsy outside-// <PrintContextProvider>). Deliberately NOT the D3Charts-local+// <PrintContextProvider>). Deliberately NOT the charts'// `usePrintContext` (hooks/core/usePrintContext.ts) — that one is a// media-query hook returning a boolean for `@media print`, a different-// concern. The PPTX export emitter must gate on the SAME provider react-ui's-// charts do, so the c1 print pipeline drives both identically.+// concern.import { usePrintContext as useReactUiPrintContext } from "../../../../context/PrintContext";-/**- * Props for the print-export emitter — a 1:1 mirror of react-ui's- * `useExportChartData` (packages/react-ui/src/components/Charts/hooks/- * useExportChartData.ts) so viz charts, once they replace react-ui's in the c1- * artifacts, keep emitting byte-identical `data-openui-chart` JSON.- */+/** Props for the print-export emitter (`data-openui-chart` JSON). */export interface UseExportChartDataProps {type: ExportChartData["type"];data: Array<Record<string, unknown>>;@@ -35,8 +29,7 @@ export interface UseExportChartDataProps {/*** PURE transform: props → the `ExportChartData` object. Extracted from the* hook so it can be unit-tested without a React/DOM environment (the hook- * itself needs a provider and is exercised at runtime). Mirrors react-ui's- * in-hook `useMemo` body exactly:+ * itself needs a provider and is exercised at runtime):* • 2D charts → one series per `dataKeys` entry, `labels` = the category* value of every row, `values` = `Number(row[key])` of every row.* • options → `chartColors`, `showLegend`, the cat/val axis-title pair@@ -78,8 +71,7 @@ export function buildExportChartData({}/**- * Emits the `data-openui-chart` payload for PPTX export — the viz-side twin of- * react-ui's `useExportChartData`. Returns the JSON string ONLY inside a+ * Emits the `data-openui-chart` payload for PPTX export. Returns the JSON string ONLY inside a* react-ui `<PrintContextProvider>` (the export path); `undefined` otherwise,* so a chart binding `data-openui-chart={exportData}` drops the attribute* entirely off the print path (React omits `undefined` attributes). Charts that@@ -102,10 +94,8 @@ export const useExportChartData = (props: UseExportChartDataProps): string | undcustomDataTransform,} = props;- // Mirror react-ui's dependency list exactly (the destructured fields + the- // print context). The memo body reads only these locals, so the dep array is- // honest — no exhaustive-deps suppression needed (and that rule is not enabled- // in this package's eslint config anyway).+ // The memo body reads only these locals (the destructured fields + the print+ // context), so the dep array is complete.return useMemo(() => {if (!printContext) {return undefined;diff --git a/packages/react-ui/src/components/D3Charts/hooks/core/useHydrated.ts b/packages/react-ui/src/components/Charts/hooks/core/useHydrated.tssimilarity index 100%rename from packages/react-ui/src/components/D3Charts/hooks/core/useHydrated.tsrename to packages/react-ui/src/components/Charts/hooks/core/useHydrated.tsdiff --git a/packages/react-ui/src/components/D3Charts/hooks/core/useIndexedClickHandler.ts b/packages/react-ui/src/components/Charts/hooks/core/useIndexedClickHandler.tssimilarity index 100%rename from packages/react-ui/src/components/D3Charts/hooks/core/useIndexedClickHandler.tsrename to packages/react-ui/src/components/Charts/hooks/core/useIndexedClickHandler.tsdiff --git a/packages/react-ui/src/components/D3Charts/hooks/core/useIsomorphicLayoutEffect.ts b/packages/react-ui/src/components/Charts/hooks/core/useIsomorphicLayoutEffect.tssimilarity index 100%rename from packages/react-ui/src/components/D3Charts/hooks/core/useIsomorphicLayoutEffect.tsrename to packages/react-ui/src/components/Charts/hooks/core/useIsomorphicLayoutEffect.tsdiff --git a/packages/react-ui/src/components/D3Charts/hooks/core/useLegendHeight.ts b/packages/react-ui/src/components/Charts/hooks/core/useLegendHeight.tssimilarity index 100%rename from packages/react-ui/src/components/D3Charts/hooks/core/useLegendHeight.tsrename to packages/react-ui/src/components/Charts/hooks/core/useLegendHeight.tsdiff --git a/packages/react-ui/src/components/D3Charts/hooks/core/usePerElementHover.ts b/packages/react-ui/src/components/Charts/hooks/core/usePerElementHover.tssimilarity index 100%rename from packages/react-ui/src/components/D3Charts/hooks/core/usePerElementHover.tsrename to packages/react-ui/src/components/Charts/hooks/core/usePerElementHover.tsdiff --git a/packages/react-ui/src/components/D3Charts/hooks/core/usePrintContext.ts b/packages/react-ui/src/components/Charts/hooks/core/usePrintContext.tssimilarity index 100%rename from packages/react-ui/src/components/D3Charts/hooks/core/usePrintContext.tsrename to packages/react-ui/src/components/Charts/hooks/core/usePrintContext.tsdiff --git a/packages/react-ui/src/components/D3Charts/hooks/core/useSeriesVisibility.ts b/packages/react-ui/src/components/Charts/hooks/core/useSeriesVisibility.tssimilarity index 100%rename from packages/react-ui/src/components/D3Charts/hooks/core/useSeriesVisibility.tsrename to packages/react-ui/src/components/Charts/hooks/core/useSeriesVisibility.tsdiff --git a/packages/react-ui/src/components/D3Charts/hooks/core/useTooltipPayload.test.ts b/packages/react-ui/src/components/Charts/hooks/core/useTooltipPayload.test.tssimilarity index 100%rename from packages/react-ui/src/components/D3Charts/hooks/core/useTooltipPayload.test.tsrename to packages/react-ui/src/components/Charts/hooks/core/useTooltipPayload.test.tsdiff --git a/packages/react-ui/src/components/D3Charts/hooks/core/useTooltipPayload.ts b/packages/react-ui/src/components/Charts/hooks/core/useTooltipPayload.tssimilarity index 100%rename from packages/react-ui/src/components/D3Charts/hooks/core/useTooltipPayload.tsrename to packages/react-ui/src/components/Charts/hooks/core/useTooltipPayload.tsdiff --git a/packages/react-ui/src/components/D3Charts/hooks/core/useTransformedKeys.ts b/packages/react-ui/src/components/Charts/hooks/core/useTransformedKeys.tssimilarity index 100%rename from packages/react-ui/src/components/D3Charts/hooks/core/useTransformedKeys.tsrename to packages/react-ui/src/components/Charts/hooks/core/useTransformedKeys.tsdiff --git a/packages/react-ui/src/components/Charts/hooks/index.ts b/packages/react-ui/src/components/Charts/hooks/index.tsindex e465f700c..bd686f96d 100644--- a/packages/react-ui/src/components/Charts/hooks/index.ts+++ b/packages/react-ui/src/components/Charts/hooks/index.ts@@ -1,7 +1,3 @@-export * from "./useAutoAngleCalculation";-export * from "./useCanvasContextForLabelSize";-export * from "./useExportChartData";-export * from "./useMaxLabelHeight";-export * from "./useMaxLabelWidth";-export * from "./useTransformKey";-export * from "./useYAxisLabelWidth";+export * from "./cartesian";+export * from "./core";+export * from "./polar";diff --git a/packages/react-ui/src/components/D3Charts/hooks/polar/index.ts b/packages/react-ui/src/components/Charts/hooks/polar/index.tssimilarity index 100%rename from packages/react-ui/src/components/D3Charts/hooks/polar/index.tsrename to packages/react-ui/src/components/Charts/hooks/polar/index.tsdiff --git a/packages/react-ui/src/components/D3Charts/hooks/polar/useCategoricalChartOrchestrator.ts b/packages/react-ui/src/components/Charts/hooks/polar/useCategoricalChartOrchestrator.tssimilarity index 98%rename from packages/react-ui/src/components/D3Charts/hooks/polar/useCategoricalChartOrchestrator.tsrename to packages/react-ui/src/components/Charts/hooks/polar/useCategoricalChartOrchestrator.tsindex 904a9b6ce..9744838a1 100644--- a/packages/react-ui/src/components/D3Charts/hooks/polar/useCategoricalChartOrchestrator.ts+++ b/packages/react-ui/src/components/Charts/hooks/polar/useCategoricalChartOrchestrator.ts@@ -180,10 +180,7 @@ export function useCategoricalChartOrchestrator<T extends ChartData>({const items: TooltipItem[] = [{name: slice.label,- value:- format === "percentage"- ? parseFloat(formatPercentage(slice.value, visibleTotal))- : slice.value,+ value: format === "percentage" ? formatPercentage(slice.value, visibleTotal) : slice.value,color: slice.color,},];diff --git a/packages/react-ui/src/components/D3Charts/hooks/polar/useRadarChartOrchestrator.ts b/packages/react-ui/src/components/Charts/hooks/polar/useRadarChartOrchestrator.tssimilarity index 100%rename from packages/react-ui/src/components/D3Charts/hooks/polar/useRadarChartOrchestrator.tsrename to packages/react-ui/src/components/Charts/hooks/polar/useRadarChartOrchestrator.tsdiff --git a/packages/react-ui/src/components/Charts/hooks/useAutoAngleCalculation.ts b/packages/react-ui/src/components/Charts/hooks/useAutoAngleCalculation.tsdeleted file mode 100644index 46df941b8..000000000--- a/packages/react-ui/src/components/Charts/hooks/useAutoAngleCalculation.ts+++ /dev/null@@ -1,83 +0,0 @@-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 (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 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,- enabled: boolean,- widthOfData?: number,-): 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)- // Use widthOfData if provided (space per data point), otherwise fall back to padding- const base = widthOfData ?? 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, enabled, widthOfData]);-};diff --git a/packages/react-ui/src/components/Charts/hooks/useCanvasContextForLabelSize.ts b/packages/react-ui/src/components/Charts/hooks/useCanvasContextForLabelSize.tsdeleted file mode 100644index 44537b8e5..000000000--- a/packages/react-ui/src/components/Charts/hooks/useCanvasContextForLabelSize.ts+++ /dev/null@@ -1,28 +0,0 @@-import { useMemo } from "react";--import { useTheme } from "../../ThemeProvider";--/**- * Creates a canvas 2D rendering context and sets its font style.- *- * This hook initializes a canvas element in memory, gets its 2D context,- * and then applies a font style based on the theme. It includes a fallback- * to a default font if the theme property is not available.- *- * @returns The canvas 2D context with the font style applied, or `null` if the- *- */--export const useCanvasContextForLabelSize = () => {- const { theme: userTheme } = useTheme();-- return useMemo(() => {- const canvas = document.createElement("canvas");- const context = canvas.getContext("2d")!;-- // Should match the chart's actual font for accuracy.- const font = userTheme.textLabelXs ?? "400 10px/12px Inter";- context.font = font;- return context;- }, [userTheme.textLabelXs]);-};diff --git a/packages/react-ui/src/components/Charts/hooks/useExportChartData.ts b/packages/react-ui/src/components/Charts/hooks/useExportChartData.tsdeleted file mode 100644index c86ba39e8..000000000--- a/packages/react-ui/src/components/Charts/hooks/useExportChartData.ts+++ /dev/null@@ -1,77 +0,0 @@-import { useMemo } from "react";-import { usePrintContext } from "../../../context/PrintContext";-import { ExportChartData } from "../Charts";--export interface UseExportChartDataProps {- type: ExportChartData["type"];- data: any[];- categoryKey?: string;- dataKeys?: string[];- colors: string[];- legend?: boolean;- xAxisLabel?: React.ReactNode;- yAxisLabel?: React.ReactNode;- extraOptions?: Omit<- NonNullable<ExportChartData["options"]>,- "chartColors" | "showLegend" | "catAxisTitle" | "valAxisTitle"- >;- // For specialized charts like scatter- customDataTransform?: () => ExportChartData["data"];-}--export const useExportChartData = ({- type,- data,- categoryKey,- dataKeys,- colors,- legend,- xAxisLabel,- yAxisLabel,- extraOptions,- customDataTransform,-}: UseExportChartDataProps): string | undefined => {- const printContext = usePrintContext();-- return useMemo(() => {- if (!printContext) {- return undefined;- }-- const chartData = customDataTransform- ? customDataTransform()- : (dataKeys || []).map((key) => ({- name: key,- labels: data.map((item) => (categoryKey ? String(item[categoryKey]) : "")),- values: data.map((item) => Number(item[key])),- }));-- const exportData: ExportChartData = {- type,- data: chartData,- options: {- chartColors: colors,- showLegend: legend,- catAxisTitle: typeof xAxisLabel === "string" ? xAxisLabel : undefined,- showCatAxisTitle: typeof xAxisLabel === "string",- valAxisTitle: typeof yAxisLabel === "string" ? yAxisLabel : undefined,- showValAxisTitle: typeof yAxisLabel === "string",- ...extraOptions,- },- };-- return JSON.stringify(exportData);- }, [- type,- data,- dataKeys,- categoryKey,- colors,- legend,- xAxisLabel,- yAxisLabel,- extraOptions,- customDataTransform,- printContext,- ]);-};diff --git a/packages/react-ui/src/components/Charts/hooks/useMaxLabelHeight.tsx b/packages/react-ui/src/components/Charts/hooks/useMaxLabelHeight.tsxdeleted file mode 100644index ce8bcfd32..000000000--- a/packages/react-ui/src/components/Charts/hooks/useMaxLabelHeight.tsx+++ /dev/null@@ -1,130 +0,0 @@-import { useMemo } from "react";--import { useTheme } from "../../ThemeProvider";-import { XAxisTickVariant } from "../types";--const DEFAULT_HEIGHT = 30;--export const useMaxLabelHeight = (- data: Record<string, string | number>[],- categoryKey: string,- tickVariant: XAxisTickVariant,- widthOfGroup = 70,-) => {- const { theme: userTheme } = useTheme();-- const maxLabelHeight = useMemo(() => {- if (typeof window === "undefined" || !data || data.length === 0) {- return DEFAULT_HEIGHT;- }-- const largestLabel = data.reduce((max, item) => {- const label = String(item[categoryKey]);- if (max.length < label.length) {- return label;- }- return max;- }, "");-- const [div1, div2, div3] = [- document.createElement("div"),- document.createElement("div"),- document.createElement("div"),- ];-- div1.style.font = userTheme.textLabelXs ?? "";- div1.style.letterSpacing = userTheme.textLabelXsLetterSpacing ?? "";- div1.style.opacity = "0";- div1.style.pointerEvents = "none";-- div2.innerText = largestLabel;- div3.innerText = "a";- div1.append(div2, div3);-- div1.style.width = `${widthOfGroup}px`;- div1.style.maxWidth = `${widthOfGroup}px`;- div1.style.wordBreak = "break-word";- div1.style.position = "absolute";- div1.style.visibility = "hidden";-- document.body.append(div1);-- const largestLabelHeight = Math.min(- div2.getBoundingClientRect().height,- div3.getBoundingClientRect().height * 3,- );- div1.remove();-- return largestLabelHeight;- }, [data, categoryKey, tickVariant, widthOfGroup]);-- if (tickVariant === "multiLine") {- return Math.max(maxLabelHeight + 13, DEFAULT_HEIGHT);- } else {- return DEFAULT_HEIGHT;- }-};--/**- * Hook to calculate the maximum label height for horizontal bar charts.- * This considers the vertical layout and label width constraints specific to horizontal bars.- * @param data - The chart data- * @param categoryKey - The category key- * @param labelWidth - The available width for labels (full chart width for horizontal bars)- * @returns The calculated label height- */-export const useHorizontalBarLabelHeight = (- data: Record<string, string | number>[],- categoryKey: string,- labelWidth: number,-) => {- const { theme: userTheme } = useTheme();-- const labelHeight = useMemo(() => {- if (typeof window === "undefined" || !data || data.length === 0) {- return 20; // Default height for horizontal bar labels- }-- const largestLabel = data.reduce((max, item) => {- const label = String(item[categoryKey]);- if (max.length < label.length) {- return label;- }- return max;- }, "");-- const [div1, div2] = [document.createElement("div"), document.createElement("div")];-- // Apply the same typography as the horizontal bar chart labels- div1.style.font = userTheme.textLabelXs ?? "";- div1.style.letterSpacing = userTheme.textLabelXsLetterSpacing ?? "";- div1.style.opacity = "0";- div1.style.pointerEvents = "none";- div1.style.position = "absolute";- div1.style.visibility = "hidden";-- div2.innerText = largestLabel;- div1.append(div2);-- // For horizontal bar charts, labels span the full width- // Set width constraint for horizontal bar labels- div1.style.width = `${labelWidth}px`;- div1.style.maxWidth = `${labelWidth}px`;- div1.style.overflow = "hidden";- div1.style.whiteSpace = "nowrap";- div1.style.textOverflow = "ellipsis";- div1.style.display = "flex";- div1.style.alignItems = "center";-- document.body.append(div1);-- const calculatedHeight = div2.getBoundingClientRect().height;- div1.remove();-- // Add some padding for better visual spacing- // For horizontal bars, we need more space since labels are positioned above bars- return Math.max(calculatedHeight + 8, 24);- }, [data, categoryKey, labelWidth, userTheme.textLabelXs, userTheme.textLabelXsLetterSpacing]);-- return labelHeight;-};diff --git a/packages/react-ui/src/components/Charts/hooks/useMaxLabelWidth.ts b/packages/react-ui/src/components/Charts/hooks/useMaxLabelWidth.tsdeleted file mode 100644index d352a4b66..000000000--- a/packages/react-ui/src/components/Charts/hooks/useMaxLabelWidth.ts+++ /dev/null@@ -1,41 +0,0 @@-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/packages/react-ui/src/components/Charts/hooks/useTransformKey.tsx b/packages/react-ui/src/components/Charts/hooks/useTransformKey.tsxdeleted file mode 100644index f5e2fe85e..000000000--- a/packages/react-ui/src/components/Charts/hooks/useTransformKey.tsx+++ /dev/null@@ -1,20 +0,0 @@-import { useMemo, useRef } from "react";--export const useTransformedKeys = (keys: string[]) => {- // Use a ref to maintain a stable cache of key -> UUID mappings- const cacheRef = useRef<Record<string, string>>({});-- return useMemo(() => {- return keys.reduce(- (acc, key) => {- // Only generate a new UUID if we don't already have one for this key- if (!cacheRef.current[key]) {- cacheRef.current[key] = crypto.randomUUID();- }- acc[key] = cacheRef.current[key];- return acc;- },- {} as Record<string, string>,- );- }, [keys]);-};diff --git a/packages/react-ui/src/components/Charts/hooks/useYAxisLabelWidth.tsx b/packages/react-ui/src/components/Charts/hooks/useYAxisLabelWidth.tsxdeleted file mode 100644index 8433b13a8..000000000--- a/packages/react-ui/src/components/Charts/hooks/useYAxisLabelWidth.tsx+++ /dev/null@@ -1,67 +0,0 @@-import { useCallback, useMemo, useRef, useState } from "react";--import { AreaChartData } from "../AreaChart";-import { BarChartData } from "../BarChart";-import { LineChartData } from "../LineChart";-import { ScatterPoint } from "../ScatterChart/types";-import { numberTickFormatter } from "../utils";-import { useCanvasContextForLabelSize } from "./useCanvasContextForLabelSize";--const DEFAULT_Y_AXIS_WIDTH = 40;-const MIN_Y_AXIS_WIDTH = 20;-const MAX_Y_AXIS_WIDTH = 200;-const LABEL_PADDING = 10;--export const useYAxisLabelWidth = (- data: AreaChartData | LineChartData | BarChartData | ScatterPoint[],- dataKeys: string[],-) => {- const context = useCanvasContextForLabelSize();- const [maxLabelWidthReceived, setMaxLabelWidthReceived] = useState(0);-- const maxLabelWidth = useMemo(() => {- if (typeof window === "undefined" || !data || data.length === 0 || !dataKeys.length) {- return DEFAULT_Y_AXIS_WIDTH;- }-- if (!context) {- return DEFAULT_Y_AXIS_WIDTH;- }-- let maxWidth = 0;-- // Measure all possible Y-axis values- dataKeys.forEach((key) => {- // Get all unique values for this data key we basically want to get the max width of the values- const values = [- ...new Set(data.map((item) => item[key]).filter((v) => v != null && typeof v === "number")),- ];-- values.forEach((value) => {- const displayValue = numberTickFormatter(value);- const textWidth = context.measureText(displayValue).width;-- maxWidth = Math.max(maxWidth, textWidth);- });- });-- // Add padding for better visual appearance- const totalWidth = Math.ceil(maxWidth) + LABEL_PADDING; // 5px padding on each side-- // Clamp the width between MIN and MAX values- return Math.max(MIN_Y_AXIS_WIDTH, Math.min(MAX_Y_AXIS_WIDTH, totalWidth));- }, [data, dataKeys, context]);-- const maxLabelWidthRef = useRef(maxLabelWidth);- maxLabelWidthRef.current = maxLabelWidthReceived || maxLabelWidth;-- const setLabelWidth = useCallback(- (displayValue: string) => {- const textWidth = context.measureText(displayValue).width + LABEL_PADDING;- setMaxLabelWidthReceived((currentWidth) => Math.max(currentWidth, textWidth));- },- [context],- );-- return { yAxisWidth: maxLabelWidthRef.current, setLabelWidth };-};diff --git a/packages/react-ui/src/components/Charts/index.ts b/packages/react-ui/src/components/Charts/index.tsindex 914a4e0a2..1678782d0 100644--- a/packages/react-ui/src/components/Charts/index.ts+++ b/packages/react-ui/src/components/Charts/index.ts@@ -1,15 +1,86 @@-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";-export * from "./PieChart";-export * from "./RadarChart";-export * from "./RadialChart";-export * from "./ScatterChart";-export * from "./SingleStackedBarChart";+export { AreaChart, AreaChartCondensed } from "./AreaChart";+export type { AreaChartCondensedProps } from "./AreaChart";+export type { AreaChartData, AreaChartProps, AreaChartVariant } from "./AreaChart/types";++export { LineChart, LineChartCondensed } from "./LineChart";+export type { LineChartCondensedProps } from "./LineChart";+export type { LineChartData, LineChartProps, LineChartVariant } from "./LineChart/types";++export { BarChart, BarChartCondensed, HorizontalBarChart } from "./BarChart";+export type {+ BarChartCondensedProps,+ HorizontalBarChartData,+ HorizontalBarChartProps,+ HorizontalBarChartVariant,+} from "./BarChart";+export type {+ BarChartData,+ BarChartOrientation,+ BarChartProps,+ BarChartVariant,+} from "./BarChart/types";++export { PieChart } from "./PieChart";+export type { PieChartData, PieChartProps } from "./PieChart/types";++export { RadialChart } from "./RadialChart";+export type { RadialChartData, RadialChartProps } from "./RadialChart/types";++export { RadarChart } from "./RadarChart";+export type { RadarChartData, RadarChartProps } from "./RadarChart/types";++export {+ ScatterChart,+ calculateScatterDomain,+ formatScatterTooltipValue,+ getScatterDatasets,+ transformScatterData,+} from "./ScatterChart";+export type {+ ScatterChartData,+ ScatterChartProps,+ ScatterDataset,+ ScatterPoint,+} from "./ScatterChart/types";++export { HeatmapChart } from "./HeatmapChart";+export type { HeatmapChartData, HeatmapChartProps } from "./HeatmapChart/types";++export { FunnelChart } from "./FunnelChart";+export type {+ FunnelChartData,+ FunnelChartProps,+ FunnelEdges,+ FunnelOrientation,+} from "./FunnelChart/types";++export { SegmentedBar, SingleStackedBar } from "./SegmentedBar";+export type { SingleStackedBarData, SingleStackedBarProps } from "./SegmentedBar";+export type { SegmentedBarData, SegmentedBarProps } from "./SegmentedBar/types";++export { CalendarHeatmap } from "./CalendarHeatmap";+export type { CalendarHeatmapDatum, CalendarHeatmapProps } from "./CalendarHeatmap/types";++export { MiniAreaChart } from "./MiniAreaChart";+export type { MiniAreaChartData, MiniAreaChartProps } from "./MiniAreaChart/types";++export { MiniBarChart } from "./MiniBarChart";+export type { MiniBarChartData, MiniBarChartProps } from "./MiniBarChart/types";++export { MiniLineChart } from "./MiniLineChart";+export type { MiniLineChartData, MiniLineChartProps } from "./MiniLineChart/types";++export { LegendStoreProvider, useLegendEntry } from "./shared/core/legend";+export type { LegendEntry, StackedLegendItem } from "./shared/core/legend";+export { StackedLegend } from "./shared/core/StackedLegend";+export type { StackedLegendProps } from "./shared/core/StackedLegend";++export type {+ BaseChartProps,+ ChartData,+ ExportChartData,+ LegendItem,+ XAxisTickVariant,+} from "./types";++export { CHART_CLASS_PREFIX } from "./utils/constants";diff --git a/packages/react-ui/src/components/Charts/shared/ActiveDot/ActiveDot.tsx b/packages/react-ui/src/components/Charts/shared/ActiveDot/ActiveDot.tsxdeleted file mode 100644index a60b2fa41..000000000--- a/packages/react-ui/src/components/Charts/shared/ActiveDot/ActiveDot.tsx+++ /dev/null@@ -1,55 +0,0 @@-import React, { useLayoutEffect, useRef } from "react";--export interface ActiveDotProps {- cx?: number;- cy?: number;- payload?: any;- value?: any;- fill?: string;- stroke?: string;-}--export const ActiveDot: React.FC<ActiveDotProps> = (props) => {- const { cx, cy, fill, stroke } = props;- const ref = useRef<SVGGElement>(null);-- useLayoutEffect(() => {- if (ref.current) {- const parent = ref.current.parentElement?.parentElement;- const dotGroup = document.createElementNS("http://www.w3.org/2000/svg", "g");-- const circle1 = document.createElementNS("http://www.w3.org/2000/svg", "circle");- circle1.setAttribute("cx", String(cx));- circle1.setAttribute("cy", String(cy));- circle1.setAttribute("r", "4");- circle1.setAttribute("fill", "var(--openui-foreground)");- circle1.setAttribute("stroke", "var(--openui-foreground)");- circle1.setAttribute("stroke-width", "1");-- const circle2 = document.createElementNS("http://www.w3.org/2000/svg", "circle");- circle2.setAttribute("cx", String(cx));- circle2.setAttribute("cy", String(cy));- circle2.setAttribute("r", "2");- circle2.setAttribute("fill", fill || "var(--color-bg)");- circle2.setAttribute("stroke", stroke || "transparent");- circle2.setAttribute("stroke-width", "0");-- dotGroup.appendChild(circle1);- dotGroup.appendChild(circle2);- if (parent) {- parent.appendChild(dotGroup);- }-- return () => {- dotGroup.remove();- };- }- return undefined;- });-- if (cx === undefined || cy === undefined || cx === null || cy === null) {- return null;- }-- return <g ref={ref}></g>;-};diff --git a/packages/react-ui/src/components/Charts/shared/CartesianGrid/cartesianGrid.tsx b/packages/react-ui/src/components/Charts/shared/CartesianGrid/cartesianGrid.tsxdeleted file mode 100644index d4a5a916f..000000000--- a/packages/react-ui/src/components/Charts/shared/CartesianGrid/cartesianGrid.tsx+++ /dev/null@@ -1,20 +0,0 @@-import { CartesianGrid } from "recharts";--export const cartesianGrid = () => gridCartesianGrid({ vertical: false });--export const verticalCartesianGrid = () => gridCartesianGrid({ horizontal: false });--export const gridCartesianGrid = (props: { vertical?: boolean; horizontal?: boolean }) => (- <CartesianGrid- vertical={props.vertical ?? true}- horizontal={props.horizontal ?? true}- fillOpacity={1}- strokeOpacity={1}- strokeWidth={1}- strokeDasharray="0"- strokeLinecap="round"- strokeLinejoin="round"- stroke="currentColor"- className="openui-chart-cartesian-grid"- />-);diff --git a/packages/react-ui/src/components/Charts/shared/DefaultLegend/DefaultLegend.tsx b/packages/react-ui/src/components/Charts/shared/DefaultLegend/DefaultLegend.tsxdeleted file mode 100644index 0d5f72a3b..000000000--- a/packages/react-ui/src/components/Charts/shared/DefaultLegend/DefaultLegend.tsx+++ /dev/null@@ -1,140 +0,0 @@-import clsx from "clsx";-import { ChevronDownIcon, ChevronUpIcon } from "lucide-react";-import React, { memo, useCallback, useState } from "react";-import { Button } from "../../../Button/Button";-import { type LegendItem } from "../../types";-import { useDefaultLegend } from "./hooks/useDefaultLegend";--interface DefaultLegendProps {- items: LegendItem[];- className?: string;- yAxisLabel?: React.ReactNode;- xAxisLabel?: React.ReactNode;- containerWidth?: number;- isExpanded: boolean;- setIsExpanded: (isExpanded: boolean) => void;- style?: React.CSSProperties;-}--const DefaultLegend = memo(- React.forwardRef<HTMLDivElement, DefaultLegendProps>(- (- {- items,- className,- yAxisLabel,- xAxisLabel,- containerWidth,- isExpanded,- setIsExpanded,- style,- },- ref,- ) => {- const [buttonWidth, setButtonWidth] = useState(0);- const { displayItems, hasMoreItems, toggleButtonText } = useDefaultLegend({- items,- containerWidth,- buttonWidth,- isExpanded,- });-- // We use a callback ref to measure the button's width as soon as it's mounted.- // This is more reliable than useEffect with ref.current in the dependency array,- // as it correctly triggers a re-render when the node is available.- // This is a workaround for the fact that the button's width is not available immediately.- // and we need the actual button width to calculate the layout of the legend items.- const buttonRef = useCallback(- (node: HTMLButtonElement | null) => {- if (node) {- if (node.clientWidth !== buttonWidth) {- setButtonWidth(node.clientWidth);- }- }- },- [buttonWidth],- );-- const handleToggleExpanded = () => {- setIsExpanded(!isExpanded);- };-- const showToggleButton = hasMoreItems;-- return (- <div- ref={ref}- className={clsx("openui-chart-legend-container openui-chart-legend--bottom", className)}- style={style}- >- {/* this is x and y axis labels container*/}- {(xAxisLabel || yAxisLabel) && (- <div className="openui-chart-legend-axis-label-container">- {xAxisLabel && (- <span className="openui-chart-legend-axis-label">- X-Axis: <span className="openui-chart-legend-axis-label-text">{xAxisLabel}</span>- </span>- )}- {yAxisLabel && (- <span className="openui-chart-legend-axis-label">- Y-Axis: <span className="openui-chart-legend-axis-label-text">{yAxisLabel}</span>- </span>- )}- </div>- )}- {/* this is the legend items container*/}- <div- className={clsx("openui-chart-legend", {- "openui-chart-legend--expanded": isExpanded,- "openui-chart-legend--collapsed": !isExpanded && showToggleButton,- })}- >- {displayItems.map((item) => (- <div key={item.key} className="openui-chart-legend-item">- {item.icon ? (- <item.icon />- ) : (- <div- className="openui-chart-legend-item-indicator"- style={{ backgroundColor: item.color }}- />- )}- <div className="openui-chart-legend-item-label-container">- <span className="openui-chart-legend-item-label">{item.label}</span>- {item.percentage !== undefined && (- <span className="openui-chart-legend-item-percentage">- {item.percentage.toFixed(1)}%- </span>- )}- </div>- </div>- ))}-- {showToggleButton && (- <Button- variant="tertiary"- size="small"- ref={buttonRef}- className="openui-chart-legend-toggle-button"- onClick={handleToggleExpanded}- iconRight={- isExpanded ? (- <ChevronUpIcon className="openui-chart-legend-toggle-button-icon" />- ) : (- <ChevronDownIcon className="openui-chart-legend-toggle-button-icon" />- )- }- >- {toggleButtonText}- </Button>- )}- </div>- </div>- );- },- ),-);--DefaultLegend.displayName = "DefaultLegend";-export { DefaultLegend };-export type { DefaultLegendProps };diff --git a/packages/react-ui/src/components/Charts/shared/DefaultLegend/defaultLegend.scss b/packages/react-ui/src/components/Charts/shared/DefaultLegend/defaultLegend.scssdeleted file mode 100644index 3e3e23f71..000000000--- a/packages/react-ui/src/components/Charts/shared/DefaultLegend/defaultLegend.scss+++ /dev/null@@ -1,97 +0,0 @@-@use "../../../../cssUtils" as cssUtils;--.openui-chart-legend-container {- display: flex;- flex-direction: column;- align-items: center;- justify-content: center;- gap: cssUtils.$space-s;-}--.openui-chart-legend-axis-label-container {- display: flex;- align-items: center;- justify-content: center;- gap: cssUtils.$space-m;- flex-wrap: wrap;-}--.openui-chart-legend-axis-label {- @include cssUtils.typography(label, extra-small);- color: cssUtils.$text-neutral-secondary;-- &-text {- color: cssUtils.$text-neutral-primary;- }-}--.openui-chart-legend {- display: flex;- align-items: center;- justify-content: center;- gap: cssUtils.$space-m;- text-transform: capitalize;- flex-wrap: wrap;-- &--bottom {- padding-top: cssUtils.$space-m;- }-- &--collapsed {- flex-wrap: nowrap;- overflow: hidden;- }-- &--expanded {- flex-wrap: wrap;- }-- &-item {- display: flex;- align-items: center;- gap: cssUtils.$space-xs;-- svg {- height: 10px;- width: 10px;- color: cssUtils.$text-neutral-primary;- }-- &-indicator {- height: 10px;- width: 10px;- flex-shrink: 0;- border-radius: cssUtils.$radius-2xs;- background-color: var(--color-bg);- }-- &-label {- @include cssUtils.typography(label, extra-small);- color: cssUtils.$text-neutral-primary;- }- }-- &-toggle-button {- @include cssUtils.typography(label, extra-small);- color: cssUtils.$text-neutral-primary;- padding-left: cssUtils.$space-2xs;- padding-right: cssUtils.$space-3xs;-- &-icon {- width: 1em;- height: 1em;- color: cssUtils.$text-neutral-primary;- }- }-- &-item-label-container {- display: flex;- align-items: center;- gap: cssUtils.$space-2xs;- }-- &-item-percentage {- @include cssUtils.typography(label, extra-small);- color: cssUtils.$text-neutral-secondary;- }-}diff --git a/packages/react-ui/src/components/Charts/shared/DefaultLegend/hooks/useDefaultLegend.ts b/packages/react-ui/src/components/Charts/shared/DefaultLegend/hooks/useDefaultLegend.tsdeleted file mode 100644index 5c444ed81..000000000--- a/packages/react-ui/src/components/Charts/shared/DefaultLegend/hooks/useDefaultLegend.ts+++ /dev/null@@ -1,112 +0,0 @@-import { useMemo } from "react";-import { useCanvasContextForLabelSize } from "../../../hooks/useCanvasContextForLabelSize";-import { LegendItem } from "../../../types";--const CHARACTER_WIDTH = 7; // Fallback width per character-const INDICATOR_WIDTH = 10;-const GAP_WIDTH = 12;--interface UseDefaultLegendProps {- items: LegendItem[];- containerWidth?: number;- buttonWidth?: number;- isExpanded: boolean;-}--interface UseDefaultLegendResult {- displayItems: LegendItem[];- hasMoreItems: boolean;- toggleButtonText: string;-}--export const useDefaultLegend = ({- items,- containerWidth,- buttonWidth,- isExpanded,-}: UseDefaultLegendProps): UseDefaultLegendResult => {- const canvasContext = useCanvasContextForLabelSize();-- const calculateItemWidth = useMemo(- () =>- (item: LegendItem): number => {- let displayText = item.label;-- // If percentage is provided, include it in the width calculation- if (item.percentage !== undefined) {- displayText += ` (${item.percentage.toFixed(1)}%)`;- }-- if (canvasContext) {- // If canvas is supported, measure text width accurately- return canvasContext.measureText(displayText).width + INDICATOR_WIDTH + GAP_WIDTH;- }-- // Fallback for SSR or if canvas is not supported- return displayText.length * CHARACTER_WIDTH + INDICATOR_WIDTH + GAP_WIDTH;- },- [canvasContext],- );-- const { visibleItems, hasMoreItems } = useMemo(() => {- if (!containerWidth || items.length === 0) {- return { visibleItems: items, hasMoreItems: false };- }-- const availableWidth = containerWidth - (buttonWidth ?? 0);- let currentWidth = 0;- let visibleCount = 0;-- for (let i = 0; i < items.length; i++) {- const item = items[i];- if (!item) continue;-- const itemWidth = calculateItemWidth(item);- // Add gap between items except for the first one- const requiredWidth = visibleCount > 0 ? itemWidth + GAP_WIDTH : itemWidth;-- if (currentWidth + requiredWidth <= availableWidth) {- currentWidth += requiredWidth;- visibleCount++;- } else {- break;- }- }- // If all items fit within available width, show all items- if (visibleCount === items.length) {- return { visibleItems: items, hasMoreItems: false };- }-- // If no items fit within available width, show at least the first item- if (visibleCount === 0 && items[0]) {- return {- visibleItems: [items[0]], // Show first item- hasMoreItems: items.length > 1, // Has more if there are additional items- };- }-- return {- visibleItems: items.slice(0, visibleCount),- hasMoreItems: items.length > visibleCount,- };- }, [items, containerWidth, buttonWidth, calculateItemWidth]);-- const displayItems = useMemo(- () => (isExpanded ? items : visibleItems),- [isExpanded, items, visibleItems],- );-- const toggleButtonText = useMemo(() => {- if (isExpanded) {- return "Show Less";- }- const hiddenCount = items.length - visibleItems.length;- return `${hiddenCount} more`;- }, [isExpanded, items.length, visibleItems.length]);-- return {- displayItems,- hasMoreItems,- toggleButtonText,- };-};diff --git a/packages/react-ui/src/components/Charts/shared/DefaultLegend/stories/DefaultLegend.stories.tsx b/packages/react-ui/src/components/Charts/shared/DefaultLegend/stories/DefaultLegend.stories.tsxdeleted file mode 100644index 8b617b284..000000000--- a/packages/react-ui/src/components/Charts/shared/DefaultLegend/stories/DefaultLegend.stories.tsx+++ /dev/null@@ -1,338 +0,0 @@-import type { Meta, StoryObj } from "@storybook/react";-import { useEffect, useRef, useState } from "react";-import { LegendItem } from "../../../types";-import { DefaultLegend } from "../DefaultLegend";--const meta: Meta<typeof DefaultLegend> = {- title: "Components/Charts/Shared/DefaultLegend",- component: DefaultLegend,- parameters: {- layout: "centered",- },- tags: ["!dev", "!autodocs"],- argTypes: {- containerWidth: {- control: { type: "range", min: 200, max: 800, step: 50 },- },- },-};--export default meta;-type Story = StoryObj<typeof meta>;--// Sample legend items with varying label lengths-const shortItems: LegendItem[] = [- { key: "sales", label: "Sales", color: "#3b82f6" },- { key: "users", label: "Users", color: "#ef4444" },- { key: "revenue", label: "Revenue", color: "#10b981" },-];--const mediumItems: LegendItem[] = [- { key: "sales", label: "Sales Data", color: "#3b82f6" },- { key: "marketing", label: "Marketing Leads", color: "#ef4444" },- { key: "revenue", label: "Total Revenue", color: "#10b981" },- { key: "conversion", label: "Conversion Rate", color: "#f59e0b" },- { key: "retention", label: "User Retention", color: "#8b5cf6" },-];--const longItems: LegendItem[] = [- { key: "sales", label: "Monthly Sales Performance", color: "#3b82f6" },- { key: "marketing", label: "Digital Marketing Campaigns", color: "#ef4444" },- { key: "revenue", label: "Quarterly Revenue Growth", color: "#10b981" },- { key: "conversion", label: "Customer Conversion Metrics", color: "#f59e0b" },- { key: "retention", label: "Long-term User Retention", color: "#8b5cf6" },- { key: "engagement", label: "User Engagement Analytics", color: "#ec4899" },- { key: "support", label: "Customer Support Tickets", color: "#14b8a6" },- { key: "satisfaction", label: "Customer Satisfaction Score", color: "#f97316" },-];--const expandCollapseItems: LegendItem[] = [- { key: "web_traffic", label: "Website Traffic and Organic Search Results", color: "#3b82f6" },- { key: "social_media", label: "Social Media Engagement and Brand Awareness", color: "#ef4444" },- { key: "email_campaigns", label: "Email Marketing Campaign Performance", color: "#10b981" },- { key: "paid_advertising", label: "Paid Advertising and PPC Campaign ROI", color: "#f59e0b" },- { key: "content_marketing", label: "Content Marketing and Blog Performance", color: "#8b5cf6" },- { key: "mobile_app", label: "Mobile Application Downloads and Usage", color: "#ec4899" },- {- key: "customer_support",- label: "Customer Support Response Time and Quality",- color: "#14b8a6",- },- {- key: "sales_conversion",- label: "Sales Funnel Conversion and Lead Generation",- color: "#f97316",- },- { key: "user_retention", label: "User Retention and Churn Rate Analysis", color: "#6366f1" },- {- key: "product_analytics",- label: "Product Feature Usage and Performance Metrics",- color: "#06b6d4",- },- { key: "market_research", label: "Market Research and Competitive Analysis", color: "#84cc16" },- {- key: "brand_sentiment",- label: "Brand Sentiment and Public Relations Impact",- color: "#f59e0b",- },-];--export const Basic: Story = {- args: {- items: shortItems,- containerWidth: 400,- },-};--export const WithAxisLabels: Story = {- args: {- items: mediumItems,- containerWidth: 400,- xAxisLabel: "Time Period",- yAxisLabel: "Value",- },-};--export const SmallContainer: Story = {- args: {- items: mediumItems,- containerWidth: 300,- },-};--export const ManyItemsSmallContainer: Story = {- args: {- items: longItems,- containerWidth: 400,- },-};--export const ManyItemsLargeContainer: Story = {- args: {- items: longItems,- containerWidth: 800,- },-};--export const VerySmallContainer: Story = {- args: {- items: longItems,- containerWidth: 200,- },-};--export const Interactive: Story = {- args: {- items: longItems,- xAxisLabel: "Monthly Data",- yAxisLabel: "Performance Metrics",- },- render: (args: any) => {- const DynamicLegendExample = () => {- const containerRef = useRef<HTMLDivElement>(null);- const [containerWidth, setContainerWidth] = useState<number>(500);-- useEffect(() => {- const container = containerRef.current;- if (!container) return;-- const resizeObserver = new ResizeObserver((entries) => {- for (const entry of entries) {- // Subtract padding from the observed width- const paddingX = 40; // 20px padding on each side- const observedWidth = Math.max(200, entry.contentRect.width - paddingX);- setContainerWidth(observedWidth);- }- });-- resizeObserver.observe(container);-- return () => {- resizeObserver.disconnect();- };- }, []);-- return (- <div- ref={containerRef}- style={{- width: "100%",- padding: "20px",- resize: "horizontal",- overflow: "auto",- border: "1px dashed #ccc",- minWidth: "250px",- }}- >- <p style={{ marginBottom: "16px", fontSize: "14px", color: "#666" }}>- This legend demonstrates dynamic behavior with ResizeObserver.- <strong>Drag the bottom-right corner</strong> to resize the container and see how the- legend adapts in real-time. Current width: <strong>{containerWidth}px</strong>- </p>- <DefaultLegend {...args} containerWidth={containerWidth} />- </div>- );- };-- return <DynamicLegendExample />;- },-};--export const ExpandCollapseDemo: Story = {- args: {- items: expandCollapseItems,- containerWidth: 500,- xAxisLabel: "Marketing Channels",- yAxisLabel: "Performance Metrics",- },- render: (args: any) => (- <div style={{ width: "100%", padding: "20px" }}>- <h3 style={{ marginBottom: "16px", fontSize: "16px", fontWeight: "600" }}>- 🔄 Expand/Collapse Functionality Demo- </h3>- <p style={{ marginBottom: "16px", fontSize: "14px", color: "#666" }}>- This legend has <strong>12 items with long labels</strong> in a{" "}- <strong>500px container</strong>. Only the items that fit in one line are shown initially,- with a <strong>"Show More"</strong> button to expand and see all items. Click the button to- toggle between collapsed and expanded states.- </p>- <div- style={{- border: "1px dashed #ccc",- padding: "16px",- borderRadius: "8px",- backgroundColor: "#f9f9f9",- }}- >- <DefaultLegend {...args} />- </div>- <div style={{ marginTop: "12px", fontSize: "12px", color: "#888" }}>- 💡 <strong>Features:</strong> Dynamic width calculation, intelligent truncation, responsive- behavior- </div>- </div>- ),- parameters: {- docs: {- description: {- story:- "Demonstrates the expand/collapse functionality with 12 marketing-themed legend items. The legend automatically calculates how many items fit in the container width and shows a toggle button when items overflow.",- },- },- },-};--export const ResponsiveExpandCollapse: Story = {- args: {- items: expandCollapseItems,- xAxisLabel: "Marketing Channels",- yAxisLabel: "Performance Metrics",- },- render: (args: any) => (- <div style={{ width: "100%", padding: "20px" }}>- <h3 style={{ marginBottom: "16px", fontSize: "16px", fontWeight: "600" }}>- 📐 Responsive Expand/Collapse Behavior- </h3>- <p style={{ marginBottom: "16px", fontSize: "14px", color: "#666" }}>- The same legend data shown in different container widths. Notice how the number of visible- items and the toggle button behavior adapts to the available space.- </p>-- <div style={{ display: "flex", flexDirection: "column", gap: "24px" }}>- <div>- <h4 style={{ margin: "0 0 8px 0", fontSize: "14px", fontWeight: "600" }}>- Small Container (350px) - Shows fewer items- </h4>- <div- style={{- border: "1px solid #e0e0e0",- padding: "12px",- borderRadius: "6px",- backgroundColor: "#fafafa",- width: "350px",- }}- >- <DefaultLegend {...args} containerWidth={350} />- </div>- </div>-- <div>- <h4 style={{ margin: "0 0 8px 0", fontSize: "14px", fontWeight: "600" }}>- Medium Container (500px) - Shows more items- </h4>- <div- style={{- border: "1px solid #e0e0e0",- padding: "12px",- borderRadius: "6px",- backgroundColor: "#fafafa",- width: "500px",- }}- >- <DefaultLegend {...args} containerWidth={500} />- </div>- </div>-- <div>- <h4 style={{ margin: "0 0 8px 0", fontSize: "14px", fontWeight: "600" }}>- Large Container (700px) - Shows most items- </h4>- <div- style={{- border: "1px solid #e0e0e0",- padding: "12px",- borderRadius: "6px",- backgroundColor: "#fafafa",- width: "700px",- }}- >- <DefaultLegend {...args} containerWidth={700} />- </div>- </div>-- <div>- <h4 style={{ margin: "0 0 8px 0", fontSize: "14px", fontWeight: "600" }}>- Extra Large Container (900px) - Shows all items (no toggle button)- </h4>- <div- style={{- border: "1px solid #e0e0e0",- padding: "12px",- borderRadius: "6px",- backgroundColor: "#fafafa",- width: "900px",- }}- >- <DefaultLegend {...args} containerWidth={900} />- </div>- </div>- </div>- </div>- ),- parameters: {- docs: {- description: {- story:- "Shows how the expand/collapse behavior adapts to different container widths. Smaller containers show fewer items initially, while larger containers may show all items without needing a toggle button.",- },- },- },-};--export const DefaultBehavior: Story = {- args: {- items: longItems,- // No containerWidth provided - should show all items- xAxisLabel: "Monthly Data",- yAxisLabel: "Performance Metrics",- },- render: (args: any) => (- <div style={{ width: "100%", padding: "20px" }}>- <p style={{ marginBottom: "16px", fontSize: "14px", color: "#666" }}>- This demonstrates the default behavior when no containerWidth is provided. All legend items- are shown without truncation or show more/less functionality.- </p>- <DefaultLegend {...args} />- </div>- ),-};diff --git a/packages/react-ui/src/components/Charts/shared/LabelTooltip/LabelTooltip.tsx b/packages/react-ui/src/components/Charts/shared/LabelTooltip/LabelTooltip.tsxdeleted file mode 100644index 46e7bae31..000000000--- a/packages/react-ui/src/components/Charts/shared/LabelTooltip/LabelTooltip.tsx+++ /dev/null@@ -1,85 +0,0 @@-import * as Tooltip from "@radix-ui/react-tooltip";-import React from "react";--interface LabelTooltipProviderProps {- children: React.ReactNode;- delayDuration?: number;- skipDelayDuration?: number;- disableHoverableContent?: boolean;-}--interface LabelTooltipProps {- children: React.ReactNode;- content: string;- side?: "top" | "bottom" | "left" | "right";- sideOffset?: number;- delayDuration?: number;- className?: string;- disabled?: boolean;- open?: boolean;- defaultOpen?: boolean;- onOpenChange?: (open: boolean) => void;-}--const DEFAULT_DELAY_DURATION = 300;-const DEFAULT_SKIP_DELAY_DURATION = 300;-const DEFAULT_DISABLE_HOVERABLE_CONTENT = false;--const LabelTooltipProvider: React.FC<LabelTooltipProviderProps> = (props) => {- const {- children,- delayDuration = DEFAULT_DELAY_DURATION,- skipDelayDuration = DEFAULT_SKIP_DELAY_DURATION,- disableHoverableContent = DEFAULT_DISABLE_HOVERABLE_CONTENT,- } = props;-- return (- <Tooltip.Provider- delayDuration={delayDuration}- skipDelayDuration={skipDelayDuration}- disableHoverableContent={disableHoverableContent}- >- {children}- </Tooltip.Provider>- );-};--const LabelTooltip = React.forwardRef<HTMLDivElement, LabelTooltipProps>((props, ref) => {- const {- children,- content,- side = "top",- sideOffset = 1,- delayDuration = DEFAULT_DELAY_DURATION,- className = "openui-chart-label-tooltip",- disabled = false,- open,- defaultOpen,- onOpenChange,- } = props;-- if (disabled) {- return children;- }-- return (- <Tooltip.Root- delayDuration={delayDuration}- open={open}- defaultOpen={defaultOpen}- onOpenChange={onOpenChange}- >- <Tooltip.Trigger asChild>{children}</Tooltip.Trigger>- <Tooltip.Portal>- <Tooltip.Content ref={ref} className={className} side={side} sideOffset={sideOffset}>- {content}- </Tooltip.Content>- </Tooltip.Portal>- </Tooltip.Root>- );-});--LabelTooltip.displayName = "LabelTooltip";--export { LabelTooltip, LabelTooltipProvider };-export type { LabelTooltipProps, LabelTooltipProviderProps };diff --git a/packages/react-ui/src/components/Charts/shared/LabelTooltip/labelTooltip.scss b/packages/react-ui/src/components/Charts/shared/LabelTooltip/labelTooltip.scssdeleted file mode 100644index f1391fec4..000000000--- a/packages/react-ui/src/components/Charts/shared/LabelTooltip/labelTooltip.scss+++ /dev/null@@ -1,88 +0,0 @@-@use "../../../../cssUtils" as cssUtils;--.openui-chart-label-tooltip {- z-index: 1000;- border-radius: cssUtils.$radius-s;- padding: cssUtils.$space-xs cssUtils.$space-s;- background-color: cssUtils.$foreground;- border: 1px solid cssUtils.$border-default;- box-shadow: cssUtils.$shadow-s;- color: cssUtils.$text-neutral-primary;- @include cssUtils.typography(label, extra-small);- max-width: 200px;- word-wrap: break-word;- animation-duration: 0.15s;- animation-timing-function: ease-out;- will-change: transform, opacity;-}--.openui-chart-label-tooltip[data-state="delayed-open"],-.openui-chart-label-tooltip[data-state="instant-open"] {- animation-name: tooltipSlideUpAndFade;-}--.openui-chart-label-tooltip[data-side="top"] {- animation-name: tooltipSlideDownAndFade;-}--.openui-chart-label-tooltip[data-side="bottom"] {- animation-name: tooltipSlideUpAndFade;-}--.openui-chart-label-tooltip[data-side="left"] {- animation-name: tooltipSlideRightAndFade;-}--.openui-chart-label-tooltip[data-side="right"] {- animation-name: tooltipSlideLeftAndFade;-}--.openui-chart-label-tooltip-arrow {- fill: cssUtils.$foreground;- stroke: cssUtils.$border-default;- stroke-width: 1px;-}--@keyframes tooltipSlideUpAndFade {- from {- opacity: 0;- transform: translateY(2px);- }- to {- opacity: 1;- transform: translateY(0);- }-}--@keyframes tooltipSlideDownAndFade {- from {- opacity: 0;- transform: translateY(-2px);- }- to {- opacity: 1;- transform: translateY(0);- }-}--@keyframes tooltipSlideRightAndFade {- from {- opacity: 0;- transform: translateX(-2px);- }- to {- opacity: 1;- transform: translateX(0);- }-}--@keyframes tooltipSlideLeftAndFade {- from {- opacity: 0;- transform: translateX(2px);- }- to {- opacity: 1;- transform: translateX(0);- }-}diff --git a/packages/react-ui/src/components/Charts/shared/LineInBarShape/LineInBarShape.test.tsx b/packages/react-ui/src/components/Charts/shared/LineInBarShape/LineInBarShape.test.tsxdeleted file mode 100644index 2bc4d36be..000000000--- a/packages/react-ui/src/components/Charts/shared/LineInBarShape/LineInBarShape.test.tsx+++ /dev/null@@ -1,32 +0,0 @@-import { renderToStaticMarkup } from "react-dom/server";-import { describe, expect, it } from "vitest";-import { LineInBarShape } from "./LineInBarShape";--const validGeometry = {- x: 10,- y: 20,- width: 100,- height: 24,- orientation: "horizontal" as const,-};--describe("LineInBarShape", () => {- it("renders finite SVG geometry", () => {- const markup = renderToStaticMarkup(<LineInBarShape {...validGeometry} />);-- expect(markup).toContain("<path");- expect(markup).toContain("<line");- expect(markup).not.toContain("NaN");- });-- it.each(["x", "y", "width", "height"] as const)(- "skips rendering when %s is not finite",- (dimension) => {- const markup = renderToStaticMarkup(- <LineInBarShape {...validGeometry} {...{ [dimension]: Number.NaN }} />,- );-- expect(markup).toBe("");- },- );-});diff --git a/packages/react-ui/src/components/Charts/shared/LineInBarShape/LineInBarShape.tsx b/packages/react-ui/src/components/Charts/shared/LineInBarShape/LineInBarShape.tsxdeleted file mode 100644index d2c585c67..000000000--- a/packages/react-ui/src/components/Charts/shared/LineInBarShape/LineInBarShape.tsx+++ /dev/null@@ -1,372 +0,0 @@-import React, { FunctionComponent, useMemo } from "react";--interface LineInBarShapeProps {- x?: number;- y?: number;- width?: number;- height?: number;- fill?: string;- stroke?: string;- strokeWidth?: number | string;- radius?: number | number[];- internalLineColor?: string;- internalLineWidth?: number;- isHovered?: boolean;- hoveredCategory?: string | number | null;- categoryKey?: string;- payload?: any;- variant?: "grouped" | "stacked";- stackGap?: number;- orientation?: "vertical" | "horizontal";- hasNegativeValueInStack?: boolean;- [key: string]: any; // Allow other props from Recharts-}--const DEFAULT_STACK_GAP = 1;-const MIN_LINE_DIMENSION = 8; // For internal line visibility (height/width threshold)-const MIN_BAR_WIDTH_FOR_LINE = 3; // Minimum bar width to show internal line in vertical mode-const LINE_PADDING = 6;-const MIN_GROUP_BAR_HEIGHT = 2; // For vertical bars-const MIN_STACKED_BAR_HEIGHT = 4; // For vertical bars-const MIN_BAR_WIDTH = 2; // For horizontal bars--const LineInBarShape: FunctionComponent<LineInBarShapeProps> = React.memo((props) => {- const {- x = 0,- y = 0,- width = 0,- height = 0,- fill,- radius: r,- stroke,- strokeWidth,- internalLineColor: iLineColor,- internalLineWidth: iLineWidth,- isHovered,- hoveredCategory,- categoryKey,- payload,- variant = "grouped",- stackGap = DEFAULT_STACK_GAP,- orientation = "vertical",- hasNegativeValueInStack,- } = props;-- const isVertical = orientation === "vertical";- const isNegative = isVertical ? height < 0 : width < 0;-- const w = isNegative && !isVertical ? -width : width;- const h = isNegative && isVertical ? -height : height;-- const x_ = isNegative && !isVertical ? x + width : x;- const y_ = isNegative && isVertical ? y + height : y;-- /**- * Calculates the corner radii for the bar.- * This logic ensures that only the "outer" corners of a bar are rounded,- * depending on its orientation (vertical/horizontal) and whether it's a- * positive or negative value.- *- * - For vertical bars, top corners are rounded for positive values, and- * bottom corners for negative values.- * - For horizontal bars, right corners are rounded for positive values, and- * left corners for negative values.- *- * If the bar's dimensions are below a certain threshold, no rounding is applied.- * The `radius` prop can be a single number or an array `[rTL, rTR, rBR, rBL]`.- */- const { rTL, rTR, rBL, rBR } = useMemo(() => {- // This code calculates which corners of a bar should be rounded based on several factors:-- // First check if the bar is too small to have rounded corners- const minDimension = isVertical ? MIN_GROUP_BAR_HEIGHT : MIN_BAR_WIDTH;- const dimension = isVertical ? h : w;-- // If bar is too small, return no rounded corners- if (- (variant === "grouped" && dimension < minDimension) ||- (variant === "stacked" && dimension < MIN_STACKED_BAR_HEIGHT)- ) {- return { rTL: 0, rTR: 0, rBL: 0, rBR: 0 };- }-- // Check bar thickness and remove rounded corners if too thin- // For vertical bars: check width, for horizontal bars: check height- const barThickness = isVertical ? w : h;- if (barThickness < 7) {- return { rTL: 0, rTR: 0, rBL: 0, rBR: 0 };- }-- // If radius is an array, apply specific radius to each corner- if (Array.isArray(r)) {- // The radius array is expected to be in the format [rTL, rTR, rBR, rBL].- return { rTL: r[0] || 0, rTR: r[1] || 0, rBR: r[2] || 0, rBL: r[3] || 0 };- } else if (typeof r === "number") {- // If radius is a single number, apply it consistently based on orientation- if (isVertical) {- if (isNegative) return { rTL: 0, rTR: 0, rBL: r, rBR: r };- return { rTL: r, rTR: r, rBL: 0, rBR: 0 };- }- // For horizontal bars- if (isNegative) return { rTL: r, rTR: 0, rBL: r, rBR: 0 };- return { rTL: 0, rTR: r, rBL: 0, rBR: r };- }- // Default case - no rounded corners- return { rTL: 0, rTR: 0, rBL: 0, rBR: 0 };- }, [r, variant, h, w, isVertical, isNegative]);-- // This code calculates the opacity of a bar based on hover state:- // - Returns 1 (fully opaque) if:- // - Chart is not being hovered (isHovered is false)- // - No category is being hovered (hoveredCategory is null)- // - Missing required data (payload or categoryKey)- // - If chart is being hovered:- // - Returns 1 if this bar's category matches the hovered category- // - Returns 0.4 (40% opacity) if this bar's category doesn't match- const opacity = useMemo(() => {- if (!isHovered || hoveredCategory === null || !payload || !categoryKey) return 1;- return payload[categoryKey] === hoveredCategory ? 1 : 0.4;- }, [isHovered, hoveredCategory, payload, categoryKey]);-- // This code adjusts the dimensions and position of bars in the chart:- // - For vertical bars:- // - Reduces height by stackGap if stacked variant- // - Enforces minimum height based on variant (grouped vs stacked)- // - Adjusts Y position for positive values to align from bottom- // - For horizontal bars:- // - Reduces width by stackGap if stacked variant- // - Enforces minimum width- // Returns adjusted x, y coordinates and dimensions while preserving original values- const { adjustedX, adjustedY, adjustedWidth, adjustedHeight } = useMemo(() => {- // Initialize final dimensions with original values- let finalX = x_; // Starting x position- let finalY = y_; // Starting y position- let finalWidth = w; // Original width- let finalHeight = h; // Original height-- if (isVertical) {- // For vertical bars:-- // If stacked bars, reduce height by gap between bars- if (variant === "stacked" && stackGap > 0) {- finalHeight = h - stackGap;- }-- // Enforce minimum height based on variant- if (h > 0) {- const minHeight =- variant === "grouped"- ? MIN_GROUP_BAR_HEIGHT // Minimum 2px for grouped bars- : MIN_STACKED_BAR_HEIGHT - stackGap; // Minimum 4px minus gap for stacked- finalHeight = Math.max(finalHeight, minHeight);- }-- // For positive values, adjust Y to align from bottom- if (!isNegative) {- if (variant === "stacked" && stackGap > 0 && hasNegativeValueInStack) {- finalY = y + h - finalHeight - stackGap;- } else {- finalY = y + h - finalHeight;- }- }- } else {- // For horizontal bars:-- // If stacked, reduce width by gap between bars- if (variant === "stacked" && stackGap > 0) {- finalWidth = w - stackGap;- }-- // Enforce minimum width of 2px- if (w > 0) {- finalWidth = Math.max(finalWidth, MIN_BAR_WIDTH);- }- }-- // Return adjusted dimensions and positions- return {- adjustedX: finalX,- adjustedY: finalY,- adjustedWidth: finalWidth,- adjustedHeight: finalHeight,- };- }, [variant, stackGap, x, y, w, h, isVertical, isNegative, x_, y_]);-- /**- * Generates the SVG path for the bar.- * This code creates the SVG path string for a bar with rounded corners.- * The path drawing logic changes based on:- * 1. Bar orientation (vertical vs horizontal)- * 2. Value sign (positive vs negative)- *- * The SVG path is drawn using commands:- * - M x,y: Move to point (x,y) without drawing- * - L x,y: Draw line to point (x,y)- * - A rx,ry angle,large-arc,sweep x,y: Draw arc with radius rx,ry to point (x,y)- * The arc parameters control:- * - angle: rotation of arc (0 = no rotation)- * - large-arc: 0 = small arc, 1 = large arc- * - sweep: 0 = counter-clockwise, 1 = clockwise- * - Z: Close path by drawing line back to start- *- * For rounded corners, we:- * 1. Move to start point- * 2. Draw straight edges- * 3. For each corner that should be rounded:- * - Stop short of corner by radius amount- * - Draw arc with specified radius to next edge- * - Continue with straight edges- * 4. Close path- */-- const path = useMemo(() => {- // This code generates SVG path strings to draw bars with rounded corners- // The path drawing logic changes based on:- // 1. Bar orientation (vertical vs horizontal)- // 2. Value sign (positive vs negative)-- if (isVertical) {- // For vertical bars- if (isNegative) {- // Draw downward pointing bar with rounded bottom corners if specified- // This path draws a vertical bar with rounded bottom corners for negative values- // Here's how each command works:- // 1. M ${x},${adjustedY} - Move to top-left corner- // 2. L ${x + adjustedWidth},${adjustedY} - Draw line to top-right corner- // 3. L ${x + adjustedWidth},${adjustedY + adjustedHeight - rBR} - Draw line down right side, stopping before bottom-right corner- // 4. If bottom-right radius (rBR) > 0:- // A ${rBR},${rBR} 0 0 1 ${x + adjustedWidth - rBR},${adjustedY + adjustedHeight}- // Draw arc: radius rBR, no rotation (0), small arc (0), clockwise (1), end at bottom-right rounded corner- // Else: Draw straight line to bottom-right corner- // 5. L ${x + rBL},${adjustedY + adjustedHeight} - Draw line left along bottom, stopping before bottom-left corner- // 6. If bottom-left radius (rBL) > 0:- // A ${rBL},${rBL} 0 0 1 ${x},${adjustedY + adjustedHeight - rBL}- // Draw arc: radius rBL, no rotation (0), small arc (0), clockwise (1), end at bottom-left rounded corner- // Else: Draw straight line to bottom-left corner- // 7. Z - Close path by drawing line back to start- return `- M ${x},${adjustedY}- L ${x + adjustedWidth},${adjustedY}- L ${x + adjustedWidth},${adjustedY + adjustedHeight - rBR}- ${rBR > 0 ? `A ${rBR},${rBR} 0 0 1 ${x + adjustedWidth - rBR},${adjustedY + adjustedHeight}` : `L ${x + adjustedWidth},${adjustedY + adjustedHeight}`}- L ${x + rBL},${adjustedY + adjustedHeight}- ${rBL > 0 ? `A ${rBL},${rBL} 0 0 1 ${x},${adjustedY + adjustedHeight - rBL}` : `L ${x},${adjustedY + adjustedHeight}`}- Z`;- }- // Draw upward pointing bar with rounded top corners if specified- return `- M ${x},${adjustedY + rTL}- ${rTL > 0 ? `A ${rTL},${rTL} 0 0 1 ${x + rTL},${adjustedY}` : `L ${x},${adjustedY}`}- L ${x + adjustedWidth - rTR},${adjustedY}- ${rTR > 0 ? `A ${rTR},${rTR} 0 0 1 ${x + adjustedWidth},${adjustedY + rTR}` : `L ${x + adjustedWidth},${adjustedY}`}- L ${x + adjustedWidth},${adjustedY + adjustedHeight}- L ${x},${adjustedY + adjustedHeight}- Z`;- }-- // For horizontal bars- if (isNegative) {- // Draw leftward pointing bar with rounded left corners if specified- return `- M ${adjustedX + rTL},${y}- ${rTL > 0 ? `A ${rTL},${rTL} 0 0 0 ${adjustedX},${y + rTL}` : `L ${adjustedX},${y}`}- L ${adjustedX},${y + height - rBL}- ${rBL > 0 ? `A ${rBL},${rBL} 0 0 0 ${adjustedX + rBL},${y + height}` : `L ${adjustedX},${y + height}`}- L ${adjustedX + adjustedWidth},${y + height}- L ${adjustedX + adjustedWidth},${y}- Z`;- }- // Draw rightward pointing bar with rounded right corners if specified- return `- M ${adjustedX},${y}- L ${adjustedX + adjustedWidth - rTR},${y}- ${rTR > 0 ? `A ${rTR},${rTR} 0 0 1 ${adjustedX + adjustedWidth},${y + rTR}` : `L ${adjustedX + adjustedWidth},${y}`}- L ${adjustedX + adjustedWidth},${y + height - rBR}- ${rBR > 0 ? `A ${rBR},${rBR} 0 0 1 ${adjustedX + adjustedWidth - rBR},${y + height}` : `L ${adjustedX + adjustedWidth},${y + height}`}- L ${adjustedX},${y + height}- Z`;- }, [- x,- y,- adjustedX,- adjustedY,- adjustedWidth,- adjustedHeight,- height,- rTL,- rTR,- rBL,- rBR,- isVertical,- isNegative,- ]);-- const lineCoords = useMemo(() => {- if (isVertical) {- // For vertical bars: hide line if bar width < 3px (too thin) OR height < 8px (too short)- // This ensures thin bars don't have a visible internal line that looks awkward- if (width <= 0 || width < MIN_BAR_WIDTH_FOR_LINE || adjustedHeight < MIN_LINE_DIMENSION) {- return null;- }- const centerX = x + width / 2;- return {- x1: centerX,- y1: adjustedY + LINE_PADDING,- x2: centerX,- y2: adjustedY + adjustedHeight - LINE_PADDING,- };- }- // Horizontal bars: hide line if width < 8px OR height <= 0- if (adjustedWidth < MIN_LINE_DIMENSION || height <= 0) return null;- const centerY = y + height / 2;- return {- x1: adjustedX + LINE_PADDING,- y1: centerY,- x2: adjustedX + adjustedWidth - LINE_PADDING,- y2: centerY,- };- }, [x, y, adjustedX, adjustedY, width, height, adjustedWidth, adjustedHeight, isVertical]);-- const hasFiniteGeometry = [- x,- y,- width,- height,- adjustedX,- adjustedY,- adjustedWidth,- adjustedHeight,- rTL,- rTR,- rBL,- rBR,- ].every(Number.isFinite);-- // Recharts can briefly provide NaN dimensions while a responsive chart is- // being measured (for example, inside an inactive tab). Rendering those- // values produces invalid SVG coordinates and React warnings. The chart will- // render normally once Recharts supplies valid geometry on a later pass.- if (!hasFiniteGeometry) return null;-- return (- <g>- <path d={path} fill={fill} stroke={stroke} strokeWidth={strokeWidth} opacity={opacity} />- {lineCoords && (- <line- x1={lineCoords.x1}- y1={lineCoords.y1}- x2={lineCoords.x2}- y2={lineCoords.y2}- stroke={iLineColor}- strokeWidth={iLineWidth}- strokeLinecap="round"- opacity={opacity}- />- )}- </g>- );-});--LineInBarShape.displayName = "LineInBarShape";--export { LineInBarShape };diff --git a/packages/react-ui/src/components/Charts/shared/LineInBarShape/index.ts b/packages/react-ui/src/components/Charts/shared/LineInBarShape/index.tsdeleted file mode 100644index c06d067c4..000000000--- a/packages/react-ui/src/components/Charts/shared/LineInBarShape/index.ts+++ /dev/null@@ -1 +0,0 @@-export * from "./LineInBarShape";diff --git a/packages/react-ui/src/components/Charts/shared/PortalTooltip/CustomTooltipContent.tsx b/packages/react-ui/src/components/Charts/shared/PortalTooltip/CustomTooltipContent.tsxdeleted file mode 100644index c07ae42da..000000000--- a/packages/react-ui/src/components/Charts/shared/PortalTooltip/CustomTooltipContent.tsx+++ /dev/null@@ -1,278 +0,0 @@-import clsx from "clsx";-import { forwardRef, memo, useEffect, useMemo, useState } from "react";-import * as RechartsPrimitive from "recharts";-import { ChartStyle, getPayloadConfigFromPayload, useChart } from "../../../Charts/Charts";-import { useSideBarTooltip } from "../../context/SideBarTooltipContext";-import { FloatingUIPortal } from "./FloatingUIPortal";-import { tooltipNumberFormatter } from "./utils";--const DEFAULT_INDICATOR = "dot" as const;--type CustomTooltipContentProps = React.ComponentProps<typeof RechartsPrimitive.Tooltip> &- React.ComponentProps<"div"> & {- hideLabel?: boolean;- hideIndicator?: boolean;- indicator?: "line" | "dot" | "dashed";- nameKey?: string;- labelKey?: string;- showPercentage?: boolean;- portalContainer?: React.RefObject<HTMLElement | null>;- parentRef: React.RefObject<HTMLElement | null>;- };--/**- * Custom tooltip content component for floating tooltips- * Mirrors the functionality of ChartTooltipContent but works with FloatingUIPortal- */-function CustomTooltipContentRender(- props: CustomTooltipContentProps,- ref: React.ForwardedRef<HTMLDivElement>,-) {- const {- active,- payload,- className,- indicator = DEFAULT_INDICATOR,- hideLabel = false,- hideIndicator = false,- label,- labelFormatter,- labelClassName,- formatter,- color,- nameKey,- labelKey,- showPercentage = false,- portalContainer,- parentRef,- } = props;-- const { config, id } = useChart();- const { isSideBarTooltipOpen } = useSideBarTooltip();- const isGreaterThanTen = !!(payload?.length && payload.length > 10);- const remainingItems = payload && isGreaterThanTen ? payload.length - 5 : 0;- // this state is used to forcefully hide the tooltip when the user touches outside of the parent element- // this is not handled by recharts- const [forcefullyHideTooltip, setForcefullyHideTooltip] = useState(false);- const [parentScrollPosition, setParentScrollPosition] = useState({- x: 0,- y: 0,- width: 0,- height: 0,- });-- const tooltipLabel = useMemo(() => {- if (hideLabel || !payload?.length) {- return null;- }-- const [item] = payload;- const key = `${labelKey ?? item?.dataKey ?? item?.name ?? "value"}`;- const itemConfig = getPayloadConfigFromPayload(config, item, key);- const value =- !labelKey && typeof label === "string" ? config[label]?.label || label : itemConfig?.label;-- // this is active when we pass a labelFormatter prop to the recharts tooltip- // normally we would not need this, but it's useful for customizing the label- if (labelFormatter) {- return (- <div className={clsx("openui-chart-tooltip-label-heavy", labelClassName)}>- {labelFormatter(value, payload)}- </div>- );- }-- if (!value) {- return null;- }-- return <div className={clsx("openui-chart-tooltip-label", labelClassName)}>{value}</div>;- }, [label, labelFormatter, payload, hideLabel, labelClassName, config, labelKey]);-- const nestLabel = useMemo(- () => payload?.length === 1 && indicator !== DEFAULT_INDICATOR,- [payload?.length, indicator],- );-- const payloadItems = useMemo(() => {- if (!payload?.length) {- return [];- }-- const renderPayloadItem = (item: any, index: number, isTwoItemsLayout: boolean) => {- const key = `${nameKey ?? item.name ?? item.dataKey ?? "value"}`;- const itemConfig = getPayloadConfigFromPayload(config, item, key);- const indicatorColor = (color ?? item.payload?.fill) || item.color;-- return (- <div- key={`${item.dataKey}-${index}`}- className={clsx(- "openui-chart-tooltip-content-item",- !isTwoItemsLayout &&- indicator === DEFAULT_INDICATOR &&- "openui-chart-tooltip-content-item--dot",- )}- >- {formatter && item?.value !== undefined && item.name ? (- formatter(item.value, item.name, item, index, item.payload)- ) : (- <>- {itemConfig?.icon ? (- <itemConfig.icon />- ) : (- !hideIndicator && (- <div- className={clsx(- "openui-chart-tooltip-content-indicator",- `openui-chart-tooltip-content-indicator--${indicator}`,- isTwoItemsLayout && "openui-chart-tooltip-content-indicator--two-items",- )}- style={- {- "--color-bg": indicatorColor,- "--color-border": indicatorColor,- } as React.CSSProperties- }- />- )- )}-- <div- className={clsx(- "openui-chart-tooltip-content-value-wrapper",- isTwoItemsLayout && "openui-chart-tooltip-content-value-wrapper--vertical",- nestLabel- ? "openui-chart-tooltip-content-value-wrapper--nested"- : "openui-chart-tooltip-content-value-wrapper--standard",- )}- >- <div className="openui-chart-tooltip-content-label">- {nestLabel && tooltipLabel}- <span>{itemConfig?.label || item.name}</span>- </div>-- {item.value !== undefined && (- <span- className={clsx(- "openui-chart-tooltip-content-value",- showPercentage && "percentage",- )}- >- {typeof item.value === "number"- ? tooltipNumberFormatter(item.value)- : item.value}- {showPercentage ? "%" : ""}- </span>- )}- </div>- </>- )}- <div className="openui-chart-tooltip-content-item-separator" />- </div>- );- };-- // Handle two items layout- if (payload.length <= 2) {- return payload.map((item, index) => renderPayloadItem(item, index, true));- }-- // Handle regular layout with potential truncation- const morphPayload = isGreaterThanTen ? payload.slice(0, 5) : payload;- return morphPayload.map((item, index) => renderPayloadItem(item, index, false));- }, [- payload,- nameKey,- config,- color,- indicator,- formatter,- hideIndicator,- nestLabel,- tooltipLabel,- showPercentage,- ]);-- useEffect(() => {- const parent = parentRef.current;- if (!parent) {- return;- }-- const touchHandler = (e: TouchEvent) => {- for (let i = 0; i < e.targetTouches.length; i++) {- const target = e.targetTouches[i]!.target as HTMLElement;- if (!parent.contains(target)) {- setForcefullyHideTooltip(true);- return;- }- }- setForcefullyHideTooltip(false);- };- document.body.addEventListener("touchstart", touchHandler);-- const scrollHandler = () => {- setParentScrollPosition({- x: parent.scrollLeft,- y: parent.scrollTop,- width: parent.clientWidth,- height: parent.clientHeight,- });- };-- parent.addEventListener("scroll", scrollHandler);-- setParentScrollPosition({- x: parent.scrollLeft,- y: parent.scrollTop,- width: parent.clientWidth,- height: parent.clientHeight,- });-- return () => {- document.body.removeEventListener("touchstart", touchHandler);- parent.removeEventListener("scroll", scrollHandler);- };- }, [parentRef.current]);-- // Early return for inactive or empty payload - moved after all hooks- if (!active || !payload?.length || isSideBarTooltipOpen || forcefullyHideTooltip) {- return null;- }-- const tooltipContent = (- <div ref={ref} className={clsx("openui-chart-tooltip", className)}>- {!nestLabel && tooltipLabel}- <div className="openui-chart-tooltip-content-item-separator" />- <div className="openui-chart-tooltip-content">{payloadItems}</div>- {isGreaterThanTen && <div className="openui-chart-tooltip-content-item-separator" />}- {isGreaterThanTen && (- <div className="openui-chart-tooltip-content-view-more">- Click to view all {remainingItems}- </div>- )}- </div>- );- const coordinates = { x: props.coordinate?.x ?? 0, y: props.coordinate?.y ?? 0 };-- if (- parentScrollPosition.x > coordinates.x ||- parentScrollPosition.y > coordinates.y ||- parentScrollPosition.width + parentScrollPosition.x < coordinates.x ||- parentScrollPosition.height + parentScrollPosition.y < coordinates.y- ) {- return null;- }-- return (- <FloatingUIPortal chartId={id} portalContainer={portalContainer} position={props.coordinate}>- <ChartStyle id={id} config={config} />- {tooltipContent}- </FloatingUIPortal>- );-}--export const CustomTooltipContent = memo(forwardRef(CustomTooltipContentRender));--CustomTooltipContent.displayName = "CustomTooltipContent";diff --git a/packages/react-ui/src/components/Charts/shared/PortalTooltip/FloatingUIPortal.tsx b/packages/react-ui/src/components/Charts/shared/PortalTooltip/FloatingUIPortal.tsxdeleted file mode 100644index 500b24685..000000000--- a/packages/react-ui/src/components/Charts/shared/PortalTooltip/FloatingUIPortal.tsx+++ /dev/null@@ -1,64 +0,0 @@-import type { Placement } from "@floating-ui/react-dom";-import { autoUpdate, flip, hide, offset, useFloating } from "@floating-ui/react-dom";-import clsx from "clsx";-import React, { useEffect } from "react";-import { createPortal } from "react-dom";-import { useTheme } from "../../../ThemeProvider";--interface FloatingUIPortalProps {- children: React.ReactNode;- className?: string;- chartId?: string;- portalContainer?: React.RefObject<HTMLElement | null>;- position?: Partial<{ x: number; y: number }>;- placement?: Placement;- offsetDistance?: number;-}--export const FloatingUIPortal: React.FC<FloatingUIPortalProps> = ({- children,- className = "",- chartId,- portalContainer,- position,- placement = "right-start",- offsetDistance = 20,-}) => {- const { refs, floatingStyles, update } = useFloating({- placement,- middleware: [offset(offsetDistance), flip(), hide()],- whileElementsMounted: autoUpdate,- });-- const { portalThemeClassName } = useTheme();-- useEffect(() => {- if (position) {- update();- }- }, [position, update]);-- return (- <>- <div- ref={refs.setReference}- style={{- position: "absolute",- top: position?.y,- left: position?.x,- }}- />- {createPortal(- <div- ref={refs.setFloating}- className={clsx("openui-portal-tooltip", portalThemeClassName, className)}- data-chart={chartId}- style={floatingStyles}- >- {children}- </div>,- portalContainer?.current || document.body,- )}- </>- );-};diff --git a/packages/react-ui/src/components/Charts/shared/PortalTooltip/README.md b/packages/react-ui/src/components/Charts/shared/PortalTooltip/README.mddeleted file mode 100644index a0d90e0b5..000000000--- a/packages/react-ui/src/components/Charts/shared/PortalTooltip/README.md+++ /dev/null@@ -1,160 +0,0 @@-# Floating Tooltip Components--A collection of components that provide mouse-following tooltips for charts using Floating UI for superior positioning and collision detection.--## Components--### FloatingUIPortal--A portal-based tooltip component that follows the mouse cursor and uses Floating UI for intelligent positioning.--```tsx-import { FloatingUIPortal } from "./FloatingUIPortal";--<FloatingUIPortal- active={true}- placement="right-start"- offsetDistance={8}- className="custom-tooltip"->- <div>Tooltip content</div>-</FloatingUIPortal>;-```--#### Props--- `active` (boolean): Whether the tooltip should be visible and active-- `children` (ReactNode): The content to display in the tooltip-- `placement` (Placement, optional): Floating UI placement option (default: "right-start")-- `offsetDistance` (number, optional): Distance from the mouse cursor (default: 8)-- `className` (string, optional): Additional CSS classes--#### Features--- **Mouse Following**: Tooltip follows mouse cursor in real-time-- **Smart Positioning**: Uses Floating UI's `flip`, `offset`, and `shift` middleware-- **Collision Detection**: Automatically adjusts position to stay on screen-- **Portal Rendering**: Renders outside the chart container to avoid clipping-- **Virtual Element**: Creates a virtual element that tracks mouse position--### CustomTooltipContent--A specialized tooltip content component that mirrors ChartTooltipContent but works with the floating tooltip system.--```tsx-import { CustomTooltipContent } from "./CustomTooltipContent";--<ChartTooltip content={<CustomTooltipContent />} />;-```--#### Props--Supports all the same props as `ChartTooltipContent`:--- `hideLabel` (boolean, optional): Hide the tooltip label-- `hideIndicator` (boolean, optional): Hide the color indicators-- `indicator` ("line" | "dot" | "dashed", optional): Indicator style-- `nameKey` (string, optional): Key for extracting item names-- `labelKey` (string, optional): Key for extracting labels-- `showPercentage` (boolean, optional): Show values as percentages-- `formatter` (function, optional): Custom value formatter-- `labelFormatter` (function, optional): Custom label formatter--#### Features--- **Consistent Styling**: Uses the same CSS classes as ChartTooltipContent-- **Full Feature Parity**: Supports all formatting and styling options-- **Floating UI Integration**: Automatically wraps content with FloatingUIPortal-- **Chart Context**: Access to chart configuration and styling--## Usage with AreaChartV2--The floating tooltip is integrated into AreaChartV2 via the `useFloatingTooltip` prop:--```tsx-import { AreaChartV2 } from "../AreaCharts/AreaChartV2";--<AreaChartV2- data={chartData}- categoryKey="month"- useFloatingTooltip={true} // Enable floating tooltip- theme="ocean"- variant="natural"- grid={true}- legend={true}-/>;-```--## Implementation Details--### Virtual Element--The FloatingUIPortal creates a virtual element that implements Floating UI's positioning interface:--```tsx-const virtualElement: VirtualElement = {- getBoundingClientRect(): DOMRect {- return {- width: 0,- height: 0,- x: mousePositionRef.current.x,- y: mousePositionRef.current.y,- top: mousePositionRef.current.y,- left: mousePositionRef.current.x,- right: mousePositionRef.current.x,- bottom: mousePositionRef.current.y,- } as DOMRect;- },-};-```--### Mouse Tracking--Mouse position is tracked via global `mousemove` events and stored in a ref for performance:--```tsx-const handleMouseMove = (event: MouseEvent) => {- mousePositionRef.current = {- x: event.clientX,- y: event.clientY,- };- updatePosition();-};-```--### Positioning--Uses Floating UI's middleware for intelligent positioning:--```tsx-const { x, y } = await computePosition(virtualElement, tooltipElement, {- placement: "right-start",- middleware: [- offset(8), // Distance from cursor- flip(), // Flip when hitting boundaries- shift({ padding: 8 }), // Shift to stay in viewport- ],-});-```--## Dependencies--- `@floating-ui/react-dom`: For positioning calculations-- `react-dom`: For portal functionality-- Existing chart components and styling--## Browser Support--Works in all modern browsers that support:--- React Portals-- CSS Custom Properties-- Mouse Events-- Async/Await--## Performance--- Uses `useRef` for mouse position to avoid re-renders-- Debounced position updates via `requestAnimationFrame`-- Minimal DOM manipulation-- Portal rendering prevents layout thrashingdiff --git a/packages/react-ui/src/components/Charts/shared/PortalTooltip/index.ts b/packages/react-ui/src/components/Charts/shared/PortalTooltip/index.tsdeleted file mode 100644index 23a6bfcaa..000000000--- a/packages/react-ui/src/components/Charts/shared/PortalTooltip/index.ts+++ /dev/null@@ -1,2 +0,0 @@-export { CustomTooltipContent } from "./CustomTooltipContent";-export { FloatingUIPortal } from "./FloatingUIPortal";diff --git a/packages/react-ui/src/components/Charts/shared/PortalTooltip/portalTooltip.scss b/packages/react-ui/src/components/Charts/shared/PortalTooltip/portalTooltip.scssdeleted file mode 100644index d237dda82..000000000--- a/packages/react-ui/src/components/Charts/shared/PortalTooltip/portalTooltip.scss+++ /dev/null@@ -1,166 +0,0 @@-@use "../../../../cssUtils.scss" as cssUtils;--.openui-portal-tooltip {- pointer-events: none;- z-index: 1000;- position: absolute;-}--.openui-chart-tooltip {- display: grid;- align-items: start;- min-width: 128px;- max-width: 240px;- gap: cssUtils.$space-xs;- padding: cssUtils.$space-xs;- color: cssUtils.$text-neutral-primary;- @include cssUtils.typography(label, extra-small);- border-radius: cssUtils.$radius-l;- border: 1px solid cssUtils.$border-default;- background-color: cssUtils.$foreground;- box-shadow: cssUtils.$shadow-s;- text-transform: capitalize;-- &-label {- @include cssUtils.typography(label, extra-small);- color: cssUtils.$text-neutral-primary;- overflow-wrap: break-word;- word-break: break-word;- }-- &-label-heavy {- @include cssUtils.typography(label, extra-small-heavy);- color: cssUtils.$text-neutral-primary;- overflow-wrap: break-word;- word-break: break-word;- }-- // this is the content of the tooltip, where the items of the of each data point is rendered,- // todo: remove commented style once the review is done.-- &-content {- display: grid;- align-items: start;- min-width: 128px;- gap: cssUtils.$space-xs;- // padding: cssUtils.$space-xs;- color: cssUtils.$text-neutral-primary;- @include cssUtils.typography(label, extra-small);- background-color: cssUtils.$foreground;- text-transform: capitalize;-- &-item {- display: flex;- width: 100%;- flex-wrap: wrap;- gap: cssUtils.$space-xs;- align-items: flex-start;- &--dot {- align-items: center;- }-- svg {- height: 10px;- width: 10px;- color: cssUtils.$text-neutral-primary;- }- }- // this portion is responsible for styling the colored box or other indicators like line, dashed, etc.- &-indicator {- flex-shrink: 0;- border-radius: cssUtils.$radius-2xs;-- &--dot {- height: 10px;- width: 10px;- background-color: var(--color-bg);- border-color: var(--color-border);- }-- &--line {- width: 4px;- background-color: var(--color-bg);- border-color: var(--color-border);- }-- &--dashed {- width: 0;- border: 1.5px dashed var(--color-border);- background-color: transparent;- }-- &--nested-dashed {- margin: cssUtils.$space-3xs 0;- }- &--two-items {- margin-top: 2px;- }- }-- &-value-wrapper {- display: flex;- flex: 1;- gap: cssUtils.$space-s;- justify-content: space-between;- line-height: 1;-- &--nested {- align-items: flex-end;- }-- &--standard {- align-items: center;- }- &--vertical {- flex-direction: column;- align-items: flex-start;- justify-content: flex-start;- gap: cssUtils.$space-2xs;- }- }-- &-label {- display: grid;- gap: cssUtils.$space-xs;- color: cssUtils.$text-neutral-secondary;- @include cssUtils.typography(label, extra-small);-- span {- display: block;- overflow-wrap: break-word;- word-break: break-word;- }- }-- &-value {- font-variant-numeric: tabular-nums;- color: cssUtils.$text-neutral-primary;- @include cssUtils.typography(label, extra-small);- white-space: nowrap;- overflow: hidden;- text-overflow: ellipsis;-- &--percentage {- padding-left: cssUtils.$space-s;- }- }-- &-item-separator {- width: 100%;- height: 1px;- background-color: cssUtils.$border-default;- margin: 0;- }- &-item:last-child &-item-separator {- display: none;- }-- &-view-more {- @include cssUtils.typography(label, extra-small);- color: cssUtils.$text-neutral-primary;- text-align: left;- overflow-wrap: break-word;- word-break: break-word;- }- }-}diff --git a/packages/react-ui/src/components/Charts/shared/PortalTooltip/utils/index.ts b/packages/react-ui/src/components/Charts/shared/PortalTooltip/utils/index.tsdeleted file mode 100644index a97be63e6..000000000--- a/packages/react-ui/src/components/Charts/shared/PortalTooltip/utils/index.ts+++ /dev/null@@ -1,24 +0,0 @@-const tooltipNumberFormatter = (value: number) => {- const isNegative = value < 0;- const absValue = Math.abs(value);-- if (absValue < 100000) {- return (isNegative ? "-" : "") + absValue.toLocaleString();- }-- const units = ["", "K", "M", "B", "T"];- let unitIndex = 0;- let scaledValue = absValue;-- while (scaledValue >= 1000 && unitIndex < units.length - 1) {- scaledValue /= 1000;- unitIndex++;- }-- // Format with at most 1 decimal place- const formattedValue = Math.floor(scaledValue * 10) / 10;-- return (isNegative ? "-" : "") + `${formattedValue}${units[unitIndex]}`;-};--export { tooltipNumberFormatter };diff --git a/packages/react-ui/src/components/Charts/shared/SVGXAxisTick/SVGXAxisTick.tsx b/packages/react-ui/src/components/Charts/shared/SVGXAxisTick/SVGXAxisTick.tsxdeleted file mode 100644index 98817b99e..000000000--- a/packages/react-ui/src/components/Charts/shared/SVGXAxisTick/SVGXAxisTick.tsx+++ /dev/null@@ -1,68 +0,0 @@-import clsx from "clsx";-import React from "react";-import { numberTickFormatter } from "../../utils";--export type SVGXAxisTickVariant = "singleLine" | "angled";--interface SVGXAxisTickProps {- x?: number;- y?: number;- payload?: {- value: any;- };- className?: string;- angle?: number;- textAnchor?: "start" | "middle" | "end";- tickFormatter?: (value: any) => string;- dy?: number;-}--const SVGXAxisTick = React.forwardRef<SVGTextElement, SVGXAxisTickProps>((props, ref) => {- const {- x,- y,- payload,- className,- angle = 0,- textAnchor = "middle",- tickFormatter,- dy = 16,- } = props;-- if (x === undefined || y === undefined) {- return null;- }-- const raw = payload?.value;- // Auto-detect: Use custom formatter, or format numbers automatically, or stringify- const displayValue = tickFormatter- ? tickFormatter(raw)- : typeof raw === "number"- ? numberTickFormatter(raw)- : String(raw ?? "");-- const transform = angle !== 0 ? `rotate(${angle}, ${x}, ${y})` : undefined;-- return (- <text- ref={ref}- className={clsx(- "openui-chart-svg-x-axis-tick",- angle !== 0 && "openui-chart-svg-x-axis-tick-angled",- className,- )}- x={x}- y={y}- dy={dy}- textAnchor={textAnchor}- transform={transform}- >- {displayValue}- </text>- );-});--SVGXAxisTick.displayName = "SVGXAxisTick";--export { SVGXAxisTick };-export type { SVGXAxisTickProps };diff --git a/packages/react-ui/src/components/Charts/shared/SVGXAxisTick/index.ts b/packages/react-ui/src/components/Charts/shared/SVGXAxisTick/index.tsdeleted file mode 100644index 29e83fdd5..000000000--- a/packages/react-ui/src/components/Charts/shared/SVGXAxisTick/index.ts+++ /dev/null@@ -1,2 +0,0 @@-export { SVGXAxisTick } from "./SVGXAxisTick";-export type { SVGXAxisTickProps, SVGXAxisTickVariant } from "./SVGXAxisTick";diff --git a/packages/react-ui/src/components/Charts/shared/SVGXAxisTick/svgXAxisTick.scss b/packages/react-ui/src/components/Charts/shared/SVGXAxisTick/svgXAxisTick.scssdeleted file mode 100644index 046942906..000000000--- a/packages/react-ui/src/components/Charts/shared/SVGXAxisTick/svgXAxisTick.scss+++ /dev/null@@ -1,11 +0,0 @@-@use "../../../../cssUtils" as cssUtils;--.openui-chart-svg-x-axis-tick {- @include cssUtils.typography(label, extra-small);- fill: cssUtils.$text-neutral-secondary;-}--.openui-chart-svg-x-axis-tick-angled {- @include cssUtils.typography(label, extra-small);- fill: cssUtils.$text-neutral-secondary;-}diff --git a/packages/react-ui/src/components/Charts/shared/ScrollButtonsHorizontal/ScrollButtonsHorizontal.tsx b/packages/react-ui/src/components/Charts/shared/ScrollButtonsHorizontal/ScrollButtonsHorizontal.tsxdeleted file mode 100644index a8495818d..000000000--- a/packages/react-ui/src/components/Charts/shared/ScrollButtonsHorizontal/ScrollButtonsHorizontal.tsx+++ /dev/null@@ -1,67 +0,0 @@-import clsx from "clsx";-import { ChevronLeft, ChevronRight } from "lucide-react";-import React from "react";-import { IconButton } from "../../../IconButton";--interface ScrollButtonsHorizontalProps {- dataWidth: number;- effectiveWidth: number;- canScrollLeft: boolean;- canScrollRight: boolean;- isSideBarTooltipOpen: boolean;- onScrollLeft: () => void;- onScrollRight: () => void;-}--export const ScrollButtonsHorizontal = React.memo(- ({- dataWidth,- effectiveWidth,- canScrollLeft,- canScrollRight,- isSideBarTooltipOpen,- onScrollLeft,- onScrollRight,- }: ScrollButtonsHorizontalProps) => {- if (dataWidth <= effectiveWidth) {- return null;- }-- return (- <div className="openui-chart-horizontal-scroll-buttons-container">- <IconButton- className={clsx(- "openui-chart-horizontal-scroll-button openui-chart-horizontal-scroll-button--left",- {- "openui-chart-horizontal-scroll-button--disabled": !canScrollLeft,- },- )}- icon={<ChevronLeft />}- variant="secondary"- onClick={onScrollLeft}- size="2-extra-small"- disabled={!canScrollLeft}- aria-label="Scroll left"- />-- <IconButton- className={clsx(- "openui-chart-horizontal-scroll-button openui-chart-horizontal-scroll-button--right",- {- "openui-chart-horizontal-scroll-button--disabled": !canScrollRight,- "openui-chart-horizontal-scroll-button--SideBarTooltip": isSideBarTooltipOpen,- },- )}- icon={<ChevronRight />}- variant="secondary"- size="2-extra-small"- onClick={onScrollRight}- disabled={!canScrollRight}- aria-label="Scroll right"- />- </div>- );- },-);--ScrollButtonsHorizontal.displayName = "ScrollButtonsHorizontal";diff --git a/packages/react-ui/src/components/Charts/shared/ScrollButtonsHorizontal/index.ts b/packages/react-ui/src/components/Charts/shared/ScrollButtonsHorizontal/index.tsdeleted file mode 100644index 0c82716bd..000000000--- a/packages/react-ui/src/components/Charts/shared/ScrollButtonsHorizontal/index.ts+++ /dev/null@@ -1 +0,0 @@-export * from "./ScrollButtonsHorizontal";diff --git a/packages/react-ui/src/components/Charts/shared/ScrollButtonsHorizontal/scrollButtonsHorizontal.scss b/packages/react-ui/src/components/Charts/shared/ScrollButtonsHorizontal/scrollButtonsHorizontal.scssdeleted file mode 100644index 72a43cd13..000000000--- a/packages/react-ui/src/components/Charts/shared/ScrollButtonsHorizontal/scrollButtonsHorizontal.scss+++ /dev/null@@ -1,40 +0,0 @@-@use "../../../../cssUtils.scss" as cssUtils;--.openui-chart-horizontal-scroll {- &-buttons-container {- position: relative;- }-- &-button {- position: absolute;- background-color: cssUtils.$foreground;-- &:hover {- background-color: cssUtils.$foreground;- }-- &--left {- top: -23px;- transform: translateY(-50%);- left: 20px;- }-- &--right {- top: -23px;- transform: translateY(-50%);- right: 0px;- }-- &--disabled {- visibility: hidden;- cursor: not-allowed;- transition: visibility 0.1s linear;- }-- &--SideBarTooltip {- top: -23px;- transform: translateY(-50%);- right: 185px;- }- }-}diff --git a/packages/react-ui/src/components/Charts/shared/ScrollButtonsVertical/ScrollButtonsVertical.tsx b/packages/react-ui/src/components/Charts/shared/ScrollButtonsVertical/ScrollButtonsVertical.tsxdeleted file mode 100644index 406bbffc6..000000000--- a/packages/react-ui/src/components/Charts/shared/ScrollButtonsVertical/ScrollButtonsVertical.tsx+++ /dev/null@@ -1,67 +0,0 @@-import clsx from "clsx";-import { ChevronDown, ChevronUp } from "lucide-react";-import React from "react";-import { IconButton } from "../../../IconButton";--interface ScrollButtonsVerticalProps {- dataHeight: number;- effectiveHeight: number;- canScrollUp: boolean;- canScrollDown: boolean;- isSideBarTooltipOpen: boolean;- onScrollUp: () => void;- onScrollDown: () => void;-}--export const ScrollButtonsVertical = React.memo(- ({- dataHeight,- effectiveHeight,- canScrollUp,- canScrollDown,- isSideBarTooltipOpen,- onScrollUp,- onScrollDown,- }: ScrollButtonsVerticalProps) => {- if (dataHeight <= effectiveHeight) {- return null;- }-- return (- <div className="openui-chart-vertical-scroll-buttons-container">- <IconButton- className={clsx(- "openui-chart-vertical-scroll-button openui-chart-vertical-scroll-button--up",- {- "openui-chart-vertical-scroll-button--disabled": !canScrollUp,- },- )}- icon={<ChevronUp />}- variant="secondary"- onClick={onScrollUp}- size="extra-small"- disabled={!canScrollUp}- aria-label="Scroll up"- />-- <IconButton- className={clsx(- "openui-chart-vertical-scroll-button openui-chart-vertical-scroll-button--down",- {- "openui-chart-vertical-scroll-button--disabled": !canScrollDown,- "openui-chart-vertical-scroll-button--SideBarTooltip": isSideBarTooltipOpen,- },- )}- icon={<ChevronDown />}- variant="secondary"- size="extra-small"- onClick={onScrollDown}- disabled={!canScrollDown}- aria-label="Scroll down"- />- </div>- );- },-);--ScrollButtonsVertical.displayName = "ScrollButtonsVertical";diff --git a/packages/react-ui/src/components/Charts/shared/ScrollButtonsVertical/index.ts b/packages/react-ui/src/components/Charts/shared/ScrollButtonsVertical/index.tsdeleted file mode 100644index a379c56b7..000000000--- a/packages/react-ui/src/components/Charts/shared/ScrollButtonsVertical/index.ts+++ /dev/null@@ -1 +0,0 @@-export * from "./ScrollButtonsVertical";diff --git a/packages/react-ui/src/components/Charts/shared/ScrollButtonsVertical/scrollButtonsVertical.scss b/packages/react-ui/src/components/Charts/shared/ScrollButtonsVertical/scrollButtonsVertical.scssdeleted file mode 100644index a40abdd10..000000000--- a/packages/react-ui/src/components/Charts/shared/ScrollButtonsVertical/scrollButtonsVertical.scss+++ /dev/null@@ -1,32 +0,0 @@-@use "../../../../cssUtils.scss" as cssUtils;--.openui-chart-vertical-scroll {- &-buttons-container {- display: flex;- flex-direction: column;- justify-content: space-between;- width: 25px;- height: calc(100% - 44px);- flex-shrink: 0;- padding-left: cssUtils.$space-2xs;- }-- &-button {- background-color: cssUtils.$foreground;- pointer-events: auto;-- &:hover {- background-color: cssUtils.$foreground;- }-- &--disabled {- visibility: hidden;- cursor: not-allowed;- transition: visibility 0.1s linear;- }-- &--SideBarTooltip {- margin-right: 190px;- }- }-}diff --git a/packages/react-ui/src/components/Charts/shared/SideBarTooltip/SideBarTooltip.tsx b/packages/react-ui/src/components/Charts/shared/SideBarTooltip/SideBarTooltip.tsxdeleted file mode 100644index e50761c67..000000000--- a/packages/react-ui/src/components/Charts/shared/SideBarTooltip/SideBarTooltip.tsx+++ /dev/null@@ -1,79 +0,0 @@-import { X } from "lucide-react";-import React, { useCallback, useMemo } from "react";-import { IconButton } from "../../../IconButton";-import { useSideBarTooltip } from "../../context/SideBarTooltipContext";-import { tooltipNumberFormatter } from "../PortalTooltip/utils";--interface SideBarTooltipProps {- height: number;-}--// Utility function for capitalizing strings-const capitalizeString = (str: string): string => {- return str.charAt(0).toUpperCase() + str.slice(1);-};--const SideBarTooltip = React.memo(({ height }: SideBarTooltipProps) => {- const { setIsSideBarTooltipOpen, data } = useSideBarTooltip();-- // if no data, close the tooltip- if (!data) {- setIsSideBarTooltipOpen(false);- return null;- }-- const handleClose = useCallback(() => {- setIsSideBarTooltipOpen(false);- }, [setIsSideBarTooltipOpen]);-- const processedValues = useMemo(() => {- return data.values?.map((value, index) => ({- ...value,- capitalizedLabel: capitalizeString(value.label),- isLast: index === data.values.length - 1,- }));- }, [data.values]);-- const title = data.title;-- return (- <div className="openui-chart-side-bar-tooltip" style={{ height: `${height}px` }}>- <div className="openui-chart-side-bar-tooltip-header">- <div className="openui-chart-side-bar-tooltip-title">{title}</div>- <IconButton- icon={<X />}- size="extra-small"- onClick={handleClose}- variant="secondary"- className="openui-chart-side-bar-tooltip-close-button"- />- </div>- <div className="openui-chart-side-bar-tooltip-content-item-separator" />- <div className="openui-chart-side-bar-tooltip-content" autoFocus>- {processedValues?.map((value, index) => (- <div key={index}>- <div className="openui-chart-side-bar-tooltip-content-item">- <div- className="openui-chart-side-bar-tooltip-content-item-color"- style={{ backgroundColor: value.color }}- />- <div className="openui-chart-side-bar-tooltip-content-item-label">- {value.capitalizedLabel}- </div>- <div className="openui-chart-side-bar-tooltip-content-item-value">- {tooltipNumberFormatter(value.value)}- </div>- </div>- {!value.isLast && (- <div className="openui-chart-side-bar-tooltip-content-item-separator" />- )}- </div>- ))}- </div>- </div>- );-});--SideBarTooltip.displayName = "SideBarTooltip";--export { SideBarTooltip };diff --git a/packages/react-ui/src/components/Charts/shared/SideBarTooltip/index.ts b/packages/react-ui/src/components/Charts/shared/SideBarTooltip/index.tsdeleted file mode 100644index 3c3aa2cec..000000000--- a/packages/react-ui/src/components/Charts/shared/SideBarTooltip/index.ts+++ /dev/null@@ -1 +0,0 @@-export * from "./SideBarTooltip";diff --git a/packages/react-ui/src/components/Charts/shared/SideBarTooltip/sideBarTooltip.scss b/packages/react-ui/src/components/Charts/shared/SideBarTooltip/sideBarTooltip.scssdeleted file mode 100644index dd6fdc94f..000000000--- a/packages/react-ui/src/components/Charts/shared/SideBarTooltip/sideBarTooltip.scss+++ /dev/null@@ -1,102 +0,0 @@-@use "../../../../cssUtils.scss" as cssUtils;--.openui-chart-side-bar-tooltip {- display: flex;- flex-direction: column;- min-width: 180px;- max-width: 180px;- overflow: hidden;- padding: cssUtils.$space-xs;- background-color: cssUtils.$foreground;- border-radius: cssUtils.$radius-s;- border: 1px solid cssUtils.$border-default;-- &-header {- display: flex;- justify-content: space-between;- align-items: flex-start;- flex-shrink: 0;- }-- &-close-button {- flex-shrink: 0;- }-- &-title {- @include cssUtils.typography(label, 2-extra-small);- }-- &-content {- flex: 1;- overflow-y: auto;- display: flex;- flex-direction: column;- min-height: 0;- &:focus {- outline: none;- }- &:focus-visible {- outline: none;- }-- // Custom scrollbar styling- scrollbar-width: thin; // Firefox - closest option (can't set exact px)- scrollbar-color: cssUtils.$border-default transparent; // Firefox - thumb and track colors-- // Custom scrollbar for Webkit browsers (Chrome, Safari, newer Edge)- &::-webkit-scrollbar {- width: 2px; // Track width- margin-right: 2px; // Offset to right- }-- &::-webkit-scrollbar-track {- background: transparent;- border-radius: 0;- margin-right: 2px; // Additional offset for track- }-- &::-webkit-scrollbar-thumb {- background-color: cssUtils.$border-default;- border-radius: 1px;- width: 1.5px; // Thumb width (though width is constrained by scrollbar width)- border: 0.25px solid transparent; // Creates the 1.5px effect within 2px track- background-clip: content-box;- }-- &::-webkit-scrollbar-thumb:hover {- background-color: cssUtils.$border-default;- }-- &-item {- display: flex;- justify-content: space-between;- align-items: center;- gap: cssUtils.$space-xs;-- &-label {- @include cssUtils.typography(label, 2-extra-small);- color: cssUtils.$text-neutral-secondary;- flex: 1;- min-width: 0;- }-- &-value {- @include cssUtils.typography(label, 2-extra-small);- flex-shrink: 0;- text-align: right;- }-- &-color {- width: 10px;- height: 10px;- border-radius: cssUtils.$radius-2xs;- }- &-separator {- width: 100%;- margin: cssUtils.$space-xs 0;- height: 1px;- background-color: cssUtils.$border-default;- }- }- }-}diff --git a/packages/react-ui/src/components/Charts/shared/StackedLegend/StackedLegend.tsx b/packages/react-ui/src/components/Charts/shared/StackedLegend/StackedLegend.tsxdeleted file mode 100644index 70df1dfd5..000000000--- a/packages/react-ui/src/components/Charts/shared/StackedLegend/StackedLegend.tsx+++ /dev/null@@ -1,225 +0,0 @@-import clsx from "clsx";-import { ChevronDown, ChevronUp } from "lucide-react";-import React, { useEffect, useRef, useState } from "react";-import { Button } from "../../../Button";-import { IconButton } from "../../../IconButton";-import { Separator } from "../../../Separator";-import { StackedLegendItem } from "../../types";--export type StackedLegendLayout = "auto" | "showMore" | "scrollable";--interface StackedLegendProps {- items: StackedLegendItem[];- onItemHover?: (key: string | null) => void;- activeKey?: string | null;- onLegendItemHover?: (index: number | null) => void;- containerWidth?: number;- title?: string;- separator?: boolean;- showTitle?: boolean;- layout?: StackedLegendLayout;- className?: string;- style?: React.CSSProperties;-}--const formatPercentage = (value: number, total: number): string => {- const percentage = (value / total) * 100;- return `${percentage.toFixed(1)}%`;-};--const ITEM_HEIGHT = 36; // Height of each legend item-const ITEM_GAP = 2; // Gap between items-const LEGEND_ITEM_LIMIT = 6;-const SHOW_MORE_BREAKPOINT = 450;--export const StackedLegend = ({- items,- onItemHover,- activeKey,- onLegendItemHover,- containerWidth,- separator = false,- showTitle = true,- layout = "auto",- className,- style,-}: StackedLegendProps) => {- const containerRef = useRef<HTMLDivElement>(null);- const listRef = useRef<HTMLDivElement>(null);- const [showUpButton, setShowUpButton] = useState(false);- const [showDownButton, setShowDownButton] = useState(false);- const [showAll, setShowAll] = useState(false);- const [isOverflowing, setIsOverflowing] = useState(false);-- // Determine the actual layout to use- const isShowMoreLayout =- layout === "showMore" ||- (layout === "auto" &&- containerWidth !== undefined &&- (containerWidth < SHOW_MORE_BREAKPOINT || items.length > LEGEND_ITEM_LIMIT));-- const isScrollableLayout = layout === "scrollable" || (layout === "auto" && !isShowMoreLayout);-- const handleMouseEnter = (key: string, index: number) => {- onItemHover?.(key);- onLegendItemHover?.(index);- };-- const handleMouseLeave = () => {- onItemHover?.(null);- onLegendItemHover?.(null);- };-- // Check if scrolling is needed- useEffect(() => {- const checkScroll = () => {- if (listRef.current && containerRef.current) {- const { scrollTop, scrollHeight, clientHeight } = listRef.current;- const overflowing = scrollHeight > clientHeight;- setIsOverflowing(overflowing);- setShowUpButton(scrollTop > 0);- setShowDownButton(scrollTop < scrollHeight - clientHeight - 1);- }- };-- if (isShowMoreLayout) {- setShowUpButton(false);- setShowDownButton(false);- return;- }-- // Initial check- checkScroll();-- // Add event listener for scroll- const currentRef = listRef.current;- if (currentRef) {- currentRef.addEventListener("scroll", checkScroll);-- // Also add resize observer to handle responsive changes- const resizeObserver = new ResizeObserver(checkScroll);- resizeObserver.observe(currentRef);-- return () => {- currentRef.removeEventListener("scroll", checkScroll);- resizeObserver.disconnect();- };- }- return () => {};- }, [isShowMoreLayout]);-- // Scroll functions- const scrollUp = () => {- if (listRef.current) {- // Scroll one item up- listRef.current.scrollBy({ top: -(ITEM_HEIGHT + ITEM_GAP), behavior: "smooth" });- }- };-- const scrollDown = () => {- if (listRef.current) {- // Scroll one item down- listRef.current.scrollBy({ top: ITEM_HEIGHT + ITEM_GAP, behavior: "smooth" });- }- };-- // Calculate total for percentage- const total = items.reduce((sum, item) => sum + item.value, 0);-- // Items are already sorted by the parent component, so we use them as-is- const itemsToDisplay = isShowMoreLayout && !showAll ? items.slice(0, 6) : items;- const shouldShowScrollControls =- isScrollableLayout && isOverflowing && items.length > LEGEND_ITEM_LIMIT;-- return (- <div- ref={containerRef}- className={clsx("openui-stacked-legend-container", className)}- style={{- width: containerWidth ? `${containerWidth}px` : "100%",- ...style,- }}- >- {shouldShowScrollControls && (- <div className="openui-stacked-legend-header">- {showTitle && (- <div className="openui-stacked-legend-header-title">{items.length} labels</div>- )}- <div className="openui-stacked-legend-header-buttons">- {shouldShowScrollControls && (- <>- <IconButton- className="openui-stacked-legend-scroll-button openui-stacked-legend-scroll-up"- onClick={scrollUp}- aria-label="Scroll legend up"- icon={<ChevronUp />}- variant="secondary"- size="extra-small"- disabled={!showUpButton}- />- <IconButton- className="openui-stacked-legend-scroll-button openui-stacked-legend-scroll-down"- onClick={scrollDown}- aria-label="Scroll legend down"- icon={<ChevronDown />}- variant="secondary"- size="extra-small"- disabled={!showDownButton}- />- </>- )}- </div>- </div>- )}- <div ref={listRef} className="openui-stacked-legend">- {itemsToDisplay.map((item, index) => (- <React.Fragment key={item.key}>- <div- className={`openui-stacked-legend__item ${- activeKey === item.key ? "openui-stacked-legend__item--active" : ""- }`}- onMouseEnter={() => handleMouseEnter(item.key, index)}- onMouseLeave={handleMouseLeave}- >- <div className="openui-stacked-legend__item-label">- <div className="openui-stacked-legend__item-color-container">- <div- className="openui-stacked-legend__item-color"- style={{ backgroundColor: item.color }}- />- </div>- <div className="openui-stacked-legend__item-label-text">{item.label}</div>- </div>- <div className="openui-stacked-legend__item-value">- {formatPercentage(item.value, total)}- </div>- </div>- {index !== itemsToDisplay.length - 1 && separator && (- <Separator className="openui-stacked-legend-separator" />- )}- </React.Fragment>- ))}- </div>- {isShowMoreLayout && !showAll && items.length > LEGEND_ITEM_LIMIT && (- <Button- variant="secondary"- size="small"- onClick={() => setShowAll(true)}- className="openui-stacked-legend-show-more-button"- >- Show more- </Button>- )}- {isShowMoreLayout && showAll && items.length > LEGEND_ITEM_LIMIT && (- <Button- variant="secondary"- size="small"- onClick={() => setShowAll(false)}- className="openui-stacked-legend-show-less-button"- >- Show less- </Button>- )}- </div>- );-};diff --git a/packages/react-ui/src/components/Charts/shared/StackedLegend/stackedLegend.scss b/packages/react-ui/src/components/Charts/shared/StackedLegend/stackedLegend.scssdeleted file mode 100644index b96af5cf4..000000000--- a/packages/react-ui/src/components/Charts/shared/StackedLegend/stackedLegend.scss+++ /dev/null@@ -1,162 +0,0 @@-@use "../../../../cssUtils" as cssUtils;--.openui-stacked-legend-container {- position: relative;- display: flex;- flex-direction: column;- align-items: center;- height: 100%;-}--.openui-stacked-legend-header {- width: 100%;- display: flex;- flex-direction: row;- align-items: center;- justify-content: space-between;- gap: 10px;- padding: 0 cssUtils.$space-xs cssUtils.$space-xs cssUtils.$space-l;- color: cssUtils.$text-neutral-secondary;-- &-buttons {- display: flex;- flex-direction: row;- align-items: center;- gap: cssUtils.$space-xs;- }-}-.openui-stacked-legend-scroll-button {- z-index: 1;- display: flex;- align-items: center;- justify-content: center;- cursor: pointer;- z-index: 100;-- &.openui-stacked-legend-scroll-up {- top: 2px;- }-- &.openui-stacked-legend-scroll-down {- bottom: 2px;- }-}--.openui-stacked-legend {- width: 100%;- display: flex;- flex-direction: column;- min-width: 200px;- overflow-y: scroll;- height: 100%;- scrollbar-width: none;- -ms-overflow-style: none;- scroll-behavior: smooth;-- &::-webkit-scrollbar {- display: none;- }-- &__item {- width: 100%;- display: flex;- flex-direction: row;- justify-content: space-between;- align-items: center;- gap: 10px;- padding: 4px 8px;- border-radius: cssUtils.$radius-m;- transition: all 0.2s ease-in-out;- cursor: pointer;- height: 32px;-- &:hover {- background-color: cssUtils.$sunk;- }-- &--active {- background-color: cssUtils.$sunk;- }-- &-label {- display: flex;- flex-direction: row;- align-items: center;- gap: 8px;- min-width: 0;- flex: 1;-- &-text {- color: cssUtils.$text-neutral-primary;- overflow: hidden;- text-overflow: ellipsis;- white-space: nowrap;- min-width: 0;- }- }-- &-color-container {- display: flex;- flex-direction: row;- align-items: center;- justify-content: center;- gap: 10px;- height: 36px;- width: 32px;- flex-shrink: 0;- }-- &-color {- width: 10px;- height: 10px;- border-radius: 2px;- transition: all 0.2s ease-in-out;-- .openui-stacked-legend__item:hover & {- transform: scale(1.2);- }-- .openui-stacked-legend__item--active & {- transform: scale(1.3);- }- }-- &-label-text {- @include cssUtils.typography(label, small);- color: cssUtils.$text-neutral-primary;- transition: color 0.2s ease-in-out;- overflow: hidden;- text-overflow: ellipsis;- white-space: nowrap;- min-width: 0;- }-- &-value {- @include cssUtils.typography(label, small);- color: cssUtils.$text-neutral-primary;- transition: all 0.2s ease-in-out;- flex-shrink: 0;- }- }-- &-show-more-button {- width: 100%;- justify-content: center;- margin-top: cssUtils.$space-2xs;- }-- &-show-less-button {- width: 100%;- justify-content: center;- margin-top: cssUtils.$space-2xs;- }-}--.openui-stacked-legend-separator {- margin: cssUtils.$space-2xs 0;-}--.openui-stacked-legend-header-title {- @include cssUtils.typography(label, small);- color: cssUtils.$text-neutral-secondary;-}diff --git a/packages/react-ui/src/components/Charts/shared/XAxisTick/XAxisTick.tsx b/packages/react-ui/src/components/Charts/shared/XAxisTick/XAxisTick.tsxdeleted file mode 100644index 6afe268cd..000000000--- a/packages/react-ui/src/components/Charts/shared/XAxisTick/XAxisTick.tsx+++ /dev/null@@ -1,123 +0,0 @@-import clsx from "clsx";-import React, { useLayoutEffect, useRef, useState } from "react";-import { XAxisTickVariant } from "../../types";-import { LabelTooltip } from "../LabelTooltip/LabelTooltip";--interface XAxisTickProps {- x?: number;- y?: number;- payload?: {- value: any;- coordinate?: number;- tickCoord?: number;- index?: number;- offset?: number;- isShow?: boolean;- };- textAnchor?: "start" | "middle" | "end";- verticalAnchor?: "start" | "middle" | "end";- fill?: string;- stroke?: string;- width?: number;- height?: number;- className?: string;- orientation?: "top" | "bottom";- tickFormatter?: (value: any) => string;- index?: number;- visibleTicksCount?: number;- variant?: XAxisTickVariant;- widthOfGroup?: number;- labelHeight?: number;- onMouseEnter?: (tickProps: XAxisTickProps) => void;- onMouseLeave?: (tickProps: XAxisTickProps) => void;-}--const XAxisTick = React.forwardRef<SVGGElement, XAxisTickProps>((props, ref) => {- const {- x,- y,- payload,- className,- variant = "multiLine",- widthOfGroup = 70,- labelHeight = 20,- onMouseEnter,- onMouseLeave,- } = props;-- const rawValue = payload?.value;- const value = String(rawValue || "");-- const foreignObjectRef = useRef<SVGForeignObjectElement>(null);- const spanRef = useRef<HTMLSpanElement>(null);- const [isTruncated, setIsTruncated] = useState(false);-- // Check if text is truncated- useLayoutEffect(() => {- if (spanRef.current) {- const element = spanRef.current;- const isCurrentlyTruncated =- variant === "multiLine"- ? element.scrollHeight > element.clientHeight- : element.scrollWidth > element.clientWidth;- setIsTruncated(isCurrentlyTruncated);- }- }, [value, variant, widthOfGroup]);-- if (x === undefined || y === undefined) {- return null;- }-- // The x position from Recharts is the center of the group- // To center the foreignObject, we need to offset by half of widthOfGroup- // +2 is for the multiLine variant to center the text- // +5 is for the singleLine variant to center the text- // offset for padding - 4 and -10 respectively- const calX = variant === "multiLine" ? x - widthOfGroup / 2 + 2 : x - widthOfGroup / 2 + 5;- const calWidth = variant === "multiLine" ? widthOfGroup - 4 : widthOfGroup - 10;-- const spanClassName =- variant === "multiLine"- ? "openui-chart-x-axis-tick-multi-line"- : "openui-chart-x-axis-tick-single-line";-- return (- <g ref={ref} transform={`translate(${calX},${y})`}>- <foreignObject- ref={foreignObjectRef}- transform="translate(0, 0)"- width={calWidth}- height={labelHeight} // Initial height, will be updated by useLayoutEffect- className="openui-chart-x-axis-tick-foreign"- >- <div- style={{- width: "100%",- height: "100%",- boxSizing: "border-box",- }}- onMouseEnter={() => onMouseEnter?.(props)}- onMouseLeave={() => onMouseLeave?.(props)}- >- <LabelTooltip content={value} side="top" disabled={!isTruncated}>- <span- ref={spanRef}- style={{- textAlign: "center",- wordBreak: "break-word",- }}- className={clsx(spanClassName, className)}- >- {value}- </span>- </LabelTooltip>- </div>- </foreignObject>- </g>- );-});--XAxisTick.displayName = "XAxisTick";--export { XAxisTick };-export type { XAxisTickProps };diff --git a/packages/react-ui/src/components/Charts/shared/XAxisTick/xAxisTick.scss b/packages/react-ui/src/components/Charts/shared/XAxisTick/xAxisTick.scssdeleted file mode 100644index 6c5772e69..000000000--- a/packages/react-ui/src/components/Charts/shared/XAxisTick/xAxisTick.scss+++ /dev/null@@ -1,26 +0,0 @@-@use "../../../../cssUtils" as cssUtils;--.openui-chart-x-axis-tick-multi-line {- margin: 0;- padding: 0;- @include cssUtils.typography(label, extra-small);- color: cssUtils.$text-neutral-secondary;- display: -webkit-box;- -webkit-box-orient: vertical;- line-clamp: 3;- -webkit-line-clamp: 3;- overflow: hidden;- text-overflow: ellipsis;- word-break: break-word;- min-width: 0;-}--.openui-chart-x-axis-tick-single-line {- @include cssUtils.typography(label, extra-small);- color: cssUtils.$text-neutral-secondary;- white-space: nowrap;- overflow: hidden;- text-overflow: ellipsis;- width: 100%;- display: block;-}diff --git a/packages/react-ui/src/components/Charts/shared/YAxisTick/YAxisTick.tsx b/packages/react-ui/src/components/Charts/shared/YAxisTick/YAxisTick.tsxdeleted file mode 100644index 804171701..000000000--- a/packages/react-ui/src/components/Charts/shared/YAxisTick/YAxisTick.tsx+++ /dev/null@@ -1,57 +0,0 @@-import { useLayoutEffect } from "react";-import { numberTickFormatter } from "../../utils";--interface YAxisTickProps {- x?: number;- y?: number;- payload?: {- value: any;- coordinate?: number;- tickCoord?: number;- index?: number;- offset?: number;- isShow?: boolean;- };- textAnchor?: "start" | "middle" | "end";- verticalAnchor?: "start" | "middle" | "end";- fill?: string;- stroke?: string;- width?: number;- height?: number;- className?: string;- orientation?: "left" | "right";- tickFormatter?: (value: any) => string;- index?: number;- visibleTicksCount?: number;- setLabelWidth: (label: string) => void;-}--const YAxisTick: React.FC<YAxisTickProps> = (props) => {- const { x, y, payload, textAnchor, verticalAnchor, className, setLabelWidth } = props;-- const displayValue =- typeof payload?.value === "number"- ? numberTickFormatter(payload?.value)- : String(payload?.value);-- useLayoutEffect(() => {- setLabelWidth(displayValue);- }, [displayValue, setLabelWidth]);-- return (- <g transform={`translate(${x},${y})`} className={className}>- <text- x={0}- y={0}- dy={verticalAnchor === "middle" ? 4 : 0} // Adjust based on vertical anchor- textAnchor={textAnchor || "end"}- className="openui-chart-y-axis-tick"- >- {displayValue}- </text>- </g>- );-};--export { YAxisTick };-export type { YAxisTickProps };diff --git a/packages/react-ui/src/components/Charts/shared/YAxisTick/yAxisTick.scss b/packages/react-ui/src/components/Charts/shared/YAxisTick/yAxisTick.scssdeleted file mode 100644index beec6de41..000000000--- a/packages/react-ui/src/components/Charts/shared/YAxisTick/yAxisTick.scss+++ /dev/null@@ -1,6 +0,0 @@-@use "../../../../cssUtils" as cssUtils;--.openui-chart-y-axis-tick {- @include cssUtils.typography(label, extra-small);- fill: cssUtils.$text-neutral-secondary;-}diff --git a/packages/react-ui/src/components/D3Charts/shared/cartesian/AnimatedPath.tsx b/packages/react-ui/src/components/Charts/shared/cartesian/AnimatedPath.tsxsimilarity index 100%rename from packages/react-ui/src/components/D3Charts/shared/cartesian/AnimatedPath.tsxrename to packages/react-ui/src/components/Charts/shared/cartesian/AnimatedPath.tsxdiff --git a/packages/react-ui/src/components/D3Charts/shared/cartesian/ClipDefs.tsx b/packages/react-ui/src/components/Charts/shared/cartesian/ClipDefs.tsxsimilarity index 100%rename from packages/react-ui/src/components/D3Charts/shared/cartesian/ClipDefs.tsxrename to packages/react-ui/src/components/Charts/shared/cartesian/ClipDefs.tsxdiff --git a/packages/react-ui/src/components/D3Charts/shared/cartesian/Grid.tsx b/packages/react-ui/src/components/Charts/shared/cartesian/Grid.tsxsimilarity index 100%rename from packages/react-ui/src/components/D3Charts/shared/cartesian/Grid.tsxrename to packages/react-ui/src/components/Charts/shared/cartesian/Grid.tsxdiff --git a/packages/react-ui/src/components/D3Charts/shared/cartesian/LineDotCrosshair.tsx b/packages/react-ui/src/components/Charts/shared/cartesian/LineDotCrosshair.tsxsimilarity index 100%rename from packages/react-ui/src/components/D3Charts/shared/cartesian/LineDotCrosshair.tsxrename to packages/react-ui/src/components/Charts/shared/cartesian/LineDotCrosshair.tsxdiff --git a/packages/react-ui/src/components/D3Charts/shared/cartesian/ScrollButtonsHorizontal/ScrollButtonsHorizontal.tsx b/packages/react-ui/src/components/Charts/shared/cartesian/ScrollButtonsHorizontal/ScrollButtonsHorizontal.tsxsimilarity index 100%rename from packages/react-ui/src/components/D3Charts/shared/cartesian/ScrollButtonsHorizontal/ScrollButtonsHorizontal.tsxrename to packages/react-ui/src/components/Charts/shared/cartesian/ScrollButtonsHorizontal/ScrollButtonsHorizontal.tsxdiff --git a/packages/react-ui/src/components/D3Charts/shared/cartesian/ScrollButtonsHorizontal/scrollButtonsHorizontal.scss b/packages/react-ui/src/components/Charts/shared/cartesian/ScrollButtonsHorizontal/scrollButtonsHorizontal.scsssimilarity index 94%rename from packages/react-ui/src/components/D3Charts/shared/cartesian/ScrollButtonsHorizontal/scrollButtonsHorizontal.scssrename to packages/react-ui/src/components/Charts/shared/cartesian/ScrollButtonsHorizontal/scrollButtonsHorizontal.scssindex 0436fa6bf..b0c4a90ab 100644--- a/packages/react-ui/src/components/D3Charts/shared/cartesian/ScrollButtonsHorizontal/scrollButtonsHorizontal.scss+++ b/packages/react-ui/src/components/Charts/shared/cartesian/ScrollButtonsHorizontal/scrollButtonsHorizontal.scss@@ -8,7 +8,7 @@// Nested under the container (specificity 0,2,0) so these beat react-ui's// single-class IconButton rules — the `-secondary` transparent background// and the base `transition` — whatever order the stylesheets load in- // (react-ui's generated components index forwards D3Charts before+ // (react-ui's generated components index forwards Charts before// IconButton). IconButton's own `:hover` / `:active` / `:disabled` states// still win on specificity..#{brand.$prefix}-chart-horizontal-scroll-button {diff --git a/packages/react-ui/src/components/D3Charts/shared/cartesian/ScrollButtonsVertical/ScrollButtonsVertical.tsx b/packages/react-ui/src/components/Charts/shared/cartesian/ScrollButtonsVertical/ScrollButtonsVertical.tsxsimilarity index 100%rename from packages/react-ui/src/components/D3Charts/shared/cartesian/ScrollButtonsVertical/ScrollButtonsVertical.tsxrename to packages/react-ui/src/components/Charts/shared/cartesian/ScrollButtonsVertical/ScrollButtonsVertical.tsxdiff --git a/packages/react-ui/src/components/D3Charts/shared/cartesian/ScrollButtonsVertical/scrollButtonsVertical.scss b/packages/react-ui/src/components/Charts/shared/cartesian/ScrollButtonsVertical/scrollButtonsVertical.scsssimilarity index 95%rename from packages/react-ui/src/components/D3Charts/shared/cartesian/ScrollButtonsVertical/scrollButtonsVertical.scssrename to packages/react-ui/src/components/Charts/shared/cartesian/ScrollButtonsVertical/scrollButtonsVertical.scssindex 3a93316dd..6bc59f14b 100644--- a/packages/react-ui/src/components/D3Charts/shared/cartesian/ScrollButtonsVertical/scrollButtonsVertical.scss+++ b/packages/react-ui/src/components/Charts/shared/cartesian/ScrollButtonsVertical/scrollButtonsVertical.scss@@ -18,7 +18,7 @@// Nested under the container (specificity 0,2,0) so these beat react-ui's// single-class IconButton rules — the `-secondary` transparent background// and the base `transition` — whatever order the stylesheets load in- // (react-ui's generated components index forwards D3Charts before+ // (react-ui's generated components index forwards Charts before// IconButton). IconButton's own `:hover` / `:active` / `:disabled` states// still win on specificity..#{brand.$prefix}-chart-vertical-scroll-button {diff --git a/packages/react-ui/src/components/D3Charts/shared/cartesian/VerticalGrid.tsx b/packages/react-ui/src/components/Charts/shared/cartesian/VerticalGrid.tsxsimilarity index 100%rename from packages/react-ui/src/components/D3Charts/shared/cartesian/VerticalGrid.tsxrename to packages/react-ui/src/components/Charts/shared/cartesian/VerticalGrid.tsxdiff --git a/packages/react-ui/src/components/D3Charts/shared/cartesian/axes/CartesianXAxis.tsx b/packages/react-ui/src/components/Charts/shared/cartesian/axes/CartesianXAxis.tsxsimilarity index 100%rename from packages/react-ui/src/components/D3Charts/shared/cartesian/axes/CartesianXAxis.tsxrename to packages/react-ui/src/components/Charts/shared/cartesian/axes/CartesianXAxis.tsxdiff --git a/packages/react-ui/src/components/D3Charts/shared/cartesian/axes/CondensedXAxis.tsx b/packages/react-ui/src/components/Charts/shared/cartesian/axes/CondensedXAxis.tsxsimilarity index 100%rename from packages/react-ui/src/components/D3Charts/shared/cartesian/axes/CondensedXAxis.tsxrename to packages/react-ui/src/components/Charts/shared/cartesian/axes/CondensedXAxis.tsxdiff --git a/packages/react-ui/src/components/D3Charts/shared/cartesian/axes/NumericXAxis.tsx b/packages/react-ui/src/components/Charts/shared/cartesian/axes/NumericXAxis.tsxsimilarity index 100%rename from packages/react-ui/src/components/D3Charts/shared/cartesian/axes/NumericXAxis.tsxrename to packages/react-ui/src/components/Charts/shared/cartesian/axes/NumericXAxis.tsxdiff --git a/packages/react-ui/src/components/D3Charts/shared/cartesian/axes/XAxis.tsx b/packages/react-ui/src/components/Charts/shared/cartesian/axes/XAxis.tsxsimilarity index 68%rename from packages/react-ui/src/components/D3Charts/shared/cartesian/axes/XAxis.tsxrename to packages/react-ui/src/components/Charts/shared/cartesian/axes/XAxis.tsxindex 7a8ff00d1..73b273ee0 100644--- a/packages/react-ui/src/components/D3Charts/shared/cartesian/axes/XAxis.tsx+++ b/packages/react-ui/src/components/Charts/shared/cartesian/axes/XAxis.tsx@@ -12,6 +12,8 @@ import {import { LabelTooltip } from "../../core/LabelTooltip/LabelTooltip";const X_AXIS_TOP_GAP = 4;+/** Space kept between neighbouring labels on a thinned axis. */+const THINNED_LABEL_GAP = 8;type XAxisScale = ScalePoint<string> | ScaleBand<string>;@@ -50,16 +52,36 @@ export const XAxis: React.FC<XAxisProps> = ({const lineHeight = parseLineHeight(ctx.font);const domain = scale.domain();const band = isBandScale(scale);- const labelWidth = band ? (scale as ScaleBand<string>).bandwidth() : (widthOfGroup ?? 0);+ const bandWidth = band ? (scale as ScaleBand<string>).bandwidth() : (widthOfGroup ?? 0);+ const step = band ? (scale as ScaleBand<string>).step() : (widthOfGroup ?? 0);+ const shown = domain+ .map((_, i) => i)+ .filter((i) => labelInterval <= 1 || i % labelInterval === 0 || i === domain.length - 1);+ // The last label is always shown; a regular label too close before it makes+ // way, so neither is squeezed.+ if (labelInterval > 1 && shown.length > 2) {+ const [prev, last] = shown.slice(-2) as [number, number];+ if (last - prev < labelInterval) shown.splice(-2, 1);+ }+ // On a thinned axis a label may use the room up to its nearest shown+ // neighbour, not just its own category.+ const labelWidthAt = (pos: number) => {+ if (labelInterval <= 1) return bandWidth;+ const i = shown[pos]!;+ const gaps = [shown[pos - 1], shown[pos + 1]]+ .filter((n): n is number => n !== undefined)+ .map((n) => Math.abs(n - i));+ const span = gaps.length ? Math.min(...gaps) : 1;+ return Math.max(bandWidth, step * span - THINNED_LABEL_GAP);+ };return (<g className={`${classPrefix}-x-axis`}>- {domain.map((category, i) => {- const show = labelInterval <= 1 || i % labelInterval === 0 || i === domain.length - 1;- if (!show) return null;-+ {shown.map((i, pos) => {+ const category = domain[i]!;+ const labelWidth = labelWidthAt(pos);const rawX = scale(category) ?? 0;- const cx = band ? rawX + labelWidth / 2 : rawX;+ const cx = band ? rawX + bandWidth / 2 : rawX;const label = String(category);const lines =diff --git a/packages/react-ui/src/components/D3Charts/shared/cartesian/axes/YAxis.tsx b/packages/react-ui/src/components/Charts/shared/cartesian/axes/YAxis.tsxsimilarity index 100%rename from packages/react-ui/src/components/D3Charts/shared/cartesian/axes/YAxis.tsxrename to packages/react-ui/src/components/Charts/shared/cartesian/axes/YAxis.tsxdiff --git a/packages/react-ui/src/components/D3Charts/shared/cartesian/chartBase.scss b/packages/react-ui/src/components/Charts/shared/cartesian/chartBase.scsssimilarity index 100%rename from packages/react-ui/src/components/D3Charts/shared/cartesian/chartBase.scssrename to packages/react-ui/src/components/Charts/shared/cartesian/chartBase.scssdiff --git a/packages/react-ui/src/components/D3Charts/shared/cartesian/layouts/CartesianChartLayout.tsx b/packages/react-ui/src/components/Charts/shared/cartesian/layouts/CartesianChartLayout.tsxsimilarity index 100%rename from packages/react-ui/src/components/D3Charts/shared/cartesian/layouts/CartesianChartLayout.tsxrename to packages/react-ui/src/components/Charts/shared/cartesian/layouts/CartesianChartLayout.tsxdiff --git a/packages/react-ui/src/components/D3Charts/shared/cartesian/roundedBarPath.test.ts b/packages/react-ui/src/components/Charts/shared/cartesian/roundedBarPath.test.tssimilarity index 100%rename from packages/react-ui/src/components/D3Charts/shared/cartesian/roundedBarPath.test.tsrename to packages/react-ui/src/components/Charts/shared/cartesian/roundedBarPath.test.tsdiff --git a/packages/react-ui/src/components/D3Charts/shared/cartesian/roundedBarPath.ts b/packages/react-ui/src/components/Charts/shared/cartesian/roundedBarPath.tssimilarity index 100%rename from packages/react-ui/src/components/D3Charts/shared/cartesian/roundedBarPath.tsrename to packages/react-ui/src/components/Charts/shared/cartesian/roundedBarPath.tsdiff --git a/packages/react-ui/src/components/D3Charts/shared/cartesian/seriesGeometry.test.ts b/packages/react-ui/src/components/Charts/shared/cartesian/seriesGeometry.test.tssimilarity index 100%rename from packages/react-ui/src/components/D3Charts/shared/cartesian/seriesGeometry.test.tsrename to packages/react-ui/src/components/Charts/shared/cartesian/seriesGeometry.test.tsdiff --git a/packages/react-ui/src/components/D3Charts/shared/cartesian/seriesGeometry.ts b/packages/react-ui/src/components/Charts/shared/cartesian/seriesGeometry.tssimilarity index 100%rename from packages/react-ui/src/components/D3Charts/shared/cartesian/seriesGeometry.tsrename to packages/react-ui/src/components/Charts/shared/cartesian/seriesGeometry.tsdiff --git a/packages/react-ui/src/components/D3Charts/shared/core/ChartShell.tsx b/packages/react-ui/src/components/Charts/shared/core/ChartShell.tsxsimilarity index 100%rename from packages/react-ui/src/components/D3Charts/shared/core/ChartShell.tsxrename to packages/react-ui/src/components/Charts/shared/core/ChartShell.tsxdiff --git a/packages/react-ui/src/components/D3Charts/shared/core/DefaultLegend/DefaultLegend.tsx b/packages/react-ui/src/components/Charts/shared/core/DefaultLegend/DefaultLegend.tsxsimilarity index 100%rename from packages/react-ui/src/components/D3Charts/shared/core/DefaultLegend/DefaultLegend.tsxrename to packages/react-ui/src/components/Charts/shared/core/DefaultLegend/DefaultLegend.tsxdiff --git a/packages/react-ui/src/components/D3Charts/shared/core/DefaultLegend/defaultLegend.scss b/packages/react-ui/src/components/Charts/shared/core/DefaultLegend/defaultLegend.scsssimilarity index 98%rename from packages/react-ui/src/components/D3Charts/shared/core/DefaultLegend/defaultLegend.scssrename to packages/react-ui/src/components/Charts/shared/core/DefaultLegend/defaultLegend.scssindex 512db29f0..2385a9ba7 100644--- a/packages/react-ui/src/components/D3Charts/shared/core/DefaultLegend/defaultLegend.scss+++ b/packages/react-ui/src/components/Charts/shared/core/DefaultLegend/defaultLegend.scss@@ -31,7 +31,6 @@align-items: center;justify-content: center;gap: cssUtils.$space-m;- text-transform: capitalize;flex-wrap: wrap;&--bottom {diff --git a/packages/react-ui/src/components/D3Charts/shared/core/DefaultLegend/hooks/useDefaultLegend.ts b/packages/react-ui/src/components/Charts/shared/core/DefaultLegend/hooks/useDefaultLegend.tssimilarity index 100%rename from packages/react-ui/src/components/D3Charts/shared/core/DefaultLegend/hooks/useDefaultLegend.tsrename to packages/react-ui/src/components/Charts/shared/core/DefaultLegend/hooks/useDefaultLegend.tsdiff --git a/packages/react-ui/src/components/D3Charts/shared/core/LabelTooltip/LabelTooltip.tsx b/packages/react-ui/src/components/Charts/shared/core/LabelTooltip/LabelTooltip.tsxsimilarity index 100%rename from packages/react-ui/src/components/D3Charts/shared/core/LabelTooltip/LabelTooltip.tsxrename to packages/react-ui/src/components/Charts/shared/core/LabelTooltip/LabelTooltip.tsxdiff --git a/packages/react-ui/src/components/D3Charts/shared/core/PortalTooltip/ChartTooltip.tsx b/packages/react-ui/src/components/Charts/shared/core/PortalTooltip/ChartTooltip.tsxsimilarity index 100%rename from packages/react-ui/src/components/D3Charts/shared/core/PortalTooltip/ChartTooltip.tsxrename to packages/react-ui/src/components/Charts/shared/core/PortalTooltip/ChartTooltip.tsxdiff --git a/packages/react-ui/src/components/D3Charts/shared/core/PortalTooltip/portalTooltip.scss b/packages/react-ui/src/components/Charts/shared/core/PortalTooltip/portalTooltip.scsssimilarity index 98%rename from packages/react-ui/src/components/D3Charts/shared/core/PortalTooltip/portalTooltip.scssrename to packages/react-ui/src/components/Charts/shared/core/PortalTooltip/portalTooltip.scssindex c210dac8b..36fb7ed5a 100644--- a/packages/react-ui/src/components/D3Charts/shared/core/PortalTooltip/portalTooltip.scss+++ b/packages/react-ui/src/components/Charts/shared/core/PortalTooltip/portalTooltip.scss@@ -20,7 +20,6 @@border: 1px solid cssUtils.$border-default;background-color: cssUtils.$foreground;box-shadow: cssUtils.$shadow-s;- text-transform: capitalize;&-label {@include cssUtils.typography(label, extra-small);@@ -44,7 +43,6 @@color: cssUtils.$text-neutral-primary;@include cssUtils.typography(label, extra-small);background-color: cssUtils.$foreground;- text-transform: capitalize;&-item {display: flex;diff --git a/packages/react-ui/src/components/D3Charts/shared/core/PortalTooltip/utils/index.ts b/packages/react-ui/src/components/Charts/shared/core/PortalTooltip/utils/index.tssimilarity index 100%rename from packages/react-ui/src/components/D3Charts/shared/core/PortalTooltip/utils/index.tsrename to packages/react-ui/src/components/Charts/shared/core/PortalTooltip/utils/index.tsdiff --git a/packages/react-ui/src/components/D3Charts/shared/core/StackedLegend/ChartWithStackedLegend.tsx b/packages/react-ui/src/components/Charts/shared/core/StackedLegend/ChartWithStackedLegend.tsxsimilarity index 79%rename from packages/react-ui/src/components/D3Charts/shared/core/StackedLegend/ChartWithStackedLegend.tsxrename to packages/react-ui/src/components/Charts/shared/core/StackedLegend/ChartWithStackedLegend.tsxindex 81fda05b6..eeb1e8d6a 100644--- a/packages/react-ui/src/components/D3Charts/shared/core/StackedLegend/ChartWithStackedLegend.tsx+++ b/packages/react-ui/src/components/Charts/shared/core/StackedLegend/ChartWithStackedLegend.tsx@@ -15,11 +15,11 @@ const toCssSize = (value: number | string | undefined) =>/*** A polar chart with its built-in stacked legend — the `legendVariant="stacked"`- * layout of react-ui's Recharts Pie and Radial charts: chart and legend side by- * side (half the width each) from 400px up, the legend under the chart when- * narrower. Chart and legend share a local legend store, so hovering or- * toggling a legend row drives the chart and the reverse. `width`, `height`- * and `className` size and style the whole layout, as in Recharts.+ * layout of the Pie and Radial charts: chart and legend side by side (half the+ * width each) from 400px up, the legend under the chart when narrower. Chart+ * and legend share a local legend store, so hovering or toggling a legend row+ * drives the chart and the reverse. `width`, `height` and `className` size and+ * style the whole layout.*/export function ChartWithStackedLegend({children,@@ -47,7 +47,7 @@ export function ChartWithStackedLegend({<div className={`${CLASS}__chart`}>{children}</div><div className={`${CLASS}__legend`}>{/* Side by side the list scrolls; stacked, the width drives show-more.- Rows show each item's share, as Recharts' stacked legend does. */}+ Rows show each item's share. */}<StackedLegend format="percentage" containerWidth={isRow ? undefined : layoutWidth} /></div></div>diff --git a/packages/react-ui/src/components/D3Charts/shared/core/StackedLegend/StackedLegend.tsx b/packages/react-ui/src/components/Charts/shared/core/StackedLegend/StackedLegend.tsxsimilarity index 100%rename from packages/react-ui/src/components/D3Charts/shared/core/StackedLegend/StackedLegend.tsxrename to packages/react-ui/src/components/Charts/shared/core/StackedLegend/StackedLegend.tsxdiff --git a/packages/react-ui/src/components/D3Charts/shared/core/StackedLegend/StackedLegendView.tsx b/packages/react-ui/src/components/Charts/shared/core/StackedLegend/StackedLegendView.tsxsimilarity index 94%rename from packages/react-ui/src/components/D3Charts/shared/core/StackedLegend/StackedLegendView.tsxrename to packages/react-ui/src/components/Charts/shared/core/StackedLegend/StackedLegendView.tsxindex eefac1f51..5d723c380 100644--- a/packages/react-ui/src/components/D3Charts/shared/core/StackedLegend/StackedLegendView.tsx+++ b/packages/react-ui/src/components/Charts/shared/core/StackedLegend/StackedLegendView.tsx@@ -13,8 +13,8 @@ import {type StackedLegendLayout,} from "./stackedLegendLayout";-const ITEM_HEIGHT = 36;-const ITEM_GAP = 2;+/** Fallback scroll step: a row's height in stackedLegend.scss. */+const ITEM_HEIGHT = 32;export interface StackedLegendViewProps {items: StackedLegendItem[];@@ -82,11 +82,12 @@ export const StackedLegendView = ({};}, [isShowMore, items.length]);- const scrollBy = (dir: 1 | -1) =>- listRef.current?.scrollBy({- top: dir * (ITEM_HEIGHT + ITEM_GAP),- behavior: "smooth",- });+ // One row per click, measured so the step always matches the rendered rows.+ const scrollBy = (dir: 1 | -1) => {+ const list = listRef.current;+ const rowHeight = list?.firstElementChild?.getBoundingClientRect().height || ITEM_HEIGHT;+ list?.scrollBy({ top: dir * rowHeight, behavior: "smooth" });+ };// Re-normalize percentages over the VISIBLE set so visible rows match the// (re-normalized) wedges. Hidden rows are dimmed; their % over the visiblediff --git a/packages/react-ui/src/components/D3Charts/shared/core/StackedLegend/index.ts b/packages/react-ui/src/components/Charts/shared/core/StackedLegend/index.tssimilarity index 100%rename from packages/react-ui/src/components/D3Charts/shared/core/StackedLegend/index.tsrename to packages/react-ui/src/components/Charts/shared/core/StackedLegend/index.tsdiff --git a/packages/react-ui/src/components/D3Charts/shared/core/StackedLegend/stackedLegend.scss b/packages/react-ui/src/components/Charts/shared/core/StackedLegend/stackedLegend.scsssimilarity index 88%rename from packages/react-ui/src/components/D3Charts/shared/core/StackedLegend/stackedLegend.scssrename to packages/react-ui/src/components/Charts/shared/core/StackedLegend/stackedLegend.scssindex 8ffd757c5..eeca876c8 100644--- a/packages/react-ui/src/components/D3Charts/shared/core/StackedLegend/stackedLegend.scss+++ b/packages/react-ui/src/components/Charts/shared/core/StackedLegend/stackedLegend.scss@@ -11,6 +11,7 @@.#{brand.$prefix}-stacked-legend-header {width: 100%;+ box-sizing: border-box;display: flex;flex-direction: row;align-items: center;@@ -60,7 +61,10 @@}&__item {+ // Padding inside the size, with or without a global box-sizing reset: a+ // wider row spills past the legend, whose scroll overflow clips the values.width: 100%;+ box-sizing: border-box;display: flex;flex-direction: row;justify-content: space-between;@@ -70,6 +74,8 @@border-radius: cssUtils.$radius-m;transition: all 0.2s ease-in-out;height: 32px;+ // Rows keep their height when the list overflows; the list scrolls.+ flex-shrink: 0;&:hover {background-color: cssUtils.$sunk;@@ -145,9 +151,9 @@margin: cssUtils.$space-2xs 0;}-// Chart + built-in stacked legend (ChartWithStackedLegend) — mirrors react-ui's-// Recharts Pie/Radial `legendVariant="stacked"` layout: legend under the chart-// on narrow containers, side by side (half the width each) from 400px up.+// Chart + built-in stacked legend (ChartWithStackedLegend), the Pie/Radial+// `legendVariant="stacked"` layout: legend under the chart on narrow+// containers, side by side (half the width each) from 400px up..#{brand.$prefix}-chart-with-stacked-legend {display: flex;position: relative;diff --git a/packages/react-ui/src/components/D3Charts/shared/core/StackedLegend/stackedLegendLayout.test.ts b/packages/react-ui/src/components/Charts/shared/core/StackedLegend/stackedLegendLayout.test.tssimilarity index 100%rename from packages/react-ui/src/components/D3Charts/shared/core/StackedLegend/stackedLegendLayout.test.tsrename to packages/react-ui/src/components/Charts/shared/core/StackedLegend/stackedLegendLayout.test.tsdiff --git a/packages/react-ui/src/components/D3Charts/shared/core/StackedLegend/stackedLegendLayout.ts b/packages/react-ui/src/components/Charts/shared/core/StackedLegend/stackedLegendLayout.tssimilarity index 100%rename from packages/react-ui/src/components/D3Charts/shared/core/StackedLegend/stackedLegendLayout.tsrename to packages/react-ui/src/components/Charts/shared/core/StackedLegend/stackedLegendLayout.tsdiff --git a/packages/react-ui/src/components/Charts/shared/core/StackedLegend/stories/StackedLegend.stories.tsx b/packages/react-ui/src/components/Charts/shared/core/StackedLegend/stories/StackedLegend.stories.tsxnew file mode 100644index 000000000..bf9ecba4f--- /dev/null+++ b/packages/react-ui/src/components/Charts/shared/core/StackedLegend/stories/StackedLegend.stories.tsx@@ -0,0 +1,1034 @@+import type { Meta, StoryObj } from "@storybook/react";+import { useId, useState } from "react";+import {+ LegendStoreProvider,+ PieChart,+ RadialChart,+ StackedLegend,+ StackedLegendItem,+ StackedLegendProps,+ useLegendEntry,+} from "../../../..";+import { Card } from "../../../../../Card";++// Sample data sets - each chart publishes one legend row per category++// Six-slice part-to-whole data - the typical chart + legend pairing+const trafficSourceData = [+ { source: "Organic Search", visits: 42800 },+ { source: "Direct", visits: 26400 },+ { source: "Referral", visits: 15300 },+ { source: "Social", visits: 12100 },+ { source: "Email", visits: 8700 },+ { source: "Paid Search", visits: 6200 },+];++// Department budget - used with the RadialChart+const departmentBudgetData = [+ { department: "Engineering", budget: 420000 },+ { department: "Sales", budget: 280000 },+ { department: "Marketing", budget: 190000 },+ { department: "Operations", budget: 140000 },+ { department: "Support", budget: 90000 },+];++// Team headcount - the second chart in the two-chart story+const headcountData = [+ { team: "Platform", people: 34 },+ { team: "Product", people: 22 },+ { team: "Design", people: 12 },+ { team: "Data", people: 9 },+];++// Thirteen categories - enough to overflow the legend+const productCategoryData = [+ { category: "Electronics", sales: 12500 },+ { category: "Apparel", sales: 9800 },+ { category: "Groceries", sales: 14500 },+ { category: "Home Goods", sales: 13200 },+ { category: "Books", sales: 8800 },+ { category: "Toys", sales: 7600 },+ { category: "Automotive", sales: 6500 },+ { category: "Health", sales: 11200 },+ { category: "Beauty", sales: 9300 },+ { category: "Sports", sales: 8100 },+ { category: "Outdoors", sales: 7200 },+ { category: "Music", sales: 4500 },+ { category: "Software", sales: 10500 },+];++// Hand-built rows for the standalone (no chart, no store) legend+const storageItems: StackedLegendItem[] = [+ { key: "photos", label: "Photos", color: "#383FC9", value: 48.2 },+ { key: "videos", label: "Videos", color: "#5F67F4", value: 31.5 },+ { key: "documents", label: "Documents", color: "#97A9FF", value: 12.4 },+ { key: "backups", label: "Backups", color: "#CBD7FF", value: 7.9 },+];++/**+ * # StackedLegend Component Documentation+ *+ * StackedLegend is the vertical legend of the polar charts (PieChart, RadialChart) as a+ * component of its own: one row per category - colour swatch, label and value - placed+ * anywhere in the tree, away from the chart it describes.+ *+ * - **LegendStoreProvider**: Owns a small store scoped to its subtree+ * - **legendKey**: The address a chart publishes its rows to and a legend reads them from+ * - **Bidirectional**: Hovering or clicking a row drives the chart; hovering a slice highlights the row+ * - **useLegendEntry**: Reads a published entry to build custom UI+ */++type StandaloneLegendProps = Extract<StackedLegendProps, { items: StackedLegendItem[] }>;+type StackedLegendStoryArgs = Partial<Omit<StandaloneLegendProps, "legendKey">> & {+ legendKey?: string;+};++const meta: Meta<StackedLegendStoryArgs> = {+ title: "Components/Charts/StackedLegend",+ component: StackedLegend,+ parameters: {+ layout: "centered",+ docs: {+ description: {+ component: `+## Installation and Basic Usage++\`\`\`tsx+import { LegendStoreProvider, PieChart, StackedLegend } from '@openuidev/react-ui/Charts';++<LegendStoreProvider>+ <PieChart data={data} categoryKey="source" dataKey="visits" legendKey="traffic" />+ <div style={{ height: 280 }}>+ <StackedLegend legendKey="traffic" />+ </div>+</LegendStoreProvider>+\`\`\`++## How the Legend Store Works++- **\`LegendStoreProvider\`** owns one store, scoped to its subtree. Wrap it around the chart+ *and* the legend - they can sit in completely different parts of that subtree.+- **A chart with a \`legendKey\`** (\`PieChart\`, \`RadialChart\`) publishes its legend rows to the+ store under that key and stops rendering its own legend.+- **\`<StackedLegend legendKey="…" />\`** renders the rows published under the same key and+ writes hover and toggle back, so the chart and the legend always stay in sync.+- **Key resolution**: an explicit \`legendKey\` prop wins; otherwise both sides fall back to the+ provider's own \`legendKey\`. For one chart + one legend, say the key once on the provider.+- **Graceful fallback**: without a provider, a chart given a \`legendKey\` falls back to its compact+ inline legend, and a connected \`StackedLegend\` renders nothing until a chart publishes.++## When to Use It++- **Use the chart's built-in legend** (\`legendVariant="stacked"\`, the default) when the legend+ belongs right next to the chart - it already switches between side by side (400px and wider)+ and legend-below-chart for you.+- **Use \`StackedLegend\` + \`LegendStoreProvider\`** when the legend lives somewhere else: a+ sidebar, a separate card, your own grid, or one legend panel for several charts.+- **Use \`StackedLegend\` with \`items\`** for a purely presentational legend that you drive+ with your own state - no chart and no store involved.++## Layout Requirements++StackedLegend fills **100% of its container's height**: rows are centred vertically and the list+scrolls when it overflows. Always give its container a definite height (a fixed-height box or a+flex row with a set height). The \`showMore\` layout is the exception - it grows with its rows.++## Rules of Thumb+- **One chart per key**: two charts publishing to one key log a duplicate \`legendKey\` warning.+ Any number of legends may read the same key.+- **Unique keys**: use \`useId()\` so repeated instances on one page never collide.+- **Never empty**: the last visible row cannot be hidden.+ `,+ },+ },+ },+ tags: ["dev", "autodocs"],+ argTypes: {+ legendKey: {+ description:+ "**Connected mode.** The store key to read - the same `legendKey` the chart publishes under. Falls back to the nearest provider's `legendKey`; renders nothing until a chart has published.",+ control: false,+ table: {+ type: { summary: "string" },+ defaultValue: { summary: "provider's legendKey" },+ category: "📊 Data Configuration",+ },+ },+ items: {+ description:+ "**Standalone mode.** Rows to render directly, without a store (`{ key, label, color, value }[]`). Passing `items` makes the legend presentational - `legendKey` is ignored.",+ control: false,+ table: {+ type: { summary: "StackedLegendItem[]" },+ defaultValue: { summary: "undefined" },+ category: "📊 Data Configuration",+ },+ },+ format: {+ description: `+**Value Format:**++- **percentage**: Each row's share of the visible total. Hidden rows are left out of the total but still show their value against it, so they can read above 100%+- **number**: The raw value++A connected legend inherits the publishing chart's \`format\` when this is not set.+ `,+ control: "radio",+ options: ["percentage", "number"],+ table: {+ type: { summary: '"percentage" | "number"' },+ defaultValue: { summary: "chart's format (connected) / percentage (standalone)" },+ category: "📱 Display Options",+ },+ },+ layout: {+ description: `+**Overflow Behavior:**++- **auto**: Show more when \`containerWidth\` is set and is under 450px or there are more than 6 rows; scrollable otherwise+- **scrollable**: Full list in its container; a header with "N labels" and up/down buttons appears when it overflows+- **showMore**: First 6 rows plus a Show more / Show less button+ `,+ control: "radio",+ options: ["auto", "scrollable", "showMore"],+ table: {+ type: { summary: '"auto" | "scrollable" | "showMore"' },+ defaultValue: { summary: "auto" },+ category: "📱 Display Options",+ },+ },+ containerWidth: {+ description:+ "Fixed legend width in pixels. Also feeds the `auto` layout decision. When unset the legend is 100% wide.",+ control: { type: "number", min: 160, max: 600 },+ table: {+ type: { summary: "number" },+ defaultValue: { summary: "undefined (100%)" },+ category: "📱 Display Options",+ },+ },+ showTitle: {+ description:+ 'Shows the "N labels" title in the scroll header. The header only appears when a scrollable list overflows.',+ control: "boolean",+ table: {+ type: { summary: "boolean" },+ defaultValue: { summary: "true" },+ category: "📱 Display Options",+ },+ },+ separator: {+ description: "Draws a separator line between rows.",+ control: "boolean",+ table: {+ type: { summary: "boolean" },+ defaultValue: { summary: "false" },+ category: "🎨 Visual Styling",+ },+ },+ className: {+ description: "Extra class name on the legend's root element.",+ control: false,+ table: {+ type: { summary: "string" },+ category: "🎨 Visual Styling",+ },+ },+ style: {+ description: "Inline styles on the legend's root element.",+ control: false,+ table: {+ type: { summary: "React.CSSProperties" },+ category: "🎨 Visual Styling",+ },+ },+ activeKey: {+ description:+ "**Standalone mode only.** Key of the highlighted row. In connected mode the store supplies it.",+ control: false,+ table: {+ type: { summary: "string | null" },+ category: "🎬 Animation & Interaction",+ },+ },+ hiddenKeys: {+ description:+ "**Standalone mode only.** Keys of hidden rows - drawn dimmed and left out of the percentage total. In connected mode the store supplies them.",+ control: false,+ table: {+ type: { summary: "Set<string>" },+ category: "🎬 Animation & Interaction",+ },+ },+ onItemHover: {+ description:+ "**Standalone mode only.** Called with a row's key on mouse enter and with `null` on mouse leave. In connected mode hover is written to the store.",+ control: false,+ table: {+ type: { summary: "(key: string | null) => void" },+ category: "🎬 Animation & Interaction",+ },+ },+ onItemToggle: {+ description:+ "**Standalone mode only.** Called with a row's key on click. Rows are only clickable when it is set. In connected mode the toggle is written to the store.",+ control: false,+ table: {+ type: { summary: "(key: string) => void" },+ category: "🎬 Animation & Interaction",+ },+ },+ },+};++export default meta;+type Story = StoryObj<typeof meta>;++const titleStyle = { margin: "0 0 8px 0", fontSize: "18px", fontWeight: "600" };+const subtitleStyle = { margin: 0, color: "#666", fontSize: "14px" };+const noteStyle = {+ marginTop: "16px",+ padding: "12px",+ backgroundColor: "#f8f9fa",+ borderRadius: "6px",+ fontSize: "12px",+ color: "#666",+};++/**+ * Custom UI built on `useLegendEntry`: reads the entry a chart published and shows the+ * highlighted row, the hidden rows and the visible total.+ */+function LegendStateReadout({ legendKey }: { legendKey: string }) {+ const entry = useLegendEntry(legendKey);+ if (!entry) return <div style={noteStyle}>Waiting for the chart to publish…</div>;++ const visible = entry.items.filter((item) => !entry.hiddenKeys.includes(item.key));+ const visibleTotal = visible.reduce((sum, item) => sum + item.value, 0);+ const active = entry.items.find((item) => item.key === entry.activeKey);++ return (+ <div+ style={{ ...noteStyle, display: "grid", gridTemplateColumns: "auto 1fr", gap: "6px 12px" }}+ >+ <strong>Highlighted</strong>+ <span>+ {active+ ? `${active.label} - ${((active.value / visibleTotal) * 100).toFixed(1)}% of visible`+ : "none"}+ </span>+ <strong>Hidden</strong>+ <span>{entry.hiddenKeys.length ? entry.hiddenKeys.join(", ") : "none"}</span>+ <strong>Visible total</strong>+ <span>+ {visibleTotal.toLocaleString()} visits ({visible.length} of {entry.items.length} rows)+ </span>+ </div>+ );+}++/**+ * ## Interactive Playground+ *+ * A donut chart publishing to a StackedLegend beside it. Use the Controls panel to try every+ * display prop of the legend.+ */+export const InteractivePlayground: Story = {+ name: "🎮 Interactive Playground",+ args: {+ legendKey: "playground",+ format: "percentage",+ layout: "auto",+ showTitle: true,+ separator: false,+ containerWidth: undefined,+ },+ render: (args: any) => (+ <Card style={{ width: "640px", padding: "24px" }}>+ <LegendStoreProvider>+ <div style={{ display: "flex", gap: "24px", alignItems: "center", height: "300px" }}>+ <div style={{ flex: 1, minWidth: 0 }}>+ <PieChart+ data={trafficSourceData}+ categoryKey="source"+ dataKey="visits"+ variant="donut"+ legendKey={args.legendKey}+ maxChartSize={260}+ />+ </div>+ <div style={{ width: "280px", height: "100%" }}>+ <StackedLegend {...args} />+ </div>+ </div>+ </LegendStoreProvider>+ </Card>+ ),+ parameters: {+ docs: {+ description: {+ story: `+Every display prop of the legend is wired to the Controls panel. The chart publishes with its+default \`format="number"\`; the legend's \`format\` arg overrides it. With \`layout="auto"\`, set+\`containerWidth\` below 450 to switch the legend to show-more.+ `,+ },+ source: {+ code: `+<LegendStoreProvider>+ <div style={{ display: "flex", gap: 24, alignItems: "center", height: 300 }}>+ <div style={{ flex: 1, minWidth: 0 }}>+ <PieChart data={data} categoryKey="source" dataKey="visits" variant="donut" legendKey="playground" />+ </div>+ <div style={{ width: 280, height: "100%" }}>+ <StackedLegend legendKey="playground" format="percentage" layout="auto" showTitle separator={false} />+ </div>+ </div>+</LegendStoreProvider>+`,+ },+ },+ },+};++function PieWithLegendDemo() {+ // One chart + one legend: state the key once, on the provider.+ const uid = useId();+ return (+ <LegendStoreProvider legendKey={uid}>+ <div style={{ display: "flex", gap: "24px", alignItems: "center", height: "280px" }}>+ <div style={{ flex: 1, minWidth: 0 }}>+ <PieChart+ data={trafficSourceData}+ categoryKey="source"+ dataKey="visits"+ format="percentage"+ maxChartSize={260}+ />+ </div>+ <div style={{ width: "260px", height: "100%" }}>+ <StackedLegend />+ </div>+ </div>+ </LegendStoreProvider>+ );+}++/**+ * ## Pie Chart with an External Legend+ *+ * The most common composition: a PieChart and a StackedLegend side by side, sharing one store.+ */+export const PieChartWithExternalLegend: Story = {+ name: "🥧 Pie Chart + StackedLegend",+ render: () => (+ <Card style={{ width: "640px", padding: "24px" }}>+ <div style={{ marginBottom: "16px" }}>+ <h3 style={titleStyle}>Traffic Sources</h3>+ <p style={subtitleStyle}>Share of 111,500 visits by acquisition channel</p>+ </div>+ <PieWithLegendDemo />+ </Card>+ ),+ parameters: {+ docs: {+ description: {+ story: `+**Say the key once.** Here the key lives on the provider (\`legendKey={useId()}\`), so neither+the chart nor the legend repeats it - both fall back to the provider's key.++**What you get:**+- The chart publishes its rows and suppresses its own legend+- The legend inherits the chart's \`format="percentage"\`+- Hovering and clicking rows drives the chart, and hovering slices highlights rows+- The legend box has a fixed height; rows are centred inside it+ `,+ },+ source: {+ code: `+const uid = useId();++<LegendStoreProvider legendKey={uid}>+ <div style={{ display: "flex", gap: 24, alignItems: "center", height: 280 }}>+ <div style={{ flex: 1, minWidth: 0 }}>+ <PieChart data={trafficSourceData} categoryKey="source" dataKey="visits" format="percentage" />+ </div>+ <div style={{ width: 260, height: "100%" }}>+ <StackedLegend />+ </div>+ </div>+</LegendStoreProvider>+`,+ },+ },+ },+};++/**+ * ## Radial Chart with an External Legend+ *+ * The same wiring with a RadialChart, this time with explicit keys and the legend below the chart.+ */+export const RadialChartWithExternalLegend: Story = {+ name: "🎯 Radial Chart + StackedLegend",+ args: {+ separator: true,+ },+ render: (args: any) => (+ <Card style={{ width: "420px", padding: "24px" }}>+ <div style={{ marginBottom: "16px" }}>+ <h3 style={titleStyle}>Department Budget</h3>+ <p style={subtitleStyle}>Annual budget in USD</p>+ </div>+ <LegendStoreProvider>+ <RadialChart+ data={departmentBudgetData}+ categoryKey="department"+ dataKey="budget"+ legendKey="budget"+ maxChartSize={240}+ />+ <div style={{ height: "220px", marginTop: "16px" }}>+ <StackedLegend {...args} legendKey="budget" />+ </div>+ </LegendStoreProvider>+ </Card>+ ),+ parameters: {+ docs: {+ description: {+ story: `+**Explicit keys.** The chart and the legend both name \`legendKey="budget"\`. An explicit prop+always wins over a provider's default key.++**Configuration Details:**+- **Chart**: RadialChart with its default \`format="number"\` - the legend inherits raw values+- **Legend**: Below the chart in a 220px-tall box, with \`separator\` lines between rows+ `,+ },+ source: {+ code: `+<LegendStoreProvider>+ <RadialChart data={departmentBudgetData} categoryKey="department" dataKey="budget" legendKey="budget" />+ <div style={{ height: 220, marginTop: 16 }}>+ <StackedLegend legendKey="budget" separator />+ </div>+</LegendStoreProvider>+`,+ },+ },+ },+};++/**+ * ## Bidirectional Hover & Toggle+ *+ * The chart and the legend drive each other through the store. The panel underneath is custom UI+ * built with `useLegendEntry`, showing the store state live.+ */+export const BidirectionalInteraction: Story = {+ name: "🔁 Bidirectional Hover & Toggle",+ render: () => (+ <Card style={{ width: "640px", padding: "24px" }}>+ <div style={{ marginBottom: "16px" }}>+ <h3 style={titleStyle}>Traffic Sources</h3>+ <p style={subtitleStyle}>Hover a slice or a row, click a row to hide its slice</p>+ </div>+ <LegendStoreProvider>+ <div style={{ display: "flex", gap: "24px", alignItems: "center", height: "280px" }}>+ <div style={{ flex: 1, minWidth: 0 }}>+ <PieChart+ data={trafficSourceData}+ categoryKey="source"+ dataKey="visits"+ variant="donut"+ format="percentage"+ paddingAngle={1}+ legendKey="traffic"+ maxChartSize={260}+ />+ </div>+ <div style={{ width: "260px", height: "100%" }}>+ <StackedLegend legendKey="traffic" />+ </div>+ </div>+ <LegendStateReadout legendKey="traffic" />+ </LegendStoreProvider>+ </Card>+ ),+ parameters: {+ docs: {+ description: {+ story: `+**Legend → chart:**+- **Hover a row**: its slice is highlighted and the other slices dim+- **Click a row**: its slice is hidden; the row stays in the legend, dimmed, so a second click brings it back+- **Percentages re-normalize** over the visible rows, matching the redrawn slices+- **Never empty**: clicking the last visible row does nothing++**Chart → legend:**+- **Hover a slice**: the matching row gets the active background++**Reading the store yourself:** \`useLegendEntry(key)\` returns the published entry -+\`items\`, \`activeKey\`, \`hiddenKeys\` and \`format\` - or \`undefined\` before the chart publishes.+It is read-only: hover and toggle are written by the chart and the StackedLegend.+ `,+ },+ source: {+ code: `+function LegendStateReadout({ legendKey }: { legendKey: string }) {+ const entry = useLegendEntry(legendKey);+ if (!entry) return null;+ const active = entry.items.find((item) => item.key === entry.activeKey);+ return (+ <div>+ Highlighted: {active?.label ?? "none"} · Hidden: {entry.hiddenKeys.join(", ") || "none"}+ </div>+ );+}++<LegendStoreProvider>+ <PieChart data={data} categoryKey="source" dataKey="visits" variant="donut" format="percentage" legendKey="traffic" />+ <div style={{ width: 260, height: 280 }}>+ <StackedLegend legendKey="traffic" />+ </div>+ <LegendStateReadout legendKey="traffic" />+</LegendStoreProvider>+`,+ },+ },+ },+};++/**+ * ## Legend Far From Its Chart+ *+ * A dashboard layout where the legend sits in a sidebar and the chart in the main panel.+ */+export const LegendInSidebar: Story = {+ name: "🧭 Legend in a Sidebar",+ render: () => (+ <Card style={{ width: "820px", padding: "24px" }}>+ <LegendStoreProvider>+ <div style={{ display: "grid", gridTemplateColumns: "240px 1fr", gap: "24px" }}>+ <Card variant="sunk" width="full" style={{ padding: "16px" }}>+ <div>+ <h4 style={{ margin: "0 0 4px 0", fontSize: "14px", fontWeight: "600" }}>+ Budget breakdown+ </h4>+ <p style={{ ...subtitleStyle, fontSize: "12px" }}>Click a department to hide it</p>+ </div>+ <div style={{ height: "220px" }}>+ <StackedLegend legendKey="sidebar-budget" format="percentage" />+ </div>+ </Card>+ <div>+ <div style={{ marginBottom: "16px" }}>+ <h3 style={titleStyle}>Department Budget FY26</h3>+ <p style={subtitleStyle}>$1.12M allocated across five departments</p>+ </div>+ <PieChart+ data={departmentBudgetData}+ categoryKey="department"+ dataKey="budget"+ variant="donut"+ appearance="semiCircular"+ cornerRadius={4}+ paddingAngle={1}+ legendKey="sidebar-budget"+ maxChartSize={400}+ />+ </div>+ </div>+ </LegendStoreProvider>+ </Card>+ ),+ parameters: {+ docs: {+ description: {+ story: `+The legend and the chart are in different branches of the layout - a sidebar and a main panel.+They only need a common \`LegendStoreProvider\` above them and the same key.++**Why this needs StackedLegend:** a chart's built-in legend always sits beside or below the chart.+To put the legend anywhere else, publish with \`legendKey\` and place the legend where you want it.++**Note:** \`format="percentage"\` on the legend overrides the chart's default \`number\` format.+ `,+ },+ source: {+ code: `+<LegendStoreProvider>+ <div style={{ display: "grid", gridTemplateColumns: "240px 1fr", gap: 24 }}>+ <aside>+ <div style={{ height: 220 }}>+ <StackedLegend legendKey="sidebar-budget" format="percentage" />+ </div>+ </aside>+ <main>+ <PieChart+ data={departmentBudgetData}+ categoryKey="department"+ dataKey="budget"+ variant="donut"+ appearance="semiCircular"+ legendKey="sidebar-budget"+ />+ </main>+ </div>+</LegendStoreProvider>+`,+ },+ },+ },+};++/**+ * ## Two Charts, One Provider+ *+ * One provider can hold several chart + legend pairs, each addressed by its own key.+ */+export const MultipleChartsOneProvider: Story = {+ name: "🧩 Two Charts, One Provider",+ render: () => (+ <Card style={{ width: "760px", padding: "24px" }}>+ <div style={{ marginBottom: "16px" }}>+ <h3 style={titleStyle}>Company Overview</h3>+ <p style={subtitleStyle}>Two charts, two keys, one LegendStoreProvider</p>+ </div>+ <LegendStoreProvider>+ <div style={{ display: "grid", gridTemplateColumns: "1fr 1fr", gap: "32px" }}>+ <div>+ <h4 style={{ margin: "0 0 12px 0", fontSize: "14px", fontWeight: "600" }}>+ Traffic by channel+ </h4>+ <PieChart+ data={trafficSourceData}+ categoryKey="source"+ dataKey="visits"+ variant="donut"+ legendKey="channels"+ maxChartSize={220}+ />+ <div style={{ height: "230px", marginTop: "12px" }}>+ <StackedLegend legendKey="channels" format="percentage" />+ </div>+ </div>+ <div>+ <h4 style={{ margin: "0 0 12px 0", fontSize: "14px", fontWeight: "600" }}>+ Headcount by team+ </h4>+ <RadialChart+ data={headcountData}+ categoryKey="team"+ dataKey="people"+ legendKey="teams"+ maxChartSize={220}+ />+ <div style={{ height: "230px", marginTop: "12px" }}>+ <StackedLegend legendKey="teams" />+ </div>+ </div>+ </div>+ </LegendStoreProvider>+ </Card>+ ),+ parameters: {+ docs: {+ description: {+ story: `+**Independent entries.** The store holds one entry per key, so hovering or hiding a row in the+"channels" legend never touches the "teams" chart.++**Best Practices:**+- Give every chart its own key - two charts publishing to one key log a duplicate \`legendKey\` warning+- Keep the provider local: wrap just the charts and legends that belong together+- The headcount legend inherits the RadialChart's default \`number\` format, the traffic legend overrides it with \`percentage\`+ `,+ },+ source: {+ code: `+<LegendStoreProvider>+ <PieChart data={trafficSourceData} categoryKey="source" dataKey="visits" variant="donut" legendKey="channels" />+ <div style={{ height: 230 }}>+ <StackedLegend legendKey="channels" format="percentage" />+ </div>++ <RadialChart data={headcountData} categoryKey="team" dataKey="people" legendKey="teams" />+ <div style={{ height: 230 }}>+ <StackedLegend legendKey="teams" />+ </div>+</LegendStoreProvider>+`,+ },+ },+ },+};++/**+ * ## Many Items: Scroll vs Show More+ *+ * Thirteen categories in two overflow layouts.+ */+export const ManyItems: Story = {+ name: "📜 Many Items: Scroll vs Show More",+ render: () => (+ <div style={{ display: "grid", gridTemplateColumns: "1fr 1fr", gap: "24px", width: "760px" }}>+ <Card style={{ padding: "24px" }}>+ <h4 style={{ margin: "0 0 12px 0", fontSize: "14px", fontWeight: "600" }}>+ layout="scrollable"+ </h4>+ <LegendStoreProvider legendKey="scrollable-sales">+ <PieChart+ data={productCategoryData}+ categoryKey="category"+ dataKey="sales"+ variant="donut"+ maxChartSize={200}+ />+ <div style={{ height: "240px", marginTop: "16px" }}>+ <StackedLegend layout="scrollable" format="percentage" />+ </div>+ </LegendStoreProvider>+ </Card>+ <Card style={{ padding: "24px" }}>+ <h4 style={{ margin: "0 0 12px 0", fontSize: "14px", fontWeight: "600" }}>+ layout="showMore"+ </h4>+ <LegendStoreProvider legendKey="show-more-sales">+ <PieChart+ data={productCategoryData}+ categoryKey="category"+ dataKey="sales"+ variant="donut"+ maxChartSize={200}+ />+ <div style={{ marginTop: "16px" }}>+ <StackedLegend layout="showMore" format="percentage" />+ </div>+ </LegendStoreProvider>+ </Card>+ </div>+ ),+ parameters: {+ docs: {+ description: {+ story: `+**Scrollable** (left): the list stays inside its fixed-height box. When the rows overflow, a header+appears with the row count ("13 labels", hidden with \`showTitle={false}\`) and up/down buttons+that scroll one row at a time. The scrollbar itself is hidden.++**Show More** (right): the first 6 rows are shown with a Show more / Show less button. This layout+grows with its rows, so its container can have an auto height.++**Auto** (the default) picks show-more when \`containerWidth\` is set and is under 450px or there+are more than 6 rows, and scrollable otherwise.+ `,+ },+ source: {+ code: `+// Scrollable: definite height, header + up/down buttons on overflow+<LegendStoreProvider legendKey="scrollable-sales">+ <PieChart data={productCategoryData} categoryKey="category" dataKey="sales" variant="donut" />+ <div style={{ height: 240 }}>+ <StackedLegend layout="scrollable" format="percentage" />+ </div>+</LegendStoreProvider>++// Show more: first 6 rows + toggle button, grows with its rows+<LegendStoreProvider legendKey="show-more-sales">+ <PieChart data={productCategoryData} categoryKey="category" dataKey="sales" variant="donut" />+ <StackedLegend layout="showMore" format="percentage" />+</LegendStoreProvider>+`,+ },+ },+ },+};++/**+ * ## Value Format: Inherited vs Overridden+ *+ * Two legends reading the same key: one inherits the chart's format, one overrides it.+ */+export const ValueFormats: Story = {+ name: "🔢 Value Format: Inherited vs Overridden",+ render: () => (+ <Card style={{ width: "760px", padding: "24px" }}>+ <div style={{ marginBottom: "16px" }}>+ <h3 style={titleStyle}>Department Budget</h3>+ <p style={subtitleStyle}>One chart, two legends on the same key</p>+ </div>+ <LegendStoreProvider>+ <div style={{ display: "flex", gap: "24px", alignItems: "center", height: "260px" }}>+ <div style={{ flex: 1, minWidth: 0 }}>+ <PieChart+ data={departmentBudgetData}+ categoryKey="department"+ dataKey="budget"+ format="number"+ legendKey="formats"+ maxChartSize={240}+ />+ </div>+ <div style={{ width: "220px", height: "100%" }}>+ <p style={{ ...subtitleStyle, fontSize: "12px", paddingLeft: "8px" }}>+ Inherited (number)+ </p>+ <div style={{ height: "calc(100% - 20px)" }}>+ <StackedLegend legendKey="formats" />+ </div>+ </div>+ <div style={{ width: "220px", height: "100%" }}>+ <p style={{ ...subtitleStyle, fontSize: "12px", paddingLeft: "8px" }}>+ format="percentage"+ </p>+ <div style={{ height: "calc(100% - 20px)" }}>+ <StackedLegend legendKey="formats" format="percentage" />+ </div>+ </div>+ </div>+ </LegendStoreProvider>+ </Card>+ ),+ parameters: {+ docs: {+ description: {+ story: `+**Data Display Format:**++- **Inherited**: a connected legend without \`format\` uses the publishing chart's \`format\` - here \`number\`, so rows show raw values+- **percentage**: each row's share of the **visible** total. Hide a row and the others re-normalize to 100%+- **number**: the raw value, whatever is hidden++**Many readers, one publisher.** Both legends read the same key, so hovering or clicking a row+in either one updates the chart and the other legend.+ `,+ },+ source: {+ code: `+<LegendStoreProvider>+ <PieChart data={departmentBudgetData} categoryKey="department" dataKey="budget" format="number" legendKey="formats" />+ <div style={{ height: 240 }}>+ <StackedLegend legendKey="formats" /> {/* inherits "number" */}+ </div>+ <div style={{ height: 240 }}>+ <StackedLegend legendKey="formats" format="percentage" /> {/* overrides */}+ </div>+</LegendStoreProvider>+`,+ },+ },+ },+};++function StandaloneLegendDemo(args: any) {+ const [activeKey, setActiveKey] = useState<string | null>(null);+ const [hiddenKeys, setHiddenKeys] = useState<Set<string>>(new Set());++ const toggle = (key: string) =>+ setHiddenKeys((prev) => {+ const next = new Set(prev);+ if (next.has(key)) next.delete(key);+ // Mirror the store's guard: keep at least one row visible.+ else if (next.size < storageItems.length - 1) next.add(key);+ return next;+ });++ const visible = storageItems.filter((item) => !hiddenKeys.has(item.key));+ const visibleTotal = visible.reduce((sum, item) => sum + item.value, 0);++ return (+ <>+ {/* Your own visualization, driven by the same state as the legend */}+ <div style={{ display: "flex", height: "16px", borderRadius: "8px", overflow: "hidden" }}>+ {visible.map((item) => (+ <div+ key={item.key}+ style={{+ width: `${(item.value / visibleTotal) * 100}%`,+ backgroundColor: item.color,+ opacity: activeKey && activeKey !== item.key ? 0.4 : 1,+ transition: "all 0.2s ease",+ }}+ />+ ))}+ </div>+ <div style={{ height: "150px" }}>+ <StackedLegend+ {...args}+ items={storageItems}+ activeKey={activeKey}+ hiddenKeys={hiddenKeys}+ onItemHover={setActiveKey}+ onItemToggle={toggle}+ />+ </div>+ </>+ );+}++/**+ * ## Standalone Legend+ *+ * With `items`, StackedLegend is purely presentational - no provider, no chart, no store.+ */+export const StandaloneLegend: Story = {+ name: "🧱 Standalone Legend (items)",+ args: {+ format: "number",+ },+ render: (args: any) => (+ <Card style={{ width: "400px", padding: "24px" }}>+ <div style={{ marginBottom: "16px" }}>+ <h3 style={titleStyle}>Storage Usage</h3>+ <p style={subtitleStyle}>GB used per file type</p>+ </div>+ <StandaloneLegendDemo {...args} />+ </Card>+ ),+ parameters: {+ docs: {+ description: {+ story: `+**Presentational path.** Pass \`items\` and the legend renders them directly; \`legendKey\` is+ignored. You own the interaction state:++- **\`activeKey\`** + **\`onItemHover\`**: highlight a row and react to hover+- **\`hiddenKeys\`** + **\`onItemToggle\`**: dim hidden rows and react to clicks (rows are only clickable when \`onItemToggle\` is set)++Use it for a legend next to your own visualization - here a plain bar made of divs, driven by the+same state as the legend. The store's never-empty guard does not apply here, so this demo adds its own.+ `,+ },+ source: {+ code: `+const [activeKey, setActiveKey] = useState<string | null>(null);+const [hiddenKeys, setHiddenKeys] = useState<Set<string>>(new Set());+const toggle = (key: string) =>+ setHiddenKeys((prev) => {+ const next = new Set(prev);+ if (next.has(key)) next.delete(key);+ else next.add(key);+ return next;+ });++<div style={{ height: 150 }}>+ <StackedLegend+ items={[+ { key: "photos", label: "Photos", color: "#383FC9", value: 48.2 },+ { key: "videos", label: "Videos", color: "#5F67F4", value: 31.5 },+ // ...+ ]}+ format="number"+ activeKey={activeKey}+ hiddenKeys={hiddenKeys}+ onItemHover={setActiveKey}+ onItemToggle={toggle}+ />+</div>+`,+ },+ },+ },+};diff --git a/packages/react-ui/src/components/D3Charts/shared/core/legend/ARCHITECTURE.md b/packages/react-ui/src/components/Charts/shared/core/legend/ARCHITECTURE.mdsimilarity index 97%rename from packages/react-ui/src/components/D3Charts/shared/core/legend/ARCHITECTURE.mdrename to packages/react-ui/src/components/Charts/shared/core/legend/ARCHITECTURE.mdindex a8eb14344..358ad3ea5 100644--- a/packages/react-ui/src/components/D3Charts/shared/core/legend/ARCHITECTURE.md+++ b/packages/react-ui/src/components/Charts/shared/core/legend/ARCHITECTURE.md@@ -14,7 +14,7 @@ shared/core/legend/legendStore.ts createLegendStore() — Zustand store FACTORYlegendSelectors.ts indexToKey / keyToIndex / stackedItemsFromSlicestypes.ts LegendEntry, StackedLegendItem, LegendStoreState- index.ts barrel (what the rest of D3Charts imports)+ index.ts barrel (what the rest of Charts imports)shared/core/StackedLegend/StackedLegend.tsx connected (store-backed) vs presentational split@@ -24,7 +24,7 @@ hooks/polar/useCategoricalChartOrchestrator.ts the CHART side of the bridge```-Public exports (`D3Charts/index.ts`): `LegendStoreProvider`, `useLegendEntry`,+Public exports (`Charts/index.ts`): `LegendStoreProvider`, `useLegendEntry`,`StackedLegend` + types. The publisher/bridge hooks and`useResolvedLegendKey` are internal (legend barrel only).diff --git a/packages/react-ui/src/components/D3Charts/shared/core/legend/LegendStoreProvider.tsx b/packages/react-ui/src/components/Charts/shared/core/legend/LegendStoreProvider.tsxsimilarity index 100%rename from packages/react-ui/src/components/D3Charts/shared/core/legend/LegendStoreProvider.tsxrename to packages/react-ui/src/components/Charts/shared/core/legend/LegendStoreProvider.tsxdiff --git a/packages/react-ui/src/components/D3Charts/shared/core/legend/README.md b/packages/react-ui/src/components/Charts/shared/core/legend/README.mdsimilarity index 100%rename from packages/react-ui/src/components/D3Charts/shared/core/legend/README.mdrename to packages/react-ui/src/components/Charts/shared/core/legend/README.mddiff --git a/packages/react-ui/src/components/D3Charts/shared/core/legend/index.ts b/packages/react-ui/src/components/Charts/shared/core/legend/index.tssimilarity index 100%rename from packages/react-ui/src/components/D3Charts/shared/core/legend/index.tsrename to packages/react-ui/src/components/Charts/shared/core/legend/index.tsdiff --git a/packages/react-ui/src/components/D3Charts/shared/core/legend/legendSelectors.test.ts b/packages/react-ui/src/components/Charts/shared/core/legend/legendSelectors.test.tssimilarity index 100%rename from packages/react-ui/src/components/D3Charts/shared/core/legend/legendSelectors.test.tsrename to packages/react-ui/src/components/Charts/shared/core/legend/legendSelectors.test.tsdiff --git a/packages/react-ui/src/components/D3Charts/shared/core/legend/legendSelectors.ts b/packages/react-ui/src/components/Charts/shared/core/legend/legendSelectors.tssimilarity index 100%rename from packages/react-ui/src/components/D3Charts/shared/core/legend/legendSelectors.tsrename to packages/react-ui/src/components/Charts/shared/core/legend/legendSelectors.tsdiff --git a/packages/react-ui/src/components/D3Charts/shared/core/legend/legendStore.test.ts b/packages/react-ui/src/components/Charts/shared/core/legend/legendStore.test.tssimilarity index 100%rename from packages/react-ui/src/components/D3Charts/shared/core/legend/legendStore.test.tsrename to packages/react-ui/src/components/Charts/shared/core/legend/legendStore.test.tsdiff --git a/packages/react-ui/src/components/D3Charts/shared/core/legend/legendStore.ts b/packages/react-ui/src/components/Charts/shared/core/legend/legendStore.tssimilarity index 100%rename from packages/react-ui/src/components/D3Charts/shared/core/legend/legendStore.tsrename to packages/react-ui/src/components/Charts/shared/core/legend/legendStore.tsdiff --git a/packages/react-ui/src/components/D3Charts/shared/core/legend/types.ts b/packages/react-ui/src/components/Charts/shared/core/legend/types.tssimilarity index 100%rename from packages/react-ui/src/components/D3Charts/shared/core/legend/types.tsrename to packages/react-ui/src/components/Charts/shared/core/legend/types.tsdiff --git a/packages/react-ui/src/components/D3Charts/shared/core/spring/FadeFollower.tsx b/packages/react-ui/src/components/Charts/shared/core/spring/FadeFollower.tsxsimilarity index 100%rename from packages/react-ui/src/components/D3Charts/shared/core/spring/FadeFollower.tsxrename to packages/react-ui/src/components/Charts/shared/core/spring/FadeFollower.tsxdiff --git a/packages/react-ui/src/components/D3Charts/shared/core/spring/dataMorph.test.ts b/packages/react-ui/src/components/Charts/shared/core/spring/dataMorph.test.tssimilarity index 100%rename from packages/react-ui/src/components/D3Charts/shared/core/spring/dataMorph.test.tsrename to packages/react-ui/src/components/Charts/shared/core/spring/dataMorph.test.tsdiff --git a/packages/react-ui/src/components/D3Charts/shared/core/spring/dataMorph.ts b/packages/react-ui/src/components/Charts/shared/core/spring/dataMorph.tssimilarity index 100%rename from packages/react-ui/src/components/D3Charts/shared/core/spring/dataMorph.tsrename to packages/react-ui/src/components/Charts/shared/core/spring/dataMorph.tsdiff --git a/packages/react-ui/src/components/D3Charts/shared/core/spring/index.ts b/packages/react-ui/src/components/Charts/shared/core/spring/index.tssimilarity index 100%rename from packages/react-ui/src/components/D3Charts/shared/core/spring/index.tsrename to packages/react-ui/src/components/Charts/shared/core/spring/index.tsdiff --git a/packages/react-ui/src/components/D3Charts/shared/core/spring/presets.ts b/packages/react-ui/src/components/Charts/shared/core/spring/presets.tssimilarity index 100%rename from packages/react-ui/src/components/D3Charts/shared/core/spring/presets.tsrename to packages/react-ui/src/components/Charts/shared/core/spring/presets.tsdiff --git a/packages/react-ui/src/components/D3Charts/shared/core/spring/spring.test.ts b/packages/react-ui/src/components/Charts/shared/core/spring/spring.test.tssimilarity index 100%rename from packages/react-ui/src/components/D3Charts/shared/core/spring/spring.test.tsrename to packages/react-ui/src/components/Charts/shared/core/spring/spring.test.tsdiff --git a/packages/react-ui/src/components/D3Charts/shared/core/spring/spring.ts b/packages/react-ui/src/components/Charts/shared/core/spring/spring.tssimilarity index 100%rename from packages/react-ui/src/components/D3Charts/shared/core/spring/spring.tsrename to packages/react-ui/src/components/Charts/shared/core/spring/spring.tsdiff --git a/packages/react-ui/src/components/D3Charts/shared/core/spring/ticker.ts b/packages/react-ui/src/components/Charts/shared/core/spring/ticker.tssimilarity index 100%rename from packages/react-ui/src/components/D3Charts/shared/core/spring/ticker.tsrename to packages/react-ui/src/components/Charts/shared/core/spring/ticker.tsdiff --git a/packages/react-ui/src/components/D3Charts/shared/core/spring/useDataMorph.ts b/packages/react-ui/src/components/Charts/shared/core/spring/useDataMorph.tssimilarity index 100%rename from packages/react-ui/src/components/D3Charts/shared/core/spring/useDataMorph.tsrename to packages/react-ui/src/components/Charts/shared/core/spring/useDataMorph.tsdiff --git a/packages/react-ui/src/components/D3Charts/shared/core/spring/useSeededAim.ts b/packages/react-ui/src/components/Charts/shared/core/spring/useSeededAim.tssimilarity index 100%rename from packages/react-ui/src/components/D3Charts/shared/core/spring/useSeededAim.tsrename to packages/react-ui/src/components/Charts/shared/core/spring/useSeededAim.tsdiff --git a/packages/react-ui/src/components/D3Charts/shared/core/spring/useSpring.ts b/packages/react-ui/src/components/Charts/shared/core/spring/useSpring.tssimilarity index 100%rename from packages/react-ui/src/components/D3Charts/shared/core/spring/useSpring.tsrename to packages/react-ui/src/components/Charts/shared/core/spring/useSpring.tsdiff --git a/packages/react-ui/src/components/D3Charts/shared/core/spring/useTranslate.ts b/packages/react-ui/src/components/Charts/shared/core/spring/useTranslate.tssimilarity index 100%rename from packages/react-ui/src/components/D3Charts/shared/core/spring/useTranslate.tsrename to packages/react-ui/src/components/Charts/shared/core/spring/useTranslate.tsdiff --git a/packages/react-ui/src/components/Charts/shared/index.ts b/packages/react-ui/src/components/Charts/shared/index.tsdeleted file mode 100644index f0bd23b31..000000000--- a/packages/react-ui/src/components/Charts/shared/index.ts+++ /dev/null@@ -1,12 +0,0 @@-export * from "./ActiveDot/ActiveDot";-export * from "./CartesianGrid/cartesianGrid";-export * from "./DefaultLegend/DefaultLegend";-export * from "./LineInBarShape";-export * from "./PortalTooltip";-export * from "./ScrollButtonsHorizontal";-export * from "./ScrollButtonsVertical";-export * from "./SideBarTooltip";-export * from "./StackedLegend/StackedLegend";-export * from "./SVGXAxisTick";-export * from "./XAxisTick/XAxisTick";-export * from "./YAxisTick/YAxisTick";diff --git a/packages/react-ui/src/components/D3Charts/shared/mini/MiniChartFrame.tsx b/packages/react-ui/src/components/Charts/shared/mini/MiniChartFrame.tsxsimilarity index 71%rename from packages/react-ui/src/components/D3Charts/shared/mini/MiniChartFrame.tsxrename to packages/react-ui/src/components/Charts/shared/mini/MiniChartFrame.tsxindex 461b873bc..a2c6aecf8 100644--- a/packages/react-ui/src/components/D3Charts/shared/mini/MiniChartFrame.tsx+++ b/packages/react-ui/src/components/Charts/shared/mini/MiniChartFrame.tsx@@ -3,9 +3,11 @@ import { type MouseEventHandler, type ReactNode, useRef } from "react";import { useContainerSize } from "../../hooks/core/useContainerSize";import { CHART_CLASS_PREFIX } from "../../utils/constants";+/** Smallest frame side, in px; matches `min-width` / `min-height` in miniChart.scss. */+const MIN_MINI_SIZE = 100;+/**- * The square frame every mini chart draws in, as react-ui's Recharts mini- * charts do: `size` sets width and height (default "100%"), kept square and at+ * The square frame every mini chart draws in: `size` sets width and height (default "100%"), kept square and at* least 100px each way. Measures itself and hands the svg size to `children`.*/export function MiniChartFrame({@@ -22,7 +24,9 @@ export function MiniChartFrame({children: (width: number, height: number) => ReactNode;}) {const ref = useRef<HTMLDivElement>(null);- const { width, height } = useContainerSize(ref, size, size);+ // A number below the minimum draws at the minimum, as the CSS box does.+ const side = typeof size === "number" ? Math.max(size, MIN_MINI_SIZE) : size;+ const { width, height } = useContainerSize(ref, side, side);return (<div@@ -33,7 +37,7 @@ export function MiniChartFrame({onClick && `${CHART_CLASS_PREFIX}-mini-chart--clickable`,className,)}- style={{ width: size, height: size }}+ style={{ width: side, height: side }}onClick={onClick}>{width > 0 && height > 0 && (diff --git a/packages/react-ui/src/components/D3Charts/shared/mini/miniChart.scss b/packages/react-ui/src/components/Charts/shared/mini/miniChart.scsssimilarity index 75%rename from packages/react-ui/src/components/D3Charts/shared/mini/miniChart.scssrename to packages/react-ui/src/components/Charts/shared/mini/miniChart.scssindex 1d4e1d5c0..5bbfea60e 100644--- a/packages/react-ui/src/components/D3Charts/shared/mini/miniChart.scss+++ b/packages/react-ui/src/components/Charts/shared/mini/miniChart.scss@@ -1,8 +1,8 @@+@use "../../../../cssUtils" as cssUtils;@use "../cartesian/chartBase" as base;@use "../../prefix" as brand;-// The mini charts' frame (MiniChartFrame): square, at least 100px each way,-// as react-ui's Recharts mini charts are.+// The mini charts' frame (MiniChartFrame): square, at least 100px each way..#{brand.$prefix}-mini-chart {position: relative;aspect-ratio: 1 / 1;@@ -18,6 +18,11 @@}}+// The dot marking a single-value line mini: hollow, on the surface color.+.#{brand.$prefix}-mini-line-chart-point {+ fill: cssUtils.$background;+}+// Entrance: marks fade in. The whole rule is gated so reduced-motion users// never sit at the opacity: 0 start.@media (prefers-reduced-motion: no-preference) {diff --git a/packages/react-ui/src/components/D3Charts/shared/mini/miniChartUtils.test.ts b/packages/react-ui/src/components/Charts/shared/mini/miniChartUtils.test.tssimilarity index 100%rename from packages/react-ui/src/components/D3Charts/shared/mini/miniChartUtils.test.tsrename to packages/react-ui/src/components/Charts/shared/mini/miniChartUtils.test.tsdiff --git a/packages/react-ui/src/components/D3Charts/shared/mini/miniChartUtils.ts b/packages/react-ui/src/components/Charts/shared/mini/miniChartUtils.tssimilarity index 97%rename from packages/react-ui/src/components/D3Charts/shared/mini/miniChartUtils.tsrename to packages/react-ui/src/components/Charts/shared/mini/miniChartUtils.tsindex 9fca66037..bdcfad6c0 100644--- a/packages/react-ui/src/components/D3Charts/shared/mini/miniChartUtils.ts+++ b/packages/react-ui/src/components/Charts/shared/mini/miniChartUtils.ts@@ -1,6 +1,5 @@// Pure geometry for the mini charts (MiniAreaChart / MiniLineChart /-// MiniBarChart) — the sizing rules of react-ui's Recharts mini charts, kept out-// of the React layer so they are unit-testable in node.+// MiniBarChart), kept out of the React layer so they are unit-testable in node.import { scaleLinear, scalePoint } from "d3-scale";import { curveLinear, curveMonotoneX, curveStep } from "d3-shape";@@ -119,6 +118,8 @@ export const miniCurves = {/** Room above the highest point on the area/line minis (Recharts' `margin.top`). */export const MINI_TOP_MARGIN = 10;+/** Radius of the dot that marks a single-value area/line mini. */+export const MINI_POINT_RADIUS = 3;/*** Area/line geometry: the most recent points that fit, spread edge to edge,diff --git a/packages/react-ui/src/components/Charts/types/Legend.ts b/packages/react-ui/src/components/Charts/types/Legend.tsdeleted file mode 100644index 91a35c198..000000000--- a/packages/react-ui/src/components/Charts/types/Legend.ts+++ /dev/null@@ -1,14 +0,0 @@-export interface LegendItem {- key: string;- label: string;- color: string;- icon?: React.ComponentType;- percentage?: number;-}--export interface StackedLegendItem {- key: string;- label: string;- value: number;- color: string;-}diff --git a/packages/react-ui/src/components/Charts/types/XAxisTicks.ts b/packages/react-ui/src/components/Charts/types/XAxisTicks.tsdeleted file mode 100644index d7eb6822f..000000000--- a/packages/react-ui/src/components/Charts/types/XAxisTicks.ts+++ /dev/null@@ -1 +0,0 @@-export type XAxisTickVariant = "singleLine" | "multiLine";diff --git a/packages/react-ui/src/components/Charts/types/common.ts b/packages/react-ui/src/components/Charts/types/common.tsindex 0019c0f7a..f441914d9 100644--- a/packages/react-ui/src/components/Charts/types/common.ts+++ b/packages/react-ui/src/components/Charts/types/common.ts@@ -1 +1,88 @@-export type BarChartVariant = "grouped" | "stacked";+export interface LegendItem {+ key: string;+ label: string;+ color: string;+ icon?: React.ComponentType;+ percentage?: number;+}++export type XAxisTickVariant = "singleLine" | "multiLine" | "angled";++export type ChartData = Array<Record<string, string | number>>;++export interface BaseChartProps<T extends ChartData> {+ data: T;+ categoryKey: keyof T[number];+ customPalette?: string[];+ /**+ * How the x-axis category labels are drawn. The label band never takes more+ * than half the chart's height; labels that don't fit are truncated with an+ * ellipsis and show their full text on hover.+ * - `"singleLine"`: one horizontal line. Default when `condensed`.+ * - `"multiLine"`: wraps onto up to three lines. Default otherwise.+ * - `"angled"`: rotates labels 45° when they don't fit horizontally.+ * `condensed` only; the scrolling layout draws it as `"singleLine"`.+ */+ tickVariant?: XAxisTickVariant;+ grid?: boolean;+ /**+ * Show the legend. NOTE: `xAxisLabel`/`yAxisLabel` render inside the legend+ * strip, so `legend={false}` hides them too.+ */+ legend?: boolean;+ icons?: Partial<Record<keyof T[number], React.ComponentType>>;+ /**+ * Play the entrance animation. Gates the entrance ONLY — any hover or+ * data-update motion is independent of this flag, and printing always+ * disables it.+ * Default false (streaming-safe: marks mounted while data streams in don't+ * replay staggered entrances).+ */+ isAnimationActive?: boolean;+ showYAxis?: boolean;+ /** Axis caption — rendered in the legend strip (hidden when `legend` is false). */+ xAxisLabel?: React.ReactNode;+ yAxisLabel?: React.ReactNode;+ className?: string;+ height?: number | string;+ width?: number | string;+ /** When true, legend height is subtracted from container height so chart + legend+ * fit within specified dimensions. Defaults to true when `height` is set, false otherwise. */+ fitLegendInHeight?: boolean;+ /** When true, all data fits within the container width (no scrolling). Default false. */+ condensed?: boolean;+ /** Controls spacing between data points in scrollable mode. Default "default". */+ density?: "compact" | "default" | "spacious";+ /**+ * Hint for the number of y-axis ticks (and the matching horizontal+ * gridlines — they share the y-scale, so this drives both in lockstep).+ * d3 treats it as a target and picks nice round values near it, so the+ * rendered count can differ from the number given; the value is floored at 2.+ * Default: derived from chart height (~1 tick per 40px).+ *+ * Vertical orientation only. The horizontal BarChart's value axis is the+ * X axis and ignores this prop for now.+ */+ yTickCount?: number;+}++/**+ * Toggles for the hover overlay on line/area charts. Each element toggles+ * independently: `activeDots` defaults `true`, while `crosshair` and `highlight`+ * default `false` (opt-in — the gliding line and the traveling curve highlight+ * are off unless asked for).+ * Plain booleans for now — they can widen to a config object+ * (e.g. `boolean | {...}`) later without breaking.+ */+export interface HoverOverlayProps {+ /** The vertical crosshair line that tracks the hovered x. Default `false` for+ * Line/Area — pass `crosshair` to turn it on. */+ crosshair?: boolean;+ /** The highlight segment — a brighter slice of the curve that travels along it+ * around the hovered point. Default `false` for Line/Area — pass `highlight`+ * to turn it on. */+ highlight?: boolean;+ /** The dots that ride the curve at the hovered point, one per series. Distinct from+ * the static series dots (`showDots`/`dotRadius`). Default `true`. */+ activeDots?: boolean;+}diff --git a/packages/react-ui/src/components/Charts/types/exportChartData.ts b/packages/react-ui/src/components/Charts/types/exportChartData.tsnew file mode 100644index 000000000..1d4c87e27--- /dev/null+++ b/packages/react-ui/src/components/Charts/types/exportChartData.ts@@ -0,0 +1,27 @@+/**+ * Data structure for chart export (e.g., to PPTX)+ */+export type ExportChartData = {+ type: "line" | "bar" | "area" | "pie" | "radar" | "scatter";+ data: {+ name: string;+ labels?: string[];+ values?: number[];+ x?: number[];+ y?: number[];+ }[];+ options?: {+ chartColors?: string[];+ showLegend?: boolean;+ legendPos?: "b" | "t" | "l" | "r";+ title?: string;+ showTitle?: boolean;+ catAxisTitle?: string;+ showCatAxisTitle?: boolean;+ valAxisTitle?: string;+ showValAxisTitle?: boolean;+ lineSize?: number;+ barDir?: "bar" | "col";+ barGrouping?: "stacked" | "clustered" | "percent" | "standard";+ };+};diff --git a/packages/react-ui/src/components/Charts/types/index.ts b/packages/react-ui/src/components/Charts/types/index.tsindex 033cda0b0..c06863049 100644--- a/packages/react-ui/src/components/Charts/types/index.ts+++ b/packages/react-ui/src/components/Charts/types/index.ts@@ -1,3 +1,2 @@export * from "./common";-export * from "./Legend";-export * from "./XAxisTicks";+export type { ExportChartData } from "./exportChartData";diff --git a/packages/react-ui/src/components/Charts/utils/AreaAndLine/AreaAndLineUtils.ts b/packages/react-ui/src/components/Charts/utils/AreaAndLine/AreaAndLineUtils.tsdeleted file mode 100644index 7fefe4570..000000000--- a/packages/react-ui/src/components/Charts/utils/AreaAndLine/AreaAndLineUtils.ts+++ /dev/null@@ -1,108 +0,0 @@-// Common utility functions for Area and Line charts-// These functions are chart-type agnostic and can be shared between AreaChartV2 and LineChartV2--import { AreaChartData } from "../../AreaChart/types";-import { LineChartData } from "../../LineChart/types";--const ELEMENT_SPACING = 72;--// Common type for chart data - both AreaChart and LineChart data structures-type ChartData = AreaChartData | LineChartData;--/**- * AREA CHART AND LINE CHART SPECIFIC FUNCTION- * This function returns the width of the data in the area chart, used for padding calculation, scroll amount calculation, and- * for the width of the chart container.- * @param data - The data to be displayed in the chart.- */-export const getWidthOfData = (data: ChartData, containerWidth: number) => {- if (data.length === 0) {- return containerWidth;- }- // For area charts, we calculate based on the number of data points.- // We use getWidthOfGroup to ensure consistency- const width = data.length * getWidthOfGroup(data);-- // if the container width is greater than the width of the data, then we return the container width- // because the we need the chart minimum width to be the container width- // this decision is made because area chart an bar chart are span from the left to the right of the container- if (containerWidth >= width) {- return containerWidth;- }-- if (data.length === 1) {- const minSingleDataWidth = 200; // Minimum width for single data points- // if the data point is only one, then we need to set the width to the minimum width- return Math.max(width, minSingleDataWidth);- }-- return width;-};--/**- * SHARED UTILITY FUNCTION- * This function returns the nearest snap position index for both chart types.- * The implementation is identical for both AreaChart and LineChart.- * @param snapPositions - The snap positions for the chart.- * @param currentScroll - The current scroll of the chart.- * @param direction - The direction of the scroll.- * @returns The nearest snap position index for the chart.- */-export const findNearestSnapPosition = (- snapPositions: number[],- currentScroll: number,- direction: "left" | "right",-): number => {- // Find current position index- let currentIndex = 0;- for (let i = 0; i < snapPositions.length; i++) {- const snapPosition = snapPositions[i];- if (snapPosition !== undefined && currentScroll >= snapPosition) {- currentIndex = i;- } else {- break;- }- }-- if (direction === "left") {- // Go to previous snap position- return Math.max(0, currentIndex - 1);- } else {- // Go to next snap position- return Math.min(snapPositions.length - 1, currentIndex + 1);- }-};--/**- * SHARED UTILITY FUNCTION- * This function returns the width of each group/category for both chart types.- * Both AreaChart and LineChart use the same ELEMENT_SPACING.- * @param data - The data to be displayed in the chart.- * @returns The width of each group/category.- */-export const getWidthOfGroup = (data: ChartData) => {- if (data.length === 0) return 200; // Fallback-- // Both chart types use the same spacing- return ELEMENT_SPACING;-};--/**- * SHARED UTILITY FUNCTION- * This function returns the snap positions for both chart types, used for smooth scrolling.- * @param data - The data to be displayed in the chart.- * @returns The snap positions for the chart.- */-export const getSnapPositions = (data: ChartData): number[] => {- if (data.length === 0) return [0];-- const positions = [0]; // Start position- const groupWidthValue = getWidthOfGroup(data);-- // Calculate all valid snap positions based on data points- for (let i = 1; i < data.length; i++) {- positions.push(i * groupWidthValue);- }-- return positions;-};diff --git a/packages/react-ui/src/components/Charts/utils/AreaAndLine/MiniAreaAndLineUtils.ts b/packages/react-ui/src/components/Charts/utils/AreaAndLine/MiniAreaAndLineUtils.tsdeleted file mode 100644index 31b99f79e..000000000--- a/packages/react-ui/src/components/Charts/utils/AreaAndLine/MiniAreaAndLineUtils.ts+++ /dev/null@@ -1,67 +0,0 @@-// Common utility functions for Mini Area and Line charts-// These functions are shared between MiniAreaChart and MiniLineChart components--import { MiniAreaChartData } from "../../MiniAreaChart/types";-import { MiniLineChartData } from "../../MiniLineChart/types";--// Element spacing constant for both chart types-export const MINI_ELEMENT_SPACING: number = 20;--type ChartData = Array<{- value: number;- label: string;-}>;--// Common type for mini chart data - both area and line use the same structure-export type MiniChartData = MiniAreaChartData | MiniLineChartData;--/**- * Transforms mini chart data into a standardized format for rendering.- * Handles both numeric values and objects with value/label properties.- * Works for both MiniAreaChart and MiniLineChart components.- *- * @param data - The mini chart data array (can contain numbers or objects with value/label)- * @returns An array of chart data objects with value and label properties- */-export const transformDataForChart = (data: MiniChartData): ChartData => {- return data.map((item, index) => {- if (typeof item === "number") {- return { value: item, label: `Item ${index + 1}` };- } else {- return { value: item.value, label: item.label || `Item ${index + 1}` };- }- });-};--/**- * Filters data to include only the most recent items that can fit within the container width.- * This function ensures the chart displays the latest data when space is limited.- * Works for both MiniAreaChart and MiniLineChart components.- *- * @param data - The complete mini chart data array- * @param containerWidth - The total width of the container in pixels- * @returns A filtered array containing only the most recent data items that fit in the container- */-export const getRecentDataThatFits = (- data: MiniChartData,- containerWidth: number,-): MiniChartData => {- if (containerWidth <= 0 || data.length === 0) {- return data;- }-- // Calculate how many items can fit in the available space- const maxItems = Math.floor((containerWidth + 20) / MINI_ELEMENT_SPACING);- // +20 because the element spacing is between so if we have 2 element then its data 20px data- // so we need to add 20px to the container width to get the actual width of the data-- // If all items fit, return all data- if (maxItems >= data.length) {- return data;- }-- // Return the most recent items that fit- return data.slice(-maxItems);-};--export const DATA_KEY = "value";diff --git a/packages/react-ui/src/components/Charts/utils/AreaAndLine/common.ts b/packages/react-ui/src/components/Charts/utils/AreaAndLine/common.tsdeleted file mode 100644index 2081521fd..000000000--- a/packages/react-ui/src/components/Charts/utils/AreaAndLine/common.ts+++ /dev/null@@ -1,12 +0,0 @@-import { AreaChartVariant, LineChartVariant } from "../..";--export const getLineType = (lineType: LineChartVariant | AreaChartVariant) => {- switch (lineType) {- case "linear":- return "linear";- case "natural":- return "monotone";- case "step":- return "step";- }-};diff --git a/packages/react-ui/src/components/Charts/utils/BarCharts/BarChartsUtils.ts b/packages/react-ui/src/components/Charts/utils/BarCharts/BarChartsUtils.tsdeleted file mode 100644index 8cf311f41..000000000--- a/packages/react-ui/src/components/Charts/utils/BarCharts/BarChartsUtils.ts+++ /dev/null@@ -1,122 +0,0 @@-import { BarChartVariant } from "../../types";--export const getRadiusArray = (- variant: BarChartVariant,- radius: number,- orientation: "vertical" | "horizontal",- isFirst?: boolean,- isLast?: boolean,- isNegative?: boolean,-): [number, number, number, number] => {- if (variant === "grouped") {- if (orientation === "vertical") {- if (isNegative) {- return [0, 0, radius, radius]; // bottom-right, bottom-left for negative bars- }- return [radius, radius, 0, 0]; // top-left, top-right for positive bars- } else {- // horizontal- if (isNegative) {- return [radius, 0, 0, radius]; // top-left, bottom-left for negative bars- }- return [0, radius, radius, 0]; // top-right, bottom-right for positive bars- }- } else if (variant === "stacked") {- // For single-item stacks, round the end of the bar.- if (isFirst && isLast) {- if (orientation === "vertical") {- return isNegative ? [0, 0, radius, radius] : [radius, radius, 0, 0];- } else {- // horizontal- return isNegative ? [radius, 0, 0, radius] : [0, radius, radius, 0];- }- }-- // For multi-item stacks, only round the last bar in the stack.- if (orientation === "vertical") {- if (isLast) {- // Top of the stack for vertical bar- if (isNegative) {- return [0, 0, radius, radius];- }- return [radius, radius, 0, 0];- }- } else {- // horizontal- if (isLast) {- // Right of the stack for horizontal bar- if (isNegative) {- return [radius, 0, 0, radius];- }- return [0, radius, radius, 0];- }- }- // First and middle bars of the stack have no rounding.- return [0, 0, 0, 0];- }- // Default or other variants- return [radius, radius, radius, radius];-};--export const findNearestSnapPosition = (- snapPositions: number[],- currentScroll: number,- direction: "up" | "down" | "left" | "right",-): number => {- // Find current position index- let currentIndex = 0;- for (let i = 0; i < snapPositions.length; i++) {- const snapPosition = snapPositions[i]!;- if (currentScroll >= snapPosition) {- currentIndex = i;- } else {- break;- }- }-- if (direction === "up" || direction === "left") {- // Go to previous snap position- return Math.max(0, currentIndex - 1);- } else {- // Go to next snap position- return Math.min(snapPositions.length - 1, currentIndex + 1);- }-};--export interface BarStackInfo {- isNegative: boolean;- isFirstInStack?: boolean;- isLastInStack?: boolean;- hasNegativeValueInStack?: boolean;-}--export function getBarStackInfo(- variant: "grouped" | "stacked",- value: number | [number, number],- dataKey: string,- payload: Record<string, unknown>,- dataKeys: string[],-): BarStackInfo {- const isNegative = Array.isArray(value) ? value[0] <= 0 && value[1] < 0 : value < 0;-- if (variant !== "stacked") {- return { isNegative };- }-- const stackedKeys = dataKeys.filter((k) => typeof payload[k] === "number");- const positiveKeys = stackedKeys.filter((k) => (payload[k] as number) >= 0);- const negativeKeys = stackedKeys.filter((k) => (payload[k] as number) < 0);- const hasNegativeValueInStack = negativeKeys.length > 0;-- const keys = isNegative ? negativeKeys : positiveKeys;- const currentIndex = keys.indexOf(dataKey);- const isFirstInStack = currentIndex === 0;- const isLastInStack = currentIndex === keys.length - 1;-- return {- isNegative,- isFirstInStack,- isLastInStack,- hasNegativeValueInStack,- };-}diff --git a/packages/react-ui/src/components/Charts/utils/PalletUtils.ts b/packages/react-ui/src/components/Charts/utils/PalletUtils.tsdeleted file mode 100644index 973bdd723..000000000--- a/packages/react-ui/src/components/Charts/utils/PalletUtils.ts+++ /dev/null@@ -1,193 +0,0 @@-import { useMemo } from "react";-import invariant from "tiny-invariant";-import { ChartColorPalette, useTheme } from "../../ThemeProvider";--export type ColorPalette = {- name: string;- // colors are used to display the palette- colors: string[];-};--export type PaletteName = "ocean" | "orchid" | "emerald" | "spectrum" | "sunset" | "vivid";--type PaletteMap = Record<string, ColorPalette>;--const colorPalettes: PaletteMap = {- ocean: {- name: "Ocean",- colors: [- "#0D47A1",- "#1565C0",- "#1976D2",- "#1E88E5",- "#2196F3",- "#42A5F5",- "#64B5F6",- "#90CAF9",- "#BBDEFB",- "#E3F2FD",- "#EFF8FF",- ],- },- orchid: {- name: "Orchid",- colors: [- "#3A365B",- "#482E77",- "#552594",- "#631DB0",- "#7014CC",- "#883BD5",- "#A062DD",- "#B88AE6",- "#CFB1EE",- "#E7D8F7",- "#F7EFFF",- ],- },- emerald: {- name: "Emerald",- colors: [- "#10451D",- "#155D27",- "#1A7431",- "#208B3A",- "#25A244",- "#2DC653",- "#4AD66D",- "#6EDE8A",- "#92E6A7",- "#B7EFC5",- "#DCFFE5",- ],- },- spectrum: {- name: "Spectrum",- colors: [- "#2171BC",- "#2681D7",- "#72A4EB",- "#A0C0F7",- "#C2D4F7",- "#EADDE8",- "#EEB3B1",- "#E99492",- "#E17475",- "#D75259",- "#CB253E",- ],- },- sunset: {- name: "Sunset",- colors: [- "#0D0887",- "#42049E",- "#6A00A8",- "#900DA4",- "#B12A90",- "#CC4678",- "#E16462",- "#F1844B",- "#FCA636",- "#FCCE25",- "#FFE06E",- ],- },- vivid: {- name: "Vivid",- colors: [- "#FF595E",- "#FF924C",- "#FFCA3A",- "#C5CA30",- "#8AC926",- "#36949D",- "#1982C4",- "#4267AC",- "#565AA0",- "#6A4C93",- "#63438F",- ],- },-};--export type PaletteKey = keyof typeof colorPalettes;--export const getPalette = (key: PaletteKey): ColorPalette => {- const palette = colorPalettes[key];- invariant(palette, `Palette ${key} not found`);- return palette;-};--export const getAllPalettes = (): ColorPalette[] => {- return Object.values(colorPalettes);-};--export const getPaletteKeys = (): PaletteKey[] => {- return Object.keys(colorPalettes) as PaletteKey[];-};--export const getPaletteKey = (palette: ColorPalette): PaletteKey => {- return Object.keys(colorPalettes).find((key) => colorPalettes[key] === palette) as PaletteKey;-};--export const getPaletteMap = (): PaletteMap => {- return colorPalettes;-};--export const getDistributedColors = (colors: string[], dataLength: number): string[] => {- const midIndex = Math.floor(colors.length / 2);-- if (dataLength === 1) {- return [colors[midIndex]!];- }-- if (dataLength === 2) {- return [colors[midIndex - 1]!, colors[midIndex + 1]!];- }-- const result: string[] = [];- const offset = Math.floor((dataLength - 1) / 2);-- for (let i = 0; i < dataLength; i++) {- const index = midIndex + (i - offset);-- // Handle out of bounds by cycling through colors- let actualIndex: number;- if (index < 0) {- // Wrap around from the end- actualIndex = colors.length + (index % colors.length);- } else if (index >= colors.length) {- // Wrap around from the beginning- actualIndex = index % colors.length;- } else {- actualIndex = index;- }-- result.push(colors[actualIndex]!);- }-- return result;-};--export const useChartPalette = ({- chartThemeName,- customPalette,- themePaletteName,- dataLength,-}: {- chartThemeName: PaletteName;- customPalette?: string[];- themePaletteName: keyof ChartColorPalette;- dataLength: number;-}) => {- const { theme } = useTheme();- const paletteFromTheme = theme[themePaletteName] || theme.defaultChartPalette;- const paletteFromChartTheme = getPalette(chartThemeName);-- const palette = customPalette || paletteFromTheme || paletteFromChartTheme.colors;-- return useMemo(() => {- return getDistributedColors(palette, dataLength);- }, [palette, dataLength]);-};diff --git a/packages/react-ui/src/components/D3Charts/utils/buildContainerStyle.ts b/packages/react-ui/src/components/Charts/utils/buildContainerStyle.tssimilarity index 100%rename from packages/react-ui/src/components/D3Charts/utils/buildContainerStyle.tsrename to packages/react-ui/src/components/Charts/utils/buildContainerStyle.tsdiff --git a/packages/react-ui/src/components/D3Charts/utils/colorLuminance.test.ts b/packages/react-ui/src/components/Charts/utils/colorLuminance.test.tssimilarity index 100%rename from packages/react-ui/src/components/D3Charts/utils/colorLuminance.test.tsrename to packages/react-ui/src/components/Charts/utils/colorLuminance.test.tsdiff --git a/packages/react-ui/src/components/D3Charts/utils/colorLuminance.ts b/packages/react-ui/src/components/Charts/utils/colorLuminance.tssimilarity index 100%rename from packages/react-ui/src/components/D3Charts/utils/colorLuminance.tsrename to packages/react-ui/src/components/Charts/utils/colorLuminance.tsdiff --git a/packages/react-ui/src/components/D3Charts/utils/constants.test.ts b/packages/react-ui/src/components/Charts/utils/constants.test.tssimilarity index 100%rename from packages/react-ui/src/components/D3Charts/utils/constants.test.tsrename to packages/react-ui/src/components/Charts/utils/constants.test.tsdiff --git a/packages/react-ui/src/components/D3Charts/utils/constants.ts b/packages/react-ui/src/components/Charts/utils/constants.tssimilarity index 83%rename from packages/react-ui/src/components/D3Charts/utils/constants.tsrename to packages/react-ui/src/components/Charts/utils/constants.tsindex 036b909e8..77e6ec50c 100644--- a/packages/react-ui/src/components/D3Charts/utils/constants.ts+++ b/packages/react-ui/src/components/Charts/utils/constants.ts@@ -1,15 +1,14 @@/*** Brand prefix for every chart class name and `@keyframes` name the library- * emits (`openui-d3-bar-chart-container`, `openui-d3-chart-tooltip`,- * `openui-d3-fade-appear`, …). Distinct from the Recharts `Charts/` folder's- * `openui-` classes so both stylesheets can ship side by side. Always compose- * class names from this constant; never hardcode the brand token in TSX/TS.+ * emits (`openui-bar-chart-container`, `openui-chart-tooltip`,+ * `openui-fade-appear`, …). Always compose class names from this constant;+ * never hardcode the brand token in TSX/TS.* SCSS can't read TS constants: `_prefix.scss` mirrors this as `$prefix`* — change BOTH or the stylesheets stop matching the DOM.* NOTE: the `data-openui-chart` print/PPTX attribute is a backend contract and* deliberately NOT derived from this prefix (see `useExportChartData`).*/-export const CHART_CLASS_PREFIX = "openui-d3";+export const CHART_CLASS_PREFIX = "openui";export const CHART_MARGIN_TOP = 10;// Minimum vertical px between y-ticks. Grid and YAxis must share this value:diff --git a/packages/react-ui/src/components/Charts/utils/dataUtils.ts b/packages/react-ui/src/components/Charts/utils/dataUtils.tsindex fe0755e86..2c294b326 100644--- a/packages/react-ui/src/components/Charts/utils/dataUtils.ts+++ b/packages/react-ui/src/components/Charts/utils/dataUtils.ts@@ -1,14 +1,14 @@-import { ChartConfig } from "../Charts";-import { PieChartData } from "../PieChart";-import { RadialChartData } from "../RadialChart";import { LegendItem } from "../types";-/**- * This function returns the data keys for the chart, used for the data keys of the chart.- * @param data - The data to be displayed in the chart.- * @param categoryKey - The key of the category to be displayed in the chart.- * @returns The data keys for the chart.- */+export interface ChartConfig {+ [key: string]: {+ label: string;+ icon?: React.ComponentType;+ color?: string;+ transformed?: string;+ };+}+export const getDataKeys = (data: Array<Record<string, string | number>>,categoryKey: string,@@ -16,21 +16,11 @@ export const getDataKeys = (return Object.keys(data[0] || {}).filter((key) => key !== categoryKey);};-/**- * This function returns the chart configuration object, used for the chart configuration object of the chart.- * @param dataKeys - The data keys for the chart.- * @param colors - The colors for the chart.- * @param transformedKeys - The transformed keys for the chart.- * @param secondaryColors - The secondary colors for the chart (optional).- * @param icons - The icons for the chart (optional).- * @returns The chart configuration object for the chart.- */export const get2dChartConfig = (dataKeys: string[],colors: string[],transformedKeys: Record<string, string>,- secondaryColors?: string[],- icons?: Partial<Record<string, React.ComponentType>>,+ icons?: Partial<Record<string | number, React.ComponentType>>,): ChartConfig => {return dataKeys.reduce((config, key, index) => ({@@ -39,7 +29,6 @@ export const get2dChartConfig = (label: key,icon: icons?.[key],color: colors[index],- secondaryColor: secondaryColors?.[index] || colors[dataKeys.length - index - 1],transformed: transformedKeys[key],},}),@@ -47,62 +36,15 @@ export const get2dChartConfig = ();};-type CategoricalChartData = RadialChartData | PieChartData;--export const getCategoricalChartConfig = <T extends CategoricalChartData>(- data: T,- categoryKey: keyof T[number],- colors: string[], // Change this from 'theme: string' to 'colors: string[]'- transformedKeys: Record<string, string>,-): ChartConfig => {- return data.reduce<ChartConfig>((config, item, index) => {- const originalKey = String(item[categoryKey]);- const transformedKey = `key-${transformedKeys[originalKey] ?? originalKey}`;- return {- ...config,- [transformedKey]: {- label: String(item[categoryKey as string]),- color: colors[index],- secondaryColor: colors[data.length - index - 1], // Add secondary color for gradient effect- },- };- }, {});-};--/**- * This function returns the legend items for the chart, used for the legend items of the chart.- * @param dataKeys - The data keys for the chart.- * @param colors - The colors for the chart.- * @param icons - The icons for the chart.- * @returns The legend items for the chart.- */-export const getLegendItems = (dataKeys: string[],colors: string[],- icons?: Partial<Record<string, React.ComponentType>>,+ icons?: Partial<Record<string | number, React.ComponentType>>,): LegendItem[] => {return dataKeys.map((key, index) => ({key,label: key,- color: colors[index] ?? "#000000", // Fallback color if undefined+ color: colors[index] ?? "#000000",icon: icons?.[key] as React.ComponentType | undefined,}));};--/**- * This function returns the color value for a specific data key based on its position in the dataKeys array.- * Use this instead of payload.fill to ensure consistent color mapping.- * @param dataKey - The data key to get the color for.- * @param dataKeys - The array of all data keys in the chart.- * @param colors - The array of colors corresponding to the data keys.- * @returns The color value for the specified data key.- */-export const getColorForDataKey = (- dataKey: string,- dataKeys: string[],- colors: string[],-): string => {- const index = dataKeys.indexOf(dataKey);- return colors[index] ?? "#000000"; // Fallback color if dataKey not found or color undefined-};diff --git a/packages/react-ui/src/components/D3Charts/utils/entranceUtils.test.ts b/packages/react-ui/src/components/Charts/utils/entranceUtils.test.tssimilarity index 100%rename from packages/react-ui/src/components/D3Charts/utils/entranceUtils.test.tsrename to packages/react-ui/src/components/Charts/utils/entranceUtils.test.tsdiff --git a/packages/react-ui/src/components/D3Charts/utils/entranceUtils.ts b/packages/react-ui/src/components/Charts/utils/entranceUtils.tssimilarity index 100%rename from packages/react-ui/src/components/D3Charts/utils/entranceUtils.tsrename to packages/react-ui/src/components/Charts/utils/entranceUtils.tsdiff --git a/packages/react-ui/src/components/D3Charts/utils/heatmapUtils.test.ts b/packages/react-ui/src/components/Charts/utils/heatmapUtils.test.tssimilarity index 100%rename from packages/react-ui/src/components/D3Charts/utils/heatmapUtils.test.tsrename to packages/react-ui/src/components/Charts/utils/heatmapUtils.test.tsdiff --git a/packages/react-ui/src/components/D3Charts/utils/heatmapUtils.ts b/packages/react-ui/src/components/Charts/utils/heatmapUtils.tssimilarity index 100%rename from packages/react-ui/src/components/D3Charts/utils/heatmapUtils.tsrename to packages/react-ui/src/components/Charts/utils/heatmapUtils.tsdiff --git a/packages/react-ui/src/components/Charts/utils/index.ts b/packages/react-ui/src/components/Charts/utils/index.tsdeleted file mode 100644index b1abb1e73..000000000--- a/packages/react-ui/src/components/Charts/utils/index.ts+++ /dev/null@@ -1,3 +0,0 @@-export * from "./dataUtils";-export * from "./PalletUtils";-export * from "./styleUtils";diff --git a/packages/react-ui/src/components/D3Charts/utils/labelWrap.test.ts b/packages/react-ui/src/components/Charts/utils/labelWrap.test.tssimilarity index 100%rename from packages/react-ui/src/components/D3Charts/utils/labelWrap.test.tsrename to packages/react-ui/src/components/Charts/utils/labelWrap.test.tsdiff --git a/packages/react-ui/src/components/D3Charts/utils/labelWrap.ts b/packages/react-ui/src/components/Charts/utils/labelWrap.tssimilarity index 100%rename from packages/react-ui/src/components/D3Charts/utils/labelWrap.tsrename to packages/react-ui/src/components/Charts/utils/labelWrap.tsdiff --git a/packages/react-ui/src/components/D3Charts/utils/mouseUtils.test.ts b/packages/react-ui/src/components/Charts/utils/mouseUtils.test.tssimilarity index 100%rename from packages/react-ui/src/components/D3Charts/utils/mouseUtils.test.tsrename to packages/react-ui/src/components/Charts/utils/mouseUtils.test.tsdiff --git a/packages/react-ui/src/components/D3Charts/utils/mouseUtils.ts b/packages/react-ui/src/components/Charts/utils/mouseUtils.tssimilarity index 100%rename from packages/react-ui/src/components/D3Charts/utils/mouseUtils.tsrename to packages/react-ui/src/components/Charts/utils/mouseUtils.tsdiff --git a/packages/react-ui/src/components/D3Charts/utils/paletteUtils.test.ts b/packages/react-ui/src/components/Charts/utils/paletteUtils.test.tssimilarity index 83%rename from packages/react-ui/src/components/D3Charts/utils/paletteUtils.test.tsrename to packages/react-ui/src/components/Charts/utils/paletteUtils.test.tsindex 4faff706a..15fc4eb64 100644--- a/packages/react-ui/src/components/D3Charts/utils/paletteUtils.test.ts+++ b/packages/react-ui/src/components/Charts/utils/paletteUtils.test.ts@@ -1,6 +1,11 @@import { describe, expect, it } from "vitest";import type { ChartColorPalette } from "../../ThemeProvider";-import { getDistributedColors, OCEAN_DEFAULT, resolvePalette } from "./paletteUtils";+import {+ getDistributedColors,+ OCEAN_DEFAULT,+ orientRampToSurface,+ resolvePalette,+} from "./paletteUtils";const bar = ["#b1", "#b2"];const def = ["#d1", "#d2"];@@ -96,3 +101,21 @@ describe("getDistributedColors (center-out distribution over a ramp)", () => {expect(getDistributedColors(["#a"], 0)).toEqual([]);});});++// No canvas here, so luminance is unknown and the dark → light series order+// of theme palettes is assumed.+describe("orientRampToSurface (low end nearest the surface)", () => {+ it("puts the light end first in light mode", () => {+ const ramp = orientRampToSurface(OCEAN_DEFAULT, "light");+ expect(ramp[0]).toBe(OCEAN_DEFAULT[OCEAN_DEFAULT.length - 1]);+ expect(ramp[ramp.length - 1]).toBe(OCEAN_DEFAULT[0]);+ });++ it("keeps the dark end first in dark mode", () => {+ expect(orientRampToSurface(OCEAN_DEFAULT, "dark")).toEqual(OCEAN_DEFAULT);+ });++ it("leaves a single color alone", () => {+ expect(orientRampToSurface(["#123456"], "light")).toEqual(["#123456"]);+ });+});diff --git a/packages/react-ui/src/components/D3Charts/utils/paletteUtils.ts b/packages/react-ui/src/components/Charts/utils/paletteUtils.tssimilarity index 82%rename from packages/react-ui/src/components/D3Charts/utils/paletteUtils.tsrename to packages/react-ui/src/components/Charts/utils/paletteUtils.tsindex 3a222253c..2ca9060f3 100644--- a/packages/react-ui/src/components/D3Charts/utils/paletteUtils.ts+++ b/packages/react-ui/src/components/Charts/utils/paletteUtils.ts@@ -1,5 +1,6 @@import { useMemo } from "react";import { ChartColorPalette, useTheme } from "../../ThemeProvider";+import { getColorLuminance } from "./colorLuminance";/*** The single built-in default ramp.@@ -135,3 +136,20 @@ export const useChartPalette = ({return getDistributedColors(palette, dataLength);}, [palette, dataLength]);};++/**+ * A palette read as a sequential low → high ramp (heatmap, calendar levels),+ * oriented so its low end is the color nearest the surface: the lightest in+ * light mode, the darkest in dark mode. Low values then fade into the+ * background and high values stand out. Theme and built-in palettes run dark →+ * light (the series order), so light mode reverses them.+ */+export const orientRampToSurface = (ramp: string[], mode: string | undefined): string[] => {+ if (ramp.length < 2) return ramp;+ const first = getColorLuminance(ramp[0]!);+ const last = getColorLuminance(ramp[ramp.length - 1]!);+ // Without a canvas (SSR) assume the dark → light series order.+ const firstIsLighter = first !== null && last !== null ? first > last : false;+ const lightFirst = mode !== "dark";+ return firstIsLighter === lightFirst ? ramp : [...ramp].reverse();+};diff --git a/packages/react-ui/src/components/D3Charts/utils/polarUtils.test.ts b/packages/react-ui/src/components/Charts/utils/polarUtils.test.tssimilarity index 100%rename from packages/react-ui/src/components/D3Charts/utils/polarUtils.test.tsrename to packages/react-ui/src/components/Charts/utils/polarUtils.test.tsdiff --git a/packages/react-ui/src/components/D3Charts/utils/polarUtils.ts b/packages/react-ui/src/components/Charts/utils/polarUtils.tssimilarity index 100%rename from packages/react-ui/src/components/D3Charts/utils/polarUtils.tsrename to packages/react-ui/src/components/Charts/utils/polarUtils.tsdiff --git a/packages/react-ui/src/components/D3Charts/utils/radarLabelLayout.test.ts b/packages/react-ui/src/components/Charts/utils/radarLabelLayout.test.tssimilarity index 100%rename from packages/react-ui/src/components/D3Charts/utils/radarLabelLayout.test.tsrename to packages/react-ui/src/components/Charts/utils/radarLabelLayout.test.tsdiff --git a/packages/react-ui/src/components/D3Charts/utils/radarLabelLayout.ts b/packages/react-ui/src/components/Charts/utils/radarLabelLayout.tssimilarity index 100%rename from packages/react-ui/src/components/D3Charts/utils/radarLabelLayout.tsrename to packages/react-ui/src/components/Charts/utils/radarLabelLayout.tsdiff --git a/packages/react-ui/src/components/D3Charts/utils/rampUtils.test.ts b/packages/react-ui/src/components/Charts/utils/rampUtils.test.tssimilarity index 100%rename from packages/react-ui/src/components/D3Charts/utils/rampUtils.test.tsrename to packages/react-ui/src/components/Charts/utils/rampUtils.test.tsdiff --git a/packages/react-ui/src/components/D3Charts/utils/rampUtils.ts b/packages/react-ui/src/components/Charts/utils/rampUtils.tssimilarity index 100%rename from packages/react-ui/src/components/D3Charts/utils/rampUtils.tsrename to packages/react-ui/src/components/Charts/utils/rampUtils.tsdiff --git a/packages/react-ui/src/components/D3Charts/utils/resolveShouldFitLegend.test.ts b/packages/react-ui/src/components/Charts/utils/resolveShouldFitLegend.test.tssimilarity index 100%rename from packages/react-ui/src/components/D3Charts/utils/resolveShouldFitLegend.test.tsrename to packages/react-ui/src/components/Charts/utils/resolveShouldFitLegend.test.tsdiff --git a/packages/react-ui/src/components/D3Charts/utils/resolveShouldFitLegend.ts b/packages/react-ui/src/components/Charts/utils/resolveShouldFitLegend.tssimilarity index 100%rename from packages/react-ui/src/components/D3Charts/utils/resolveShouldFitLegend.tsrename to packages/react-ui/src/components/Charts/utils/resolveShouldFitLegend.tsdiff --git a/packages/react-ui/src/components/D3Charts/utils/scrollUtils.test.ts b/packages/react-ui/src/components/Charts/utils/scrollUtils.test.tssimilarity index 100%rename from packages/react-ui/src/components/D3Charts/utils/scrollUtils.test.tsrename to packages/react-ui/src/components/Charts/utils/scrollUtils.test.tsdiff --git a/packages/react-ui/src/components/D3Charts/utils/scrollUtils.ts b/packages/react-ui/src/components/Charts/utils/scrollUtils.tssimilarity index 100%rename from packages/react-ui/src/components/D3Charts/utils/scrollUtils.tsrename to packages/react-ui/src/components/Charts/utils/scrollUtils.tsdiff --git a/packages/react-ui/src/components/D3Charts/utils/styleUtils.test.ts b/packages/react-ui/src/components/Charts/utils/styleUtils.test.tssimilarity index 100%rename from packages/react-ui/src/components/D3Charts/utils/styleUtils.test.tsrename to packages/react-ui/src/components/Charts/utils/styleUtils.test.tsdiff --git a/packages/react-ui/src/components/Charts/utils/styleUtils.ts b/packages/react-ui/src/components/Charts/utils/styleUtils.tsindex 13809901f..c76566764 100644--- a/packages/react-ui/src/components/Charts/utils/styleUtils.ts+++ b/packages/react-ui/src/components/Charts/utils/styleUtils.ts@@ -1,10 +1,4 @@-/**- * This function returns the formatter for the Y-axis tick values.- * @returns The formatter for the Y-axis tick values.- * internally used by the YAxis component reCharts- */const numberTickFormatter = (value: number) => {- // Format the Y-axis tick values with abbreviationsif (typeof value === "number") {const absValue = Math.abs(value);@@ -17,7 +11,6 @@ const numberTickFormatter = (value: number) => {} else if (absValue >= 1e3) {return (value / 1e3).toFixed(absValue >= 10e3 ? 0 : 1) + "K";} else {- // For values < 1000, show only 1 decimal place if there's a decimalif (value % 1 !== 0) {return value.toFixed(2);}@@ -27,4 +20,26 @@ const numberTickFormatter = (value: number) => {return String(value);};-export { numberTickFormatter };+const DEFAULT_MIN_Y_AXIS_WIDTH = 20;+const DEFAULT_MAX_Y_AXIS_WIDTH = 200;+const DEFAULT_Y_AXIS_PADDING = 10;++const measureYAxisWidth = (+ ticks: number[],+ context: CanvasRenderingContext2D,+ options?: { minWidth?: number; maxWidth?: number; padding?: number },+): number => {+ const minWidth = options?.minWidth ?? DEFAULT_MIN_Y_AXIS_WIDTH;+ const maxWidth = options?.maxWidth ?? DEFAULT_MAX_Y_AXIS_WIDTH;+ const padding = options?.padding ?? DEFAULT_Y_AXIS_PADDING;++ let maxTextWidth = 0;+ for (const tick of ticks) {+ const w = context.measureText(numberTickFormatter(tick)).width;+ if (w > maxTextWidth) maxTextWidth = w;+ }++ return Math.max(minWidth, Math.min(maxWidth, Math.ceil(maxTextWidth) + padding));+};++export { measureYAxisWidth, numberTickFormatter };diff --git a/packages/react-ui/src/components/D3Charts/utils/xAxisLabelLayout.test.ts b/packages/react-ui/src/components/Charts/utils/xAxisLabelLayout.test.tssimilarity index 100%rename from packages/react-ui/src/components/D3Charts/utils/xAxisLabelLayout.test.tsrename to packages/react-ui/src/components/Charts/utils/xAxisLabelLayout.test.tsdiff --git a/packages/react-ui/src/components/D3Charts/utils/xAxisLabelLayout.ts b/packages/react-ui/src/components/Charts/utils/xAxisLabelLayout.tssimilarity index 100%rename from packages/react-ui/src/components/D3Charts/utils/xAxisLabelLayout.tsrename to packages/react-ui/src/components/Charts/utils/xAxisLabelLayout.tsdiff --git a/packages/react-ui/src/components/D3Charts/utils/yDomain.test.ts b/packages/react-ui/src/components/Charts/utils/yDomain.test.tssimilarity index 100%rename from packages/react-ui/src/components/D3Charts/utils/yDomain.test.tsrename to packages/react-ui/src/components/Charts/utils/yDomain.test.tsdiff --git a/packages/react-ui/src/components/D3Charts/utils/yDomain.ts b/packages/react-ui/src/components/Charts/utils/yDomain.tssimilarity index 100%rename from packages/react-ui/src/components/D3Charts/utils/yDomain.tsrename to packages/react-ui/src/components/Charts/utils/yDomain.tsdiff --git a/packages/react-ui/src/components/D3Charts/AreaChart/AreaChart.tsx b/packages/react-ui/src/components/D3Charts/AreaChart/AreaChart.tsxdeleted file mode 100644index 3d28887d9..000000000--- a/packages/react-ui/src/components/D3Charts/AreaChart/AreaChart.tsx+++ /dev/null@@ -1,233 +0,0 @@-import clsx from "clsx";-import { useCallback, useMemo } from "react";--import {- useCartesianChartOrchestrator,- useEffectiveAnimation,- useExportChartData,- useStackedData,- useXScale,- useYScale,-} from "../hooks";-import { CartesianXAxis } from "../shared/cartesian/axes/CartesianXAxis";-import { CartesianChartLayout } from "../shared/cartesian/layouts/CartesianChartLayout";-import { LineDotCrosshair } from "../shared/cartesian/LineDotCrosshair";-import { findNearestDataIndex } from "../utils/mouseUtils";-import { AreaSeries } from "./parts/AreaSeries";-import { GradientDefs } from "./parts/GradientDefs";--import { CHART_CLASS_PREFIX } from "../utils/constants";-import type { AreaChartData, AreaChartProps } from "./types";--/**- * Empty-data guard lives here, in a hook-free dispatcher: the chart impl below- * calls hooks unconditionally, so the "no data" branch must short-circuit- * *before* any hook runs (a count → 0 transition on a mounted chart would- * otherwise break the Rules of Hooks).- */-export function AreaChart<T extends AreaChartData>(props: AreaChartProps<T>) {- if (!props.data || props.data.length === 0) {- return (- <div- className={clsx(- `${CHART_CLASS_PREFIX}-area-chart-container ${CHART_CLASS_PREFIX}-chart-empty`,- props.className,- )}- >- <span className={`${CHART_CLASS_PREFIX}-chart-empty-text`}>No data available</span>- </div>- );- }- return <AreaChartImpl {...props} />;-}--// Stacked areas keep one running total per row — a negative value lowers the-// stack — matching Recharts' area charts (bars stack by sign instead).-const AREA_STACK_OFFSET = "none";--function AreaChartImpl<T extends AreaChartData>({- data,- categoryKey,- customPalette,- variant = "natural",- tickVariant: tickVariantProp,- stacked = true,- grid = true,- legend: showLegend = true,- icons,- isAnimationActive = false,- showYAxis = true,- xAxisLabel,- yAxisLabel,- className,- height,- width: fixedWidth,- fitLegendInHeight,- condensed = false,- density,- onClick,- crosshair = false,- highlight = false,- activeDots = true,- yTickCount,-}: AreaChartProps<T>) {- const animate = useEffectiveAnimation(isAnimationActive);- const mode = condensed ? "fit" : "scroll";-- const orch = useCartesianChartOrchestrator({- layout: mode,- data,- categoryKey,- themePaletteName: "areaChartPalette",- customPalette,- showLegend,- showYAxis,- height,- fixedWidth,- fitLegendInHeight,- tickVariantProp: tickVariantProp ?? (condensed ? "singleLine" : "multiLine"),- chartIdPrefix: "d3ac",- icons,- onClick,- density,- stacked,- stackOffset: AREA_STACK_OFFSET,- yTickCount,- });-- const xScale = useXScale(- data,- orch.data.catKey,- orch.dimensions.chartAreaWidth,- orch.dimensions.widthOfGroup,- );- const stackedData = useStackedData(data, orch.data.dataKeys, stacked, AREA_STACK_OFFSET);-- // Unstacked series whose values are entirely <= 0 hang below the zero line —- // flip their fill gradient so the strongest opacity stays at the data edge.- // Stacked series sit on the running total, so their gradient never flips.- const negativeKeys = useMemo(() => {- const keys = new Set<string>();- if (stacked) return keys;- for (const key of orch.data.dataKeys) {- let max = -Infinity;- for (const row of data) max = Math.max(max, Number(row[key]) || 0);- if (max <= 0) keys.add(key);- }- return keys;- }, [data, orch.data.dataKeys, stacked]);- const yScale = useYScale(- data,- orch.data.dataKeys,- orch.dimensions.chartInnerHeight,- stacked,- AREA_STACK_OFFSET,- );-- const getYValue = useCallback(- (_row: Record<string, string | number>, key: string, seriesIndex: number) => {- if (stackedData && orch.hover.hoveredIndex !== null) {- const series = stackedData[seriesIndex];- const point = series?.[orch.hover.hoveredIndex];- // The running total after this series — the edge its line is drawn on.- return point ? point[1] : 0;- }- return Number(_row[key]) || 0;- },- [stackedData, orch.hover.hoveredIndex],- );-- const findIndex = useCallback((mouseX: number) => findNearestDataIndex(xScale, mouseX), [xScale]);- const mouseHandlers = orch.hover.createMouseHandlers(findIndex);-- // PPTX print-export JSON — mirrors react-ui's AreaChart call (type:'area',- // no extraOptions). Undefined off the print path.- const exportData = useExportChartData({- type: "area",- data,- categoryKey: orch.data.catKey,- dataKeys: orch.data.dataKeys,- colors: orch.data.colors,- legend: showLegend,- xAxisLabel,- yAxisLabel,- });-- return (- <CartesianChartLayout- orch={orch}- yScale={yScale}- mouseHandlers={mouseHandlers}- classPrefix="area-chart"- chartType="area"- exportData={exportData}- ariaLabel="Area chart"- showYAxis={showYAxis}- grid={grid}- showLegend={showLegend}- xAxisLabel={xAxisLabel}- yAxisLabel={yAxisLabel}- yTickCount={yTickCount}- className={className}- defs={- <GradientDefs- negativeKeys={negativeKeys}- dataKeys={orch.data.dataKeys}- transformedKeys={orch.data.transformedKeys}- colors={orch.data.colorMap}- chartId={orch.identity.chartId}- chartWidth={orch.dimensions.chartAreaWidth}- chartHeight={orch.dimensions.chartInnerHeight}- />- }- series={- <>- <AreaSeries- data={data}- dataKeys={orch.data.dataKeys}- xScale={xScale}- yScale={yScale}- variant={variant}- stackedData={stackedData}- categoryKey={orch.data.catKey}- transformedKeys={orch.data.transformedKeys}- colors={orch.data.colorMap}- chartId={orch.identity.chartId}- isAnimationActive={animate}- />- <LineDotCrosshair- hoveredIndex={orch.hover.hoveredIndex}- xScale={xScale}- yScale={yScale}- data={data}- dataKeys={orch.data.dataKeys}- categoryKey={orch.data.catKey}- colors={orch.data.colorMap}- chartHeight={orch.dimensions.chartInnerHeight}- getYValue={getYValue}- classPrefix={`${CHART_CLASS_PREFIX}-area-chart`}- crosshair={crosshair}- highlight={highlight}- activeDots={activeDots}- />- </>- }- xAxis={- <CartesianXAxis- mode={mode}- scale={xScale}- classPrefix={`${CHART_CLASS_PREFIX}-area-chart`}- tickVariant={orch.dimensions.tickVariant}- widthOfGroup={orch.dimensions.widthOfGroup}- labelHeight={orch.xAxis.xAxisHeight}- labelWidth={orch.xAxis.labelWidth}- maxLines={orch.xAxis.maxLines}- labelInterval={orch.dimensions.labelInterval}- angle={orch.xAxis.angle}- chartWidth={orch.dimensions.chartAreaWidth}- yAxisWidth={orch.dimensions.effectiveYAxisWidth}- />- }- />- );-}diff --git a/packages/react-ui/src/components/D3Charts/AreaChart/areaChart.scss b/packages/react-ui/src/components/D3Charts/AreaChart/areaChart.scssdeleted file mode 100644index 2203eb1a1..000000000--- a/packages/react-ui/src/components/D3Charts/AreaChart/areaChart.scss+++ /dev/null@@ -1,33 +0,0 @@-@use "../shared/cartesian/chartBase" as base;-@use "../prefix" as brand;--@include base.chart-base("area-chart");-@include base.crosshair-styles("area-chart");--// No `transition: d` here: data-change motion is the spring data morph in-// AreaSeries (gated on isAnimationActive). A CSS transition restarted from-// progress 0 on every attribute write, so per-frame streaming rewrites pinned-// the rendered geometry (and would fight the morph's per-tick writes).-.#{brand.$prefix}-area-chart-area-path {- transition: opacity 0.2s ease;-}--.#{brand.$prefix}-area-chart-area-line {- fill: none;- stroke-width: 2;-}--// Entrances are decorative: gate the whole rule (pre-state included) behind-// reduced-motion so users who opt out get the natural static state immediately-// — gating only the animation would strand elements at the opacity: 0 start.-@media (prefers-reduced-motion: no-preference) {- .#{brand.$prefix}-area-chart-area-line--animated {- stroke-dasharray: var(--path-length);- stroke-dashoffset: var(--path-length);- animation: #{brand.$prefix}-draw-line 1s ease-out forwards;- }- .#{brand.$prefix}-area-chart-area-path--animated {- opacity: 0;- animation: #{brand.$prefix}-fade-appear 0.6s ease-out 0.4s forwards;- }-}diff --git a/packages/react-ui/src/components/D3Charts/AreaChart/index.ts b/packages/react-ui/src/components/D3Charts/AreaChart/index.tsdeleted file mode 100644index 372c6d233..000000000--- a/packages/react-ui/src/components/D3Charts/AreaChart/index.ts+++ /dev/null@@ -1,2 +0,0 @@-export { AreaChart } from "./AreaChart";-export type { AreaChartData, AreaChartProps, AreaChartVariant } from "./types";diff --git a/packages/react-ui/src/components/D3Charts/AreaChart/stories/areaChart.stories.tsx b/packages/react-ui/src/components/D3Charts/AreaChart/stories/areaChart.stories.tsxdeleted file mode 100644index 8040158fc..000000000--- a/packages/react-ui/src/components/D3Charts/AreaChart/stories/areaChart.stories.tsx+++ /dev/null@@ -1,1367 +0,0 @@-// Copy of Charts/AreaChart/stories/areaChart.stories.tsx with only the chart import and the title changed:-// the same args and renders, rendering the D3Charts chart via-// ../../stories/rechartsStoryAdapters.-import type { Meta, StoryObj } from "@storybook/react";-import {- Calendar,- Globe,- Laptop,- Monitor,- Smartphone,- TabletSmartphone,- Tv,- Watch,-} from "lucide-react";-import { useState } from "react";-import { Card } from "../../../Card";-import { AreaChart, AreaChartProps } from "../../stories/rechartsStoryAdapters";--// 🔥 COMPREHENSIVE DATA VARIATIONS - Designed to test label collision scenarios-const dataVariations = {- default: [- { month: "January", desktop: 150, mobile: 90, tablet: 120 },- { month: "February", desktop: 280, mobile: 180, tablet: 140 },- { month: "March", desktop: 220, mobile: 140, tablet: 160 },- { month: "April", desktop: 180, mobile: 160, tablet: 180 },- { month: "May", desktop: 250, mobile: 120, tablet: 140 },- { month: "June", desktop: 300, mobile: 180, tablet: 160 },- { month: "July", desktop: 350, mobile: 220, tablet: 180 },- { month: "August", desktop: 400, mobile: 240, tablet: 200 },- { month: "September", desktop: 450, mobile: 260, tablet: 220 },- { month: "October", desktop: 500, mobile: 280, tablet: 240 },- { month: "November", desktop: 550, mobile: 300, tablet: 260 },- { month: "December", desktop: 600, mobile: 320, tablet: 280 },- ],- // 🏷️ BIG LABELS - Testing collision detection and truncation- bigLabels: [- {- category: "Very Long Category Name That Should Be Truncated",- sales: 150,- revenue: 90,- profit: 120,- },- {- category: "Another Extremely Long Label That Causes Collisions",- sales: 280,- revenue: 180,- profit: 140,- },- {- category: "Super Duper Long Category Name That Tests Truncation",- sales: 220,- revenue: 140,- profit: 160,- },- {- category: "Incredibly Long Text That Should Trigger Collision Detection",- sales: 180,- revenue: 160,- profit: 180,- },- {- category: "Maximum Length Category Name That Tests All Edge Cases",- sales: 250,- revenue: 120,- profit: 140,- },- {- category: "Extra Long Business Category Name With Many Words",- sales: 300,- revenue: 180,- profit: 160,- },- {- category: "Comprehensive Long Label For Testing Horizontal Offset",- sales: 350,- revenue: 220,- profit: 180,- },- {- category: "Extended Category Name That Pushes Truncation Limits",- sales: 400,- revenue: 240,- profit: 200,- },- ],- // 📅 DENSE TIMELINE - Many items with medium-length labels- denseTimeline: [- { period: "Q1 2022 Jan-Mar", visitors: 120, conversions: 15, revenue: 1200 },- { period: "Q1 2022 Apr-Jun", visitors: 150, conversions: 22, revenue: 1800 },- { period: "Q2 2022 Jul-Sep", visitors: 180, conversions: 28, revenue: 2100 },- { period: "Q2 2022 Oct-Dec", visitors: 200, conversions: 35, revenue: 2500 },- { period: "Q3 2023 Jan-Mar", visitors: 160, conversions: 18, revenue: 1600 },- { period: "Q3 2023 Apr-Jun", visitors: 190, conversions: 32, revenue: 2300 },- { period: "Q4 2023 Jul-Sep", visitors: 220, conversions: 40, revenue: 2800 },- { period: "Q4 2023 Oct-Dec", visitors: 240, conversions: 45, revenue: 3200 },- { period: "Q1 2024 Jan-Mar", visitors: 210, conversions: 38, revenue: 2700 },- { period: "Q1 2024 Apr-Jun", visitors: 230, conversions: 42, revenue: 3000 },- { period: "Q2 2024 Jul-Sep", visitors: 250, conversions: 48, revenue: 3400 },- { period: "Q2 2024 Oct-Dec", visitors: 270, conversions: 52, revenue: 3800 },- { period: "Q3 2024 Jan-Mar", visitors: 260, conversions: 50, revenue: 3600 },- { period: "Q3 2024 Apr-Jun", visitors: 280, conversions: 55, revenue: 4000 },- { period: "Q4 2024 Jul-Sep", visitors: 300, conversions: 60, revenue: 4300 },- { period: "Q4 2024 Oct-Dec", visitors: 290, conversions: 58, revenue: 4100 },- ],- // 🏢 COMPANY NAMES - Real-world long business names- companyNames: [- { company: "Apple Inc.", revenue: 394328000000, profit: 99803000000, marketCap: 3500000000000 },- {- company: "Microsoft Corporation",- revenue: 211915000000,- profit: 83383000000,- marketCap: 2800000000000,- },- {- company: "Alphabet Inc. (Google)",- revenue: 307394000000,- profit: 76033000000,- marketCap: 2100000000000,- },- {- company: "Amazon.com Inc.",- revenue: 574785000000,- profit: 33364000000,- marketCap: 1600000000000,- },- {- company: "Tesla Motors Inc.",- revenue: 96773000000,- profit: 15000000000,- marketCap: 800000000000,- },- {- company: "Meta Platforms Inc.",- revenue: 134902000000,- profit: 39370000000,- marketCap: 900000000000,- },- {- company: "NVIDIA Corporation",- revenue: 60922000000,- profit: 29760000000,- marketCap: 1800000000000,- },- {- company: "Berkshire Hathaway Inc.",- revenue: 364482000000,- profit: 96223000000,- marketCap: 780000000000,- },- ],- // 🌍 COUNTRY NAMES - Geographic labels with varying lengths- countryData: [- { country: "United States of America", population: 331900000, gdp: 26900000000000 },- { country: "People's Republic of China", population: 1412000000, gdp: 17700000000000 },- { country: "Federal Republic of Germany", population: 83200000, gdp: 4300000000000 },- { country: "United Kingdom of Great Britain", population: 67500000, gdp: 3100000000000 },- { country: "French Republic", population: 68000000, gdp: 2900000000000 },- { country: "Republic of India", population: 1380000000, gdp: 3700000000000 },- { country: "Federative Republic of Brazil", population: 215000000, gdp: 2100000000000 },- { country: "Russian Federation", population: 146000000, gdp: 1800000000000 },- ],- // 📈 FINANCIAL QUARTERS - Testing medium-density scenarios- financialQuarters: [- { quarter: "Q1 FY2022", revenue: 1200000, expenses: 800000, profit: 400000 },- { quarter: "Q2 FY2022", revenue: 1500000, expenses: 950000, profit: 550000 },- { quarter: "Q3 FY2022", revenue: 1800000, expenses: 1100000, profit: 700000 },- { quarter: "Q4 FY2022", revenue: 2000000, expenses: 1300000, profit: 700000 },- { quarter: "Q1 FY2023", revenue: 2200000, expenses: 1400000, profit: 800000 },- { quarter: "Q2 FY2023", revenue: 2500000, expenses: 1600000, profit: 900000 },- { quarter: "Q3 FY2023", revenue: 2800000, expenses: 1800000, profit: 1000000 },- { quarter: "Q4 FY2023", revenue: 3000000, expenses: 1900000, profit: 1100000 },- ],- // 🔤 MIXED LENGTHS - Testing various label length scenarios- mixedLengths: [- { item: "A", valueA: 100, valueB: 80 },- { item: "Short", valueA: 150, valueB: 120 },- { item: "Medium Length Item", valueA: 200, valueB: 160 },- { item: "Very Long Item Name That Tests Truncation", valueA: 250, valueB: 200 },- { item: "B", valueA: 180, valueB: 140 },- { item: "Another Really Long Category Name", valueA: 220, valueB: 180 },- { item: "XL", valueA: 190, valueB: 150 },- ],- // 🎯 EDGE CASES - Extreme scenarios- edgeCases: [- {- name: "SinglePointDataSetForTestingEdgeCasesInCollisionDetectionAndLabelTruncationFunctionality",- value: 500,- },- {- name: "SecondExtremelyLongDataPointNameThatShouldDefinitelyTriggerTruncationMechanisms",- value: 600,- },- ],- // 📱 MINIMAL - Small dataset for baseline testing- minimal: [- { category: "Mobile Devices", users: 150, sessions: 90 },- { category: "Desktop Computers", users: 280, sessions: 180 },- { category: "Tablet Devices", users: 220, sessions: 140 },- ],- // 🔄 EXPAND/COLLAPSE - Marketing channels dataset for legend overflow testing- expandCollapseMarketing: [- {- channel: "Website Traffic and Organic Search Results",- impressions: 120000,- clicks: 15000,- conversions: 1200,- cost: 8500,- revenue: 24000,- roi: 182,- ctr: 12.5,- cpc: 0.57,- cpa: 7.08,- reach: 95000,- engagement: 8200,- shares: 420,- saves: 180,- comments: 650,- videoViews: 0,- },- {- channel: "Social Media Engagement and Brand Awareness",- impressions: 85000,- clicks: 12000,- conversions: 950,- cost: 6200,- revenue: 19000,- roi: 206,- ctr: 14.1,- cpc: 0.52,- cpa: 6.53,- reach: 72000,- engagement: 15400,- shares: 890,- saves: 340,- comments: 1200,- videoViews: 28000,- },- {- channel: "Email Marketing Campaign Performance",- impressions: 45000,- clicks: 8500,- conversions: 800,- cost: 2100,- revenue: 16000,- roi: 562,- ctr: 18.9,- cpc: 0.25,- cpa: 2.63,- reach: 42000,- engagement: 6800,- shares: 120,- saves: 85,- comments: 240,- videoViews: 0,- },- {- channel: "Paid Advertising and PPC Campaign ROI",- impressions: 95000,- clicks: 18000,- conversions: 1500,- cost: 12500,- revenue: 30000,- roi: 140,- ctr: 18.9,- cpc: 0.69,- cpa: 8.33,- reach: 88000,- engagement: 12600,- shares: 320,- saves: 150,- comments: 480,- videoViews: 5200,- },- {- channel: "Content Marketing and Blog Performance",- impressions: 60000,- clicks: 9500,- conversions: 750,- cost: 4800,- revenue: 15000,- roi: 213,- ctr: 15.8,- cpc: 0.51,- cpa: 6.4,- reach: 55000,- engagement: 7800,- shares: 680,- saves: 420,- comments: 950,- videoViews: 12000,- },- {- channel: "Mobile Application Downloads and Usage",- impressions: 70000,- clicks: 11000,- conversions: 1100,- cost: 5500,- revenue: 22000,- roi: 300,- ctr: 15.7,- cpc: 0.5,- cpa: 5.0,- reach: 65000,- engagement: 9200,- shares: 180,- saves: 95,- comments: 320,- videoViews: 8500,- },- {- channel: "Customer Support Response Time and Quality",- impressions: 35000,- clicks: 5500,- conversions: 450,- cost: 2800,- revenue: 9000,- roi: 221,- ctr: 15.7,- cpc: 0.51,- cpa: 6.22,- reach: 32000,- engagement: 4200,- shares: 45,- saves: 25,- comments: 180,- videoViews: 0,- },- {- channel: "Sales Funnel Conversion and Lead Generation",- impressions: 110000,- clicks: 22000,- conversions: 1800,- cost: 15000,- revenue: 36000,- roi: 140,- ctr: 20.0,- cpc: 0.68,- cpa: 8.33,- reach: 98000,- engagement: 18500,- shares: 420,- saves: 280,- comments: 750,- videoViews: 3200,- },- {- channel: "User Retention and Churn Rate Analysis",- impressions: 80000,- clicks: 14000,- conversions: 1200,- cost: 7200,- revenue: 24000,- roi: 233,- ctr: 17.5,- cpc: 0.51,- cpa: 6.0,- reach: 75000,- engagement: 11200,- shares: 280,- saves: 150,- comments: 420,- videoViews: 6800,- },- {- channel: "Product Feature Usage and Performance Metrics",- impressions: 65000,- clicks: 10500,- conversions: 900,- cost: 5200,- revenue: 18000,- roi: 246,- ctr: 16.2,- cpc: 0.5,- cpa: 5.78,- reach: 58000,- engagement: 8500,- shares: 320,- saves: 180,- comments: 650,- videoViews: 4200,- },- {- channel: "Market Research and Competitive Analysis",- impressions: 40000,- clicks: 6500,- conversions: 500,- cost: 3200,- revenue: 10000,- roi: 213,- ctr: 16.3,- cpc: 0.49,- cpa: 6.4,- reach: 36000,- engagement: 5200,- shares: 95,- saves: 65,- comments: 220,- videoViews: 1800,- },- {- channel: "Brand Sentiment and Public Relations Impact",- impressions: 55000,- clicks: 8000,- conversions: 650,- cost: 4100,- revenue: 13000,- roi: 217,- ctr: 14.5,- cpc: 0.51,- cpa: 6.31,- reach: 48000,- engagement: 6800,- shares: 520,- saves: 280,- comments: 950,- videoViews: 15000,- },- ],-};--// Category key mappings for different datasets-const categoryKeys = {- default: "month",- bigLabels: "category",- denseTimeline: "period",- companyNames: "company",- countryData: "country",- financialQuarters: "quarter",- mixedLengths: "item",- edgeCases: "name",- minimal: "category",- expandCollapseMarketing: "channel",-};--// 🔥 ACTIVE DATA - For backward compatibility-const areaChartData = dataVariations.default;--const icons = {- desktop: Monitor,- mobile: TabletSmartphone,- tablet: Calendar,- sales: Globe,- revenue: Smartphone,- profit: Laptop,- visitors: Tv,- conversions: Watch,- users: Monitor,- sessions: TabletSmartphone,-} as const;--/**- * # ScrollableAreaChart Component Documentation- *- * The AreaChart is excellent for visualizing quantitative data and showing the volume of a metric over a progression.- * It's ideal for:- *- * - **Time-Series Analysis**: Showing how a value or volume changes over time.- * - **Showing Volume**: Emphasizing the magnitude of a value.- * - **Comparing Trends**: Stacking areas to show how different series contribute to a total.- *- * ## Key Features- *- * ### Advanced Label Handling- * - **Collision Detection**: Prevents X-axis labels from overlapping.- * - **Intelligent Truncation**: Automatically shortens long labels with an ellipsis (...).- * - **Horizontal Offset**: Ensures labels are correctly positioned for maximum readability.- *- * ### Interactive & Responsive- * - **Interactive Legend**: Toggle data series visibility. It gracefully handles overflow with a "Show More" feature.- * - **Hover Tooltips**: Choose between a standard tooltip or a floating one that follows the cursor.- * - **Responsive Design**: Adapts fluidly to its container's size.- *- * ### Customization- * - **Theming**: Comes with six pre-built color palettes.- * - **Area Styles**: Supports `linear`, `natural` (smooth), and `step` interpolation.- * - **Styling Options**: Control grid visibility, axes, and more.- */-const meta: Meta<AreaChartProps<typeof areaChartData>> = {- title: "Components/D3Charts/ScrollableAreaChart",- component: AreaChart,- parameters: {- layout: "centered",- docs: {- description: {- component: `-## Installation and Basic Usage--\`\`\`tsx-import { ScrollableAreaChart } from '@openuidev/react-ui';--const trafficData = [- { date: "2023-01-01", visits: 2200 },- { date: "2023-01-02", visits: 2500 },- { date: "2023-01-03", visits: 2300 },-];--// Basic implementation-<ScrollableAreaChart- data={trafficData}- categoryKey="date"- theme="ocean"-/>-\`\`\`--## Data Structure Requirements--Your data should be an array of objects. Each object must contain:-- A **category field** (string or number): This will be used for the X-axis labels (e.g., dates, names, etc.).-- One or more **data series fields** (number): These are the values that will be plotted on the Y-axis. The key of the field will be used as the series name in the legend and tooltip.--\`\`\`tsx-const salesData = [- { month: "January", desktop: 150, mobile: 90 },- { month: "February", desktop: 280, mobile: 180 },- { month: "March", desktop: 220, mobile: 140 },-];-\`\`\`--## Performance Considerations-- **Data Density**: For very large datasets, consider disabling animations to maintain smooth performance.-- **Responsiveness**: The chart is fully responsive, but test label visibility on very small screens.-- **Animation**: Controlled via \`isAnimationActive={false}\`.-`,- },- },- },- tags: ["!dev", "autodocs"],- argTypes: {- data: {- description: `-**Required.** An array of data objects for the area chart. Each object should contain:-- A category identifier (string/number) for the X-axis.-- One or more numeric values for the Y-axis.-`,- control: false,- table: {- type: { summary: "Array<Record<string, string | number>>" },- category: "📊 Data Configuration",- },- },- categoryKey: {- description:- "**Required.** The key in your data object that represents the category for the X-axis.",- control: false,- table: {- type: { summary: "string" },- category: "📊 Data Configuration",- },- },- theme: {- description:- "Specifies the color palette for the chart's areas, tooltips, and legend. Ignored when customPalette is provided.",- control: "select",- options: ["ocean", "orchid", "emerald", "sunset", "spectrum", "vivid"],- table: {- defaultValue: { summary: "ocean" },- category: "🎨 Visual Styling",- },- },- customPalette: {- description:- "Custom array of colors to use instead of the theme palette. Overrides the theme prop when provided.",- control: "object",- table: {- type: { summary: "string[]" },- category: "🎨 Visual Styling",- },- },- variant: {- description: "Determines the area interpolation method, affecting the shape of the curves.",- control: "radio",- options: ["linear", "natural", "step"],- table: {- defaultValue: { summary: "natural" },- category: "🎨 Visual Styling",- },- },- icons: {- description:- "An object mapping data series keys to React components to be used as icons in the legend.",- control: false,- table: {- type: { summary: "Record<string, React.ReactNode>" },- category: "🎨 Visual Styling",- },- },- grid: {- description: "Toggles the visibility of the background grid lines.",- control: "boolean",- table: {- defaultValue: { summary: "true" },- category: "📱 Display Options",- },- },- legend: {- description: "Toggles the visibility of the chart legend.",- control: "boolean",- table: {- defaultValue: { summary: "true" },- category: "📱 Display Options",- },- },- showYAxis: {- description: "Toggles the visibility of the Y-axis line and labels.",- control: "boolean",- table: {- defaultValue: { summary: "true" },- category: "📱 Display Options",- },- },- xAxisLabel: {- description: "A label to display below the X-axis.",- control: "text",- table: {- type: { summary: "React.ReactNode" },- category: "📱 Display Options",- },- },- yAxisLabel: {- description: "A label to display beside the Y-axis.",- control: "text",- table: {- type: { summary: "React.ReactNode" },- category: "📱 Display Options",- },- },- isAnimationActive: {- description: "Enables or disables the initial loading animation for the areas.",- control: "boolean",- table: {- defaultValue: { summary: "true" },- category: "🎬 Animation & Interaction",- },- },- height: {- description: "Sets a fixed height for the chart container in pixels.",- control: "number",- table: {- type: { summary: "number" },- category: "Layout & Sizing",- },- },- width: {- description: "Sets a fixed width for the chart container in pixels.",- control: "number",- table: {- type: { summary: "number" },- category: "Layout & Sizing",- },- },- className: {- description: "Custom CSS class to apply to the chart's container.",- control: "text",- table: {- type: { summary: "string" },- category: "Layout & Sizing",- },- },- },-} satisfies Meta<typeof AreaChart>;--export default meta;-type Story = StoryObj<typeof meta>;--/**- * ## Comprehensive Data Explorer- *- * This story serves as a comprehensive test suite for the AreaChart component.- * Use the buttons to switch between various datasets designed to test edge cases in:- *- * - **Label Collision**: Datasets with long, dense, or overlapping labels.- * - **Data Density**: Scenarios with few or many data points.- * - **Legend Overflow**: A dataset with many series to test legend expand/collapse functionality.- *- * It's an excellent tool for developers to see how the chart behaves under different conditions.- */-export const DataExplorer: Story = {- name: "🎛️ Comprehensive Data Explorer",- args: {- data: areaChartData,- categoryKey: "month",- theme: "ocean",- variant: "natural",- grid: true,- legend: true,- isAnimationActive: true,- showYAxis: true,- xAxisLabel: "Time Period",- yAxisLabel: "Values",- // height: 300,- },- render: (args: any) => {- const [selectedDataType, setSelectedDataType] =- useState<keyof typeof dataVariations>("default");-- const currentData = dataVariations[selectedDataType];- const currentCategoryKey = categoryKeys[selectedDataType];-- const buttonStyle = {- margin: "2px",- padding: "6px 12px",- fontSize: "12px",- border: "1px solid #ddd",- borderRadius: "4px",- cursor: "pointer",- background: "#fff",- fontFamily: "monospace",- };-- const activeButtonStyle = {- ...buttonStyle,- background: "#007acc",- color: "white",- border: "1px solid #007acc",- };-- return (- <div>- <div- style={{- marginBottom: "16px",- padding: "12px",- background: "#f8f9fa",- borderRadius: "8px",- border: "1px solid #e9ecef",- width: "600px",- }}- >- <strong>🏷️ Label Collision Test Suite:</strong>- <div style={{ marginTop: "8px", display: "flex", flexWrap: "wrap", gap: "4px" }}>- <button- onClick={() => setSelectedDataType("default")}- style={selectedDataType === "default" ? activeButtonStyle : buttonStyle}- >- 📅 Default (12 months)- </button>- <button- onClick={() => setSelectedDataType("bigLabels")}- style={selectedDataType === "bigLabels" ? activeButtonStyle : buttonStyle}- >- 🏷️ Big Labels (Collision Test)- </button>- <button- onClick={() => setSelectedDataType("denseTimeline")}- style={selectedDataType === "denseTimeline" ? activeButtonStyle : buttonStyle}- >- 📅 Dense Timeline (16 periods)- </button>- <button- onClick={() => setSelectedDataType("companyNames")}- style={selectedDataType === "companyNames" ? activeButtonStyle : buttonStyle}- >- 🏢 Company Names- </button>- <button- onClick={() => setSelectedDataType("countryData")}- style={selectedDataType === "countryData" ? activeButtonStyle : buttonStyle}- >- 🌍 Country Names- </button>- <button- onClick={() => setSelectedDataType("financialQuarters")}- style={selectedDataType === "financialQuarters" ? activeButtonStyle : buttonStyle}- >- 📈 Financial Quarters- </button>- <button- onClick={() => setSelectedDataType("mixedLengths")}- style={selectedDataType === "mixedLengths" ? activeButtonStyle : buttonStyle}- >- 🔤 Mixed Lengths- </button>- <button- onClick={() => setSelectedDataType("edgeCases")}- style={selectedDataType === "edgeCases" ? activeButtonStyle : buttonStyle}- >- 🎯 Edge Cases- </button>- <button- onClick={() => setSelectedDataType("minimal")}- style={selectedDataType === "minimal" ? activeButtonStyle : buttonStyle}- >- 📱 Minimal (3 items)- </button>- <button- onClick={() => setSelectedDataType("expandCollapseMarketing")}- style={- selectedDataType === "expandCollapseMarketing" ? activeButtonStyle : buttonStyle- }- >- 🔄 Marketing Channels (12 items)- </button>- </div>- <div- style={{ marginTop: "12px", fontSize: "12px", color: "#666", fontFamily: "monospace" }}- >- <div>- <strong>Current Dataset:</strong> {selectedDataType}- </div>- <div>- <strong>Items:</strong> {currentData.length} | <strong>Category Key:</strong>{" "}- {currentCategoryKey}- </div>- <div>- <strong>Features:</strong> Auto-truncation, Collision Detection, Horizontal Offset- </div>- </div>- </div>- <Card style={{ width: "600px" }}>- <AreaChart {...args} data={currentData} categoryKey={currentCategoryKey} />- </Card>- </div>- );- },- parameters: {- docs: {- description: {- story:- "**🏷️ Big Labels Focus:** This story specifically tests label collision detection and truncation scenarios. Use the buttons to switch between different data variations that stress-test the chart's ability to handle long category names.\n\n**Key Features:**\n- ✂️ **Auto-truncation** with ellipsis for long labels\n- 🔍 **Collision detection** prevents overlapping text\n- ↔️ **Horizontal offset** for better visual distribution\n- 🚫 **No angle rotation** - labels stay horizontal for readability\n\n**Test Cases:**\n- **Big Labels**: Extremely long category names that trigger truncation\n- **Dense Timeline**: Many items with medium-length labels\n- **Company Names**: Real-world business names with varying lengths\n- **Mixed Lengths**: Combination of short and long labels\n- **Edge Cases**: Extreme scenarios for boundary testing",- },- },- },-};--/**- * ## Big Labels- *- * This story demonstrates the chart's ability to handle very long category labels.- * The chart's intelligent truncation and collision detection should be visible here.- * X-axis labels that are too long to fit will be gracefully truncated with an ellipsis.- */-export const BigLabelsStory: Story = {- name: "🏷️ Big Labels (Collision Detection)",- args: {- data: dataVariations.bigLabels as any,- categoryKey: "category" as any,- theme: "emerald",- variant: "natural",- grid: true,- legend: true,- isAnimationActive: true,- showYAxis: true,- },- render: (args: any) => (- <Card style={{ width: "700px" }}>- <AreaChart {...args} />- </Card>- ),- parameters: {- docs: {- description: {- story:- "Tests the chart's collision detection system with extremely long category names. Labels should be automatically truncated with ellipsis (...) to prevent overlapping.",- },- },- },-};--/**- * ## Dense Timeline- *- * Tests how the chart handles many data points with medium-length period labels.- * The chart should enable horizontal scrolling and apply intelligent label truncation.- * This scenario is common in financial or analytical dashboards where many time periods are displayed.- */-export const DenseTimelineStory: Story = {- name: "📅 Dense Timeline (Many Periods)",- args: {- data: dataVariations.denseTimeline as any,- categoryKey: "period" as any,- theme: "sunset",- variant: "natural",- grid: true,- legend: true,- isAnimationActive: true,- showYAxis: true,- },- render: (args: any) => (- <Card style={{ width: "500px" }}>- <AreaChart {...args} />- </Card>- ),- parameters: {- docs: {- description: {- story:- "Tests how the chart handles many data points with medium-length period labels. The chart should enable horizontal scrolling and apply intelligent label truncation.",- },- },- },-};--/**- * ## Company Names- *- * This story tests the chart with real-world company names that have varying lengths.- * It demonstrates how the chart handles business data with naturally occurring long labels.- */-export const CompanyNamesStory: Story = {- name: "🏢 Company Names (Real-world Labels)",- args: {- data: dataVariations.companyNames as any,- categoryKey: "company" as any,- theme: "vivid",- variant: "natural",- grid: true,- legend: true,- isAnimationActive: true,- showYAxis: true,- },- render: (args: any) => (- <Card style={{ width: "700px" }}>- <AreaChart {...args} />- </Card>- ),- parameters: {- docs: {- description: {- story:- "Tests with real-world company names that have varying lengths. Demonstrates how the chart handles business data with naturally occurring long labels.",- },- },- },-};--/**- * ## Country Names- *- * This story tests the chart with official country names, which are often long.- * It shows how geographic data is handled by the label collision detection system.- */-export const CountryDataStory: Story = {- name: "🌍 Country Names (Geographic Labels)",- args: {- data: dataVariations.countryData as any,- categoryKey: "country" as any,- theme: "orchid",- variant: "natural",- grid: true,- legend: true,- isAnimationActive: true,- showYAxis: true,- },- render: (args: any) => (- <Card style={{ width: "600px" }}>- <AreaChart {...args} />- </Card>- ),- parameters: {- docs: {- description: {- story:- "Tests with official country names that include full formal names. Shows how geographic data with naturally long names is handled by the collision detection system.",- },- },- },-};--/**- * ## Mixed Lengths- *- * This story tests the chart's ability to handle a mix of very short and very long labels- * within the same dataset, demonstrating its adaptive truncation behavior.- */-export const MixedLengthsStory: Story = {- name: "🔤 Mixed Lengths (Varied Label Sizes)",- args: {- data: dataVariations.mixedLengths as any,- categoryKey: "item" as any,- theme: "spectrum",- variant: "linear",- grid: true,- legend: true,- isAnimationActive: true,- showYAxis: true,- },- render: (args: any) => (- <Card style={{ width: "500px" }}>- <AreaChart {...args} />- </Card>- ),- parameters: {- docs: {- description: {- story:- "Tests the chart's ability to handle a mix of very short and very long labels within the same dataset. Demonstrates adaptive truncation behavior.",- },- },- },-};--/**- * ## Edge Cases- *- * This story pushes the collision detection and truncation system to its limits- * with exceptionally long labels and minimal data points.- */-export const EdgeCasesStory: Story = {- name: "🎯 Edge Cases (Extreme Scenarios)",- args: {- data: dataVariations.edgeCases as any,- categoryKey: "name" as any,- theme: "ocean",- variant: "step",- grid: true,- legend: true,- isAnimationActive: true,- showYAxis: true,- },- render: (args: any) => (- <Card style={{ width: "400px" }}>- <AreaChart {...args} />- </Card>- ),- parameters: {- docs: {- description: {- story:- "Tests extreme edge cases with exceptionally long labels and minimal data points. Pushes the collision detection and truncation system to its limits.",- },- },- },-};--/**- * ## Minimal Data- *- * A baseline test with a small dataset and standard-length labels. This serves as a control- * case to compare against the more complex label scenarios.- */-export const MinimalDataStory: Story = {- name: "📱 Minimal Data (Baseline)",- args: {- data: dataVariations.minimal as any,- categoryKey: "category" as any,- theme: "emerald",- variant: "natural",- grid: true,- legend: true,- isAnimationActive: true,- showYAxis: true,- },- render: (args: any) => (- <Card style={{ width: "400px" }}>- <AreaChart {...args} />- </Card>- ),- parameters: {- docs: {- description: {- story:- "Baseline test with minimal data and standard-length labels. Provides a control case to compare against the big label scenarios.",- },- },- },-};--/**- * ## Legend Expand/Collapse- *- * Tests the legend's expand/collapse functionality with a large number of data series.- * The legend should automatically show a "Show More" button when items overflow,- * allowing users to toggle between a collapsed and expanded view.- */-export const ExpandCollapseMarketingStory: Story = {- name: "🔄 Legend Expand/Collapse",- args: {- data: dataVariations.expandCollapseMarketing as any,- categoryKey: "channel" as any,- theme: "vivid",- variant: "natural",- grid: true,- legend: true,- isAnimationActive: true,- showYAxis: true,- },- render: (args: any) => (- <Card style={{ width: "600px" }}>- <AreaChart {...args} />- </Card>- ),- parameters: {- docs: {- description: {- story:- "Tests the legend expand/collapse functionality with 12 marketing channels that have long descriptive names. The legend should automatically show a 'Show More' button when items overflow the container width, allowing users to toggle between collapsed and expanded states.",- },- },- },-};--/**- * ## Custom Palette- *- * This story demonstrates how to use the customPalette prop to provide your own color scheme- * for the chart. This is useful when you need to match your brand colors or create- * specific visual themes.- */--export const CustomPaletteStory: Story = {- name: "🎨 Custom Palette",- args: {- data: dataVariations.default as any,- categoryKey: "month" as any,- theme: "ocean", // This will be overridden by customPalette- variant: "natural",- grid: true,- legend: true,- isAnimationActive: true,- showYAxis: true,- xAxisLabel: "Month",- yAxisLabel: "Traffic",- },- render: (args: any) => (- <div>- <div- style={{- marginBottom: "16px",- padding: "12px",- background: "#f8f9fa",- borderRadius: "8px",- border: "1px solid #e9ecef",- }}- >- <h4 style={{ margin: "0 0 8px 0", color: "#333" }}>🎨 Custom Color Palette</h4>- <p style={{ margin: "0 0 12px 0", fontSize: "14px", color: "#666" }}>- This chart uses a custom color palette instead of the default theme colors.- </p>- <div style={{ display: "flex", gap: "8px", flexWrap: "wrap" }}>- {args.customPalette?.map((color: string, index: number) => (- <div- key={index}- style={{- display: "flex",- alignItems: "center",- gap: "4px",- padding: "4px 8px",- background: "white",- borderRadius: "4px",- border: "1px solid #ddd",- fontSize: "12px",- }}- >- <div- style={{- width: "12px",- height: "12px",- borderRadius: "2px",- backgroundColor: color,- border: "1px solid #ccc",- }}- />- <span style={{ fontFamily: "monospace" }}>{color}</span>- </div>- ))}- </div>- </div>- <Card style={{ width: "600px" }}>- <AreaChart {...args} />- </Card>- </div>- ),- parameters: {- docs: {- description: {- story:- 'Demonstrates how to use the `customPalette` prop to provide your own color scheme for the chart. When `customPalette` is provided, it overrides the `theme` prop and uses your specified colors instead of the predefined theme palettes.\n\n**Key Features:**\n- 🎨 **Custom Colors**: Override default theme colors with your own palette\n- 🔄 **Theme Override**: The `theme` prop is ignored when `customPalette` is provided\n- 📊 **Consistent Distribution**: Colors are distributed evenly across data series\n- 🎯 **Brand Matching**: Perfect for matching your application\'s brand colors\n\n**Usage:**\n```tsx\n<AreaChart\n data={data}\n categoryKey="month"\n customPalette={["#FF6B6B", "#4ECDC4", "#45B7D1"]}\n // theme prop is ignored when customPalette is provided\n/>\n```',- },- },- },-};--/**- * ## Responsive Behavior Demo- *- * This story demonstrates the responsive capabilities of the AreaChart. Drag the handles- * on the container to resize it and observe how the chart adapts.- *- * **Responsive Features:**- * - **Label Truncation**: More aggressive truncation on smaller container widths.- * - **Layout Adaptation**: Chart elements adjust to fit the available space.- * - **Legend Behavior**: The legend may wrap or show expand/collapse buttons as needed.- */-export const ResponsiveBehaviorDemo: Story = {- name: "📱 Responsive Behavior Demo",- args: {- data: dataVariations.bigLabels as any,- categoryKey: "category" as any,- theme: "sunset",- variant: "natural",- grid: true,- legend: true,- isAnimationActive: false,- showYAxis: true,- },- render: (args: any) => {- const [dimensions, setDimensions] = useState<{ width: number; height: number | string }>({- width: 700,- height: "auto",- });-- const handleMouseDown = (e: React.MouseEvent<HTMLDivElement>, handle: string) => {- e.preventDefault();- e.stopPropagation();- const startX = e.clientX;- const startY = e.clientY;- const startWidth = dimensions.width;- const startHeight = (e.currentTarget.parentElement as HTMLElement).offsetHeight;-- const doDrag = (e: MouseEvent) => {- const dx = e.clientX - startX;- const dy = e.clientY - startY;- let newWidth = startWidth;- let newHeight = startHeight;-- if (handle.includes("e")) newWidth = startWidth + dx;- if (handle.includes("w")) newWidth = startWidth - dx;- if (handle.includes("s")) newHeight = startHeight + dy;- if (handle.includes("n")) newHeight = startHeight - dy;-- setDimensions({- width: Math.max(300, newWidth),- height: "auto",- });- };-- const stopDrag = () => {- document.removeEventListener("mousemove", doDrag);- document.removeEventListener("mouseup", stopDrag);- };-- document.addEventListener("mousemove", doDrag);- document.addEventListener("mouseup", stopDrag);- };-- const handleStyle: React.CSSProperties = {- position: "absolute",- background: "#3b82f6",- opacity: 0.6,- zIndex: 10,- transition: "opacity 0.2s ease",- };-- return (- <div style={{ padding: "20px" }}>- <div style={{ marginBottom: "20px" }}>- <h3 style={{ margin: "0 0 8px 0", fontSize: "18px", fontWeight: "600" }}>- Responsive Behavior Demonstration- </h3>- <p style={{ margin: "0 0 12px 0", color: "#666", fontSize: "14px" }}>- Drag the edges or corners of the container below to see how the chart adapts- </p>- <div- style={{- padding: "12px",- backgroundColor: "#e3f2fd",- borderRadius: "6px",- fontSize: "12px",- color: "#1565c0",- }}- >- <strong>🎯 Try This:</strong> Resize the container to see automatic label truncation and- layout adjustments.- </div>- </div>-- <Card- style={{- position: "relative",- width: `${dimensions.width}px`,- height:- typeof dimensions.height === "number" ? `${dimensions.height}px` : dimensions.height,- border: "2px dashed #9ca3af",- padding: "20px",- boxSizing: "border-box",- overflow: "hidden",- cursor: "default",- }}- >- <AreaChart {...args} />-- {/* Resize Handles */}- <div- style={{ ...handleStyle, top: -2, left: 0, right: 0, height: 12, cursor: "ns-resize" }}- onMouseDown={(e) => handleMouseDown(e, "n")}- />- <div- style={{- ...handleStyle,- bottom: -2,- left: 0,- right: 0,- height: 12,- cursor: "ns-resize",- }}- onMouseDown={(e) => handleMouseDown(e, "s")}- />- <div- style={{ ...handleStyle, top: 0, bottom: 0, left: -2, width: 12, cursor: "ew-resize" }}- onMouseDown={(e) => handleMouseDown(e, "w")}- />- <div- style={{ ...handleStyle, top: 0, bottom: 0, right: -2, width: 12, cursor: "ew-resize" }}- onMouseDown={(e) => handleMouseDown(e, "e")}- />-- {/* Corner Handles */}- <div- style={{- ...handleStyle,- top: -2,- left: -2,- width: 20,- height: 20,- cursor: "nwse-resize",- borderRadius: "2px",- }}- onMouseDown={(e) => handleMouseDown(e, "nw")}- />- <div- style={{- ...handleStyle,- top: -2,- right: -2,- width: 20,- height: 20,- cursor: "nesw-resize",- borderRadius: "2px",- }}- onMouseDown={(e) => handleMouseDown(e, "ne")}- />- <div- style={{- ...handleStyle,- bottom: -2,- right: -2,- width: 20,- height: 20,- cursor: "nwse-resize",- borderRadius: "2px",- }}- onMouseDown={(e) => handleMouseDown(e, "se")}- />-- {/* Dimension Display */}- <div- style={{- position: "absolute",- bottom: 8,- right: 8,- background: "rgba(0,0,0,0.8)",- color: "white",- padding: "4px 8px",- borderRadius: "4px",- fontSize: "11px",- fontFamily: "monospace",- fontWeight: "500",- }}- >- {dimensions.width}px ×{" "}- {typeof dimensions.height === "number" ? `${dimensions.height}px` : "auto"}- </div>- </Card>- </div>- );- },-};diff --git a/packages/react-ui/src/components/D3Charts/AreaChart/stories/areaChartCondensed.stories.tsx b/packages/react-ui/src/components/D3Charts/AreaChart/stories/areaChartCondensed.stories.tsxdeleted file mode 100644index 3a064e0c6..000000000--- a/packages/react-ui/src/components/D3Charts/AreaChart/stories/areaChartCondensed.stories.tsx+++ /dev/null@@ -1,1422 +0,0 @@-// Copy of Charts/AreaChartCondensed/stories/areaChartCondensed.stories.tsx with only the chart import and the title changed:-// the same args and renders, rendering the D3Charts chart via-// ../../stories/rechartsStoryAdapters.-import type { Meta, StoryObj } from "@storybook/react";-import {- Calendar,- Globe,- Laptop,- Monitor,- Smartphone,- TabletSmartphone,- Tv,- Watch,-} from "lucide-react";-import { useState } from "react";-import { Card } from "../../../Card";-import { AreaChartCondensed, AreaChartCondensedProps } from "../../stories/rechartsStoryAdapters";--// 🔥 COMPREHENSIVE DATA VARIATIONS - Designed to test various scenarios-const dataVariations = {- default: [- { month: "January", desktop: 150, mobile: 90, tablet: 120 },- { month: "February", desktop: 280, mobile: 180, tablet: 140 },- { month: "March", desktop: 220, mobile: 140, tablet: 160 },- { month: "April", desktop: 180, mobile: 160, tablet: 180 },- { month: "May", desktop: 250, mobile: 120, tablet: 140 },- { month: "June", desktop: 300, mobile: 180, tablet: 160 },- { month: "July", desktop: 350, mobile: 220, tablet: 180 },- { month: "August", desktop: 400, mobile: 240, tablet: 200 },- { month: "September", desktop: 450, mobile: 260, tablet: 220 },- { month: "October", desktop: 500, mobile: 280, tablet: 240 },- { month: "November", desktop: 550, mobile: 300, tablet: 260 },- { month: "December", desktop: 600, mobile: 320, tablet: 280 },- ],- // 🏷️ BIG LABELS - Testing angled tick labels- bigLabels: [- {- category: "Very Long Category Name That Should Be Truncated",- sales: 150,- revenue: 90,- profit: 120,- },- {- category: "Another Extremely Long Label That Causes Collisions",- sales: 280,- revenue: 180,- profit: 140,- },- {- category: "Super Duper Long Category Name That Tests Truncation",- sales: 220,- revenue: 140,- profit: 160,- },- {- category: "Incredibly Long Text That Should Trigger Collision Detection",- sales: 180,- revenue: 160,- profit: 180,- },- {- category: "Maximum Length Category Name That Tests All Edge Cases",- sales: 250,- revenue: 120,- profit: 140,- },- {- category: "Extra Long Business Category Name With Many Words",- sales: 300,- revenue: 180,- profit: 160,- },- {- category: "Comprehensive Long Label For Testing Horizontal Offset",- sales: 350,- revenue: 220,- profit: 180,- },- {- category: "Extended Category Name That Pushes Truncation Limits",- sales: 400,- revenue: 240,- profit: 200,- },- ],- // 📅 DENSE TIMELINE - Many items with medium-length labels- denseTimeline: [- { period: "Q1 2022 Jan-Mar", visitors: 120, conversions: 15, revenue: 1200 },- { period: "Q1 2022 Apr-Jun", visitors: 150, conversions: 22, revenue: 1800 },- { period: "Q2 2022 Jul-Sep", visitors: 180, conversions: 28, revenue: 2100 },- { period: "Q2 2022 Oct-Dec", visitors: 200, conversions: 35, revenue: 2500 },- { period: "Q3 2023 Jan-Mar", visitors: 160, conversions: 18, revenue: 1600 },- { period: "Q3 2023 Apr-Jun", visitors: 190, conversions: 32, revenue: 2300 },- { period: "Q4 2023 Jul-Sep", visitors: 220, conversions: 40, revenue: 2800 },- { period: "Q4 2023 Oct-Dec", visitors: 240, conversions: 45, revenue: 3200 },- { period: "Q1 2024 Jan-Mar", visitors: 210, conversions: 38, revenue: 2700 },- { period: "Q1 2024 Apr-Jun", visitors: 230, conversions: 42, revenue: 3000 },- { period: "Q2 2024 Jul-Sep", visitors: 250, conversions: 48, revenue: 3400 },- { period: "Q2 2024 Oct-Dec", visitors: 270, conversions: 52, revenue: 3800 },- { period: "Q3 2024 Jan-Mar", visitors: 260, conversions: 50, revenue: 3600 },- { period: "Q3 2024 Apr-Jun", visitors: 280, conversions: 55, revenue: 4000 },- { period: "Q4 2024 Jul-Sep", visitors: 300, conversions: 60, revenue: 4300 },- { period: "Q4 2024 Oct-Dec", visitors: 290, conversions: 58, revenue: 4100 },- ],- // 🏢 COMPANY NAMES - Real-world long business names- companyNames: [- { company: "Apple Inc.", revenue: 394328000000, profit: 99803000000, marketCap: 3500000000000 },- {- company: "Microsoft Corporation",- revenue: 211915000000,- profit: 83383000000,- marketCap: 2800000000000,- },- {- company: "Alphabet Inc. (Google)",- revenue: 307394000000,- profit: 76033000000,- marketCap: 2100000000000,- },- {- company: "Amazon.com Inc.",- revenue: 574785000000,- profit: 33364000000,- marketCap: 1600000000000,- },- {- company: "Tesla Motors Inc.",- revenue: 96773000000,- profit: 15000000000,- marketCap: 800000000000,- },- {- company: "Meta Platforms Inc.",- revenue: 134902000000,- profit: 39370000000,- marketCap: 900000000000,- },- {- company: "NVIDIA Corporation",- revenue: 60922000000,- profit: 29760000000,- marketCap: 1800000000000,- },- {- company: "Berkshire Hathaway Inc.",- revenue: 364482000000,- profit: 96223000000,- marketCap: 780000000000,- },- ],- // 🌍 COUNTRY NAMES - Geographic labels with varying lengths- countryData: [- { country: "United States of America", population: 331900000, gdp: 26900000000000 },- { country: "People's Republic of China", population: 1412000000, gdp: 17700000000000 },- { country: "Federal Republic of Germany", population: 83200000, gdp: 4300000000000 },- { country: "United Kingdom of Great Britain", population: 67500000, gdp: 3100000000000 },- { country: "French Republic", population: 68000000, gdp: 2900000000000 },- { country: "Republic of India", population: 1380000000, gdp: 3700000000000 },- { country: "Federative Republic of Brazil", population: 215000000, gdp: 2100000000000 },- { country: "Russian Federation", population: 146000000, gdp: 1800000000000 },- ],- // 📈 FINANCIAL QUARTERS - Testing medium-density scenarios- financialQuarters: [- { quarter: "Q1 FY2022", revenue: 1200000, expenses: 800000, profit: 400000 },- { quarter: "Q2 FY2022", revenue: 1500000, expenses: 950000, profit: 550000 },- { quarter: "Q3 FY2022", revenue: 1800000, expenses: 1100000, profit: 700000 },- { quarter: "Q4 FY2022", revenue: 2000000, expenses: 1300000, profit: 700000 },- { quarter: "Q1 FY2023", revenue: 2200000, expenses: 1400000, profit: 800000 },- { quarter: "Q2 FY2023", revenue: 2500000, expenses: 1600000, profit: 900000 },- { quarter: "Q3 FY2023", revenue: 2800000, expenses: 1800000, profit: 1000000 },- { quarter: "Q4 FY2023", revenue: 3000000, expenses: 1900000, profit: 1100000 },- ],- // 🔤 MIXED LENGTHS - Testing various label length scenarios- mixedLengths: [- { item: "A", valueA: 100, valueB: 80 },- { item: "Short", valueA: 150, valueB: 120 },- { item: "Medium Length Item", valueA: 200, valueB: 160 },- { item: "Very Long Item Name That Tests Truncation", valueA: 250, valueB: 200 },- { item: "B", valueA: 180, valueB: 140 },- { item: "Another Really Long Category Name", valueA: 220, valueB: 180 },- { item: "XL", valueA: 190, valueB: 150 },- ],- // 🎯 EDGE CASES - Extreme scenarios- edgeCases: [- {- name: "SinglePointDataSetForTestingEdgeCasesInCollisionDetectionAndLabelTruncationFunctionality",- value: 500,- },- {- name: "SecondExtremelyLongDataPointNameThatShouldDefinitelyTriggerTruncationMechanisms",- value: 600,- },- ],- // 📱 MINIMAL - Small dataset for baseline testing- minimal: [- { category: "Mobile Devices", users: 150, sessions: 90 },- { category: "Desktop Computers", users: 280, sessions: 180 },- { category: "Tablet Devices", users: 220, sessions: 140 },- ],-};--// Category key mappings for different datasets-const categoryKeys = {- default: "month",- bigLabels: "category",- denseTimeline: "period",- companyNames: "company",- countryData: "country",- financialQuarters: "quarter",- mixedLengths: "item",- edgeCases: "name",- minimal: "category",-};--// 🔥 ACTIVE DATA - For backward compatibility-const areaChartCondensedData = dataVariations.default;--const icons = {- desktop: Monitor,- mobile: TabletSmartphone,- tablet: Calendar,- sales: Globe,- revenue: Smartphone,- profit: Laptop,- visitors: Tv,- conversions: Watch,- users: Monitor,- sessions: TabletSmartphone,- expenses: Calendar,- marketCap: Globe,- population: Monitor,- gdp: Smartphone,- valueA: Monitor,- valueB: TabletSmartphone,- value: Calendar,-} as const;--/**- * # AreaChart Component Documentation- *- * The AreaChart is a compact chart designed for space-constrained layouts- * like dashboards and sidebars. It's ideal for:- *- * - **Compact Dashboards**: Showing multiple metrics in limited space- * - **Sidebar Analytics**: Quick trend visualization without taking up too much room- * - **Dense Data Display**: Efficiently showing many data points in a small area- *- * ## Key Features- *- * ### Space-Efficient Design- * - **Compact Height**: Default 200px height for tight layouts- * - **Minimal Legend**: Legend is compact and doesn't take up vertical space- * - **Adjustable Tick Variants**: Choose between horizontal or angled labels for better space usage- *- * ### Flexible Label Handling- * - **Single Line Ticks**: Horizontal labels with automatic collision detection- * - **Angled Ticks**: -45° rotation for longer labels that need more space- * - **Smart Angle Calculation**: Automatically calculates optimal rotation based on label width- *- * ### Interactive & Responsive- * - **Hover Tooltips**: Standard tooltip showing all data series- * - **Responsive Design**: Adapts fluidly to its container's size- *- * ### Customization- * - **Theming**: Comes with six pre-built color palettes- * - **Area Styles**: Supports `linear`, `natural` (smooth), and `step` interpolation- * - **Styling Options**: Control grid visibility, axes, and more- */-const meta: Meta<AreaChartCondensedProps<typeof areaChartCondensedData>> = {- title: "Components/D3Charts/AreaChart",- component: AreaChartCondensed,- parameters: {- layout: "centered",- docs: {- description: {- component: `-## Installation and Basic Usage--\`\`\`tsx-import { AreaChart } from '@openuidev/react-ui';--const trafficData = [- { date: "2023-01-01", visits: 2200 },- { date: "2023-01-02", visits: 2500 },- { date: "2023-01-03", visits: 2300 },-];--// Basic implementation-<AreaChart- data={trafficData}- categoryKey="date"- theme="ocean"- height={200}-/>-\`\`\`--## Data Structure Requirements--Your data should be an array of objects. Each object must contain:-- A **category field** (string or number): This will be used for the X-axis labels (e.g., dates, names, etc.).-- One or more **data series fields** (number): These are the values that will be plotted on the Y-axis.--\`\`\`tsx-const salesData = [- { month: "January", desktop: 150, mobile: 90 },- { month: "February", desktop: 280, mobile: 180 },- { month: "March", desktop: 220, mobile: 140 },-];-\`\`\`--## Key Differences from AreaChart--- **Compact**: Designed for smaller spaces with a default height of 200px-- **No Interactive Legend**: Legend is simplified and non-interactive-- **Tick Variants**: Supports both horizontal (singleLine) and angled labels-- **Performance**: Optimized for quick rendering in dashboards--## Performance Considerations-- **Data Density**: For very large datasets, consider disabling animations-- **Responsiveness**: The chart is fully responsive, but test label visibility on small screens-- **Animation**: Controlled via \`isAnimationActive={false}\`-`,- },- },- },- tags: ["!dev", "autodocs"],- argTypes: {- data: {- description: `-**Required.** An array of data objects for the area chart. Each object should contain:-- A category identifier (string/number) for the X-axis.-- One or more numeric values for the Y-axis.-`,- control: false,- table: {- type: { summary: "Array<Record<string, string | number>>" },- category: "📊 Data Configuration",- },- },- categoryKey: {- description:- "**Required.** The key in your data object that represents the category for the X-axis.",- control: false,- table: {- type: { summary: "string" },- category: "📊 Data Configuration",- },- },- theme: {- description:- "Specifies the color palette for the chart's areas and tooltips. Ignored when customPalette is provided.",- control: "select",- options: ["ocean", "orchid", "emerald", "sunset", "spectrum", "vivid"],- table: {- defaultValue: { summary: "ocean" },- category: "🎨 Visual Styling",- },- },- customPalette: {- description:- "Custom array of colors to use instead of the theme palette. Overrides the theme prop when provided.",- control: "object",- table: {- type: { summary: "string[]" },- category: "🎨 Visual Styling",- },- },- variant: {- description: "Determines the area interpolation method, affecting the shape of the curves.",- 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' (rotated at optimal angle).",- control: "radio",- options: ["singleLine", "angled"],- table: {- defaultValue: { summary: "singleLine" },- category: "🎨 Visual Styling",- },- },- icons: {- description:- "An object mapping data series keys to React components to be used as icons in the legend.",- control: false,- table: {- type: { summary: "Record<string, React.ReactNode>" },- category: "🎨 Visual Styling",- },- },- grid: {- description: "Toggles the visibility of the background grid lines.",- control: "boolean",- table: {- defaultValue: { summary: "true" },- category: "📱 Display Options",- },- },- showYAxis: {- description: "Toggles the visibility of the Y-axis line and labels.",- control: "boolean",- table: {- defaultValue: { summary: "true" },- category: "📱 Display Options",- },- },- xAxisLabel: {- description: "A label to display below the X-axis.",- control: "text",- table: {- type: { summary: "React.ReactNode" },- category: "📱 Display Options",- },- },- yAxisLabel: {- description: "A label to display beside the Y-axis.",- control: "text",- table: {- type: { summary: "React.ReactNode" },- category: "📱 Display Options",- },- },- isAnimationActive: {- description: "Enables or disables the initial loading animation for the areas.",- control: "boolean",- table: {- defaultValue: { summary: "false" },- category: "🎬 Animation & Interaction",- },- },- height: {- description: "Sets a fixed height for the chart container in pixels.",- control: "number",- table: {- defaultValue: { summary: "200" },- type: { summary: "number" },- category: "Layout & Sizing",- },- },- width: {- description: "Sets a fixed width for the chart container in pixels.",- control: "number",- table: {- type: { summary: "number" },- category: "Layout & Sizing",- },- },- className: {- description: "Custom CSS class to apply to the chart's container.",- control: "text",- table: {- type: { summary: "string" },- category: "Layout & Sizing",- },- },- },-} satisfies Meta<typeof AreaChartCondensed>;--export default meta;-type Story = StoryObj<typeof meta>;--/**- * ## Comprehensive Data Explorer- *- * This story serves as a comprehensive test suite for the AreaChartCondensed component.- * Use the buttons to switch between various datasets designed to test edge cases in:- *- * - **Label Handling**: Datasets with long, dense, or overlapping labels.- * - **Data Density**: Scenarios with few or many data points.- * - **Tick Variants**: Toggle between horizontal and angled label orientations.- *- * It's an excellent tool for developers to see how the chart behaves under different conditions.- */-export const DataExplorer: Story = {- name: "🎛️ Comprehensive Data Explorer",- args: {- data: areaChartCondensedData,- categoryKey: "month",- theme: "ocean",- variant: "natural",- tickVariant: "singleLine",- grid: true,- isAnimationActive: false,- showYAxis: true,- xAxisLabel: "Time Period",- yAxisLabel: "Values",- height: 200,- },- render: (args: any) => {- const [selectedDataType, setSelectedDataType] =- useState<keyof typeof dataVariations>("default");- const [tickVariant, setTickVariant] = useState<"singleLine" | "angled">("singleLine");-- const currentData = dataVariations[selectedDataType];- const currentCategoryKey = categoryKeys[selectedDataType];-- const buttonStyle = {- margin: "2px",- padding: "6px 12px",- fontSize: "12px",- border: "1px solid #ddd",- borderRadius: "4px",- cursor: "pointer",- background: "#fff",- fontFamily: "monospace",- };-- const activeButtonStyle = {- ...buttonStyle,- background: "#007acc",- color: "white",- border: "1px solid #007acc",- };-- return (- <div>- <div- style={{- marginBottom: "16px",- padding: "12px",- background: "#f8f9fa",- borderRadius: "8px",- border: "1px solid #e9ecef",- width: "600px",- }}- >- <strong>🏷️ Dataset Selection:</strong>- <div style={{ marginTop: "8px", display: "flex", flexWrap: "wrap", gap: "4px" }}>- <button- onClick={() => setSelectedDataType("default")}- style={selectedDataType === "default" ? activeButtonStyle : buttonStyle}- >- 📅 Default (12 months)- </button>- <button- onClick={() => setSelectedDataType("bigLabels")}- style={selectedDataType === "bigLabels" ? activeButtonStyle : buttonStyle}- >- 🏷️ Big Labels- </button>- <button- onClick={() => setSelectedDataType("denseTimeline")}- style={selectedDataType === "denseTimeline" ? activeButtonStyle : buttonStyle}- >- 📅 Dense Timeline (16)- </button>- <button- onClick={() => setSelectedDataType("companyNames")}- style={selectedDataType === "companyNames" ? activeButtonStyle : buttonStyle}- >- 🏢 Company Names- </button>- <button- onClick={() => setSelectedDataType("countryData")}- style={selectedDataType === "countryData" ? activeButtonStyle : buttonStyle}- >- 🌍 Country Names- </button>- <button- onClick={() => setSelectedDataType("financialQuarters")}- style={selectedDataType === "financialQuarters" ? activeButtonStyle : buttonStyle}- >- 📈 Financial Quarters- </button>- <button- onClick={() => setSelectedDataType("mixedLengths")}- style={selectedDataType === "mixedLengths" ? activeButtonStyle : buttonStyle}- >- 🔤 Mixed Lengths- </button>- <button- onClick={() => setSelectedDataType("edgeCases")}- style={selectedDataType === "edgeCases" ? activeButtonStyle : buttonStyle}- >- 🎯 Edge Cases- </button>- <button- onClick={() => setSelectedDataType("minimal")}- style={selectedDataType === "minimal" ? activeButtonStyle : buttonStyle}- >- 📱 Minimal (3 items)- </button>- </div>- <div style={{ marginTop: "12px" }}>- <strong>📐 Tick Variant:</strong>- <div style={{ marginTop: "8px", display: "flex", gap: "4px" }}>- <button- onClick={() => setTickVariant("singleLine")}- style={tickVariant === "singleLine" ? activeButtonStyle : buttonStyle}- >- Horizontal Labels- </button>- <button- onClick={() => setTickVariant("angled")}- style={tickVariant === "angled" ? activeButtonStyle : buttonStyle}- >- Angled Labels- </button>- </div>- </div>- <div- style={{ marginTop: "12px", fontSize: "12px", color: "#666", fontFamily: "monospace" }}- >- <div>- <strong>Current Dataset:</strong> {selectedDataType}- </div>- <div>- <strong>Items:</strong> {currentData.length} | <strong>Category Key:</strong>{" "}- {currentCategoryKey} | <strong>Tick:</strong> {tickVariant}- </div>- </div>- </div>- <Card style={{ width: "600px" }}>- <AreaChartCondensed- {...args}- data={currentData}- categoryKey={currentCategoryKey}- tickVariant={tickVariant}- />- </Card>- </div>- );- },- parameters: {- docs: {- description: {- story:- "**🎛️ Interactive Explorer:** This story allows you to explore different datasets and tick variants interactively. Use the buttons to switch between:\n\n**Datasets:**\n- **Default**: Standard 12-month data\n- **Big Labels**: Extremely long category names\n- **Dense Timeline**: Many items with medium-length labels\n- **Company Names**: Real-world business names\n- **Country Names**: Geographic labels\n- **Financial Quarters**: Quarterly financial data\n- **Mixed Lengths**: Combination of short and long labels\n- **Edge Cases**: Extreme scenarios\n- **Minimal**: Baseline with 3 items\n\n**Tick Variants:**\n- **Horizontal Labels**: Standard single-line labels with collision detection\n- **Angled Labels**: Rotated labels for better space utilization",- },- },- },-};--/**- * ## Large Dataset with Sidebar Tooltip- *- * This story demonstrates the sidebar tooltip feature that appears when you have- * more than 10 data series. Click on any point in the chart to see the sidebar- * tooltip in action. This provides a better UX for viewing many data series at once.- */-export const LargeDatasetWithSidebarTooltip: Story = {- name: "🎯 Large Dataset (>10 Series) - Sidebar Tooltip",- args: {- data: [- {- month: "Jan",- series1: 120,- series2: 150,- series3: 180,- series4: 200,- series5: 160,- series6: 190,- series7: 220,- series8: 240,- series9: 210,- series10: 230,- series11: 250,- series12: 270,- series13: 260,- series14: 280,- series15: 300,- },- {- month: "Feb",- series1: 140,- series2: 170,- series3: 200,- series4: 220,- series5: 180,- series6: 210,- series7: 240,- series8: 260,- series9: 230,- series10: 250,- series11: 270,- series12: 290,- series13: 280,- series14: 300,- series15: 320,- },- {- month: "Mar",- series1: 160,- series2: 190,- series3: 220,- series4: 240,- series5: 200,- series6: 230,- series7: 260,- series8: 280,- series9: 250,- series10: 270,- series11: 290,- series12: 310,- series13: 300,- series14: 320,- series15: 340,- },- {- month: "Apr",- series1: 180,- series2: 210,- series3: 240,- series4: 260,- series5: 220,- series6: 250,- series7: 280,- series8: 300,- series9: 270,- series10: 290,- series11: 310,- series12: 330,- series13: 320,- series14: 340,- series15: 360,- },- {- month: "May",- series1: 200,- series2: 230,- series3: 260,- series4: 280,- series5: 240,- series6: 270,- series7: 300,- series8: 320,- series9: 290,- series10: 310,- series11: 330,- series12: 350,- series13: 340,- series14: 360,- series15: 380,- },- {- month: "Jun",- series1: 220,- series2: 250,- series3: 280,- series4: 300,- series5: 260,- series6: 290,- series7: 320,- series8: 340,- series9: 310,- series10: 330,- series11: 350,- series12: 370,- series13: 360,- series14: 380,- series15: 400,- },- {- month: "Jul",- series1: 240,- series2: 270,- series3: 300,- series4: 320,- series5: 280,- series6: 310,- series7: 340,- series8: 360,- series9: 330,- series10: 350,- series11: 370,- series12: 390,- series13: 380,- series14: 400,- series15: 420,- },- {- month: "Aug",- series1: 260,- series2: 290,- series3: 320,- series4: 340,- series5: 300,- series6: 330,- series7: 360,- series8: 380,- series9: 350,- series10: 370,- series11: 390,- series12: 410,- series13: 400,- series14: 420,- series15: 440,- },- {- month: "Sep",- series1: 280,- series2: 310,- series3: 340,- series4: 360,- series5: 320,- series6: 350,- series7: 380,- series8: 400,- series9: 370,- series10: 390,- series11: 410,- series12: 430,- series13: 420,- series14: 440,- series15: 460,- },- {- month: "Oct",- series1: 300,- series2: 330,- series3: 360,- series4: 380,- series5: 340,- series6: 370,- series7: 400,- series8: 420,- series9: 390,- series10: 410,- series11: 430,- series12: 450,- series13: 440,- series14: 460,- series15: 480,- },- {- month: "Nov",- series1: 320,- series2: 350,- series3: 380,- series4: 400,- series5: 360,- series6: 390,- series7: 420,- series8: 440,- series9: 410,- series10: 430,- series11: 450,- series12: 470,- series13: 460,- series14: 480,- series15: 500,- },- {- month: "Dec",- series1: 340,- series2: 370,- series3: 400,- series4: 420,- series5: 380,- series6: 410,- series7: 440,- series8: 460,- series9: 430,- series10: 450,- series11: 470,- series12: 490,- series13: 480,- series14: 500,- series15: 520,- },- ] as any,- categoryKey: "month" as any,- theme: "ocean",- variant: "natural",- tickVariant: "singleLine",- grid: true,- isAnimationActive: false,- showYAxis: true,- xAxisLabel: "Months",- yAxisLabel: "Performance Metrics",- height: 300,- },- render: (args: any) => (- <div>- <div- style={{- marginBottom: "16px",- padding: "16px",- background: "#e3f2fd",- borderRadius: "8px",- border: "2px solid #2196f3",- maxWidth: "700px",- }}- >- <div style={{ fontSize: "14px", marginBottom: "8px" }}>- <strong>🎯 Sidebar Tooltip Demo</strong>- </div>- <div style={{ fontSize: "13px", color: "#1565c0", lineHeight: "1.6" }}>- This chart has <strong>15 data series</strong> (more than 10). <br />- <strong>✨ Click on any point</strong> in the chart to open the sidebar tooltip on the- right side.- <br />- The sidebar provides a scrollable list of all series values at that point, making it easy- to view large datasets.- <br />- <em>- 💡 Try hovering first (shows inline tooltip), then click to see the sidebar version!- </em>- </div>- </div>- <Card style={{ width: "700px" }}>- <AreaChartCondensed {...args} />- </Card>- </div>- ),- parameters: {- docs: {- description: {- story:- "**🎯 Large Dataset Handling:** When your chart has more than 10 data series, the inline tooltip becomes too crowded. This story demonstrates the sidebar tooltip feature:\n\n**Features:**\n- **15 data series** to showcase the sidebar tooltip\n- **Click interaction:** Click any point to open the sidebar\n- **Scrollable view:** All series values in an organized, scrollable list\n- **Better UX:** Cleaner way to view many data points simultaneously\n- **Color-coded:** Each series maintains its color for easy identification\n\n**Usage:**\n1. Hover over the chart to see the inline tooltip (works for smaller datasets)\n2. Click on any data point to open the sidebar tooltip\n3. Scroll through all 15 series values\n4. Click outside or on the X button to close the sidebar",- },- },- },-};--/**- * ## Big Labels- *- * This story demonstrates the chart's ability to handle very long category labels.- * The angled tick variant is particularly useful here for preventing label overlap.- */-export const BigLabelsStory: Story = {- name: "🏷️ Big Labels (Angled Ticks)",- args: {- data: dataVariations.bigLabels as any,- categoryKey: "category" as any,- theme: "emerald",- variant: "natural",- tickVariant: "angled",- grid: true,- isAnimationActive: false,- showYAxis: true,- height: 250,- },- render: (args: any) => (- <Card style={{ width: "700px" }}>- <AreaChartCondensed {...args} />- </Card>- ),- parameters: {- docs: {- description: {- story:- "Tests the chart with extremely long category names. The angled tick variant automatically rotates labels at an optimal angle to prevent overlapping and maximize readability.",- },- },- },-};--/**- * ## Dense Timeline- *- * Tests how the chart handles many data points with medium-length period labels.- * The angled tick variant helps display more labels without collision.- */-export const DenseTimelineStory: Story = {- name: "📅 Dense Timeline (Many Periods)",- args: {- data: dataVariations.denseTimeline as any,- categoryKey: "period" as any,- theme: "sunset",- variant: "natural",- tickVariant: "angled",- grid: true,- isAnimationActive: false,- showYAxis: true,- height: 250,- },- render: (args: any) => (- <Card style={{ width: "700px" }}>- <AreaChartCondensed {...args} />- </Card>- ),- parameters: {- docs: {- description: {- story:- "Tests how the chart handles many data points (16 periods) with medium-length labels. The angled tick variant provides better label visibility compared to horizontal labels.",- },- },- },-};--/**- * ## Company Names- *- * This story tests the chart with real-world company names that have varying lengths.- * It demonstrates how the chart handles business data with naturally occurring long labels.- */-export const CompanyNamesStory: Story = {- name: "🏢 Company Names (Real-world Labels)",- args: {- data: dataVariations.companyNames as any,- categoryKey: "company" as any,- theme: "vivid",- variant: "natural",- tickVariant: "angled",- grid: true,- isAnimationActive: false,- showYAxis: true,- height: 250,- },- render: (args: any) => (- <Card style={{ width: "700px" }}>- <AreaChartCondensed {...args} />- </Card>- ),- parameters: {- docs: {- description: {- story:- "Tests with real-world company names that have varying lengths. Demonstrates how the chart handles business data with naturally occurring long labels.",- },- },- },-};--/**- * ## Country Names- *- * This story tests the chart with official country names, which are often long.- * It shows how geographic data is handled by the angled tick system.- */-export const CountryDataStory: Story = {- name: "🌍 Country Names (Geographic Labels)",- args: {- data: dataVariations.countryData as any,- categoryKey: "country" as any,- theme: "orchid",- variant: "natural",- tickVariant: "angled",- grid: true,- isAnimationActive: false,- showYAxis: true,- height: 250,- },- render: (args: any) => (- <Card style={{ width: "700px" }}>- <AreaChartCondensed {...args} />- </Card>- ),- parameters: {- docs: {- description: {- story:- "Tests with official country names that include full formal names. Shows how geographic data with naturally long names is handled.",- },- },- },-};--/**- * ## Mixed Lengths- *- * This story tests the chart's ability to handle a mix of very short and very long labels- * within the same dataset, demonstrating its adaptive behavior.- */-export const MixedLengthsStory: Story = {- name: "🔤 Mixed Lengths (Varied Label Sizes)",- args: {- data: dataVariations.mixedLengths as any,- categoryKey: "item" as any,- theme: "spectrum",- variant: "linear",- tickVariant: "singleLine",- grid: true,- isAnimationActive: false,- showYAxis: true,- height: 200,- },- render: (args: any) => (- <Card style={{ width: "500px" }}>- <AreaChartCondensed {...args} />- </Card>- ),- parameters: {- docs: {- description: {- story:- "Tests the chart's ability to handle a mix of very short and very long labels within the same dataset.",- },- },- },-};--/**- * ## Edge Cases- *- * This story tests extreme edge cases with exceptionally long labels and minimal data points.- */-export const EdgeCasesStory: Story = {- name: "🎯 Edge Cases (Extreme Scenarios)",- args: {- data: dataVariations.edgeCases as any,- categoryKey: "name" as any,- theme: "ocean",- variant: "step",- tickVariant: "angled",- grid: true,- isAnimationActive: false,- showYAxis: true,- height: 250,- },- render: (args: any) => (- <Card style={{ width: "500px" }}>- <AreaChartCondensed {...args} />- </Card>- ),- parameters: {- docs: {- description: {- story:- "Tests extreme edge cases with exceptionally long labels and minimal data points. Pushes the label handling system to its limits.",- },- },- },-};--/**- * ## Minimal Data- *- * A baseline test with a small dataset and standard-length labels. This serves as a control- * case to compare against the more complex label scenarios.- */-export const MinimalDataStory: Story = {- name: "📱 Minimal Data (Baseline)",- args: {- data: dataVariations.minimal as any,- categoryKey: "category" as any,- theme: "emerald",- variant: "natural",- tickVariant: "singleLine",- grid: true,- isAnimationActive: false,- showYAxis: true,- height: 200,- },- render: (args: any) => (- <Card style={{ width: "400px" }}>- <AreaChartCondensed {...args} />- </Card>- ),- parameters: {- docs: {- description: {- story:- "Baseline test with minimal data and standard-length labels. Provides a control case to compare against complex scenarios.",- },- },- },-};--/**- * ## Custom Palette- *- * This story demonstrates how to use the customPalette prop to provide your own color scheme- * for the chart. This is useful when you need to match your brand colors.- */-export const CustomPaletteStory: Story = {- name: "🎨 Custom Palette",- args: {- data: dataVariations.default as any,- categoryKey: "month" as any,- theme: "ocean", // This will be overridden by customPalette- variant: "natural",- tickVariant: "singleLine",- grid: true,- isAnimationActive: false,- showYAxis: true,- xAxisLabel: "Month",- yAxisLabel: "Traffic",- customPalette: ["#FF6B6B", "#4ECDC4", "#45B7D1"],- height: 200,- },- render: (args: any) => (- <div>- <div- style={{- marginBottom: "16px",- padding: "12px",- background: "#f8f9fa",- borderRadius: "8px",- border: "1px solid #e9ecef",- width: "600px",- }}- >- <h4 style={{ margin: "0 0 8px 0", color: "#333" }}>🎨 Custom Color Palette</h4>- <p style={{ margin: "0 0 12px 0", fontSize: "14px", color: "#666" }}>- This chart uses a custom color palette instead of the default theme colors.- </p>- <div style={{ display: "flex", gap: "8px", flexWrap: "wrap" }}>- {args.customPalette?.map((color: string, index: number) => (- <div- key={index}- style={{- display: "flex",- alignItems: "center",- gap: "4px",- padding: "4px 8px",- background: "white",- borderRadius: "4px",- border: "1px solid #ddd",- fontSize: "12px",- }}- >- <div- style={{- width: "12px",- height: "12px",- borderRadius: "2px",- backgroundColor: color,- border: "1px solid #ccc",- }}- />- <span style={{ fontFamily: "monospace" }}>{color}</span>- </div>- ))}- </div>- </div>- <Card style={{ width: "600px" }}>- <AreaChartCondensed {...args} />- </Card>- </div>- ),- parameters: {- docs: {- description: {- story:- 'Demonstrates how to use the `customPalette` prop to provide your own color scheme. When `customPalette` is provided, it overrides the `theme` prop.\n\n**Usage:**\n```tsx\n<AreaChartCondensed\n data={data}\n categoryKey="month"\n customPalette={["#FF6B6B", "#4ECDC4", "#45B7D1"]}\n/>\n```',- },- },- },-};--/**- * ## Tick Variant Comparison- *- * Side-by-side comparison of single-line (horizontal) and angled tick variants.- * This helps you choose the right variant for your data.- */-export const TickVariantComparison: Story = {- name: "📐 Tick Variant Comparison",- render: () => (- <div style={{ display: "flex", flexDirection: "column", gap: "24px" }}>- <Card style={{ width: "700px", padding: "16px" }}>- <div style={{ marginBottom: "12px" }}>- <div style={{ fontSize: "16px", fontWeight: "600", marginBottom: "4px" }}>- Single Line Variant (Horizontal)- </div>- <div style={{ fontSize: "13px", color: "#666" }}>- Standard horizontal labels. Recharts automatically hides overlapping labels.- </div>- </div>- <AreaChartCondensed- data={dataVariations.bigLabels as any}- categoryKey="category"- tickVariant="singleLine"- theme="ocean"- height={200}- />- </Card>- <Card style={{ width: "700px", padding: "16px" }}>- <div style={{ marginBottom: "12px" }}>- <div style={{ fontSize: "16px", fontWeight: "600", marginBottom: "4px" }}>- Angled Variant (Rotated)- </div>- <div style={{ fontSize: "13px", color: "#666" }}>- Automatically rotates labels at an optimal angle. Shows more labels without collision.- </div>- </div>- <AreaChartCondensed- data={dataVariations.bigLabels as any}- categoryKey="category"- tickVariant="angled"- theme="emerald"- height={260}- />- </Card>- </div>- ),- parameters: {- docs: {- description: {- story:- "**Side-by-side comparison** of tick variants:\n\n- **Single Line**: Standard horizontal labels with automatic collision detection. Recharts hides overlapping labels.\n- **Angled**: Rotates labels at an optimal angle calculated based on label width and available space. Shows more labels without collision.\n\n**When to use each:**\n- Use **singleLine** for short labels or when you have few data points\n- Use **angled** for long labels or many data points where horizontal labels would overlap",- },- },- },-};--/**- * ## Responsive Behavior Demo- *- * This story demonstrates the responsive capabilities of the AreaChartCondensed.- * Drag the handles on the container to resize it and observe how the chart adapts.- */-export const ResponsiveBehaviorDemo: Story = {- name: "📱 Responsive Behavior Demo",- args: {- data: dataVariations.bigLabels as any,- categoryKey: "category" as any,- theme: "sunset",- variant: "natural",- tickVariant: "angled",- grid: true,- isAnimationActive: false,- showYAxis: true,- height: 250,- },- render: (args: any) => {- const [dimensions, setDimensions] = useState<{ width: number }>({- width: 700,- });-- const handleMouseDown = (e: React.MouseEvent<HTMLDivElement>, handle: string) => {- e.preventDefault();- e.stopPropagation();- const startX = e.clientX;- const startWidth = dimensions.width;-- const doDrag = (e: MouseEvent) => {- const dx = e.clientX - startX;- let newWidth = startWidth;-- if (handle.includes("e")) newWidth = startWidth + dx;- if (handle.includes("w")) newWidth = startWidth - dx;-- setDimensions({- width: Math.max(300, newWidth),- });- };-- const stopDrag = () => {- document.removeEventListener("mousemove", doDrag);- document.removeEventListener("mouseup", stopDrag);- };-- document.addEventListener("mousemove", doDrag);- document.addEventListener("mouseup", stopDrag);- };-- const handleStyle: React.CSSProperties = {- position: "absolute",- background: "#3b82f6",- opacity: 0.6,- zIndex: 10,- transition: "opacity 0.2s ease",- };-- return (- <div style={{ padding: "20px" }}>- <div style={{ marginBottom: "20px" }}>- <h3 style={{ margin: "0 0 8px 0", fontSize: "18px", fontWeight: "600" }}>- Responsive Behavior Demonstration- </h3>- <p style={{ margin: "0 0 12px 0", color: "#666", fontSize: "14px" }}>- Drag the left or right edges of the container to see how the chart adapts- </p>- <div- style={{- padding: "12px",- backgroundColor: "#e3f2fd",- borderRadius: "6px",- fontSize: "12px",- color: "#1565c0",- }}- >- <strong>🎯 Try This:</strong> Resize the container to see how angled labels adapt to- available space.- </div>- </div>-- <Card- style={{- position: "relative",- width: `${dimensions.width}px`,- border: "2px dashed #9ca3af",- padding: "20px",- boxSizing: "border-box",- overflow: "hidden",- cursor: "default",- }}- >- <AreaChartCondensed {...args} />-- {/* Resize Handles */}- <div- style={{ ...handleStyle, top: 0, bottom: 0, left: -2, width: 12, cursor: "ew-resize" }}- onMouseDown={(e) => handleMouseDown(e, "w")}- />- <div- style={{ ...handleStyle, top: 0, bottom: 0, right: -2, width: 12, cursor: "ew-resize" }}- onMouseDown={(e) => handleMouseDown(e, "e")}- />-- {/* Dimension Display */}- <div- style={{- position: "absolute",- bottom: 8,- right: 8,- background: "rgba(0,0,0,0.8)",- color: "white",- padding: "4px 8px",- borderRadius: "4px",- fontSize: "11px",- fontFamily: "monospace",- fontWeight: "500",- }}- >- {dimensions.width}px- </div>- </Card>- </div>- );- },-};diff --git a/packages/react-ui/src/components/D3Charts/BarChart/BarChart.tsx b/packages/react-ui/src/components/D3Charts/BarChart/BarChart.tsxdeleted file mode 100644index f355a9494..000000000--- a/packages/react-ui/src/components/D3Charts/BarChart/BarChart.tsx+++ /dev/null@@ -1,189 +0,0 @@-import clsx from "clsx";-import { useCallback } from "react";--import {- useCartesianChartOrchestrator,- useEffectiveAnimation,- useExportChartData,- useStackedData,- useXBandScale,- useYScale,-} from "../hooks";-import { ClipDefs } from "../shared/cartesian/ClipDefs";-import { CartesianXAxis } from "../shared/cartesian/axes/CartesianXAxis";-import { CartesianChartLayout } from "../shared/cartesian/layouts/CartesianChartLayout";-import { findBandIndex } from "../utils/mouseUtils";-import { BarSeries } from "./parts/BarSeries";-import { Crosshair } from "./parts/Crosshair";-import { HorizontalBarChartImpl } from "./parts/HorizontalBarChartImpl";--import { CHART_CLASS_PREFIX } from "../utils/constants";-import type { BarChartData, BarChartProps } from "./types";--/**- * Empty-data guard lives here, in a hook-free dispatcher: the chart impl below- * calls hooks unconditionally, so the "no data" branch must short-circuit- * *before* any hook runs (a count → 0 transition on a mounted chart would- * otherwise break the Rules of Hooks).- */-export function BarChart<T extends BarChartData>(props: BarChartProps<T>) {- if (!props.data || props.data.length === 0) {- return (- <div- className={clsx(- `${CHART_CLASS_PREFIX}-bar-chart-container ${CHART_CLASS_PREFIX}-chart-empty`,- props.className,- )}- >- <span className={`${CHART_CLASS_PREFIX}-chart-empty-text`}>No data available</span>- </div>- );- }- if (props.orientation === "horizontal") {- return <HorizontalBarChartImpl {...props} />;- }- return <BarChartImpl {...props} />;-}--function BarChartImpl<T extends BarChartData>({- data,- categoryKey,- customPalette,- variant = "grouped",- tickVariant: tickVariantProp,- barRadius = 4,- maxBarWidth,- internalLine = true,- internalLineColor,- internalLineWidth,- grid = true,- legend: showLegend = true,- icons,- isAnimationActive = false,- showYAxis = true,- xAxisLabel,- yAxisLabel,- className,- height,- width: fixedWidth,- fitLegendInHeight,- condensed = false,- density,- onClick,- yTickCount,-}: BarChartProps<T>) {- const animate = useEffectiveAnimation(isAnimationActive);- const mode = condensed ? "fit" : "scroll";-- const orch = useCartesianChartOrchestrator({- layout: mode,- data,- categoryKey,- themePaletteName: "barChartPalette",- customPalette,- showLegend,- showYAxis,- height,- fixedWidth,- fitLegendInHeight,- tickVariantProp: tickVariantProp ?? (condensed ? "singleLine" : "multiLine"),- chartIdPrefix: "d3bc",- icons,- onClick,- density,- stacked: variant === "stacked",- yTickCount,- });-- const isStacked = variant === "stacked";- const xScale = useXBandScale(data, orch.data.catKey, orch.dimensions.chartAreaWidth);- const stackedData = useStackedData(data, orch.data.dataKeys, isStacked);- const yScale = useYScale(data, orch.data.dataKeys, orch.dimensions.chartInnerHeight, isStacked);-- const findIndex = useCallback((mouseX: number) => findBandIndex(xScale, mouseX), [xScale]);- const mouseHandlers = orch.hover.createMouseHandlers(findIndex);-- // PPTX print-export JSON — mirrors react-ui's vertical BarChart call- // (type:'bar', no extraOptions → barDir defaults to "col"). Undefined off- // the print path.- const exportData = useExportChartData({- type: "bar",- data,- categoryKey: orch.data.catKey,- dataKeys: orch.data.dataKeys,- colors: orch.data.colors,- legend: showLegend,- xAxisLabel,- yAxisLabel,- });-- return (- <CartesianChartLayout- orch={orch}- yScale={yScale}- mouseHandlers={mouseHandlers}- classPrefix="bar-chart"- chartType="bar"- exportData={exportData}- ariaLabel="Bar chart"- showYAxis={showYAxis}- grid={grid}- showLegend={showLegend}- xAxisLabel={xAxisLabel}- yAxisLabel={yAxisLabel}- yTickCount={yTickCount}- className={className}- defs={- <defs>- <ClipDefs- chartId={orch.identity.chartId}- chartWidth={orch.dimensions.chartAreaWidth}- chartHeight={orch.dimensions.chartInnerHeight}- />- </defs>- }- series={- <>- <Crosshair- hoveredIndex={orch.hover.hoveredIndex}- xScale={xScale}- data={data}- categoryKey={orch.data.catKey}- chartHeight={orch.dimensions.chartInnerHeight}- />- <BarSeries- data={data}- dataKeys={orch.data.dataKeys}- xScale={xScale}- yScale={yScale}- variant={variant}- stackedData={stackedData}- categoryKey={orch.data.catKey}- colors={orch.data.colorMap}- barRadius={barRadius}- maxBarWidth={maxBarWidth}- internalLine={internalLine}- internalLineColor={internalLineColor}- internalLineWidth={internalLineWidth}- isAnimationActive={animate}- />- </>- }- xAxis={- <CartesianXAxis- mode={mode}- scale={xScale}- classPrefix={`${CHART_CLASS_PREFIX}-bar-chart`}- tickVariant={orch.dimensions.tickVariant}- labelHeight={orch.xAxis.xAxisHeight}- labelWidth={orch.xAxis.labelWidth}- maxLines={orch.xAxis.maxLines}- labelInterval={orch.dimensions.labelInterval}- angle={orch.xAxis.angle}- chartWidth={orch.dimensions.chartAreaWidth}- yAxisWidth={orch.dimensions.effectiveYAxisWidth}- />- }- />- );-}diff --git a/packages/react-ui/src/components/D3Charts/BarChart/barChart.scss b/packages/react-ui/src/components/D3Charts/BarChart/barChart.scssdeleted file mode 100644index caf9b8a43..000000000--- a/packages/react-ui/src/components/D3Charts/BarChart/barChart.scss+++ /dev/null@@ -1,44 +0,0 @@-@use "../../../cssUtils" as cssUtils;-@use "../shared/cartesian/chartBase" as base;-@use "../prefix" as brand;--@include base.chart-base("bar-chart");--// (No data-change transition on the bar-chart-bar class: the old-// `height/y 0.3s` rule was inert — bars render as <path d=roundedBarPath(…)>,-// and height/y are rect geometry properties — so bars have always snapped.-// Removed rather than ported to the spring morph: no behavior to preserve.)--.#{brand.$prefix}-bar-chart-hover-highlight {- fill: cssUtils.$text-neutral-primary;- opacity: 0.04;- pointer-events: none;-}--.#{brand.$prefix}-bar-chart-internal-line {- pointer-events: none;-}--// Entrances are decorative: gate the whole rule (pre-state included) behind-// reduced-motion so users who opt out get the natural static state immediately-// — gating only the animation would strand elements at the opacity: 0 start.-@media (prefers-reduced-motion: no-preference) {- .#{brand.$prefix}-bar-chart-bar--animated {- transform-box: fill-box;- transform-origin: center bottom;- animation: #{brand.$prefix}-bar-grow 0.6s ease-out both;- }- // A negative bar's zero-line edge is its TOP — grow downward from there.- .#{brand.$prefix}-bar-chart-bar--animated.#{brand.$prefix}-bar-chart-bar--negative {- transform-origin: center top;- }-}--@keyframes #{brand.$prefix}-bar-grow {- from {- transform: scaleY(0);- }- to {- transform: scaleY(1);- }-}diff --git a/packages/react-ui/src/components/D3Charts/BarChart/index.ts b/packages/react-ui/src/components/D3Charts/BarChart/index.tsdeleted file mode 100644index 7a169665b..000000000--- a/packages/react-ui/src/components/D3Charts/BarChart/index.ts+++ /dev/null@@ -1,2 +0,0 @@-export { BarChart } from "./BarChart";-export type { BarChartData, BarChartProps, BarChartVariant } from "./types";diff --git a/packages/react-ui/src/components/D3Charts/BarChart/stories/HorizontalBarChart.stories.tsx b/packages/react-ui/src/components/D3Charts/BarChart/stories/HorizontalBarChart.stories.tsxdeleted file mode 100644index caea56f4f..000000000--- a/packages/react-ui/src/components/D3Charts/BarChart/stories/HorizontalBarChart.stories.tsx+++ /dev/null@@ -1,913 +0,0 @@-// Copy of Charts/HorizontalBarChart/stories/HorizontalBarChart.stories.tsx with only the chart import and the title changed:-// the same args and renders, rendering the D3Charts chart via-// ../../stories/rechartsStoryAdapters.-import type { Meta, StoryObj } from "@storybook/react";-import { Monitor, TabletSmartphone } from "lucide-react";-import { useState } from "react";-import { Card } from "../../../Card";-import { HorizontalBarChart, HorizontalBarChartProps } from "../../stories/rechartsStoryAdapters";--// 📊 ALL DATA VARIATIONS - For easy switching in stories-const dataVariations = {- default: [- {- category: "A",- desktop: 150,- mobile: 90,- tablet: 120,- laptop: 180,- },- {- category: "B",- desktop: 280,- mobile: 180,- tablet: 140,- laptop: 160,- },- {- category: "C",- desktop: 220,- mobile: 140,- tablet: 160,- laptop: 180,- },- {- category: "D",- desktop: 180,- mobile: 160,- tablet: 180,- laptop: 200,- },- {- category: "E",- desktop: 250,- mobile: 120,- tablet: 140,- laptop: 160,- },- ],- small: [- { category: "Q1", desktop: 150, mobile: 90 },- { category: "Q2", desktop: 280, mobile: 180 },- { category: "Q3", desktop: 220, mobile: 140 },- ],- large: [- {- category: "North America",- revenue: 150000,- expenses: 90000,- profit: 60000,- marketing: 30000,- operations: 40000,- },- {- category: "Europe",- revenue: 280000,- expenses: 180000,- profit: 100000,- marketing: 50000,- operations: 70000,- },- {- category: "Asia Pacific",- revenue: 220000,- expenses: 140000,- profit: 80000,- marketing: 40000,- operations: 60000,- },- {- category: "Latin America",- revenue: 180000,- expenses: 160000,- profit: 20000,- marketing: 35000,- operations: 55000,- },- {- category: "Middle East",- revenue: 250000,- expenses: 120000,- profit: 130000,- marketing: 45000,- operations: 65000,- },- {- category: "Africa",- revenue: 120000,- expenses: 80000,- profit: 40000,- marketing: 25000,- operations: 35000,- },- {- category: "Oceania",- revenue: 95000,- expenses: 65000,- profit: 30000,- marketing: 20000,- operations: 25000,- },- {- category: "Southeast Asia",- revenue: 180000,- expenses: 110000,- profit: 70000,- marketing: 35000,- operations: 50000,- },- {- category: "Eastern Europe",- revenue: 140000,- expenses: 95000,- profit: 45000,- marketing: 28000,- operations: 42000,- },- {- category: "Scandinavia",- revenue: 160000,- expenses: 100000,- profit: 60000,- marketing: 32000,- operations: 48000,- },- ],- simple: [- { department: "Sales", performance: 1200 },- { department: "Marketing", performance: 950 },- { department: "Engineering", performance: 1100 },- { department: "Support", performance: 800 },- ],- edge: [{ period: "Current Quarter", sales: 500, target: 600 }],- bigNumbers: [- { company: "Apple Inc.", revenue: 394328000000, profit: 99803000000 },- { company: "Microsoft Corp.", revenue: 211915000000, profit: 83383000000 },- { company: "Alphabet Inc.", revenue: 307394000000, profit: 76033000000 },- { company: "Amazon.com Inc.", revenue: 574785000000, profit: 33364000000 },- ],- expandCollapseChannels: [- {- channel: "Website Traffic and Organic Search Results",- impressions: 120000,- clicks: 15000,- conversions: 1200,- cost: 8500,- revenue: 24000,- roi: 182,- ctr: 12.5,- cpc: 0.57,- cpa: 7.08,- reach: 95000,- engagement: 8200,- shares: 420,- saves: 180,- comments: 650,- videoViews: 0,- },- {- channel: "Social Media Engagement and Brand Awareness",- impressions: 85000,- clicks: 12000,- conversions: 950,- cost: 6200,- revenue: 19000,- roi: 206,- ctr: 14.1,- cpc: 0.52,- cpa: 6.53,- reach: 72000,- engagement: 15400,- shares: 890,- saves: 340,- comments: 1200,- videoViews: 28000,- },- {- channel: "Email Marketing Campaign Performance",- impressions: 45000,- clicks: 8500,- conversions: 800,- cost: 2100,- revenue: 16000,- roi: 562,- ctr: 18.9,- cpc: 0.25,- cpa: 2.63,- reach: 42000,- engagement: 6800,- shares: 120,- saves: 85,- comments: 240,- videoViews: 0,- },- {- channel: "Paid Advertising and PPC Campaign ROI",- impressions: 95000,- clicks: 18000,- conversions: 1500,- cost: 12500,- revenue: 30000,- roi: 140,- ctr: 18.9,- cpc: 0.69,- cpa: 8.33,- reach: 88000,- engagement: 12600,- shares: 320,- saves: 150,- comments: 480,- videoViews: 5200,- },- {- channel: "Content Marketing and Blog Performance",- impressions: 60000,- clicks: 9500,- conversions: 750,- cost: 4800,- revenue: 15000,- roi: 213,- ctr: 15.8,- cpc: 0.51,- cpa: 6.4,- reach: 55000,- engagement: 7800,- shares: 680,- saves: 420,- comments: 950,- videoViews: 12000,- },- {- channel: "Mobile Application Downloads and Usage",- impressions: 70000,- clicks: 11000,- conversions: 1100,- cost: 5500,- revenue: 22000,- roi: 300,- ctr: 15.7,- cpc: 0.5,- cpa: 5.0,- reach: 65000,- engagement: 9200,- shares: 180,- saves: 95,- comments: 320,- videoViews: 8500,- },- {- channel: "Customer Support Response Time and Quality",- impressions: 35000,- clicks: 5500,- conversions: 450,- cost: 2800,- revenue: 9000,- roi: 221,- ctr: 15.7,- cpc: 0.51,- cpa: 6.22,- reach: 32000,- engagement: 4200,- shares: 45,- saves: 25,- comments: 180,- videoViews: 0,- },- {- channel: "Sales Funnel Conversion and Lead Generation",- impressions: 110000,- clicks: 22000,- conversions: 1800,- cost: 15000,- revenue: 36000,- roi: 140,- ctr: 20.0,- cpc: 0.68,- cpa: 8.33,- reach: 98000,- engagement: 18500,- shares: 420,- saves: 280,- comments: 750,- videoViews: 3200,- },- {- channel: "User Retention and Churn Rate Analysis",- impressions: 80000,- clicks: 14000,- conversions: 1200,- cost: 7200,- revenue: 24000,- roi: 233,- ctr: 17.5,- cpc: 0.51,- cpa: 6.0,- reach: 75000,- engagement: 11200,- shares: 280,- saves: 150,- comments: 420,- videoViews: 6800,- },- {- channel: "Product Feature Usage and Performance Metrics",- impressions: 65000,- clicks: 10500,- conversions: 900,- cost: 5200,- revenue: 18000,- roi: 246,- ctr: 16.2,- cpc: 0.5,- cpa: 5.78,- reach: 58000,- engagement: 8500,- shares: 320,- saves: 180,- comments: 650,- videoViews: 4200,- },- {- channel: "Market Research and Competitive Analysis",- impressions: 40000,- clicks: 6500,- conversions: 500,- cost: 3200,- revenue: 10000,- roi: 213,- ctr: 16.3,- cpc: 0.49,- cpa: 6.4,- reach: 36000,- engagement: 5200,- shares: 95,- saves: 65,- comments: 220,- videoViews: 1800,- },- {- channel: "Brand Sentiment and Public Relations Impact",- impressions: 55000,- clicks: 8000,- conversions: 650,- cost: 4100,- revenue: 13000,- roi: 217,- ctr: 14.5,- cpc: 0.51,- cpa: 6.31,- reach: 48000,- engagement: 6800,- shares: 520,- saves: 280,- comments: 950,- videoViews: 15000,- },- ],- mixedPositiveNegative: [- { category: "Product A", profit: 100, loss: -50, net: 50 },- { category: "Product B", profit: 150, loss: -200, net: -50 },- { category: "Product C", profit: 200, loss: -100, net: 100 },- { category: "Product D", profit: -80, loss: -120, net: -200 },- { category: "Product E", profit: 300, loss: -150, net: 150 },- ],- singleGroup: [- { region: "North America (USA, Canada, Mexico)", sales: 150000 },- { region: "Europe (UK, Germany, France, Italy)", sales: 280000 },- { region: "Asia Pacific (Japan, Australia, South Korea)", sales: 220000 },- { region: "Latin America (Brazil, Argentina, Chile)", sales: 180000 },- { region: "Middle East (UAE, Saudi Arabia, Israel)", sales: 250000 },- ],-};--// Category key mappings for different datasets-const categoryKeys = {- default: "category",- small: "category",- large: "category",- simple: "department",- edge: "period",- bigNumbers: "company",- expandCollapseChannels: "channel",- mixedPositiveNegative: "category",- singleGroup: "region",-};--// 🔥 ACTIVE DATA - For backward compatibility-const horizontalBarChartData = dataVariations.default;--const icons = {- desktop: Monitor,- mobile: TabletSmartphone,-} as const;--/**- * # HorizontalBarChart Component Documentation- *- * The HorizontalBarChart is a versatile component for comparing values across different categories in a horizontal layout.- * It's highly effective for:- *- * - **Category Comparison**: Easily compare metrics like sales, performance, or revenue across different groups.- * - **Ranking**: Show the highest and lowest performing items with a clear visual hierarchy.- * - **Data with Long Labels**: Perfect for datasets with lengthy category names that don't fit well in vertical layouts.- *- * ## Key Features- *- * ### Layout Variants- * - **Grouped**: Compare sub-categories side-by-side within a primary category.- * - **Stacked**: Show how sub-categories contribute to a total value for each primary category.- *- * ### Interactive & Responsive- * - **Vertical Scrolling**: Automatically enables scrolling when the number of bars exceeds the container height.- * - **Interactive Legend**: Toggle data series on and off. Handles overflow with a "Show More" button.- * - **Hover Tooltips**: Provides detailed data on hover for better user engagement.- * - **Responsive Design**: Adjusts gracefully to the size of its container.- *- * ### Customization- * - **Theming**: Six built-in color palettes, or use custom colors with `customPalette`.- * - **Bar Styling**: Customize the corner radius of the bars.- * - **Axis and Grid Control**: Toggle visibility of axes and grid lines.- */-const meta: Meta<HorizontalBarChartProps<typeof horizontalBarChartData>> = {- title: "Components/D3Charts/HorizontalBarChart",- component: HorizontalBarChart,- parameters: {- layout: "centered",- docs: {- description: {- component: `-## Installation and Basic Usage--\`\`\`tsx-import { HorizontalBarChart } from '@openuidev/react-ui/Charts/HorizontalBarChart';--const salesData = [- { region: "North America", sales: 150000, profit: 45000 },- { region: "Europe", sales: 280000, profit: 68000 },- { region: "Asia Pacific", sales: 220000, profit: 52000 },-];--// Basic implementation-<HorizontalBarChart- data={salesData}- categoryKey="region"- theme="ocean"-/>--// With custom colors-<HorizontalBarChart- data={salesData}- categoryKey="region"- customPalette={["#FF6B6B", "#4ECDC4", "#45B7D1"]}-/>-\`\`\`--## Data Structure Requirements--Your data should be an array of objects. Each object must contain:-- A **category field** (string or number): Used for the Y-axis labels (e.g., regions, departments).-- One or more **data series fields** (number): These are the values that will be plotted as bars. The key of the field is used as the series name in the legend and tooltip.--\`\`\`tsx-const performanceData = [- { department: "Sales", performance: 5400, target: 6000 },- { department: "Marketing", performance: 8200, target: 7500 },- { department: "Engineering", performance: 7100, target: 7000 },-];-\`\`\`--## Performance Considerations-- **Data Volume**: The chart uses virtualization for vertical scrolling, but performance can still be impacted by an extremely large number of data points (e.g., 1000+).-- **Responsiveness**: The chart adapts to its container, but ensure that bar heights and gaps are readable on very small screens.-- **Animation**: Can be disabled via \`isAnimationActive={false}\` for better performance with large datasets.-`,- },- },- },- tags: ["!dev", "autodocs"],- argTypes: {- data: {- description: `-**Required.** An array of data objects representing your dataset. Each object should contain:-- A category identifier (string/number) for the Y-axis.-- One or more numeric values for the X-axis bars.-`,- control: false,- table: {- type: { summary: "Array<Record<string, string | number>>" },- category: "📊 Data Configuration",- },- },- categoryKey: {- description:- "**Required.** The key in your data object that represents the category for the Y-axis (e.g., 'region', 'department').",- control: false,- table: {- type: { summary: "string" },- category: "📊 Data Configuration",- },- },- theme: {- description:- "Specifies the color palette for the chart's bars, tooltips, and legend. Ignored when customPalette is provided.",- control: "select",- options: ["ocean", "orchid", "emerald", "sunset", "spectrum", "vivid"],- table: {- defaultValue: { summary: "ocean" },- category: "🎨 Visual Styling",- },- },- customPalette: {- description:- "Custom array of colors to use instead of the theme palette. Overrides the theme prop when provided.",- control: "object",- table: {- type: { summary: "string[]" },- category: "🎨 Visual Styling",- },- },- variant: {- description:- "Defines how multiple data series are displayed: `grouped` (side-by-side) or `stacked` (on top of each other).",- control: "radio",- options: ["grouped", "stacked"],- table: {- defaultValue: { summary: "grouped" },- category: "🎨 Visual Styling",- },- },- radius: {- description: "Sets the corner radius for the bars, creating a rounded look.",- control: { type: "number", min: 0, max: 20 },- table: {- type: { summary: "number" },- defaultValue: { summary: "4" },- category: "🎨 Visual Styling",- },- },- icons: {- description:- "An object mapping data series keys to React components to be used as icons in the legend.",- control: false,- table: {- type: { summary: "Record<string, React.ReactNode>" },- category: "🎨 Visual Styling",- },- },- grid: {- description: "Toggles the visibility of the background grid lines.",- control: "boolean",- table: {- defaultValue: { summary: "true" },- category: "📱 Display Options",- },- },- legend: {- description: "Toggles the visibility of the chart legend.",- control: "boolean",- table: {- defaultValue: { summary: "true" },- category: "📱 Display Options",- },- },- showXAxis: {- description: "Toggles the visibility of the X-axis line and labels.",- control: "boolean",- table: {- defaultValue: { summary: "true" },- category: "📱 Display Options",- },- },- xAxisLabel: {- description: "A label to display below the X-axis.",- control: "text",- table: {- type: { summary: "React.ReactNode" },- category: "📱 Display Options",- },- },- yAxisLabel: {- description: "A label to display beside the Y-axis.",- control: "text",- table: {- type: { summary: "React.ReactNode" },- category: "📱 Display Options",- },- },- isAnimationActive: {- description: "Enables or disables the initial loading animation for the bars.",- control: "boolean",- table: {- defaultValue: { summary: "false" },- category: "🎬 Animation & Interaction",- },- },- height: {- description: "Sets a fixed height for the chart container in pixels.",- control: "number",- table: {- type: { summary: "number" },- category: "Layout & Sizing",- },- },- width: {- description: "Sets a fixed width for the chart container in pixels.",- control: "number",- table: {- type: { summary: "number" },- category: "Layout & Sizing",- },- },- },-} satisfies Meta<typeof HorizontalBarChart>;--export default meta;--type Story = StoryObj<typeof meta>;--/**- * ## Comprehensive Data Explorer- *- * This story serves as a comprehensive test suite for the HorizontalBarChart component.- * Use the buttons to switch between various datasets designed to test edge cases in:- *- * - **Data Volume**: Scenarios with few, many, or a single data point.- * - **Data Formatting**: Handling of large numbers and different value ranges.- * - **Legend Overflow**: A dataset with many series to test legend expand/collapse functionality.- *- * It's an excellent tool for developers to see how the chart behaves under different conditions.- */-export const DataExplorer: Story = {- name: "🎛️ Comprehensive Data Explorer",- args: {- data: horizontalBarChartData,- categoryKey: "category",- theme: "ocean",- variant: "grouped",- radius: 4,- grid: true,- isAnimationActive: false,- showXAxis: true,- legend: true,- height: 400,- width: 600,- },- render: (args: any) => {- const [selectedDataType, setSelectedDataType] =- useState<keyof typeof dataVariations>("default");-- const currentData = dataVariations[selectedDataType];- const currentCategoryKey = categoryKeys[selectedDataType];-- const buttonStyle = {- margin: "2px",- padding: "6px 12px",- fontSize: "12px",- border: "1px solid #ddd",- borderRadius: "4px",- cursor: "pointer",- background: "#fff",- };-- const activeButtonStyle = {- ...buttonStyle,- background: "#007acc",- color: "white",- border: "1px solid #007acc",- };-- return (- <div>- <div- style={{- marginBottom: "16px",- padding: "12px",- background: "#f8f9fa",- borderRadius: "8px",- border: "1px solid #e9ecef",- width: "700px",- }}- >- <strong>💡 Quick Data Switch:</strong>- <div style={{ marginTop: "8px", display: "flex", flexWrap: "wrap", gap: "4px" }}>- <button- onClick={() => setSelectedDataType("default")}- style={selectedDataType === "default" ? activeButtonStyle : buttonStyle}- >- 📊 Default (5 categories)- </button>- <button- onClick={() => setSelectedDataType("small")}- style={selectedDataType === "small" ? activeButtonStyle : buttonStyle}- >- 📱 Small (3 items)- </button>- <button- onClick={() => setSelectedDataType("large")}- style={selectedDataType === "large" ? activeButtonStyle : buttonStyle}- >- 🌐 Large (10 regions)- </button>- <button- onClick={() => setSelectedDataType("simple")}- style={selectedDataType === "simple" ? activeButtonStyle : buttonStyle}- >- 🏢 Simple (4 departments)- </button>- <button- onClick={() => setSelectedDataType("bigNumbers")}- style={selectedDataType === "bigNumbers" ? activeButtonStyle : buttonStyle}- >- 💰 Big Numbers- </button>- <button- onClick={() => setSelectedDataType("edge")}- style={selectedDataType === "edge" ? activeButtonStyle : buttonStyle}- >- 🎯 Single Item- </button>- <button- onClick={() => setSelectedDataType("singleGroup")}- style={selectedDataType === "singleGroup" ? activeButtonStyle : buttonStyle}- >- 🌍 Single Group- </button>- <button- onClick={() => setSelectedDataType("mixedPositiveNegative")}- style={selectedDataType === "mixedPositiveNegative" ? activeButtonStyle : buttonStyle}- >- 📈 Mixed +/-- </button>- <button- onClick={() => setSelectedDataType("expandCollapseChannels")}- style={- selectedDataType === "expandCollapseChannels" ? activeButtonStyle : buttonStyle- }- >- 🔄 Marketing Channels- </button>- </div>- <div style={{ marginTop: "8px", fontSize: "12px", color: "#666" }}>- <strong>Current:</strong> {selectedDataType} | <strong>Items:</strong>{" "}- {currentData.length} | <strong>Category:</strong> {currentCategoryKey}- </div>- </div>- <Card style={{ width: "700px" }}>- <HorizontalBarChart {...args} data={currentData} categoryKey={currentCategoryKey} />- </Card>- </div>- );- },-};--// Basic stories using the new data structure-export const Default: Story = {- args: {- data: dataVariations.default,- categoryKey: "category",- theme: "ocean",- variant: "grouped",- height: 400,- width: 600,- },- render: (args: any) => (- <Card style={{ width: "600px" }}>- <HorizontalBarChart {...args} />- </Card>- ),-};--export const Stacked: Story = {- args: {- data: dataVariations.default,- categoryKey: "category",- theme: "ocean",- variant: "stacked",- height: 400,- width: 600,- },- render: (args: any) => (- <Card style={{ width: "600px" }}>- <HorizontalBarChart {...args} />- </Card>- ),-};--export const WithAnimations: Story = {- args: {- data: dataVariations.default,- categoryKey: "category",- theme: "ocean",- variant: "grouped",- isAnimationActive: true,- height: 400,- width: 600,- },- render: (args: any) => (- <Card style={{ width: "600px" }}>- <HorizontalBarChart {...args} />- </Card>- ),-};--export const CustomPalette: Story = {- args: {- data: dataVariations.default,- categoryKey: "category",- customPalette: ["#FF6B6B", "#4ECDC4", "#45B7D1", "#96CEB4", "#FECA57"],- variant: "grouped",- height: 400,- width: 600,- },- render: (args: any) => (- <Card style={{ width: "600px" }}>- <HorizontalBarChart {...args} />- </Card>- ),-};--export const CustomPaletteVibrant: Story = {- name: "🎨 Custom Palette - Vibrant",- args: {- data: dataVariations.default,- categoryKey: "category",- customPalette: ["#FF1744", "#00E676", "#2979FF", "#FF9100", "#9C27B0"],- variant: "grouped",- height: 400,- width: 600,- },- render: (args: any) => (- <Card style={{ width: "600px" }}>- <HorizontalBarChart {...args} />- </Card>- ),-};--export const BigNumbers: Story = {- args: {- data: dataVariations.bigNumbers,- categoryKey: "company",- theme: "vivid",- variant: "grouped",- height: 400,- width: 600,- },- render: (args: any) => (- <Card style={{ width: "600px" }}>- <HorizontalBarChart {...args} />- </Card>- ),-};--export const LargeDataset: Story = {- args: {- data: dataVariations.large,- categoryKey: "category",- theme: "emerald",- variant: "grouped",- height: 400,- width: 600,- },- render: (args: any) => (- <Card style={{ width: "600px" }}>- <HorizontalBarChart {...args} />- </Card>- ),-};--export const MixedPositiveNegative: Story = {- name: "📈 Mixed Positive and Negative",- args: {- data: dataVariations.mixedPositiveNegative,- categoryKey: "category",- theme: "spectrum",- variant: "grouped",- height: 400,- width: 600,- },- render: (args: any) => (- <Card style={{ width: "600px" }}>- <HorizontalBarChart {...args} />- </Card>- ),-};--export const WithIcons: Story = {- args: {- data: dataVariations.default,- categoryKey: "category",- theme: "ocean",- variant: "grouped",- height: 400,- width: 600,- icons: {- desktop: Monitor,- mobile: TabletSmartphone,- },- },- render: (args: any) => (- <Card style={{ width: "600px" }}>- <HorizontalBarChart {...args} />- </Card>- ),-};diff --git a/packages/react-ui/src/components/D3Charts/BarChart/stories/barChart.stories.tsx b/packages/react-ui/src/components/D3Charts/BarChart/stories/barChart.stories.tsxdeleted file mode 100644index 1d5ed5e44..000000000--- a/packages/react-ui/src/components/D3Charts/BarChart/stories/barChart.stories.tsx+++ /dev/null@@ -1,1435 +0,0 @@-// Copy of Charts/BarChart/stories/barChart.stories.tsx with only the chart import and the title changed:-// the same args and renders, rendering the D3Charts chart via-// ../../stories/rechartsStoryAdapters.-import type { Meta, StoryObj } from "@storybook/react";-import { Monitor, TabletSmartphone } from "lucide-react";-import { useState } from "react";-import { Card } from "../../../Card";-import { BarChart, BarChartProps } from "../../stories/rechartsStoryAdapters";--// 📊 ALL DATA VARIATIONS - For easy switching in stories-const dataVariations = {- default: [- {- month: "January 2024 - First Month of the Year",- desktop: 150,- mobile: 90,- tablet: 120,- laptop: 180,- },- {- month: "February 2024 - Second Month of the Year",- desktop: 280,- mobile: 180,- tablet: 140,- laptop: 160,- },- {- month: "March 2024 - Third Month of the Year",- desktop: 220,- mobile: 140,- tablet: 160,- laptop: 180,- },- {- month: "April 2024 - Fourth Month of the Year",- desktop: 180,- mobile: 160,- tablet: 180,- laptop: 200,- },- {- month: "May 2024 - Fifth Month of the Year",- desktop: 250,- mobile: 120,- tablet: 140,- laptop: 160,- },- {- month: "June 2024 - Sixth Month of the Year",- desktop: 300,- mobile: 180,- tablet: 160,- laptop: 180,- },- {- month: "July 2024 - Seventh Month of the Year",- desktop: 350,- mobile: 220,- tablet: 180,- laptop: 200,- },- {- month: "August 2024 - Eighth Month of the Year",- desktop: 400,- mobile: 240,- tablet: 200,- laptop: 220,- },- {- month: "September 2024 - Ninth Month of the Year",- desktop: 450,- mobile: 260,- tablet: 220,- laptop: 240,- },- {- month: "October 2024 - Tenth Month of the Year",- desktop: 500,- mobile: 280,- tablet: 240,- laptop: 260,- },- {- month: "November 2024 - Eleventh Month of the Year",- desktop: 550,- mobile: 300,- tablet: 260,- laptop: 280,- },- {- month: "December 2024 - Twelfth Month of the Year",- desktop: 600,- mobile: 320,- tablet: 280,- laptop: 300,- },- ],- small: [- { month: "Jan", desktop: 150, mobile: 90 },- { month: "Feb", desktop: 280, mobile: 180 },- { month: "Mar", desktop: 220, mobile: 140 },- ],- large: [- {- month: "Jan 2022",- desktop: 150,- mobile: 90,- tablet: 120,- laptop: 180,- tv: 50,- watch: 30,- smartwatch: 20,- },- {- month: "Feb 2022",- desktop: 280,- mobile: 180,- tablet: 140,- laptop: 160,- tv: 70,- watch: 40,- smartwatch: 30,- },- {- month: "Mar 2022",- desktop: 220,- mobile: 140,- tablet: 160,- laptop: 180,- tv: 60,- watch: 35,- smartwatch: 25,- },- {- month: "Apr 2022",- desktop: 180,- mobile: 160,- tablet: 180,- laptop: 200,- tv: 80,- watch: 45,- smartwatch: 35,- },- {- month: "May 2022",- desktop: 250,- mobile: 120,- tablet: 140,- laptop: 160,- tv: 55,- watch: 25,- smartwatch: 20,- },- {- month: "Jun 2022",- desktop: 300,- mobile: 180,- tablet: 160,- laptop: 180,- tv: 75,- watch: 50,- smartwatch: 30,- },- {- month: "Jul 2022",- desktop: 350,- mobile: 220,- tablet: 180,- laptop: 200,- tv: 85,- watch: 55,- smartwatch: 35,- },- {- month: "Aug 2022",- desktop: 400,- mobile: 240,- tablet: 200,- laptop: 220,- tv: 90,- watch: 60,- smartwatch: 40,- },- {- month: "Sep 2022",- desktop: 450,- mobile: 260,- tablet: 220,- laptop: 240,- tv: 95,- watch: 65,- smartwatch: 45,- },- {- month: "Oct 2022",- desktop: 500,- mobile: 280,- tablet: 240,- laptop: 260,- tv: 100,- watch: 70,- smartwatch: 50,- },- {- month: "Nov 2022",- desktop: 550,- mobile: 300,- tablet: 260,- laptop: 280,- tv: 105,- watch: 75,- smartwatch: 55,- },- {- month: "Dec 2022",- desktop: 600,- mobile: 320,- tablet: 280,- laptop: 300,- tv: 110,- watch: 80,- smartwatch: 60,- },- {- month: "Jan 2023",- desktop: 650,- mobile: 340,- tablet: 300,- laptop: 320,- tv: 115,- watch: 85,- smartwatch: 65,- },- {- month: "Feb 2023",- desktop: 700,- mobile: 360,- tablet: 320,- laptop: 340,- tv: 120,- watch: 90,- smartwatch: 70,- },- {- month: "Mar 2023",- desktop: 750,- mobile: 380,- tablet: 340,- laptop: 360,- tv: 125,- watch: 95,- smartwatch: 75,- },- {- month: "Apr 2023",- desktop: 800,- mobile: 400,- tablet: 360,- laptop: 380,- tv: 130,- watch: 100,- smartwatch: 80,- },- {- month: "May 2023",- desktop: 850,- mobile: 420,- tablet: 380,- laptop: 400,- tv: 135,- watch: 105,- smartwatch: 85,- },- {- month: "Jun 2023",- desktop: 900,- mobile: 440,- tablet: 400,- laptop: 420,- tv: 140,- watch: 110,- smartwatch: 90,- },- ],- simple: [- { quarter: "Q1", revenue: 1200, profit: 800 },- { quarter: "Q2", revenue: 1500, profit: 950 },- { quarter: "Q3", revenue: 1800, profit: 1100 },- { quarter: "Q4", revenue: 2000, profit: 1300 },- ],- edge: [{ period: "Current", sales: 500, target: 600 }],- numbers: [- { category: "Small", valueA: 5, valueB: 12, valueC: 8 },- { category: "Medium", valueA: 150, valueB: 180, valueC: 120 },- { category: "Large", valueA: 2500, valueB: 3200, valueC: 2800 },- { category: "XLarge", valueA: 45000, valueB: 52000, valueC: 48000 },- ],- weekly: [- { week: "W1", visits: 120, conversions: 15, sales: 1200 },- { week: "W2", visits: 150, conversions: 22, sales: 1800 },- { week: "W3", visits: 180, conversions: 28, sales: 2100 },- { week: "W4", visits: 200, conversions: 35, sales: 2500 },- { week: "W5", visits: 160, conversions: 18, sales: 1600 },- { week: "W6", visits: 190, conversions: 32, sales: 2300 },- { week: "W7", visits: 220, conversions: 40, sales: 2800 },- { week: "W8", visits: 240, conversions: 45, sales: 3200 },- { week: "W9", visits: 210, conversions: 38, sales: 2700 },- { week: "W10", visits: 230, conversions: 42, sales: 3000 },- { week: "W11", visits: 250, conversions: 48, sales: 3400 },- { week: "W12", visits: 270, conversions: 52, sales: 3800 },- { week: "W13", visits: 260, conversions: 50, sales: 3600 },- { week: "W14", visits: 280, conversions: 55, sales: 4000 },- { week: "W15", visits: 300, conversions: 60, sales: 4300 },- { week: "W16", visits: 290, conversions: 58, sales: 4100 },- ],- bigNumbers: [- { company: "Apple", revenue: 394328000000, profit: 99803000000, marketCap: 3500000000000 }, // 394B, 99B, 3.5T- { company: "Microsoft", revenue: 211915000000, profit: 83383000000, marketCap: 2800000000000 }, // 211B, 83B, 2.8T- { company: "Alphabet", revenue: 307394000000, profit: 76033000000, marketCap: 2100000000000 }, // 307B, 76B, 2.1T- { company: "Amazon", revenue: 574785000000, profit: 33364000000, marketCap: 1600000000000 }, // 574B, 33B, 1.6T- { company: "Tesla", revenue: 96773000000, profit: 15000000000, marketCap: 800000000000 }, // 96B, 15B, 800B- { company: "Meta", revenue: 134902000000, profit: 39370000000, marketCap: 900000000000 }, // 134B, 39B, 900B- ],- // 🔄 EXPAND/COLLAPSE - Marketing channels dataset for legend overflow testing- expandCollapseMarketing: [- {- channel: "Website Traffic and Organic Search Results",- impressions: 120000,- clicks: 15000,- conversions: 1200,- cost: 8500,- revenue: 24000,- roi: 182,- ctr: 12.5,- cpc: 0.57,- cpa: 7.08,- reach: 95000,- engagement: 8200,- shares: 420,- saves: 180,- comments: 650,- videoViews: 0,- },- {- channel: "Social Media Engagement and Brand Awareness",- impressions: 85000,- clicks: 12000,- conversions: 950,- cost: 6200,- revenue: 19000,- roi: 206,- ctr: 14.1,- cpc: 0.52,- cpa: 6.53,- reach: 72000,- engagement: 15400,- shares: 890,- saves: 340,- comments: 1200,- videoViews: 28000,- },- {- channel: "Email Marketing Campaign Performance",- impressions: 45000,- clicks: 8500,- conversions: 800,- cost: 2100,- revenue: 16000,- roi: 562,- ctr: 18.9,- cpc: 0.25,- cpa: 2.63,- reach: 42000,- engagement: 6800,- shares: 120,- saves: 85,- comments: 240,- videoViews: 0,- },- {- channel: "Paid Advertising and PPC Campaign ROI",- impressions: 95000,- clicks: 18000,- conversions: 1500,- cost: 12500,- revenue: 30000,- roi: 140,- ctr: 18.9,- cpc: 0.69,- cpa: 8.33,- reach: 88000,- engagement: 12600,- shares: 320,- saves: 150,- comments: 480,- videoViews: 5200,- },- {- channel: "Content Marketing and Blog Performance",- impressions: 60000,- clicks: 9500,- conversions: 750,- cost: 4800,- revenue: 15000,- roi: 213,- ctr: 15.8,- cpc: 0.51,- cpa: 6.4,- reach: 55000,- engagement: 7800,- shares: 680,- saves: 420,- comments: 950,- videoViews: 12000,- },- {- channel: "Mobile Application Downloads and Usage",- impressions: 70000,- clicks: 11000,- conversions: 1100,- cost: 5500,- revenue: 22000,- roi: 300,- ctr: 15.7,- cpc: 0.5,- cpa: 5.0,- reach: 65000,- engagement: 9200,- shares: 180,- saves: 95,- comments: 320,- videoViews: 8500,- },- {- channel: "Customer Support Response Time and Quality",- impressions: 35000,- clicks: 5500,- conversions: 450,- cost: 2800,- revenue: 9000,- roi: 221,- ctr: 15.7,- cpc: 0.51,- cpa: 6.22,- reach: 32000,- engagement: 4200,- shares: 45,- saves: 25,- comments: 180,- videoViews: 0,- },- {- channel: "Sales Funnel Conversion and Lead Generation",- impressions: 110000,- clicks: 22000,- conversions: 1800,- cost: 15000,- revenue: 36000,- roi: 140,- ctr: 20.0,- cpc: 0.68,- cpa: 8.33,- reach: 98000,- engagement: 18500,- shares: 420,- saves: 280,- comments: 750,- videoViews: 3200,- },- {- channel: "User Retention and Churn Rate Analysis",- impressions: 80000,- clicks: 14000,- conversions: 1200,- cost: 7200,- revenue: 24000,- roi: 233,- ctr: 17.5,- cpc: 0.51,- cpa: 6.0,- reach: 75000,- engagement: 11200,- shares: 280,- saves: 150,- comments: 420,- videoViews: 6800,- },- {- channel: "Product Feature Usage and Performance Metrics",- impressions: 65000,- clicks: 10500,- conversions: 900,- cost: 5200,- revenue: 18000,- roi: 246,- ctr: 16.2,- cpc: 0.5,- cpa: 5.78,- reach: 58000,- engagement: 8500,- shares: 320,- saves: 180,- comments: 650,- videoViews: 4200,- },- {- channel: "Market Research and Competitive Analysis",- impressions: 40000,- clicks: 6500,- conversions: 500,- cost: 3200,- revenue: 10000,- roi: 213,- ctr: 16.3,- cpc: 0.49,- cpa: 6.4,- reach: 36000,- engagement: 5200,- shares: 95,- saves: 65,- comments: 220,- videoViews: 1800,- },- {- channel: "Brand Sentiment and Public Relations Impact",- impressions: 55000,- clicks: 8000,- conversions: 650,- cost: 4100,- revenue: 13000,- roi: 217,- ctr: 14.5,- cpc: 0.51,- cpa: 6.31,- reach: 48000,- engagement: 6800,- shares: 520,- saves: 280,- comments: 950,- videoViews: 15000,- },- ],- singleGroup: [- { month: "January 1st - January 31st, 2024 (Winter Quarter)", sales: 150 },- { month: "February 1st - February 28th, 2024 (Winter Quarter)", sales: 280 },- { month: "March 1st - March 31st, 2024 (Spring Quarter)", sales: 220 },- { month: "April 1st - April 30th, 2024 (Spring Quarter)", sales: 180 },- { month: "May 1st - May 31st, 2024 (Spring Quarter)", sales: 250 },- { month: "June 1st - June 30th, 2024 (Summer Quarter)", sales: 300 },- { month: "July 1st - July 31st, 2024 (Summer Quarter)", sales: 350 },- { month: "August 1st - August 31st, 2024 (Summer Quarter)", sales: 400 },- ],- positiveNegative: [- { month: "January", profit: -4000000, loss: -2000000, netWorth: 2000000 },- { month: "February", profit: 3000000, loss: -4000000, netWorth: -1000000 },- { month: "March", profit: -1000000, loss: -1500000, netWorth: -2500000 },- { month: "April", profit: 5000000, loss: -2500000, netWorth: 2500000 },- { month: "May", profit: -2000000, loss: -3000000, netWorth: -5000000 },- { month: "June", profit: 1000000, loss: -500000, netWorth: 500000 },- ],-};--// Category key mappings for different datasets-const categoryKeys = {- default: "month",- small: "month",- large: "month",- simple: "quarter",- edge: "period",- numbers: "category",- weekly: "week",- bigNumbers: "company",- expandCollapseMarketing: "channel",- singleGroup: "month",- positiveNegative: "month",-};--// 🔥 ACTIVE DATA - For backward compatibility-const barChartData = dataVariations.default;--const icons = {- desktop: Monitor,- mobile: TabletSmartphone,-} as const;--/**- * # ScrollableBarChart Component Documentation- *- * The BarChart is a versatile component for comparing values across different categories.- * It's highly effective for:- *- * - **Category Comparison**: Easily compare metrics like sales, users, or revenue across different groups.- * - **Ranking**: Show the highest and lowest performing items in a dataset.- * - **Data Over Time**: Visualize changes across discrete time intervals (e.g., monthly sales).- *- * ## Key Features- *- * ### Layout Variants- * - **Grouped**: Compare sub-categories side-by-side within a primary category.- * - **Stacked**: Show how sub-categories contribute to a total value for each primary category.- *- * ### Interactive & Responsive- * - **Horizontal Scrolling**: Automatically enables scrolling when the number of bars exceeds the container width.- * - **Interactive Legend**: Toggle data series on and off. Handles overflow with a "Show More" button.- * - **Hover Tooltips**: Provides detailed data on hover for better user engagement.- * - **Responsive Design**: Adjusts gracefully to the size of its container.- *- * ### Customization- * - **Theming**: Six built-in color palettes, or use custom colors with `customPalette`.- * - **Bar Styling**: Customize the corner radius of the bars.- * - **Axis and Grid Control**: Toggle visibility of axes and grid lines.- */-const meta: Meta<BarChartProps<typeof barChartData>> = {- title: "Components/D3Charts/ScrollableBarChart",- component: BarChart,- parameters: {- layout: "centered",- docs: {- description: {- component: `-## Installation and Basic Usage--\`\`\`tsx-import { ScrollableBarChart } from '@openuidev/react-ui';--const monthlyData = [- { month: "January", desktop: 150, mobile: 90 },- { month: "February", desktop: 280, mobile: 180 },- { month: "March", desktop: 220, mobile: 140 },-];--// Basic implementation-<ScrollableBarChart- data={monthlyData}- categoryKey="month"- theme="ocean"-/>--// With custom colors-<ScrollableBarChart- data={monthlyData}- categoryKey="month"- customPalette={["#FF6B6B", "#4ECDC4", "#45B7D1"]}-/>-\`\`\`--## Data Structure Requirements--Your data should be an array of objects. Each object must contain:-- A **category field** (string or number): Used for the X-axis labels (e.g., months, quarters).-- One or more **data series fields** (number): These are the values that will be plotted as bars. The key of the field is used as the series name in the legend and tooltip.--\`\`\`tsx-const salesData = [- { region: "North", sales: 5400, marketing: 1200 },- { region: "South", sales: 8200, marketing: 1500 },- { region: "East", sales: 7100, marketing: 1300 },-];-\`\`\`--## Performance Considerations-- **Data Volume**: The chart uses virtualization for the X-axis, but performance can still be impacted by an extremely large number of data points (e.g., 1000+).-- **Responsiveness**: The chart adapts to its container, but ensure that bar widths and gaps are readable on very small screens.-- **Animation**: Can be disabled via \`isAnimationActive={false}\` for better performance with large datasets.-`,- },- },- },- tags: ["!dev", "autodocs"],- argTypes: {- data: {- description: `-**Required.** An array of data objects representing your dataset. Each object should contain:-- A category identifier (string/number) for the X-axis.-- One or more numeric values for the Y-axis bars.-`,- control: false,- table: {- type: { summary: "Array<Record<string, string | number>>" },- category: "📊 Data Configuration",- },- },- categoryKey: {- description:- "**Required.** The key in your data object that represents the category for the X-axis (e.g., 'month', 'department').",- control: false,- table: {- type: { summary: "string" },- category: "📊 Data Configuration",- },- },- theme: {- description:- "Specifies the color palette for the chart's bars, tooltips, and legend. Ignored when customPalette is provided.",- control: "select",- options: ["ocean", "orchid", "emerald", "sunset", "spectrum", "vivid"],- table: {- defaultValue: { summary: "ocean" },- category: "🎨 Visual Styling",- },- },- customPalette: {- description:- "Custom array of colors to use instead of the theme palette. Overrides the theme prop when provided.",- control: "object",- table: {- type: { summary: "string[]" },- category: "🎨 Visual Styling",- },- },- variant: {- description:- "Defines how multiple data series are displayed: `grouped` (side-by-side) or `stacked` (on top of each other).",- control: "radio",- options: ["grouped", "stacked"],- table: {- defaultValue: { summary: "grouped" },- category: "🎨 Visual Styling",- },- },- radius: {- description: "Sets the corner radius for the top of each bar, creating a rounded look.",- control: { type: "number", min: 0, max: 20 },- table: {- type: { summary: "number" },- defaultValue: { summary: "4" },- category: "🎨 Visual Styling",- },- },- icons: {- description:- "An object mapping data series keys to React components to be used as icons in the legend.",- control: false,- table: {- type: { summary: "Record<string, React.ReactNode>" },- category: "🎨 Visual Styling",- },- },- grid: {- description: "Toggles the visibility of the background grid lines.",- control: "boolean",- table: {- defaultValue: { summary: "true" },- category: "📱 Display Options",- },- },- legend: {- description: "Toggles the visibility of the chart legend.",- control: "boolean",- table: {- defaultValue: { summary: "true" },- category: "📱 Display Options",- },- },- showYAxis: {- description: "Toggles the visibility of the Y-axis line and labels.",- control: "boolean",- table: {- defaultValue: { summary: "true" },- category: "📱 Display Options",- },- },- xAxisLabel: {- description: "A label to display below the X-axis.",- control: "text",- table: {- type: { summary: "React.ReactNode" },- category: "📱 Display Options",- },- },- yAxisLabel: {- description: "A label to display beside the Y-axis.",- control: "text",- table: {- type: { summary: "React.ReactNode" },- category: "📱 Display Options",- },- },- isAnimationActive: {- description: "Enables or disables the initial loading animation for the bars.",- control: "boolean",- table: {- defaultValue: { summary: "true" },- category: "🎬 Animation & Interaction",- },- },- height: {- description: "Sets a fixed height for the chart container in pixels.",- control: "number",- table: {- type: { summary: "number" },- category: "Layout & Sizing",- },- },- width: {- description: "Sets a fixed width for the chart container in pixels.",- control: "number",- table: {- type: { summary: "number" },- category: "Layout & Sizing",- },- },- },-} satisfies Meta<typeof BarChart>;--export default meta;-type Story = StoryObj<typeof meta>;--/**- * ## Comprehensive Data Explorer- *- * This story serves as a comprehensive test suite for the BarChart component.- * Use the buttons to switch between various datasets designed to test edge cases in:- *- * - **Data Volume**: Scenarios with few, many, or a single data point.- * - **Data Formatting**: Handling of large numbers and different value ranges.- * - **Legend Overflow**: A dataset with many series to test legend expand/collapse functionality.- *- * It's an excellent tool for developers to see how the chart behaves under different conditions.- */-export const DataExplorer: Story = {- name: "🎛️ Comprehensive Data Explorer",- args: {- data: barChartData,- categoryKey: "month",- theme: "ocean",- variant: "grouped",- radius: 4,- grid: true,- isAnimationActive: true,- showYAxis: true,- // height: 500,- },- render: (args: any) => {- const [selectedDataType, setSelectedDataType] =- useState<keyof typeof dataVariations>("default");-- const currentData = dataVariations[selectedDataType];- const currentCategoryKey = categoryKeys[selectedDataType];-- const buttonStyle = {- margin: "2px",- padding: "6px 12px",- fontSize: "12px",- border: "1px solid #ddd",- borderRadius: "4px",- cursor: "pointer",- background: "#fff",- };-- const activeButtonStyle = {- ...buttonStyle,- background: "#007acc",- color: "white",- border: "1px solid #007acc",- };-- return (- <div>- <div- style={{- marginBottom: "16px",- padding: "12px",- background: "#f8f9fa",- borderRadius: "8px",- border: "1px solid #e9ecef",- width: "700px",- }}- >- <strong>💡 Quick Data Switch:</strong>- <div style={{ marginTop: "8px", display: "flex", flexWrap: "wrap", gap: "4px" }}>- <button- onClick={() => setSelectedDataType("default")}- style={selectedDataType === "default" ? activeButtonStyle : buttonStyle}- >- 📅 Default (12 months)- </button>- <button- onClick={() => setSelectedDataType("small")}- style={selectedDataType === "small" ? activeButtonStyle : buttonStyle}- >- 📱 Small (3 items)- </button>- <button- onClick={() => setSelectedDataType("large")}- style={selectedDataType === "large" ? activeButtonStyle : buttonStyle}- >- 🌐 Large (18 months)- </button>- <button- onClick={() => setSelectedDataType("weekly")}- style={selectedDataType === "weekly" ? activeButtonStyle : buttonStyle}- >- 📈 Weekly (16 weeks)- </button>- <button- onClick={() => setSelectedDataType("bigNumbers")}- style={selectedDataType === "bigNumbers" ? activeButtonStyle : buttonStyle}- >- 💰 Big Numbers- </button>- <button- onClick={() => setSelectedDataType("edge")}- style={selectedDataType === "edge" ? activeButtonStyle : buttonStyle}- >- 🎯 Single Item- </button>- <button- onClick={() => setSelectedDataType("numbers")}- style={selectedDataType === "numbers" ? activeButtonStyle : buttonStyle}- >- 🔢 Number Ranges- </button>- <button- onClick={() => setSelectedDataType("singleGroup")}- style={selectedDataType === "singleGroup" ? activeButtonStyle : buttonStyle}- >- 🏢 Single Group- </button>- <button- onClick={() => setSelectedDataType("expandCollapseMarketing")}- style={- selectedDataType === "expandCollapseMarketing" ? activeButtonStyle : buttonStyle- }- >- 🔄 Marketing Channels- </button>- <button- onClick={() => setSelectedDataType("positiveNegative")}- style={selectedDataType === "positiveNegative" ? activeButtonStyle : buttonStyle}- >- 📈 Positive & Negative- </button>- </div>- <div style={{ marginTop: "8px", fontSize: "12px", color: "#666" }}>- <strong>Current:</strong> {selectedDataType} | <strong>Items:</strong>{" "}- {currentData.length} | <strong>Category:</strong> {currentCategoryKey}- </div>- </div>- <Card style={{ width: "700px" }}>- <BarChart {...args} data={currentData} categoryKey={currentCategoryKey} />- </Card>- </div>- );- },- parameters: {- docs: {- description: {- story:- "Use the buttons above the chart to quickly switch between different data variations and test the scrolling functionality. Active button is highlighted in blue.",- },- },- },-};--/**- * ## Small Dataset (No Scroll)- *- * This story demonstrates the BarChart's appearance with a small dataset.- * When the number of bars fits within the container width, horizontal scrolling is disabled.- */-export const SmallDataStory: Story = {- name: "📱 Small Data (No Scroll)",- args: {- data: dataVariations.small as any,- categoryKey: "month" as any,- theme: "ocean",- variant: "grouped",- radius: 2,- grid: true,- isAnimationActive: true,- showYAxis: true,- legend: true,- },- render: (args: any) => (- <Card style={{ width: "400px" }}>- <BarChart {...args} />- </Card>- ),-};--/**- * ## Large Dataset (With Scrolling)- *- * This story showcases the chart's horizontal scrolling capability.- * When the total width of the bars exceeds the container's width, users can scroll to view all data points.- */-export const LargeDataStory: Story = {- name: "🌐 Large Data (Scrolling)",- args: {- data: dataVariations.large as any,- categoryKey: "month" as any,- theme: "emerald",- variant: "grouped",- radius: 2,- grid: true,- isAnimationActive: true,- showYAxis: true,- legend: true,- },- render: (args: any) => (- <Card style={{ width: "400px" }}>- <BarChart {...args} />- </Card>- ),-};--/**- * ## Weekly Data (Many Categories)- *- * Similar to the large dataset, this story tests the chart with a high number of categories,- * which should trigger horizontal scrolling.- */-export const WeeklyDataStory: Story = {- name: "📈 Weekly Data (Many Categories)",- args: {- data: dataVariations.weekly as any,- categoryKey: "week" as any,- theme: "sunset",- variant: "grouped",- radius: 2,- grid: true,- isAnimationActive: true,- showYAxis: true,- legend: true,- },- render: (args: any) => (- <Card style={{ width: "400px" }}>- <BarChart {...args} />- </Card>- ),-};--/**- * ## Big Numbers- *- * This story tests the chart's ability to handle and format very large numbers,- * such as billions and trillions, on the Y-axis. The axis labels should be formatted- * with appropriate suffixes (e.g., "B" for billion, "T" for trillion).- */-export const BigNumbersStory: Story = {- name: "💰 Big Numbers (Billions/Trillions)",- args: {- data: dataVariations.bigNumbers as any,- categoryKey: "company" as any,- theme: "vivid",- variant: "grouped",- radius: 2,- grid: true,- isAnimationActive: true,- showYAxis: true,- legend: true,- },- render: (args: any) => (- <Card style={{ width: "500px" }}>- <BarChart {...args} />- </Card>- ),-};--/**- * ## Edge Case (Single Data Point)- *- * This story demonstrates how the chart renders with only a single data point.- * It's a useful test to ensure that the layout and axes behave correctly in minimal-data scenarios.- */-export const EdgeCaseStory: Story = {- name: "🎯 Edge Case (Single Data Point)",- args: {- data: dataVariations.edge as any,- categoryKey: "period" as any,- theme: "orchid",- variant: "grouped",- radius: 2,- grid: true,- isAnimationActive: true,- showYAxis: true,- legend: true,- },- render: (args: any) => (- <Card style={{ width: "400px" }}>- <BarChart {...args} />- </Card>- ),-};--/**- * ## Number Ranges (Scale Testing)- *- * This story tests the Y-axis scaling with data points of vastly different magnitudes.- * The chart should automatically adjust its scale to accommodate all values appropriately.- */-export const NumberRangesStory: Story = {- name: "🔢 Number Ranges (Scale Testing)",- args: {- data: dataVariations.numbers as any,- categoryKey: "category" as any,- theme: "spectrum",- variant: "grouped",- radius: 2,- grid: true,- isAnimationActive: true,- showYAxis: true,- legend: true,- },- render: (args: any) => (- <Card style={{ width: "400px" }}>- <BarChart {...args} />- </Card>- ),-};--/**- * ## Legend Expand/Collapse- *- * Tests the legend's expand/collapse functionality with a large number of data series.- * The legend should automatically show a "Show More" button when items overflow,- * allowing users to toggle between a collapsed and expanded view.- */-export const ExpandCollapseMarketingStory: Story = {- name: "🔄 Legend Expand/Collapse",- args: {- data: dataVariations.expandCollapseMarketing as any,- categoryKey: "channel" as any,- theme: "emerald",- variant: "grouped",- radius: 4,- grid: true,- isAnimationActive: true,- showYAxis: true,- legend: true,- },- render: (args: any) => (- <Card style={{ width: "600px" }}>- <BarChart {...args} />- </Card>- ),- parameters: {- docs: {- description: {- story:- "Tests the legend expand/collapse functionality with 12 marketing channels that have long descriptive names. The legend should automatically show a 'Show More' button when items overflow the container width, allowing users to toggle between collapsed and expanded states.",- },- },- },-};--/**- * ## Custom Palette- *- * This story demonstrates how to use the customPalette prop to provide your own color scheme- * for the chart. This is useful when you need to match your brand colors or create- * specific visual themes.- */-export const CustomPaletteStory: Story = {- name: "🎨 Custom Palette",- args: {- data: dataVariations.default as any,- categoryKey: "month" as any,- customPalette: [- "#0A0E60",- "#14197B",- "#272DA6",- "#383FC9",- "#444CE7",- "#5F67F4",- "#7884FF",- "#97A9FF",- "#B4C6FF",- "#CBD7FF",- ],- theme: "ocean", // This will be overridden by customPalette- variant: "grouped",- radius: 4,- grid: true,- legend: true,- isAnimationActive: true,- showYAxis: true,- xAxisLabel: "Month",- yAxisLabel: "Traffic",- },- render: (args: any) => (- <div>- <div- style={{- marginBottom: "16px",- padding: "12px",- background: "#f8f9fa",- borderRadius: "8px",- border: "1px solid #e9ecef",- }}- >- <h4 style={{ margin: "0 0 8px 0", color: "#333" }}>🎨 Custom Color Palette</h4>- <p style={{ margin: "0 0 12px 0", fontSize: "14px", color: "#666" }}>- This chart uses a custom color palette instead of the default theme colors.- </p>- <div style={{ display: "flex", gap: "8px", flexWrap: "wrap" }}>- {args.customPalette?.map((color: string, index: number) => (- <div- key={index}- style={{- display: "flex",- alignItems: "center",- gap: "4px",- padding: "4px 8px",- background: "white",- borderRadius: "4px",- border: "1px solid #ddd",- fontSize: "12px",- }}- >- <div- style={{- width: "12px",- height: "12px",- borderRadius: "2px",- backgroundColor: color,- border: "1px solid #ccc",- }}- />- <span style={{ fontFamily: "monospace" }}>{color}</span>- </div>- ))}- </div>- </div>- <Card style={{ width: "600px" }}>- <BarChart {...args} />- </Card>- </div>- ),- parameters: {- docs: {- description: {- story:- 'Demonstrates how to use the `customPalette` prop to provide your own color scheme for the chart. When `customPalette` is provided, it overrides the `theme` prop and uses your specified colors instead of the predefined theme palettes.\n\n**Key Features:**\n- 🎨 **Custom Colors**: Override default theme colors with your own palette\n- 🔄 **Theme Override**: The `theme` prop is ignored when `customPalette` is provided\n- 📊 **Consistent Distribution**: Colors are distributed evenly across data series\n- 🎯 **Brand Matching**: Perfect for matching your application\'s brand colors\n\n**Usage:**\n```tsx\n<BarChart\n data={data}\n categoryKey="month"\n customPalette={["#FF6B6B", "#4ECDC4", "#45B7D1"]}\n // theme prop is ignored when customPalette is provided\n/>\n```',- },- },- },-};--/**- * ## Responsive Behavior Demo- *- * This story demonstrates the responsive capabilities of the BarChart. Drag the handles- * on the container to resize it and observe how the chart adapts.- *- * **Responsive Features:**- * - **Bar Sizing**: Bar widths and gaps adjust to the container size.- * - **Layout Adaptation**: Chart elements are repositioned to fit the available space.- * - **Legend Behavior**: The legend may wrap or show expand/collapse buttons as needed.- */-export const ResponsiveBehaviorDemo: Story = {- name: "📱 Responsive Behavior Demo",- args: {- data: dataVariations.default as any,- categoryKey: "month" as any,- theme: "sunset",- variant: "grouped",- grid: true,- legend: true,- isAnimationActive: false,- showYAxis: true,- },- render: (args: any) => {- const [dimensions, setDimensions] = useState<{ width: number; height: number | string }>({- width: 700,- height: "auto",- });-- const handleMouseDown = (e: React.MouseEvent<HTMLDivElement>, handle: string) => {- e.preventDefault();- e.stopPropagation();- const startX = e.clientX;- const startY = e.clientY;- const startWidth = dimensions.width;- const startHeight = (e.currentTarget.parentElement as HTMLElement).offsetHeight;-- const doDrag = (e: MouseEvent) => {- const dx = e.clientX - startX;- const dy = e.clientY - startY;- let newWidth = startWidth;- let newHeight = startHeight;-- if (handle.includes("e")) newWidth = startWidth + dx;- if (handle.includes("w")) newWidth = startWidth - dx;- if (handle.includes("s")) newHeight = startHeight + dy;- if (handle.includes("n")) newHeight = startHeight - dy;-- setDimensions({- width: Math.max(300, newWidth),- height: "auto",- });- };-- const stopDrag = () => {- document.removeEventListener("mousemove", doDrag);- document.removeEventListener("mouseup", stopDrag);- };-- document.addEventListener("mousemove", doDrag);- document.addEventListener("mouseup", stopDrag);- };-- const handleStyle: React.CSSProperties = {- position: "absolute",- background: "#3b82f6",- opacity: 0.6,- zIndex: 10,- transition: "opacity 0.2s ease",- };-- return (- <div style={{ padding: "20px" }}>- <div style={{ marginBottom: "20px" }}>- <h3 style={{ margin: "0 0 8px 0", fontSize: "18px", fontWeight: "600" }}>- Responsive Behavior Demonstration- </h3>- <p style={{ margin: "0 0 12px 0", color: "#666", fontSize: "14px" }}>- Drag the edges or corners of the container below to see how the chart adapts- </p>- <div- style={{- padding: "12px",- backgroundColor: "#e3f2fd",- borderRadius: "6px",- fontSize: "12px",- color: "#1565c0",- }}- >- <strong>🎯 Try This:</strong> Resize the container to see how the bar widths and layout- adjustments.- </div>- </div>-- <Card- style={{- position: "relative",- width: `${dimensions.width}px`,- height:- typeof dimensions.height === "number" ? `${dimensions.height}px` : dimensions.height,- border: "2px dashed #9ca3af",- padding: "20px",- boxSizing: "border-box",- overflow: "hidden",- cursor: "default",- }}- >- <BarChart {...args} />-- {/* Resize Handles */}- <div- style={{ ...handleStyle, top: -2, left: 0, right: 0, height: 12, cursor: "ns-resize" }}- onMouseDown={(e) => handleMouseDown(e, "n")}- />- <div- style={{- ...handleStyle,- bottom: -2,- left: 0,- right: 0,- height: 12,- cursor: "ns-resize",- }}- onMouseDown={(e) => handleMouseDown(e, "s")}- />- <div- style={{ ...handleStyle, top: 0, bottom: 0, left: -2, width: 12, cursor: "ew-resize" }}- onMouseDown={(e) => handleMouseDown(e, "w")}- />- <div- style={{ ...handleStyle, top: 0, bottom: 0, right: -2, width: 12, cursor: "ew-resize" }}- onMouseDown={(e) => handleMouseDown(e, "e")}- />-- {/* Corner Handles */}- <div- style={{- ...handleStyle,- top: -2,- left: -2,- width: 20,- height: 20,- cursor: "nwse-resize",- borderRadius: "2px",- }}- onMouseDown={(e) => handleMouseDown(e, "nw")}- />- <div- style={{- ...handleStyle,- top: -2,- right: -2,- width: 20,- height: 20,- cursor: "nesw-resize",- borderRadius: "2px",- }}- onMouseDown={(e) => handleMouseDown(e, "ne")}- />- <div- style={{- ...handleStyle,- bottom: -2,- right: -2,- width: 20,- height: 20,- cursor: "nwse-resize",- borderRadius: "2px",- }}- onMouseDown={(e) => handleMouseDown(e, "se")}- />-- {/* Dimension Display */}- <div- style={{- position: "absolute",- bottom: 8,- right: 8,- background: "rgba(0,0,0,0.8)",- color: "white",- padding: "4px 8px",- borderRadius: "4px",- fontSize: "11px",- fontFamily: "monospace",- fontWeight: "500",- }}- >- {dimensions.width}px ×{" "}- {typeof dimensions.height === "number" ? `${dimensions.height}px` : "auto"}- </div>- </Card>- </div>- );- },-};diff --git a/packages/react-ui/src/components/D3Charts/BarChart/stories/barChartCondensed.stories.tsx b/packages/react-ui/src/components/D3Charts/BarChart/stories/barChartCondensed.stories.tsxdeleted file mode 100644index 741f4a8c2..000000000--- a/packages/react-ui/src/components/D3Charts/BarChart/stories/barChartCondensed.stories.tsx+++ /dev/null@@ -1,1777 +0,0 @@-// Copy of Charts/BarChartCondensed/stories/barChartCondensed.stories.tsx with only the chart import and the title changed:-// the same args and renders, rendering the D3Charts chart via-// ../../stories/rechartsStoryAdapters.-import type { Meta, StoryObj } from "@storybook/react";-import {- Calendar,- Globe,- Laptop,- Monitor,- Smartphone,- TabletSmartphone,- Tv,- Watch,-} from "lucide-react";-import { useState } from "react";-import { Card } from "../../../Card";-import { BarChartCondensed, BarChartCondensedProps } from "../../stories/rechartsStoryAdapters";--// 🔥 COMPREHENSIVE DATA VARIATIONS - Designed to test various scenarios-const dataVariations = {- default: [- { month: "January", desktop: 150, mobile: 90, tablet: 120 },- { month: "February", desktop: 280, mobile: 180, tablet: 140 },- { month: "March", desktop: 220, mobile: 140, tablet: 160 },- { month: "April", desktop: 180, mobile: 160, tablet: 180 },- { month: "May", desktop: 250, mobile: 120, tablet: 140 },- { month: "June", desktop: 300, mobile: 180, tablet: 160 },- { month: "July", desktop: 350, mobile: 220, tablet: 180 },- { month: "August", desktop: 400, mobile: 240, tablet: 200 },- { month: "September", desktop: 450, mobile: 260, tablet: 220 },- { month: "October", desktop: 500, mobile: 280, tablet: 240 },- { month: "November", desktop: 550, mobile: 300, tablet: 260 },- { month: "December", desktop: 600, mobile: 320, tablet: 280 },- ],- // 🏷️ BIG LABELS - Testing angled tick labels- bigLabels: [- {- category: "Very Long Category Name That Should Be Truncated",- sales: 150,- revenue: 90,- profit: 120,- },- {- category: "Another Extremely Long Label That Causes Collisions",- sales: 280,- revenue: 180,- profit: 140,- },- {- category: "Super Duper Long Category Name That Tests Truncation",- sales: 220,- revenue: 140,- profit: 160,- },- {- category: "Incredibly Long Text That Should Trigger Collision Detection",- sales: 180,- revenue: 160,- profit: 180,- },- {- category: "Maximum Length Category Name That Tests All Edge Cases",- sales: 250,- revenue: 120,- profit: 140,- },- {- category: "Extra Long Business Category Name With Many Words",- sales: 300,- revenue: 180,- profit: 160,- },- {- category: "Comprehensive Long Label For Testing Horizontal Offset",- sales: 350,- revenue: 220,- profit: 180,- },- {- category: "Extended Category Name That Pushes Truncation Limits",- sales: 400,- revenue: 240,- profit: 200,- },- ],- // 🏢 COMPANY NAMES - Real-world long business names- companyNames: [- { company: "Apple Inc.", revenue: 394328000000, profit: 99803000000, marketCap: 3500000000000 },- {- company: "Microsoft Corporation",- revenue: 211915000000,- profit: 83383000000,- marketCap: 2800000000000,- },- {- company: "Alphabet Inc. (Google)",- revenue: 307394000000,- profit: 76033000000,- marketCap: 2100000000000,- },- {- company: "Amazon.com Inc.",- revenue: 574785000000,- profit: 33364000000,- marketCap: 1600000000000,- },- {- company: "Tesla Motors Inc.",- revenue: 96773000000,- profit: 15000000000,- marketCap: 800000000000,- },- {- company: "Meta Platforms Inc.",- revenue: 134902000000,- profit: 39370000000,- marketCap: 900000000000,- },- ],- // 📈 FINANCIAL QUARTERS - Testing medium-density scenarios- financialQuarters: [- { quarter: "Q1 FY2022", revenue: 1200000, expenses: 800000, profit: 400000 },- { quarter: "Q2 FY2022", revenue: 1500000, expenses: 950000, profit: 550000 },- { quarter: "Q3 FY2022", revenue: 1800000, expenses: 1100000, profit: 700000 },- { quarter: "Q4 FY2022", revenue: 2000000, expenses: 1300000, profit: 700000 },- { quarter: "Q1 FY2023", revenue: 2200000, expenses: 1400000, profit: 800000 },- { quarter: "Q2 FY2023", revenue: 2500000, expenses: 1600000, profit: 900000 },- { quarter: "Q3 FY2023", revenue: 2800000, expenses: 1800000, profit: 1000000 },- { quarter: "Q4 FY2023", revenue: 3000000, expenses: 1900000, profit: 1100000 },- ],- // 📱 MINIMAL - Small dataset for baseline testing- minimal: [- { category: "Mobile Devices", users: 150, sessions: 90 },- { category: "Desktop Computers", users: 280, sessions: 180 },- { category: "Tablet Devices", users: 220, sessions: 140 },- ],- // 📊 WEEKLY TRAFFIC- weeklyTraffic: [- { day: "Monday", visits: 2200, conversions: 180, bounces: 800 },- { day: "Tuesday", visits: 2500, conversions: 220, bounces: 900 },- { day: "Wednesday", visits: 2300, conversions: 190, bounces: 850 },- { day: "Thursday", visits: 2800, conversions: 250, bounces: 1000 },- { day: "Friday", visits: 3200, conversions: 280, bounces: 1100 },- { day: "Saturday", visits: 1800, conversions: 120, bounces: 600 },- { day: "Sunday", visits: 1500, conversions: 100, bounces: 500 },- ],-};--// Category key mappings for different datasets-const categoryKeys = {- default: "month",- bigLabels: "category",- companyNames: "company",- financialQuarters: "quarter",- minimal: "category",- weeklyTraffic: "day",-};--// 🔥 ACTIVE DATA - For backward compatibility-const barChartCondensedData = dataVariations.default;--const icons = {- desktop: Monitor,- mobile: TabletSmartphone,- tablet: Calendar,- sales: Globe,- revenue: Smartphone,- profit: Laptop,- visitors: Tv,- conversions: Watch,- users: Monitor,- sessions: TabletSmartphone,- expenses: Calendar,- marketCap: Globe,- visits: Monitor,- bounces: Calendar,-} as const;--/**- * # BarChart Component Documentation- *- * The BarChart is a compact chart designed for space-constrained layouts- * like dashboards and sidebars. It's ideal for:- *- * - **Compact Dashboards**: Showing multiple metrics in limited space- * - **Sidebar Analytics**: Quick comparison visualization without taking up too much room- * - **Dense Data Display**: Efficiently showing many data points in a small area- *- * ## Key Features- *- * ### Space-Efficient Design- * - **Compact Height**: Default 200px height for tight layouts- * - **Minimal Legend**: Legend is compact and doesn't take up vertical space- * - **Adjustable Tick Variants**: Choose between horizontal or angled labels for better space usage- *- * ### Layout Variants- * - **Grouped**: Compare sub-categories side-by-side within a primary category- * - **Stacked**: Show how sub-categories contribute to a total value- *- * ### Flexible Label Handling- * - **Single Line Ticks**: Horizontal labels with automatic collision detection- * - **Angled Ticks**: Optimal rotation angle for longer labels that need more space- * - **Smart Angle Calculation**: Automatically calculates optimal rotation based on label width- *- * ### Interactive & Responsive- * - **Hover Tooltips**: Standard tooltip showing all data series- * - **Responsive Design**: Adapts fluidly to its container's size- *- * ### Customization- * - **Theming**: Comes with six pre-built color palettes- * - **Bar Styling**: Customize corner radius with the radius prop- * - **Styling Options**: Control grid visibility, axes, and more- */-const meta: Meta<BarChartCondensedProps<typeof barChartCondensedData>> = {- title: "Components/D3Charts/BarChart",- component: BarChartCondensed,- parameters: {- layout: "centered",- docs: {- description: {- component: `-## Installation and Basic Usage--\`\`\`tsx-import { BarChart } from '@openuidev/react-ui';--const salesData = [- { month: "January", desktop: 150, mobile: 90 },- { month: "February", desktop: 280, mobile: 180 },- { month: "March", desktop: 220, mobile: 140 },-];--// Basic implementation-<BarChart- data={salesData}- categoryKey="month"- theme="ocean"- height={200}-/>-\`\`\`--## Data Structure Requirements--Your data should be an array of objects. Each object must contain:-- A **category field** (string or number): This will be used for the X-axis labels (e.g., months, categories, etc.).-- One or more **data series fields** (number): These are the values that will be plotted as bars.--\`\`\`tsx-const salesData = [- { region: "North", sales: 150, marketing: 90 },- { region: "South", sales: 280, marketing: 180 },- { region: "East", sales: 220, marketing: 140 },-];-\`\`\`--## Key Differences from BarChart--- **Compact**: Designed for smaller spaces with a default height of 200px-- **No Interactive Legend**: Legend is simplified and non-interactive-- **Tick Variants**: Supports both horizontal (singleLine) and angled labels-- **Performance**: Optimized for quick rendering in dashboards--## Performance Considerations-- **Data Density**: For very large datasets, consider disabling animations-- **Responsiveness**: The chart is fully responsive, but test label visibility on small screens-- **Animation**: Controlled via \`isAnimationActive={false}\`-`,- },- },- },- tags: ["dev", "autodocs"],- argTypes: {- data: {- description: `-**Required.** An array of data objects for the bar chart. Each object should contain:-- A category identifier (string/number) for the X-axis.-- One or more numeric values for the Y-axis bars.-`,- control: false,- table: {- type: { summary: "Array<Record<string, string | number>>" },- category: "📊 Data Configuration",- },- },- categoryKey: {- description:- "**Required.** The key in your data object that represents the category for the X-axis.",- control: false,- table: {- type: { summary: "string" },- category: "📊 Data Configuration",- },- },- theme: {- description:- "Specifies the color palette for the chart's bars and tooltips. Ignored when customPalette is provided.",- control: "select",- options: ["ocean", "orchid", "emerald", "sunset", "spectrum", "vivid"],- table: {- defaultValue: { summary: "ocean" },- category: "🎨 Visual Styling",- },- },- customPalette: {- description:- "Custom array of colors to use instead of the theme palette. Overrides the theme prop when provided.",- control: "object",- table: {- type: { summary: "string[]" },- category: "🎨 Visual Styling",- },- },- variant: {- description:- "Defines how multiple data series are displayed: `grouped` (side-by-side) or `stacked` (on top of each other).",- 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' (rotated at optimal angle).",- control: "radio",- options: ["singleLine", "angled"],- table: {- defaultValue: { summary: "singleLine" },- category: "🎨 Visual Styling",- },- },- radius: {- description: "Sets the corner radius for the top of each bar, creating a rounded look.",- control: { type: "number", min: 0, max: 12, step: 1 },- table: {- defaultValue: { summary: "4" },- category: "🎨 Visual Styling",- },- },- icons: {- description:- "An object mapping data series keys to React components to be used as icons in the legend.",- control: false,- table: {- type: { summary: "Record<string, React.ReactNode>" },- category: "🎨 Visual Styling",- },- },- grid: {- description: "Toggles the visibility of the background grid lines.",- control: "boolean",- table: {- defaultValue: { summary: "true" },- category: "📱 Display Options",- },- },- showYAxis: {- description: "Toggles the visibility of the Y-axis line and labels.",- control: "boolean",- table: {- defaultValue: { summary: "true" },- category: "📱 Display Options",- },- },- xAxisLabel: {- description: "A label to display below the X-axis.",- control: "text",- table: {- type: { summary: "React.ReactNode" },- category: "📱 Display Options",- },- },- yAxisLabel: {- description: "A label to display beside the Y-axis.",- control: "text",- table: {- type: { summary: "React.ReactNode" },- category: "📱 Display Options",- },- },- isAnimationActive: {- description: "Enables or disables the initial loading animation for the bars.",- control: "boolean",- table: {- defaultValue: { summary: "false" },- category: "🎬 Animation & Interaction",- },- },- height: {- description: "Sets a fixed height for the chart container in pixels.",- control: "number",- table: {- defaultValue: { summary: "200" },- type: { summary: "number" },- category: "Layout & Sizing",- },- },- width: {- description: "Sets a fixed width for the chart container in pixels.",- control: "number",- table: {- type: { summary: "number" },- category: "Layout & Sizing",- },- },- className: {- description: "Custom CSS class to apply to the chart's container.",- control: "text",- table: {- type: { summary: "string" },- category: "Layout & Sizing",- },- },- },-} satisfies Meta<typeof BarChartCondensed>;--export default meta;-type Story = StoryObj<typeof meta>;--/**- * ## Comprehensive Data Explorer- *- * This story serves as a comprehensive test suite for the BarChartCondensed component.- * Use the buttons to switch between various datasets designed to test edge cases in:- *- * - **Label Handling**: Datasets with long, dense, or overlapping labels.- * - **Data Density**: Scenarios with few or many data points.- * - **Chart Variants**: Toggle between grouped and stacked layouts.- * - **Tick Variants**: Toggle between horizontal and angled label orientations.- *- * It's an excellent tool for developers to see how the chart behaves under different conditions.- */-export const DataExplorer: Story = {- name: "🎛️ Comprehensive Data Explorer",- args: {- data: barChartCondensedData,- categoryKey: "month",- theme: "ocean",- variant: "grouped",- tickVariant: "singleLine",- radius: 4,- grid: true,- isAnimationActive: false,- showYAxis: true,- xAxisLabel: "Time Period",- yAxisLabel: "Values",- height: 200,- },- render: (args: any) => {- const [selectedDataType, setSelectedDataType] =- useState<keyof typeof dataVariations>("default");- const [variant, setVariant] = useState<"grouped" | "stacked">("grouped");- const [tickVariant, setTickVariant] = useState<"singleLine" | "angled">("singleLine");-- const currentData = dataVariations[selectedDataType];- const currentCategoryKey = categoryKeys[selectedDataType];-- const buttonStyle = {- margin: "2px",- padding: "6px 12px",- fontSize: "12px",- border: "1px solid #ddd",- borderRadius: "4px",- cursor: "pointer",- background: "#fff",- fontFamily: "monospace",- };-- const activeButtonStyle = {- ...buttonStyle,- background: "#007acc",- color: "white",- border: "1px solid #007acc",- };-- return (- <div>- <div- style={{- marginBottom: "16px",- padding: "12px",- background: "#f8f9fa",- borderRadius: "8px",- border: "1px solid #e9ecef",- width: "600px",- }}- >- <strong>🏷️ Dataset Selection:</strong>- <div style={{ marginTop: "8px", display: "flex", flexWrap: "wrap", gap: "4px" }}>- <button- onClick={() => setSelectedDataType("default")}- style={selectedDataType === "default" ? activeButtonStyle : buttonStyle}- >- 📅 Default (12 months)- </button>- <button- onClick={() => setSelectedDataType("bigLabels")}- style={selectedDataType === "bigLabels" ? activeButtonStyle : buttonStyle}- >- 🏷️ Big Labels- </button>- <button- onClick={() => setSelectedDataType("companyNames")}- style={selectedDataType === "companyNames" ? activeButtonStyle : buttonStyle}- >- 🏢 Company Names- </button>- <button- onClick={() => setSelectedDataType("financialQuarters")}- style={selectedDataType === "financialQuarters" ? activeButtonStyle : buttonStyle}- >- 📈 Financial Quarters- </button>- <button- onClick={() => setSelectedDataType("minimal")}- style={selectedDataType === "minimal" ? activeButtonStyle : buttonStyle}- >- 📱 Minimal (3 items)- </button>- <button- onClick={() => setSelectedDataType("weeklyTraffic")}- style={selectedDataType === "weeklyTraffic" ? activeButtonStyle : buttonStyle}- >- 📊 Weekly Traffic- </button>- </div>- <div style={{ marginTop: "12px" }}>- <strong>📊 Chart Variant:</strong>- <div style={{ marginTop: "8px", display: "flex", gap: "4px" }}>- <button- onClick={() => setVariant("grouped")}- style={variant === "grouped" ? activeButtonStyle : buttonStyle}- >- Grouped (Side-by-side)- </button>- <button- onClick={() => setVariant("stacked")}- style={variant === "stacked" ? activeButtonStyle : buttonStyle}- >- Stacked (On top)- </button>- </div>- </div>- <div style={{ marginTop: "12px" }}>- <strong>📐 Tick Variant:</strong>- <div style={{ marginTop: "8px", display: "flex", gap: "4px" }}>- <button- onClick={() => setTickVariant("singleLine")}- style={tickVariant === "singleLine" ? activeButtonStyle : buttonStyle}- >- Horizontal Labels- </button>- <button- onClick={() => setTickVariant("angled")}- style={tickVariant === "angled" ? activeButtonStyle : buttonStyle}- >- Angled Labels- </button>- </div>- </div>- <div- style={{ marginTop: "12px", fontSize: "12px", color: "#666", fontFamily: "monospace" }}- >- <div>- <strong>Current Dataset:</strong> {selectedDataType}- </div>- <div>- <strong>Items:</strong> {currentData.length} | <strong>Category Key:</strong>{" "}- {currentCategoryKey} | <strong>Variant:</strong> {variant} | <strong>Tick:</strong>{" "}- {tickVariant}- </div>- </div>- </div>- <Card style={{ width: "600px" }}>- <BarChartCondensed- {...args}- data={currentData}- categoryKey={currentCategoryKey}- variant={variant}- tickVariant={tickVariant}- />- </Card>- </div>- );- },- parameters: {- docs: {- description: {- story:- "**🎛️ Interactive Explorer:** This story allows you to explore different datasets, chart variants, and tick variants interactively. Use the buttons to switch between:\n\n**Datasets:**\n- **Default**: Standard 12-month data\n- **Big Labels**: Extremely long category names\n- **Company Names**: Real-world business names\n- **Financial Quarters**: Quarterly financial data\n- **Minimal**: Baseline with 3 items\n- **Weekly Traffic**: 7-day traffic data\n\n**Chart Variants:**\n- **Grouped**: Bars side-by-side for comparison\n- **Stacked**: Bars stacked to show totals\n\n**Tick Variants:**\n- **Horizontal Labels**: Standard single-line labels with collision detection\n- **Angled Labels**: Rotated labels for better space utilization",- },- },- },-};--/**- * ## Large Dataset with Sidebar Tooltip- *- * This story demonstrates the sidebar tooltip feature that appears when you have- * more than 10 data series. Click on any bar in the chart to see the sidebar- * tooltip in action. This provides a better UX for viewing many data series at once.- */-export const LargeDatasetWithSidebarTooltip: Story = {- name: "🎯 Large Dataset (>10 Series) - Sidebar Tooltip",- args: {- data: [- {- quarter: "Q1",- metric1: 120,- metric2: 150,- metric3: 180,- metric4: 200,- metric5: 160,- metric6: 190,- metric7: 220,- metric8: 240,- metric9: 210,- metric10: 230,- metric11: 250,- metric12: 270,- metric13: 260,- metric14: 280,- metric15: 300,- },- {- quarter: "Q2",- metric1: 140,- metric2: 170,- metric3: 200,- metric4: 220,- metric5: 180,- metric6: 210,- metric7: 240,- metric8: 260,- metric9: 230,- metric10: 250,- metric11: 270,- metric12: 290,- metric13: 280,- metric14: 300,- metric15: 320,- },- {- quarter: "Q3",- metric1: 160,- metric2: 190,- metric3: 220,- metric4: 240,- metric5: 200,- metric6: 230,- metric7: 260,- metric8: 280,- metric9: 250,- metric10: 270,- metric11: 290,- metric12: 310,- metric13: 300,- metric14: 320,- metric15: 340,- },- {- quarter: "Q4",- metric1: 180,- metric2: 210,- metric3: 240,- metric4: 260,- metric5: 220,- metric6: 250,- metric7: 280,- metric8: 300,- metric9: 270,- metric10: 290,- metric11: 310,- metric12: 330,- metric13: 320,- metric14: 340,- metric15: 360,- },- ] as any,- categoryKey: "quarter" as any,- theme: "ocean",- variant: "grouped",- tickVariant: "singleLine",- grid: true,- isAnimationActive: false,- showYAxis: true,- xAxisLabel: "Quarters",- yAxisLabel: "Performance Metrics",- height: 300,- },- render: (args: any) => (- <div>- <div- style={{- marginBottom: "16px",- padding: "16px",- background: "#e3f2fd",- borderRadius: "8px",- border: "2px solid #2196f3",- maxWidth: "700px",- }}- >- <div style={{ fontSize: "14px", marginBottom: "8px" }}>- <strong>🎯 Sidebar Tooltip Demo</strong>- </div>- <div style={{ fontSize: "13px", color: "#1565c0", lineHeight: "1.6" }}>- This chart has <strong>15 data series</strong> (more than 10). <br />- <strong>✨ Click on any bar</strong> in the chart to open the sidebar tooltip on the right- side.- <br />- The sidebar provides a scrollable list of all series values at that quarter, making it- easy to view large datasets.- <br />- <em>- 💡 Try hovering first (shows inline tooltip), then click to see the sidebar version!- </em>- </div>- </div>- <Card style={{ width: "700px" }}>- <BarChartCondensed {...args} />- </Card>- </div>- ),- parameters: {- docs: {- description: {- story:- "**🎯 Large Dataset Handling:** When your chart has more than 10 data series, the inline tooltip becomes too crowded. This story demonstrates the sidebar tooltip feature:\n\n**Features:**\n- **15 data series** to showcase the sidebar tooltip\n- **Click interaction:** Click any bar to open the sidebar\n- **Scrollable view:** All series values in an organized, scrollable list\n- **Better UX:** Cleaner way to view many data points simultaneously\n- **Color-coded:** Each series maintains its color for easy identification\n- **Works with both variants:** Try switching between grouped and stacked variants\n\n**Usage:**\n1. Hover over the chart to see the inline tooltip (works for smaller datasets)\n2. Click on any bar to open the sidebar tooltip\n3. Scroll through all 15 series values\n4. Click outside or on the X button to close the sidebar",- },- },- },-};--/**- * ## Grouped vs Stacked Comparison- *- * Side-by-side comparison of grouped and stacked bar chart variants.- * This helps you choose the right variant for your data visualization needs.- */-export const VariantComparison: Story = {- name: "📊 Grouped vs Stacked Comparison",- render: () => (- <div style={{ display: "flex", flexDirection: "column", gap: "24px" }}>- <Card style={{ width: "700px", padding: "16px" }}>- <div style={{ marginBottom: "12px" }}>- <div style={{ fontSize: "16px", fontWeight: "600", marginBottom: "4px" }}>- Grouped Variant (Side-by-side)- </div>- <div style={{ fontSize: "13px", color: "#666" }}>- Best for comparing individual values across categories- </div>- </div>- <BarChartCondensed- data={dataVariations.default as any}- categoryKey="month"- variant="grouped"- theme="ocean"- height={200}- />- </Card>- <Card style={{ width: "700px", padding: "16px" }}>- <div style={{ marginBottom: "12px" }}>- <div style={{ fontSize: "16px", fontWeight: "600", marginBottom: "4px" }}>- Stacked Variant (On top of each other)- </div>- <div style={{ fontSize: "13px", color: "#666" }}>- Best for showing how parts contribute to a total- </div>- </div>- <BarChartCondensed- data={dataVariations.default as any}- categoryKey="month"- variant="stacked"- theme="emerald"- height={200}- />- </Card>- </div>- ),- parameters: {- docs: {- description: {- story:- "**Side-by-side comparison** of chart variants:\n\n- **Grouped**: Bars are placed side-by-side within each category. Perfect for comparing individual values across different categories.\n- **Stacked**: Bars are stacked on top of each other to show how parts contribute to a total. Great for showing composition and totals simultaneously.\n\n**When to use each:**\n- Use **grouped** when you want to compare individual series values\n- Use **stacked** when you want to emphasize totals and part-to-whole relationships",- },- },- },-};--/**- * ## Big Labels with Angled Ticks- *- * This story demonstrates the chart's ability to handle very long category labels.- * The angled tick variant is particularly useful here for preventing label overlap.- */-export const BigLabelsStory: Story = {- name: "🏷️ Big Labels (Angled Ticks)",- args: {- data: dataVariations.bigLabels as any,- categoryKey: "category" as any,- theme: "emerald",- variant: "grouped",- tickVariant: "angled",- radius: 4,- grid: true,- isAnimationActive: false,- showYAxis: true,- height: 250,- },- render: (args: any) => (- <Card style={{ width: "700px" }}>- <BarChartCondensed {...args} />- </Card>- ),- parameters: {- docs: {- description: {- story:- "Tests the chart with extremely long category names. The angled tick variant automatically rotates labels at an optimal angle to prevent overlapping and maximize readability.",- },- },- },-};--/**- * ## Company Names with Big Numbers- *- * This story tests the chart with real-world company names and very large numbers (billions/trillions).- * It demonstrates both label handling and number formatting capabilities.- */-export const CompanyNamesStory: Story = {- name: "🏢 Company Names (Big Numbers)",- args: {- data: dataVariations.companyNames as any,- categoryKey: "company" as any,- theme: "vivid",- variant: "grouped",- tickVariant: "angled",- radius: 4,- grid: true,- isAnimationActive: false,- showYAxis: true,- height: 250,- },- render: (args: any) => (- <Card style={{ width: "700px" }}>- <BarChartCondensed {...args} />- </Card>- ),- parameters: {- docs: {- description: {- story:- "Tests with real-world company names and very large numbers (billions and trillions). The Y-axis should format numbers with appropriate suffixes (B, T).",- },- },- },-};--/**- * ## Financial Quarters (Grouped)- *- * Standard financial reporting scenario with quarterly data in grouped layout.- */-export const FinancialQuartersGrouped: Story = {- name: "📈 Financial Quarters (Grouped)",- args: {- data: dataVariations.financialQuarters as any,- categoryKey: "quarter" as any,- theme: "sunset",- variant: "grouped",- tickVariant: "singleLine",- radius: 4,- grid: true,- isAnimationActive: false,- showYAxis: true,- height: 220,- },- render: (args: any) => (- <Card style={{ width: "600px" }}>- <BarChartCondensed {...args} />- </Card>- ),- parameters: {- docs: {- description: {- story:- "Financial reporting scenario with quarterly data. Grouped layout allows comparison of revenue, expenses, and profit across quarters.",- },- },- },-};--/**- * ## Financial Quarters (Stacked)- *- * Same financial data in stacked layout to show totals and composition.- */-export const FinancialQuartersStacked: Story = {- name: "📈 Financial Quarters (Stacked)",- args: {- data: dataVariations.financialQuarters as any,- categoryKey: "quarter" as any,- theme: "orchid",- variant: "stacked",- tickVariant: "singleLine",- radius: 4,- grid: true,- isAnimationActive: false,- showYAxis: true,- height: 220,- },- render: (args: any) => (- <Card style={{ width: "600px" }}>- <BarChartCondensed {...args} />- </Card>- ),- parameters: {- docs: {- description: {- story:- "Same financial data in stacked layout. This view emphasizes the total values and how components contribute to them.",- },- },- },-};--/**- * ## Weekly Traffic Analytics- *- * Typical analytics dashboard data showing weekly traffic metrics.- */-export const WeeklyTrafficStory: Story = {- name: "📊 Weekly Traffic Analytics",- args: {- data: dataVariations.weeklyTraffic as any,- categoryKey: "day" as any,- theme: "spectrum",- variant: "grouped",- tickVariant: "singleLine",- radius: 4,- grid: true,- isAnimationActive: false,- showYAxis: true,- height: 220,- },- render: (args: any) => (- <Card style={{ width: "650px" }}>- <BarChartCondensed {...args} />- </Card>- ),- parameters: {- docs: {- description: {- story: "Weekly traffic analytics showing visits, conversions, and bounces across the week.",- },- },- },-};--/**- * ## Minimal Data- *- * A baseline test with a small dataset and standard-length labels.- */-export const MinimalDataStory: Story = {- name: "📱 Minimal Data (Baseline)",- args: {- data: dataVariations.minimal as any,- categoryKey: "category" as any,- theme: "emerald",- variant: "grouped",- tickVariant: "singleLine",- radius: 4,- grid: true,- isAnimationActive: false,- showYAxis: true,- height: 200,- },- render: (args: any) => (- <Card style={{ width: "400px" }}>- <BarChartCondensed {...args} />- </Card>- ),- parameters: {- docs: {- description: {- story: "Baseline test with minimal data (3 items) and standard-length labels.",- },- },- },-};--/**- * ## Custom Palette- *- * This story demonstrates how to use the customPalette prop to provide your own color scheme.- */-export const CustomPaletteStory: Story = {- name: "🎨 Custom Palette",- args: {- data: dataVariations.default as any,- categoryKey: "month" as any,- theme: "ocean", // This will be overridden by customPalette- variant: "grouped",- tickVariant: "singleLine",- radius: 4,- grid: true,- isAnimationActive: false,- showYAxis: true,- xAxisLabel: "Month",- yAxisLabel: "Traffic",- customPalette: ["#FF6B6B", "#4ECDC4", "#45B7D1"],- height: 200,- },- render: (args: any) => (- <div>- <div- style={{- marginBottom: "16px",- padding: "12px",- background: "#f8f9fa",- borderRadius: "8px",- border: "1px solid #e9ecef",- width: "600px",- }}- >- <h4 style={{ margin: "0 0 8px 0", color: "#333" }}>🎨 Custom Color Palette</h4>- <p style={{ margin: "0 0 12px 0", fontSize: "14px", color: "#666" }}>- This chart uses a custom color palette instead of the default theme colors.- </p>- <div style={{ display: "flex", gap: "8px", flexWrap: "wrap" }}>- {args.customPalette?.map((color: string, index: number) => (- <div- key={index}- style={{- display: "flex",- alignItems: "center",- gap: "4px",- padding: "4px 8px",- background: "white",- borderRadius: "4px",- border: "1px solid #ddd",- fontSize: "12px",- }}- >- <div- style={{- width: "12px",- height: "12px",- borderRadius: "2px",- backgroundColor: color,- border: "1px solid #ccc",- }}- />- <span style={{ fontFamily: "monospace" }}>{color}</span>- </div>- ))}- </div>- </div>- <Card style={{ width: "600px" }}>- <BarChartCondensed {...args} />- </Card>- </div>- ),- parameters: {- docs: {- description: {- story:- 'Demonstrates how to use the `customPalette` prop to provide your own color scheme. When `customPalette` is provided, it overrides the `theme` prop.\n\n**Usage:**\n```tsx\n<BarChartCondensed\n data={data}\n categoryKey="month"\n customPalette={["#FF6B6B", "#4ECDC4", "#45B7D1"]}\n/>\n```',- },- },- },-};--/**- * ## Radius Comparison- *- * Compare different corner radius values for the bars.- */-export const RadiusComparison: Story = {- name: "🔘 Radius Comparison",- render: () => (- <div style={{ display: "flex", flexDirection: "column", gap: "24px" }}>- <Card style={{ width: "700px", padding: "16px" }}>- <div style={{ marginBottom: "12px" }}>- <div style={{ fontSize: "16px", fontWeight: "600", marginBottom: "4px" }}>- Sharp Corners (0px)- </div>- <div style={{ fontSize: "13px", color: "#666" }}>No rounding, clean angular look</div>- </div>- <BarChartCondensed- data={dataVariations.default as any}- categoryKey="month"- variant="grouped"- theme="ocean"- radius={0}- height={180}- />- </Card>- <Card style={{ width: "700px", padding: "16px" }}>- <div style={{ marginBottom: "12px" }}>- <div style={{ fontSize: "16px", fontWeight: "600", marginBottom: "4px" }}>- Default Radius (4px)- </div>- <div style={{ fontSize: "13px", color: "#666" }}>Subtle rounding, balanced look</div>- </div>- <BarChartCondensed- data={dataVariations.default as any}- categoryKey="month"- variant="grouped"- theme="emerald"- radius={4}- height={180}- />- </Card>- <Card style={{ width: "700px", padding: "16px" }}>- <div style={{ marginBottom: "12px" }}>- <div style={{ fontSize: "16px", fontWeight: "600", marginBottom: "4px" }}>- Rounded Corners (8px)- </div>- <div style={{ fontSize: "13px", color: "#666" }}>More pronounced rounding</div>- </div>- <BarChartCondensed- data={dataVariations.default as any}- categoryKey="month"- variant="grouped"- theme="sunset"- radius={8}- height={180}- />- </Card>- </div>- ),- parameters: {- docs: {- description: {- story:- "**Radius comparison** showing different corner radius values:\n\n- **0px**: Sharp, angular corners for a clean, modern look\n- **4px**: Default subtle rounding, balanced appearance\n- **8px**: More pronounced rounding for a softer appearance\n\n**When to use each:**\n- Use **0px** for a clean, technical, or minimalist aesthetic\n- Use **4px** (default) for general purpose use\n- Use **8px** for a friendlier, more approachable design",- },- },- },-};--/**- * ## Tick Variant Comparison- *- * Side-by-side comparison of single-line (horizontal) and angled tick variants.- */-export const TickVariantComparison: Story = {- name: "📐 Tick Variant Comparison",- render: () => (- <div style={{ display: "flex", flexDirection: "column", gap: "24px" }}>- <Card style={{ width: "700px", padding: "16px" }}>- <div style={{ marginBottom: "12px" }}>- <div style={{ fontSize: "16px", fontWeight: "600", marginBottom: "4px" }}>- Single Line Variant (Horizontal)- </div>- <div style={{ fontSize: "13px", color: "#666" }}>- Standard horizontal labels. Recharts automatically hides overlapping labels.- </div>- </div>- <BarChartCondensed- data={dataVariations.bigLabels as any}- categoryKey="category"- variant="grouped"- tickVariant="singleLine"- theme="ocean"- height={200}- />- </Card>- <Card style={{ width: "700px", padding: "16px" }}>- <div style={{ marginBottom: "12px" }}>- <div style={{ fontSize: "16px", fontWeight: "600", marginBottom: "4px" }}>- Angled Variant (Rotated)- </div>- <div style={{ fontSize: "13px", color: "#666" }}>- Automatically rotates labels at an optimal angle. Shows more labels without collision.- </div>- </div>- <BarChartCondensed- data={dataVariations.bigLabels as any}- categoryKey="category"- variant="grouped"- tickVariant="angled"- theme="emerald"- height={260}- />- </Card>- </div>- ),- parameters: {- docs: {- description: {- story:- "**Side-by-side comparison** of tick variants:\n\n- **Single Line**: Standard horizontal labels with automatic collision detection. Recharts hides overlapping labels.\n- **Angled**: Rotates labels at an optimal angle calculated based on label width and available space. Shows more labels without collision.\n\n**When to use each:**\n- Use **singleLine** for short labels or when you have few data points\n- Use **angled** for long labels or many data points where horizontal labels would overlap",- },- },- },-};--/**- * ## Super Condensed Bar Chart- *- * This story demonstrates the chart with many data points in a very narrow container,- * creating extremely thin bars. This tests the minimum bar width logic and the- * automatic removal of rounded corners for bars thinner than 7px.- */-export const SuperCondensedStory: Story = {- name: "🔬 Super Condensed (Many Bars)",- args: {- data: [- { month: "Jan '23", desktop: 150, mobile: 90, tablet: 60 },- { month: "Feb '23", desktop: 280, mobile: 180, tablet: 100 },- { month: "Mar '23", desktop: 220, mobile: 140, tablet: 80 },- { month: "Apr '23", desktop: 180, mobile: 160, tablet: 90 },- { month: "May '23", desktop: 250, mobile: 120, tablet: 70 },- { month: "Jun '23", desktop: 300, mobile: 180, tablet: 110 },- { month: "Jul '23", desktop: 350, mobile: 220, tablet: 130 },- { month: "Aug '23", desktop: 400, mobile: 240, tablet: 150 },- { month: "Sep '23", desktop: 450, mobile: 260, tablet: 170 },- { month: "Oct '23", desktop: 500, mobile: 280, tablet: 190 },- { month: "Nov '23", desktop: 550, mobile: 300, tablet: 210 },- { month: "Dec '23", desktop: 600, mobile: 320, tablet: 230 },- { month: "Jan '24", desktop: 620, mobile: 340, tablet: 250 },- { month: "Feb '24", desktop: 640, mobile: 360, tablet: 270 },- { month: "Mar '24", desktop: 680, mobile: 380, tablet: 290 },- { month: "Apr '24", desktop: 700, mobile: 400, tablet: 310 },- { month: "May '24", desktop: 720, mobile: 420, tablet: 330 },- { month: "Jun '24", desktop: 750, mobile: 440, tablet: 350 },- { month: "Jul '24", desktop: 780, mobile: 460, tablet: 370 },- { month: "Aug '24", desktop: 800, mobile: 480, tablet: 390 },- { month: "Sep '24", desktop: 820, mobile: 500, tablet: 410 },- { month: "Oct '24", desktop: 850, mobile: 520, tablet: 430 },- { month: "Nov '24", desktop: 880, mobile: 540, tablet: 450 },- { month: "Dec '24", desktop: 900, mobile: 560, tablet: 470 },- ] as any,- categoryKey: "month" as any,- theme: "ocean",- variant: "grouped",- tickVariant: "angled",- radius: 4,- grid: true,- isAnimationActive: false,- showYAxis: true,- height: 180,- },- render: (args: any) => (- <div>- <div- style={{- marginBottom: "16px",- padding: "12px",- background: "#f8f9fa",- borderRadius: "8px",- border: "1px solid #e9ecef",- width: "320px",- }}- >- <h4 style={{ margin: "0 0 8px 0", color: "#333" }}>🔬 Ultra Condensed View</h4>- <p style={{ margin: "0 0 12px 0", fontSize: "14px", color: "#666" }}>- 24 months × 3 series = 72 bars in 320px width. Each bar is ~4px wide or less!- </p>- <ul style={{ margin: "0", paddingLeft: "20px", fontSize: "12px", color: "#666" }}>- <li>Bars {"<"} 7px wide = no rounded corners</li>- <li>Minimum bar width: 2px enforced</li>- <li>Angled labels prevent overlap</li>- <li>Internal lines hidden on thin bars</li>- </ul>- </div>- <Card style={{ width: "320px" }}>- <BarChartCondensed {...args} />- </Card>- </div>- ),- parameters: {- docs: {- description: {- story:- "**Extreme density test** with 24 data points × 3 series (72 total bars) in a 320px container, making each bar approximately 4px wide or less. This demonstrates:\n\n- **Automatic corner removal**: Bars thinner than 7px automatically become square (no rounded corners)\n- **Minimum width enforcement**: Bars maintain a minimum width of 2px for visibility\n- **Grouped bar handling**: Multiple series create even thinner individual bars\n- **Label handling**: Angled labels prevent overlap in ultra-dense scenarios\n- **Internal line hiding**: The internal line is hidden when bars are too thin to display it properly\n\nThis represents an extreme edge case useful for:\n- Compact dashboard widgets\n- Sidebar sparkline-style analytics\n- Mobile-optimized views\n- High-density data visualization in limited space",- },- },- },-};--/**- * ## Responsive Behavior Demo- *- * This story demonstrates the responsive capabilities of the BarChartCondensed.- * Drag the handles on the container to resize it and observe how the chart adapts.- */-export const ResponsiveBehaviorDemo: Story = {- name: "📱 Responsive Behavior Demo",- args: {- data: dataVariations.bigLabels as any,- categoryKey: "category" as any,- theme: "sunset",- variant: "grouped",- tickVariant: "angled",- radius: 4,- grid: true,- isAnimationActive: false,- showYAxis: true,- height: 250,- },- render: (args: any) => {- const [dimensions, setDimensions] = useState<{ width: number }>({- width: 700,- });-- const handleMouseDown = (e: React.MouseEvent<HTMLDivElement>, handle: string) => {- e.preventDefault();- e.stopPropagation();- const startX = e.clientX;- const startWidth = dimensions.width;-- const doDrag = (e: MouseEvent) => {- const dx = e.clientX - startX;- let newWidth = startWidth;-- if (handle.includes("e")) newWidth = startWidth + dx;- if (handle.includes("w")) newWidth = startWidth - dx;-- setDimensions({- width: Math.max(300, newWidth),- });- };-- const stopDrag = () => {- document.removeEventListener("mousemove", doDrag);- document.removeEventListener("mouseup", stopDrag);- };-- document.addEventListener("mousemove", doDrag);- document.addEventListener("mouseup", stopDrag);- };-- const handleStyle: React.CSSProperties = {- position: "absolute",- background: "#3b82f6",- opacity: 0.6,- zIndex: 10,- transition: "opacity 0.2s ease",- };-- return (- <div style={{ padding: "20px" }}>- <div style={{ marginBottom: "20px" }}>- <h3 style={{ margin: "0 0 8px 0", fontSize: "18px", fontWeight: "600" }}>- Responsive Behavior Demonstration- </h3>- <p style={{ margin: "0 0 12px 0", color: "#666", fontSize: "14px" }}>- Drag the left or right edges of the container to see how the chart adapts- </p>- <div- style={{- padding: "12px",- backgroundColor: "#e3f2fd",- borderRadius: "6px",- fontSize: "12px",- color: "#1565c0",- }}- >- <strong>🎯 Try This:</strong> Resize the container to see how bar widths and labels- adapt to available space.- </div>- </div>-- <Card- style={{- position: "relative",- width: `${dimensions.width}px`,- border: "2px dashed #9ca3af",- padding: "20px",- boxSizing: "border-box",- overflow: "hidden",- cursor: "default",- }}- >- <BarChartCondensed {...args} />-- {/* Resize Handles */}- <div- style={{ ...handleStyle, top: 0, bottom: 0, left: -2, width: 12, cursor: "ew-resize" }}- onMouseDown={(e) => handleMouseDown(e, "w")}- />- <div- style={{ ...handleStyle, top: 0, bottom: 0, right: -2, width: 12, cursor: "ew-resize" }}- onMouseDown={(e) => handleMouseDown(e, "e")}- />-- {/* Dimension Display */}- <div- style={{- position: "absolute",- bottom: 8,- right: 8,- background: "rgba(0,0,0,0.8)",- color: "white",- padding: "4px 8px",- borderRadius: "4px",- fontSize: "11px",- fontFamily: "monospace",- fontWeight: "500",- }}- >- {dimensions.width}px- </div>- </Card>- </div>- );- },-};--/**- * 🎯 Bar Width Testing Playground- * Interactive story to test bar width calculations with various configurations:- * - Different data set sizes (few bars vs many bars)- * - Grouped vs Stacked variants- * - Max bar width constraint (prevents bars from being too wide)- * - Container width variations- */-export const BarWidthPlayground: StoryObj<typeof BarChartCondensed> = {- render: () => {- const [variant, setVariant] = useState<"grouped" | "stacked">("grouped");- const [dataSize, setDataSize] = useState<"small" | "medium" | "large" | "xlarge">("medium");- const [maxBarWidth, setMaxBarWidth] = useState(60);- const [containerWidth, setContainerWidth] = useState<number | undefined>(undefined);-- // Generate data based on size selection- const generateData = () => {- const sizes = {- small: 4,- medium: 12,- large: 24,- xlarge: 50,- };-- const count = sizes[dataSize];- return Array.from({ length: count }, (_, i) => ({- quarter: `Q${(i % 4) + 1} FY${2022 + Math.floor(i / 4)}`,- revenue: Math.floor(Math.random() * 2000000) + 500000,- expenses: Math.floor(Math.random() * 1500000) + 300000,- profit: Math.floor(Math.random() * 800000) + 100000,- }));- };-- const data = generateData();-- return (- <div style={{ padding: "20px" }}>- {/* Control Panel */}- <Card style={{ marginBottom: "24px", padding: "20px" }}>- <h3 style={{ marginTop: 0, marginBottom: "20px", fontSize: "18px", fontWeight: 600 }}>- 🎛️ Bar Width Controls- </h3>-- <div style={{ display: "grid", gridTemplateColumns: "1fr 1fr", gap: "20px" }}>- {/* Variant Control */}- <div>- <label style={{ display: "block", marginBottom: "8px", fontWeight: 500 }}>- Chart Variant- </label>- <div style={{ display: "flex", gap: "8px" }}>- <button- onClick={() => setVariant("grouped")}- style={{- padding: "8px 16px",- borderRadius: "6px",- border: "1px solid",- borderColor: variant === "grouped" ? "#6366f1" : "#e5e7eb",- backgroundColor: variant === "grouped" ? "#6366f1" : "white",- color: variant === "grouped" ? "white" : "#374151",- cursor: "pointer",- fontWeight: 500,- }}- >- Grouped- </button>- <button- onClick={() => setVariant("stacked")}- style={{- padding: "8px 16px",- borderRadius: "6px",- border: "1px solid",- borderColor: variant === "stacked" ? "#6366f1" : "#e5e7eb",- backgroundColor: variant === "stacked" ? "#6366f1" : "white",- color: variant === "stacked" ? "white" : "#374151",- cursor: "pointer",- fontWeight: 500,- }}- >- Stacked- </button>- </div>- </div>-- {/* Data Size Control */}- <div>- <label style={{ display: "block", marginBottom: "8px", fontWeight: 500 }}>- Number of Data Points- </label>- <select- value={dataSize}- onChange={(e) => setDataSize(e.target.value as any)}- style={{- width: "100%",- padding: "8px 12px",- borderRadius: "6px",- border: "1px solid #e5e7eb",- fontSize: "14px",- }}- >- <option value="small">Small (4 points)</option>- <option value="medium">Medium (12 points)</option>- <option value="large">Large (24 points)</option>- <option value="xlarge">X-Large (50 points)</option>- </select>- </div>-- {/* Max Bar Width Control */}- <div style={{ gridColumn: "1 / -1" }}>- <label style={{ display: "block", marginBottom: "8px", fontWeight: 500 }}>- Max Bar Width: {maxBarWidth}px- <span style={{ fontWeight: 400, color: "#6b7280", marginLeft: "8px" }}>- (Prevents bars from becoming too wide)- </span>- </label>- <input- type="range"- min="10"- max="120"- value={maxBarWidth}- onChange={(e) => setMaxBarWidth(Number(e.target.value))}- style={{ width: "100%" }}- />- <div- style={{- display: "flex",- justifyContent: "space-between",- fontSize: "11px",- color: "#6b7280",- marginTop: "4px",- }}- >- <span>10px</span>- <span>120px</span>- </div>- </div>-- {/* Container Width Control */}- <div style={{ gridColumn: "1 / -1" }}>- <label style={{ display: "block", marginBottom: "8px", fontWeight: 500 }}>- Container Width: {containerWidth ? `${containerWidth}px` : "Auto (100%)"}- </label>- <div style={{ display: "flex", gap: "8px", alignItems: "center" }}>- <input- type="range"- min="400"- max="1400"- step="50"- value={containerWidth || 1400}- onChange={(e) => setContainerWidth(Number(e.target.value))}- style={{ flex: 1 }}- disabled={!containerWidth}- />- <button- onClick={() => setContainerWidth(containerWidth ? undefined : 800)}- style={{- padding: "6px 12px",- borderRadius: "6px",- border: "1px solid #e5e7eb",- backgroundColor: containerWidth ? "#ef4444" : "#10b981",- color: "white",- cursor: "pointer",- fontSize: "12px",- fontWeight: 500,- }}- >- {containerWidth ? "Auto" : "Fixed"}- </button>- </div>- <div- style={{- display: "flex",- justifyContent: "space-between",- fontSize: "11px",- color: "#6b7280",- marginTop: "4px",- }}- >- <span>400px</span>- <span>1400px</span>- </div>- </div>- </div>-- {/* Info Display */}- <div- style={{- marginTop: "20px",- padding: "12px",- backgroundColor: "#f3f4f6",- borderRadius: "6px",- fontSize: "13px",- }}- >- <div style={{ display: "grid", gridTemplateColumns: "1fr 1fr 1fr", gap: "12px" }}>- <div>- <strong>Data Points:</strong> {data.length}- </div>- <div>- <strong>Bars per Category:</strong> {variant === "stacked" ? 1 : 3}- </div>- <div>- <strong>Total Bars:</strong> {data.length * (variant === "stacked" ? 1 : 3)}- </div>- </div>- </div>- </Card>-- {/* Chart Display */}- <Card>- <h3 style={{ marginTop: 0, marginBottom: "16px" }}>- {variant === "grouped" ? "📊 Grouped" : "📚 Stacked"} Bar Chart - Bar Width Test- </h3>- <div style={{ width: containerWidth ? `${containerWidth}px` : "100%" }}>- <BarChartCondensed- data={data}- categoryKey="quarter"- variant={variant}- maxBarWidth={maxBarWidth}- width={containerWidth}- height={400}- legend- grid- showYAxis- xAxisLabel="Fiscal Quarter"- yAxisLabel="Amount ($)"- />- </div>- </Card>-- {/* Quick Test Presets */}- <Card style={{ marginTop: "24px", padding: "20px" }}>- <h3 style={{ marginTop: 0, marginBottom: "16px", fontSize: "16px", fontWeight: 600 }}>- 🚀 Quick Test Presets- </h3>- <div style={{ display: "grid", gridTemplateColumns: "repeat(3, 1fr)", gap: "12px" }}>- <button- onClick={() => {- setDataSize("small");- setVariant("grouped");- setMaxBarWidth(60);- setContainerWidth(undefined);- }}- style={{- padding: "12px",- borderRadius: "6px",- border: "1px solid #e5e7eb",- backgroundColor: "white",- cursor: "pointer",- textAlign: "left",- }}- >- <div style={{ fontWeight: 600, marginBottom: "4px" }}>🎯 Few Bars (Wide)</div>- <div style={{ fontSize: "12px", color: "#6b7280" }}>4 points, max 60px cap</div>- </button>-- <button- onClick={() => {- setDataSize("xlarge");- setVariant("grouped");- setMaxBarWidth(60);- setContainerWidth(undefined);- }}- style={{- padding: "12px",- borderRadius: "6px",- border: "1px solid #e5e7eb",- backgroundColor: "white",- cursor: "pointer",- textAlign: "left",- }}- >- <div style={{ fontWeight: 600, marginBottom: "4px" }}>📉 Many Bars (Thin)</div>- <div style={{ fontSize: "12px", color: "#6b7280" }}>- 50 points, auto-sized thin bars- </div>- </button>-- <button- onClick={() => {- setDataSize("large");- setVariant("stacked");- setMaxBarWidth(40);- setContainerWidth(800);- }}- style={{- padding: "12px",- borderRadius: "6px",- border: "1px solid #e5e7eb",- backgroundColor: "white",- cursor: "pointer",- textAlign: "left",- }}- >- <div style={{ fontWeight: 600, marginBottom: "4px" }}>🔄 Fixed Container</div>- <div style={{ fontSize: "12px", color: "#6b7280" }}>24 points, stacked, 800px</div>- </button>-- <button- onClick={() => {- setDataSize("medium");- setVariant("grouped");- setMaxBarWidth(100);- setContainerWidth(undefined);- }}- style={{- padding: "12px",- borderRadius: "6px",- border: "1px solid #e5e7eb",- backgroundColor: "white",- cursor: "pointer",- textAlign: "left",- }}- >- <div style={{ fontWeight: 600, marginBottom: "4px" }}>🎨 Large Max Width</div>- <div style={{ fontSize: "12px", color: "#6b7280" }}>Medium data, max 100px</div>- </button>-- <button- onClick={() => {- setDataSize("small");- setVariant("stacked");- setMaxBarWidth(30);- setContainerWidth(400);- }}- style={{- padding: "12px",- borderRadius: "6px",- border: "1px solid #e5e7eb",- backgroundColor: "white",- cursor: "pointer",- textAlign: "left",- }}- >- <div style={{ fontWeight: 600, marginBottom: "4px" }}>📱 Narrow Container</div>- <div style={{ fontSize: "12px", color: "#6b7280" }}>Small data, 400px width</div>- </button>-- <button- onClick={() => {- setDataSize("xlarge");- setVariant("stacked");- setMaxBarWidth(20);- setContainerWidth(undefined);- }}- style={{- padding: "12px",- borderRadius: "6px",- border: "1px solid #e5e7eb",- backgroundColor: "white",- cursor: "pointer",- textAlign: "left",- }}- >- <div style={{ fontWeight: 600, marginBottom: "4px" }}>🔬 Ultra Condensed</div>- <div style={{ fontSize: "12px", color: "#6b7280" }}>50 points, stacked, max 20px</div>- </button>- </div>- </Card>- </div>- );- },-};diff --git a/packages/react-ui/src/components/D3Charts/LineChart/LineChart.tsx b/packages/react-ui/src/components/D3Charts/LineChart/LineChart.tsxdeleted file mode 100644index a694fabda..000000000--- a/packages/react-ui/src/components/D3Charts/LineChart/LineChart.tsx+++ /dev/null@@ -1,198 +0,0 @@-import clsx from "clsx";-import { useCallback } from "react";--import {- useCartesianChartOrchestrator,- useEffectiveAnimation,- useExportChartData,- useXScale,- useYScale,-} from "../hooks";-import { CartesianXAxis } from "../shared/cartesian/axes/CartesianXAxis";-import { ClipDefs } from "../shared/cartesian/ClipDefs";-import { CartesianChartLayout } from "../shared/cartesian/layouts/CartesianChartLayout";-import { LineDotCrosshair } from "../shared/cartesian/LineDotCrosshair";-import { findNearestDataIndex } from "../utils/mouseUtils";-import { LineSeries } from "./parts/LineSeries";--import { CHART_CLASS_PREFIX } from "../utils/constants";-import type { LineChartData, LineChartProps } from "./types";--/**- * Empty-data guard lives here, in a hook-free dispatcher: the chart impl below- * calls hooks unconditionally, so the "no data" branch must short-circuit- * *before* any hook runs (a count → 0 transition on a mounted chart would- * otherwise break the Rules of Hooks).- */-export function LineChart<T extends LineChartData>(props: LineChartProps<T>) {- if (!props.data || props.data.length === 0) {- return (- <div- className={clsx(- `${CHART_CLASS_PREFIX}-line-chart-container ${CHART_CLASS_PREFIX}-chart-empty`,- props.className,- )}- >- <span className={`${CHART_CLASS_PREFIX}-chart-empty-text`}>No data available</span>- </div>- );- }- return <LineChartImpl {...props} />;-}--function LineChartImpl<T extends LineChartData>({- data,- categoryKey,- customPalette,- variant = "natural",- tickVariant: tickVariantProp,- showDots = false,- dotRadius = 3,- grid = true,- legend: showLegend = true,- icons,- isAnimationActive = false,- showYAxis = true,- xAxisLabel,- yAxisLabel,- className,- height,- width: fixedWidth,- fitLegendInHeight,- condensed = false,- density,- onClick,- crosshair = false,- highlight = false,- activeDots = true,- yTickCount,-}: LineChartProps<T>) {- const animate = useEffectiveAnimation(isAnimationActive);- const mode = condensed ? "fit" : "scroll";-- const orch = useCartesianChartOrchestrator({- layout: mode,- data,- categoryKey,- themePaletteName: "lineChartPalette",- customPalette,- showLegend,- showYAxis,- height,- fixedWidth,- fitLegendInHeight,- tickVariantProp: tickVariantProp ?? (condensed ? "singleLine" : "multiLine"),- chartIdPrefix: "d3lc",- icons,- onClick,- density,- yTickCount,- });-- const xScale = useXScale(- data,- orch.data.catKey,- orch.dimensions.chartAreaWidth,- orch.dimensions.widthOfGroup,- );- const yScale = useYScale(data, orch.data.dataKeys, orch.dimensions.chartInnerHeight, false);-- const getYValue = useCallback(- (row: Record<string, string | number>, key: string) => Number(row[key]) || 0,- [],- );-- const findIndex = useCallback((mouseX: number) => findNearestDataIndex(xScale, mouseX), [xScale]);- const mouseHandlers = orch.hover.createMouseHandlers(findIndex);-- // PPTX print-export JSON — mirrors react-ui's LineChart call (type:'line').- // react-ui also passes `extraOptions: { lineSize: strokeWidth }`, but viz's- // LineChart exposes no stroke-width prop (stroke is CSS-driven), so there is- // no real value to emit — the field is omitted rather than faked. Undefined- // off the print path.- const exportData = useExportChartData({- type: "line",- data,- categoryKey: orch.data.catKey,- dataKeys: orch.data.dataKeys,- colors: orch.data.colors,- legend: showLegend,- xAxisLabel,- yAxisLabel,- });-- return (- <CartesianChartLayout- orch={orch}- yScale={yScale}- mouseHandlers={mouseHandlers}- classPrefix="line-chart"- chartType="line"- exportData={exportData}- ariaLabel="Line chart"- showYAxis={showYAxis}- grid={grid}- showLegend={showLegend}- xAxisLabel={xAxisLabel}- yAxisLabel={yAxisLabel}- yTickCount={yTickCount}- className={className}- defs={- <defs>- <ClipDefs- chartId={orch.identity.chartId}- chartWidth={orch.dimensions.chartAreaWidth}- chartHeight={orch.dimensions.chartInnerHeight}- />- </defs>- }- series={- <>- <LineSeries- data={data}- dataKeys={orch.data.dataKeys}- xScale={xScale}- yScale={yScale}- variant={variant}- categoryKey={orch.data.catKey}- colors={orch.data.colorMap}- showDots={showDots}- dotRadius={dotRadius}- isAnimationActive={animate}- />- <LineDotCrosshair- hoveredIndex={orch.hover.hoveredIndex}- xScale={xScale}- yScale={yScale}- data={data}- dataKeys={orch.data.dataKeys}- categoryKey={orch.data.catKey}- colors={orch.data.colorMap}- chartHeight={orch.dimensions.chartInnerHeight}- getYValue={getYValue}- classPrefix={`${CHART_CLASS_PREFIX}-line-chart`}- crosshair={crosshair}- highlight={highlight}- activeDots={activeDots}- />- </>- }- xAxis={- <CartesianXAxis- mode={mode}- scale={xScale}- classPrefix={`${CHART_CLASS_PREFIX}-line-chart`}- tickVariant={orch.dimensions.tickVariant}- widthOfGroup={orch.dimensions.widthOfGroup}- labelHeight={orch.xAxis.xAxisHeight}- labelWidth={orch.xAxis.labelWidth}- maxLines={orch.xAxis.maxLines}- labelInterval={orch.dimensions.labelInterval}- angle={orch.xAxis.angle}- chartWidth={orch.dimensions.chartAreaWidth}- yAxisWidth={orch.dimensions.effectiveYAxisWidth}- />- }- />- );-}diff --git a/packages/react-ui/src/components/D3Charts/LineChart/index.ts b/packages/react-ui/src/components/D3Charts/LineChart/index.tsdeleted file mode 100644index 3f5501445..000000000--- a/packages/react-ui/src/components/D3Charts/LineChart/index.ts+++ /dev/null@@ -1,2 +0,0 @@-export { LineChart } from "./LineChart";-export type { LineChartData, LineChartProps, LineChartVariant } from "./types";diff --git a/packages/react-ui/src/components/D3Charts/LineChart/lineChart.scss b/packages/react-ui/src/components/D3Charts/LineChart/lineChart.scssdeleted file mode 100644index 2b7609de7..000000000--- a/packages/react-ui/src/components/D3Charts/LineChart/lineChart.scss+++ /dev/null@@ -1,31 +0,0 @@-@use "../../../cssUtils" as cssUtils;-@use "../shared/cartesian/chartBase" as base;-@use "../prefix" as brand;--@include base.chart-base("line-chart");-@include base.crosshair-styles("line-chart");--// No `transition: d/cx/cy` here: data-change motion is the spring data morph-// in LineSeries (gated on isAnimationActive). A CSS transition restarted from-// progress 0 on every attribute write, so per-frame streaming rewrites pinned-// the rendered geometry (and would fight the morph's per-tick writes).-.#{brand.$prefix}-line-chart-line {- fill: none;- stroke-width: 2;-}--.#{brand.$prefix}-line-chart-dot {- stroke: cssUtils.$foreground;- stroke-width: 1;-}--// Entrances are decorative: gate the whole rule (pre-state included) behind-// reduced-motion so users who opt out get the natural static state immediately-// — gating only the animation would strand elements at the opacity: 0 start.-@media (prefers-reduced-motion: no-preference) {- .#{brand.$prefix}-line-chart-line--animated {- stroke-dasharray: var(--path-length);- stroke-dashoffset: var(--path-length);- animation: #{brand.$prefix}-draw-line 1s ease-out forwards;- }-}diff --git a/packages/react-ui/src/components/D3Charts/LineChart/stories/lineChart.stories.tsx b/packages/react-ui/src/components/D3Charts/LineChart/stories/lineChart.stories.tsxdeleted file mode 100644index 550d60f74..000000000--- a/packages/react-ui/src/components/D3Charts/LineChart/stories/lineChart.stories.tsx+++ /dev/null@@ -1,1295 +0,0 @@-// Copy of Charts/LineChart/stories/lineChart.stories.tsx with only the chart import and the title changed:-// the same args and renders, rendering the D3Charts chart via-// ../../stories/rechartsStoryAdapters.-import type { Meta, StoryObj } from "@storybook/react";-import {- Calendar,- Globe,- Laptop,- Monitor,- Smartphone,- TabletSmartphone,- Tv,- Watch,-} from "lucide-react";-import { useState } from "react";-import { Card } from "../../../Card";-import { LineChart, LineChartProps } from "../../stories/rechartsStoryAdapters";--const customColorPalette = [- "#0A0E60",- "#14197B",- "#272DA6",- "#383FC9",- "#444CE7",- "#5F67F4",- "#7884FF",- "#97A9FF",- "#B4C6FF",- "#CBD7FF",-];--// 🔥 COMPREHENSIVE DATA VARIATIONS - Designed to test label collision scenarios-const dataVariations = {- default: [- { month: "January", desktop: 150, mobile: 90, tablet: 120 },- { month: "February", desktop: 280, mobile: 180, tablet: 140 },- { month: "March", desktop: 220, mobile: 140, tablet: 160 },- { month: "April", desktop: 180, mobile: 160, tablet: 180 },- { month: "May", desktop: 250, mobile: 120, tablet: 140 },- { month: "June", desktop: 300, mobile: 180, tablet: 160 },- { month: "July", desktop: 350, mobile: 220, tablet: 180 },- { month: "August", desktop: 400, mobile: 240, tablet: 200 },- { month: "September", desktop: 450, mobile: 260, tablet: 220 },- { month: "October", desktop: 500, mobile: 280, tablet: 240 },- { month: "November", desktop: 550, mobile: 300, tablet: 260 },- { month: "December", desktop: 600, mobile: 320, tablet: 280 },- ],- // 🏷️ BIG LABELS - Testing collision detection and truncation- bigLabels: [- {- category: "Very Long Category Name That Should Be Truncated",- sales: 150,- revenue: 90,- profit: 120,- },- {- category: "Another Extremely Long Label That Causes Collisions",- sales: 280,- revenue: 180,- profit: 140,- },- {- category: "Super Duper Long Category Name That Tests Truncation",- sales: 220,- revenue: 140,- profit: 160,- },- {- category: "Incredibly Long Text That Should Trigger Collision Detection",- sales: 180,- revenue: 160,- profit: 180,- },- {- category: "Maximum Length Category Name That Tests All Edge Cases",- sales: 250,- revenue: 120,- profit: 140,- },- {- category: "Extra Long Business Category Name With Many Words",- sales: 300,- revenue: 180,- profit: 160,- },- {- category: "Comprehensive Long Label For Testing Horizontal Offset",- sales: 350,- revenue: 220,- profit: 180,- },- {- category: "Extended Category Name That Pushes Truncation Limits",- sales: 400,- revenue: 240,- profit: 200,- },- ],- // 📅 DENSE TIMELINE - Many items with medium-length labels- denseTimeline: [- { period: "Q1 2022 Jan-Mar", visitors: 120, conversions: 15, revenue: 1200 },- { period: "Q1 2022 Apr-Jun", visitors: 150, conversions: 22, revenue: 1800 },- { period: "Q2 2022 Jul-Sep", visitors: 180, conversions: 28, revenue: 2100 },- { period: "Q2 2022 Oct-Dec", visitors: 200, conversions: 35, revenue: 2500 },- { period: "Q3 2023 Jan-Mar", visitors: 160, conversions: 18, revenue: 1600 },- { period: "Q3 2023 Apr-Jun", visitors: 190, conversions: 32, revenue: 2300 },- { period: "Q4 2023 Jul-Sep", visitors: 220, conversions: 40, revenue: 2800 },- { period: "Q4 2023 Oct-Dec", visitors: 240, conversions: 45, revenue: 3200 },- { period: "Q1 2024 Jan-Mar", visitors: 210, conversions: 38, revenue: 2700 },- { period: "Q1 2024 Apr-Jun", visitors: 230, conversions: 42, revenue: 3000 },- { period: "Q2 2024 Jul-Sep", visitors: 250, conversions: 48, revenue: 3400 },- { period: "Q2 2024 Oct-Dec", visitors: 270, conversions: 52, revenue: 3800 },- { period: "Q3 2024 Jan-Mar", visitors: 260, conversions: 50, revenue: 3600 },- { period: "Q3 2024 Apr-Jun", visitors: 280, conversions: 55, revenue: 4000 },- { period: "Q4 2024 Jul-Sep", visitors: 300, conversions: 60, revenue: 4300 },- { period: "Q4 2024 Oct-Dec", visitors: 290, conversions: 58, revenue: 4100 },- ],- // 🏢 COMPANY NAMES - Real-world long business names- companyNames: [- { company: "Apple Inc.", revenue: 394328000000, profit: 99803000000, marketCap: 3500000000000 },- {- company: "Microsoft Corporation",- revenue: 211915000000,- profit: 83383000000,- marketCap: 2800000000000,- },- {- company: "Alphabet Inc. (Google)",- revenue: 307394000000,- profit: 76033000000,- marketCap: 2100000000000,- },- {- company: "Amazon.com Inc.",- revenue: 574785000000,- profit: 33364000000,- marketCap: 1600000000000,- },- {- company: "Tesla Motors Inc.",- revenue: 96773000000,- profit: 15000000000,- marketCap: 800000000000,- },- {- company: "Meta Platforms Inc.",- revenue: 134902000000,- profit: 39370000000,- marketCap: 900000000000,- },- {- company: "NVIDIA Corporation",- revenue: 60922000000,- profit: 29760000000,- marketCap: 1800000000000,- },- {- company: "Berkshire Hathaway Inc.",- revenue: 364482000000,- profit: 96223000000,- marketCap: 780000000000,- },- ],- // 🌍 COUNTRY NAMES - Geographic labels with varying lengths- countryData: [- { country: "United States of America", population: 331900000, gdp: 17700000000000 },- { country: "People's Republic of China", population: 1412000000, gdp: 17700000000000 },- { country: "Federal Republic of Germany", population: 83200000, gdp: 4300000000000 },- { country: "United Kingdom of Great Britain", population: 67500000, gdp: 3100000000000 },- { country: "French Republic", population: 68000000, gdp: 2900000000000 },- { country: "Republic of India", population: 1380000000, gdp: 3700000000000 },- { country: "Federative Republic of Brazil", population: 215000000, gdp: 2100000000000 },- { country: "Russian Federation", population: 146000000, gdp: 1800000000000 },- ],- // 📈 FINANCIAL QUARTERS - Testing medium-density scenarios- financialQuarters: [- { quarter: "Q1 FY2022", revenue: 1200000, expenses: 800000, profit: 400000 },- { quarter: "Q2 FY2022", revenue: 1500000, expenses: 950000, profit: 550000 },- { quarter: "Q3 FY2022", revenue: 1800000, expenses: 1100000, profit: 700000 },- { quarter: "Q4 FY2022", revenue: 2000000, expenses: 1300000, profit: 700000 },- { quarter: "Q1 FY2023", revenue: 2200000, expenses: 1400000, profit: 800000 },- { quarter: "Q2 FY2023", revenue: 2500000, expenses: 1600000, profit: 900000 },- { quarter: "Q3 FY2023", revenue: 2800000, expenses: 1800000, profit: 1000000 },- { quarter: "Q4 FY2023", revenue: 3000000, expenses: 1900000, profit: 1100000 },- ],- // 🔤 MIXED LENGTHS - Testing various label length scenarios- mixedLengths: [- { item: "A", valueA: 100, valueB: 80 },- { item: "Short", valueA: 150, valueB: 120 },- { item: "Medium Length Item", valueA: 200, valueB: 160 },- { item: "Very Long Item Name That Tests Truncation", valueA: 250, valueB: 200 },- { item: "B", valueA: 180, valueB: 140 },- { item: "Another Really Long Category Name", valueA: 220, valueB: 180 },- { item: "XL", valueA: 190, valueB: 150 },- ],- // 🎯 EDGE CASES - Extreme scenarios- edgeCases: [- {- name: "SinglePointDataSetForTestingEdgeCasesInCollisionDetectionAndLabelTruncationFunctionality",- value: 500,- },- {- name: "SecondExtremelyLongDataPointNameThatShouldDefinitelyTriggerTruncationMechanisms",- value: 600,- },- ],- // 📱 MINIMAL - Small dataset for baseline testing- minimal: [- { category: "Mobile Devices", users: 150, sessions: 90 },- { category: "Desktop Computers", users: 280, sessions: 180 },- { category: "Tablet Devices", users: 220, sessions: 140 },- ],- // 🔄 EXPAND/COLLAPSE - Marketing channels dataset for legend overflow testing- expandCollapseMarketing: [- {- channel: "Website Traffic and Organic Search Results",- impressions: 120000,- clicks: 15000,- conversions: 1200,- cost: 8500,- revenue: 24000,- roi: 182,- ctr: 12.5,- cpc: 0.57,- cpa: 7.08,- reach: 95000,- engagement: 8200,- shares: 420,- saves: 180,- comments: 650,- videoViews: 0,- },- {- channel: "Social Media Engagement and Brand Awareness",- impressions: 85000,- clicks: 12000,- conversions: 950,- cost: 6200,- revenue: 19000,- roi: 206,- ctr: 14.1,- cpc: 0.52,- cpa: 6.53,- reach: 72000,- engagement: 15400,- shares: 890,- saves: 340,- comments: 1200,- videoViews: 28000,- },- {- channel: "Email Marketing Campaign Performance",- impressions: 45000,- clicks: 8500,- conversions: 800,- cost: 2100,- revenue: 16000,- roi: 562,- ctr: 18.9,- cpc: 0.25,- cpa: 2.63,- reach: 42000,- engagement: 6800,- shares: 120,- saves: 85,- comments: 240,- videoViews: 0,- },- {- channel: "Paid Advertising and PPC Campaign ROI",- impressions: 95000,- clicks: 18000,- conversions: 1500,- cost: 12500,- revenue: 30000,- roi: 140,- ctr: 18.9,- cpc: 0.69,- cpa: 8.33,- reach: 88000,- engagement: 12600,- shares: 320,- saves: 150,- comments: 480,- videoViews: 5200,- },- {- channel: "Content Marketing and Blog Performance",- impressions: 60000,- clicks: 9500,- conversions: 750,- cost: 4800,- revenue: 15000,- roi: 213,- ctr: 15.8,- cpc: 0.51,- cpa: 6.4,- reach: 55000,- engagement: 7800,- shares: 680,- saves: 420,- comments: 950,- videoViews: 12000,- },- {- channel: "Mobile Application Downloads and Usage",- impressions: 70000,- clicks: 11000,- conversions: 1100,- cost: 5500,- revenue: 22000,- roi: 300,- ctr: 15.7,- cpc: 0.5,- cpa: 5.0,- reach: 65000,- engagement: 9200,- shares: 180,- saves: 95,- comments: 320,- videoViews: 8500,- },- {- channel: "Customer Support Response Time and Quality",- impressions: 35000,- clicks: 5500,- conversions: 450,- cost: 2800,- revenue: 9000,- roi: 221,- ctr: 15.7,- cpc: 0.51,- cpa: 6.22,- reach: 32000,- engagement: 4200,- shares: 45,- saves: 25,- comments: 180,- videoViews: 0,- },- {- channel: "Sales Funnel Conversion and Lead Generation",- impressions: 110000,- clicks: 22000,- conversions: 1800,- cost: 15000,- revenue: 36000,- roi: 140,- ctr: 20.0,- cpc: 0.68,- cpa: 8.33,- reach: 98000,- engagement: 18500,- shares: 420,- saves: 280,- comments: 750,- videoViews: 3200,- },- {- channel: "User Retention and Churn Rate Analysis",- impressions: 80000,- clicks: 14000,- conversions: 1200,- cost: 7200,- revenue: 24000,- roi: 233,- ctr: 17.5,- cpc: 0.51,- cpa: 6.0,- reach: 75000,- engagement: 11200,- shares: 280,- saves: 150,- comments: 420,- videoViews: 6800,- },- {- channel: "Product Feature Usage and Performance Metrics",- impressions: 65000,- clicks: 10500,- conversions: 900,- cost: 5200,- revenue: 18000,- roi: 246,- ctr: 16.2,- cpc: 0.5,- cpa: 5.78,- reach: 58000,- engagement: 8500,- shares: 320,- saves: 180,- comments: 650,- videoViews: 4200,- },- {- channel: "Market Research and Competitive Analysis",- impressions: 40000,- clicks: 6500,- conversions: 500,- cost: 3200,- revenue: 10000,- roi: 213,- ctr: 16.3,- cpc: 0.49,- cpa: 6.4,- reach: 36000,- engagement: 5200,- shares: 95,- saves: 65,- comments: 220,- videoViews: 1800,- },- {- channel: "Brand Sentiment and Public Relations Impact",- impressions: 55000,- clicks: 8000,- conversions: 650,- cost: 4100,- revenue: 13000,- roi: 217,- ctr: 14.5,- cpc: 0.51,- cpa: 6.31,- reach: 48000,- engagement: 6800,- shares: 520,- saves: 280,- comments: 950,- videoViews: 15000,- },- ],-};--// Category key mappings for different datasets-const categoryKeys = {- default: "month",- bigLabels: "category",- denseTimeline: "period",- companyNames: "company",- countryData: "country",- financialQuarters: "quarter",- mixedLengths: "item",- edgeCases: "name",- minimal: "category",- expandCollapseMarketing: "channel",-};--// 🔥 ACTIVE DATA - For backward compatibility-const lineChartV2Data = dataVariations.default;--const icons = {- desktop: Monitor,- mobile: TabletSmartphone,- tablet: Calendar,- sales: Globe,- revenue: Smartphone,- profit: Laptop,- visitors: Tv,- conversions: Watch,- users: Monitor,- sessions: TabletSmartphone,-} as const;--/**- * # ScrollableLineChart Component Documentation- *- * The LineChart component is a powerful and flexible tool for visualizing trends over time or comparing continuous data.- * It's ideal for:- *- * - **Time-Series Analysis**: Tracking metrics over days, months, or years.- * - **Comparative Analysis**: Comparing the performance of multiple data series.- * - **Trend Identification**: Spotting upward or downward trends, and patterns in datasets.- *- * ## Key Features- *- * ### Advanced Label Handling- * - **Collision Detection**: Automatically detects and prevents overlapping X-axis labels.- * - **Intelligent Truncation**: Truncates long labels with an ellipsis (...) to keep the chart clean.- * - **Horizontal Offset**: Ensures truncated labels remain horizontally centered for readability.- *- * ### Interactive & Responsive- * - **Interactive Legend**: Allows toggling data series visibility and adapts with a "Show More" feature for many items.- * - **Hover Tooltips**: Provides detailed data points on hover for enhanced user interaction.- * - **Responsive Design**: Fluidly adjusts to any container size, from small widgets to large dashboards.- *- * ### Customization- * - **Theming**: Six pre-built color palettes to fit your application's design, or use custom colors with `customPalette`.- * - **Line Styles**: Supports `linear`, `natural` (smooth), and `step` variants.- * - **Styling Options**: Control stroke width, grid visibility, and more.- */-const meta: Meta<LineChartProps<typeof lineChartV2Data>> = {- title: "Components/D3Charts/ScrollableLineChart",- component: LineChart,- parameters: {- layout: "centered",- docs: {- description: {- component: `-## Installation and Basic Usage--\`\`\`tsx-import { ScrollableLineChart } from '@openuidev/react-ui';--const timeSeriesData = [- { month: "January", desktop: 150, mobile: 90 },- { month: "February", desktop: 280, mobile: 180 },- { month: "March", desktop: 220, mobile: 140 },-];--// Basic implementation-<ScrollableLineChart- data={timeSeriesData}- categoryKey="month"- theme="ocean"-/>--// With custom colors-<ScrollableLineChart- data={timeSeriesData}- categoryKey="month"- customPalette={["#FF6B6B", "#4ECDC4", "#45B7D1"]}-/>-\`\`\`--## Data Structure Requirements--Your data should be an array of objects. Each object must contain:-- A **category field** (string or number): This will be used for the X-axis labels (e.g., dates, names, etc.).-- One or more **data series fields** (number): These are the values that will be plotted on the Y-axis. The key of the field will be used as the series name in the legend and tooltip.--\`\`\`tsx-const salesData = [- { date: "2023-01-01", productA: 4000, productB: 2400 },- { date: "2023-02-01", productA: 3000, productB: 1398 },- { date: "2023-03-01", productA: 2000, productB: 9800 },-];-\`\`\`--## Performance Considerations-- **Data Density**: While the chart can handle many data points, performance may degrade with thousands of points, especially with animations enabled.-- **Responsiveness**: The chart is fully responsive, but consider the visual clarity of labels on very small screens.-- **Animation**: Can be disabled via \`isAnimationActive={false}\` for performance-critical applications.-`,- },- },- },- tags: ["!dev", "autodocs"],- argTypes: {- data: {- description: `-**Required.** An array of data objects for the line chart. Each object should contain:-- A category identifier (string/number) for the X-axis.-- One or more numeric values for the Y-axis.--**Best Practices:**-- Ensure consistent data structure across all objects.-- For time-series data, ensure items are sorted chronologically.-`,- control: false,- table: {- type: { summary: "Array<Record<string, string | number>>" },- category: "📊 Data Configuration",- },- },- categoryKey: {- description:- "**Required.** The key in your data object that represents the category for the X-axis (e.g., 'date', 'month').",- control: false,- table: {- type: { summary: "string" },- category: "📊 Data Configuration",- },- },- theme: {- description:- "Specifies the color palette for the chart's lines, tooltips, and legend. Ignored when customPalette is provided.",- control: "select",- options: ["ocean", "orchid", "emerald", "sunset", "spectrum", "vivid"],- table: {- defaultValue: { summary: "ocean" },- category: "🎨 Visual Styling",- },- },- customPalette: {- description:- "Custom array of colors to use instead of the theme palette. Overrides the theme prop when provided.",- control: "object",- table: {- type: { summary: "string[]" },- category: "🎨 Visual Styling",- },- },- variant: {- description: "Determines the line interpolation method, affecting the shape of the lines.",- control: "radio",- options: ["linear", "natural", "step"],- table: {- defaultValue: { summary: "natural" },- category: "🎨 Visual Styling",- },- },- strokeWidth: {- description: "Controls the thickness of the lines in pixels.",- control: { type: "number", min: 1, max: 10, step: 1 },- table: {- defaultValue: { summary: "2" },- category: "🎨 Visual Styling",- },- },- grid: {- description: "Toggles the visibility of the background grid lines.",- control: "boolean",- table: {- defaultValue: { summary: "true" },- category: "📱 Display Options",- },- },- legend: {- description: "Toggles the visibility of the chart legend.",- control: "boolean",- table: {- defaultValue: { summary: "true" },- category: "📱 Display Options",- },- },- showYAxis: {- description: "Toggles the visibility of the Y-axis line and labels.",- control: "boolean",- table: {- defaultValue: { summary: "true" },- category: "📱 Display Options",- },- },- isAnimationActive: {- description: "Enables or disables the initial loading animation for the lines.",- control: "boolean",- table: {- defaultValue: { summary: "true" },- category: "🎬 Animation & Interaction",- },- },- icons: {- description:- "An object mapping data series keys to React components to be used as icons in the legend.",- control: false,- table: {- type: { summary: "Record<string, React.ReactNode>" },- category: "🎨 Visual Styling",- },- },- xAxisLabel: {- description: "A label to display below the X-axis.",- control: "text",- table: {- type: { summary: "React.ReactNode" },- category: "📱 Display Options",- },- },- yAxisLabel: {- description: "A label to display beside the Y-axis.",- control: "text",- table: {- type: { summary: "React.ReactNode" },- category: "📱 Display Options",- },- },- className: {- description: "Custom CSS class to apply to the chart's container.",- control: "text",- table: {- type: { summary: "string" },- category: "Layout & Sizing",- },- },- height: {- description: "Sets the height of the chart container.",- control: "number",- table: {- type: { summary: "number" },- category: "Layout & Sizing",- },- },- width: {- description: "Sets the width of the chart container.",- control: "number",- table: {- type: { summary: "number" },- category: "Layout & Sizing",- },- },- },-} satisfies Meta<typeof LineChart>;--export default meta;-type Story = StoryObj<typeof meta>;--/**- * ## Comprehensive Data Explorer- *- * This story serves as a comprehensive test suite for the LineChart component.- * Use the buttons to switch between various datasets designed to test edge cases in:- *- * - **Label Collision**: Datasets with long, dense, or overlapping labels.- * - **Data Density**: Scenarios with few or many data points.- * - **Legend Overflow**: A dataset with many series to test legend expand/collapse functionality.- *- * It's an excellent tool for developers to see how the chart behaves under different conditions.- */-export const DataExplorer: Story = {- name: "🎛️ Comprehensive Data Explorer",- args: {- data: lineChartV2Data,- categoryKey: "month",- theme: "ocean",- variant: "natural",- grid: true,- legend: true,- isAnimationActive: true,- showYAxis: true,- strokeWidth: 2,- },- render: (args: any) => {- const [selectedDataType, setSelectedDataType] =- useState<keyof typeof dataVariations>("default");-- const currentData = dataVariations[selectedDataType];- const currentCategoryKey = categoryKeys[selectedDataType];-- const buttonStyle = {- margin: "2px",- padding: "6px 12px",- fontSize: "12px",- border: "1px solid #ddd",- borderRadius: "4px",- cursor: "pointer",- background: "#fff",- fontFamily: "monospace",- };-- const activeButtonStyle = {- ...buttonStyle,- background: "#007acc",- color: "white",- border: "1px solid #007acc",- };-- return (- <div>- <div- style={{- marginBottom: "16px",- padding: "12px",- background: "#f8f9fa",- borderRadius: "8px",- border: "1px solid #e9ecef",- width: "600px",- }}- >- <strong>📈 Line Chart Test Suite:</strong>- <div style={{ marginTop: "8px", display: "flex", flexWrap: "wrap", gap: "4px" }}>- <button- onClick={() => setSelectedDataType("default")}- style={selectedDataType === "default" ? activeButtonStyle : buttonStyle}- >- 📅 Default (12 months)- </button>- <button- onClick={() => setSelectedDataType("bigLabels")}- style={selectedDataType === "bigLabels" ? activeButtonStyle : buttonStyle}- >- 🏷️ Big Labels- </button>- <button- onClick={() => setSelectedDataType("denseTimeline")}- style={selectedDataType === "denseTimeline" ? activeButtonStyle : buttonStyle}- >- 📅 Dense Timeline (16 periods)- </button>- <button- onClick={() => setSelectedDataType("companyNames")}- style={selectedDataType === "companyNames" ? activeButtonStyle : buttonStyle}- >- 🏢 Company Names- </button>- <button- onClick={() => setSelectedDataType("countryData")}- style={selectedDataType === "countryData" ? activeButtonStyle : buttonStyle}- >- 🌍 Country Names- </button>- <button- onClick={() => setSelectedDataType("financialQuarters")}- style={selectedDataType === "financialQuarters" ? activeButtonStyle : buttonStyle}- >- 📈 Financial Quarters- </button>- <button- onClick={() => setSelectedDataType("mixedLengths")}- style={selectedDataType === "mixedLengths" ? activeButtonStyle : buttonStyle}- >- 🔤 Mixed Lengths- </button>- <button- onClick={() => setSelectedDataType("edgeCases")}- style={selectedDataType === "edgeCases" ? activeButtonStyle : buttonStyle}- >- 🎯 Edge Cases- </button>- <button- onClick={() => setSelectedDataType("minimal")}- style={selectedDataType === "minimal" ? activeButtonStyle : buttonStyle}- >- 📱 Minimal- </button>- <button- onClick={() => setSelectedDataType("expandCollapseMarketing")}- style={- selectedDataType === "expandCollapseMarketing" ? activeButtonStyle : buttonStyle- }- >- 🔄 Marketing Channels- </button>- </div>- </div>- <Card style={{ width: "600px" }}>- <LineChart {...args} data={currentData} categoryKey={currentCategoryKey} />- </Card>- </div>- );- },-};--/**- * ## Big Labels- *- * This story demonstrates the chart's ability to handle very long category labels.- * The chart's intelligent truncation and collision detection should be visible here.- * X-axis labels that are too long to fit will be gracefully truncated with an ellipsis.- */-export const BigLabelsStory: Story = {- name: "🏷️ Big Labels",- args: {- data: dataVariations.bigLabels as any,- categoryKey: "category" as any,- theme: "emerald",- variant: "natural",- grid: true,- legend: true,- showYAxis: true,- strokeWidth: 3,- },- render: (args: any) => (- <Card style={{ width: "600px" }}>- <LineChart {...args} />- </Card>- ),-};--/**- * ## Dense Timeline- *- * Tests how the chart handles many data points with medium-length period labels.- * The chart should enable horizontal scrolling and apply intelligent label truncation.- * This scenario is common in financial or analytical dashboards where many time periods are displayed.- */-export const DenseTimelineStory: Story = {- name: "📅 Dense Timeline (Many Periods)",- args: {- data: dataVariations.denseTimeline as any,- categoryKey: "period" as any,- theme: "sunset",- variant: "natural",- grid: true,- legend: true,- isAnimationActive: true,- showYAxis: true,- strokeWidth: 2,- },- render: (args: any) => (- <Card style={{ width: "500px" }}>- <LineChart {...args} />- </Card>- ),- parameters: {- docs: {- description: {- story:- "Tests how the chart handles many data points with medium-length period labels. The chart should enable horizontal scrolling and apply intelligent label truncation.",- },- },- },-};--/**- * ## Stroke and Style Customization- *- * This story showcases how to customize the appearance of the lines.- * You can adjust properties like `strokeWidth` to create different visual effects.- */-export const StrokeCustomizationStory: Story = {- name: "🎨 Stroke Customization",- args: {- data: dataVariations.default as any,- categoryKey: "month" as any,- theme: "vivid",- variant: "natural",- grid: true,- legend: true,- showYAxis: true,- },- render: (args: any) => (- <div style={{ display: "flex", flexDirection: "column", gap: "20px" }}>- <div>- <h4>Default Lines (strokeWidth: 2)</h4>- <Card style={{ width: "500px" }}>- <LineChart {...args} strokeWidth={2} />- </Card>- </div>- <div>- <h4>Thick Lines (strokeWidth: 4)</h4>- <Card style={{ width: "500px" }}>- <LineChart {...args} strokeWidth={4} />- </Card>- </div>- </div>- ),-};--/**- * ## Line Variants- *- * Compares the three available line variants:- * - **Linear**: Straight lines connecting data points.- * - **Natural**: Smooth curves for a softer, organic look.- * - **Step**: Stepped lines, useful for showing discrete changes.- */-export const VariantComparisonStory: Story = {- name: "📐 Line Variants",- args: {- data: dataVariations.minimal as any,- categoryKey: "category" as any,- theme: "orchid",- grid: true,- legend: true,- isAnimationActive: true,- showYAxis: true,- strokeWidth: 3,- },- render: (args: any) => (- <div style={{ display: "flex", flexDirection: "column", gap: "20px" }}>- <div>- <h4 style={{ margin: "0 0 8px 0", fontSize: "14px", fontWeight: "600" }}>Linear Variant</h4>- <Card style={{ width: "500px" }}>- <LineChart {...args} variant="linear" />- </Card>- </div>- <div>- <h4 style={{ margin: "0 0 8px 0", fontSize: "14px", fontWeight: "600" }}>- Natural Variant (Smooth Curves)- </h4>- <Card style={{ width: "500px" }}>- <LineChart {...args} variant="natural" />- </Card>- </div>- <div>- <h4 style={{ margin: "0 0 8px 0", fontSize: "14px", fontWeight: "600" }}>Step Variant</h4>- <Card style={{ width: "500px" }}>- <LineChart {...args} variant="step" />- </Card>- </div>- </div>- ),- parameters: {- docs: {- description: {- story:- "Compares the three available line variants: linear (straight lines), natural (smooth curves), and step (stepped lines).",- },- },- },-};--/**- * ## Custom Palette- *- * This story demonstrates how to use the customPalette prop to provide your own color scheme- * for the chart. This is useful when you need to match your brand colors or create- * specific visual themes.- */-export const CustomPaletteStory: Story = {- name: "🎨 Custom Palette",- args: {- data: dataVariations.default as any,- categoryKey: "month" as any,- customPalette: customColorPalette,- theme: "ocean", // This will be overridden by customPalette- variant: "natural",- grid: true,- legend: true,- isAnimationActive: true,- showYAxis: true,- strokeWidth: 2,- xAxisLabel: "Month",- yAxisLabel: "Traffic",- },- render: (args: any) => (- <div>- <div- style={{- marginBottom: "16px",- padding: "12px",- background: "#f8f9fa",- borderRadius: "8px",- border: "1px solid #e9ecef",- }}- >- <h4 style={{ margin: "0 0 8px 0", color: "#333" }}>🎨 Custom Color Palette</h4>- <p style={{ margin: "0 0 12px 0", fontSize: "14px", color: "#666" }}>- This chart uses a custom color palette instead of the default theme colors.- </p>- <div style={{ display: "flex", gap: "8px", flexWrap: "wrap" }}>- {args.customPalette?.map((color: string, index: number) => (- <div- key={index}- style={{- display: "flex",- alignItems: "center",- gap: "4px",- padding: "4px 8px",- background: "white",- borderRadius: "4px",- border: "1px solid #ddd",- fontSize: "12px",- }}- >- <div- style={{- width: "12px",- height: "12px",- borderRadius: "2px",- backgroundColor: color,- border: "1px solid #ccc",- }}- />- <span style={{ fontFamily: "monospace" }}>{color}</span>- </div>- ))}- </div>- </div>- <Card style={{ width: "600px" }}>- <LineChart {...args} />- </Card>- </div>- ),- parameters: {- docs: {- description: {- story:- 'Demonstrates how to use the `customPalette` prop to provide your own color scheme for the chart. When `customPalette` is provided, it overrides the `theme` prop and uses your specified colors instead of the predefined theme palettes.\n\n**Key Features:**\n- 🎨 **Custom Colors**: Override default theme colors with your own palette\n- 🔄 **Theme Override**: The `theme` prop is ignored when `customPalette` is provided\n- 📊 **Consistent Distribution**: Colors are distributed evenly across data series\n- 🎯 **Brand Matching**: Perfect for matching your application\'s brand colors\n\n**Usage:**\n```tsx\n<LineChart\n data={data}\n categoryKey="month"\n customPalette={["#FF6B6B", "#4ECDC4", "#45B7D1"]}\n // theme prop is ignored when customPalette is provided\n/>\n```',- },- },- },-};--/**- * ## Legend Expand/Collapse- *- * Tests the legend's expand/collapse functionality with a large number of data series.- * The legend should automatically show a "Show More" button when items overflow,- * allowing users to toggle between a collapsed and expanded view.- */-export const ExpandCollapseMarketingStory: Story = {- name: "🔄 Legend Expand/Collapse",- args: {- data: dataVariations.expandCollapseMarketing as any,- categoryKey: "channel" as any,- theme: "spectrum",- variant: "natural",- grid: true,- legend: true,- isAnimationActive: true,- showYAxis: true,- strokeWidth: 2,- },- render: (args: any) => (- <Card style={{ width: "600px" }}>- <LineChart {...args} />- </Card>- ),- parameters: {- docs: {- description: {- story:- "Tests the legend expand/collapse functionality with 12 marketing channels that have long descriptive names. The legend should automatically show a 'Show More' button when items overflow the container width, allowing users to toggle between collapsed and expanded states.",- },- },- },-};--/**- * ## Responsive Behavior Demo- *- * This story demonstrates the responsive capabilities of the LineChart. Drag the handles- * on the container to resize it and observe how the chart adapts.- *- * **Responsive Features:**- * - **Label Truncation**: More aggressive truncation on smaller container widths.- * - **Layout Adaptation**: Chart elements adjust to fit the available space.- * - **Legend Behavior**: The legend may wrap or show expand/collapse buttons as needed.- */-export const ResponsiveBehaviorDemo: Story = {- name: "📱 Responsive Behavior Demo",- args: {- data: dataVariations.bigLabels as any,- categoryKey: "category" as any,- theme: "sunset",- variant: "natural",- grid: true,- legend: true,- isAnimationActive: false,- showYAxis: true,- strokeWidth: 2,- },- render: (args: any) => {- const [dimensions, setDimensions] = useState<{ width: number; height: number | string }>({- width: 700,- height: "auto",- });-- const handleMouseDown = (e: React.MouseEvent<HTMLDivElement>, handle: string) => {- e.preventDefault();- e.stopPropagation();- const startX = e.clientX;- const startY = e.clientY;- const startWidth = dimensions.width;- const startHeight = (e.currentTarget.parentElement as HTMLElement).offsetHeight;-- const doDrag = (e: MouseEvent) => {- const dx = e.clientX - startX;- const dy = e.clientY - startY;- let newWidth = startWidth;- let newHeight = startHeight;-- if (handle.includes("e")) newWidth = startWidth + dx;- if (handle.includes("w")) newWidth = startWidth - dx;- if (handle.includes("s")) newHeight = startHeight + dy;- if (handle.includes("n")) newHeight = startHeight - dy;-- setDimensions({- width: Math.max(300, newWidth),- height: "auto",- });- };-- const stopDrag = () => {- document.removeEventListener("mousemove", doDrag);- document.removeEventListener("mouseup", stopDrag);- };-- document.addEventListener("mousemove", doDrag);- document.addEventListener("mouseup", stopDrag);- };-- const handleStyle: React.CSSProperties = {- position: "absolute",- background: "#3b82f6",- opacity: 0.6,- zIndex: 10,- transition: "opacity 0.2s ease",- };-- return (- <div style={{ padding: "20px" }}>- <div style={{ marginBottom: "20px" }}>- <h3 style={{ margin: "0 0 8px 0", fontSize: "18px", fontWeight: "600" }}>- Responsive Behavior Demonstration- </h3>- <p style={{ margin: "0 0 12px 0", color: "#666", fontSize: "14px" }}>- Drag the edges or corners of the container below to see how the chart adapts- </p>- <div- style={{- padding: "12px",- backgroundColor: "#e3f2fd",- borderRadius: "6px",- fontSize: "12px",- color: "#1565c0",- }}- >- <strong>🎯 Try This:</strong> Resize the container to see automatic label truncation and- layout adjustments.- </div>- </div>-- <Card- style={{- position: "relative",- width: `${dimensions.width}px`,- height:- typeof dimensions.height === "number" ? `${dimensions.height}px` : dimensions.height,- border: "2px dashed #9ca3af",- padding: "20px",- boxSizing: "border-box",- overflow: "hidden",- cursor: "default",- }}- >- <LineChart {...args} />-- {/* Resize Handles */}- <div- style={{ ...handleStyle, top: -2, left: 0, right: 0, height: 12, cursor: "ns-resize" }}- onMouseDown={(e) => handleMouseDown(e, "n")}- />- <div- style={{- ...handleStyle,- bottom: -2,- left: 0,- right: 0,- height: 12,- cursor: "ns-resize",- }}- onMouseDown={(e) => handleMouseDown(e, "s")}- />- <div- style={{ ...handleStyle, top: 0, bottom: 0, left: -2, width: 12, cursor: "ew-resize" }}- onMouseDown={(e) => handleMouseDown(e, "w")}- />- <div- style={{ ...handleStyle, top: 0, bottom: 0, right: -2, width: 12, cursor: "ew-resize" }}- onMouseDown={(e) => handleMouseDown(e, "e")}- />-- {/* Corner Handles */}- <div- style={{- ...handleStyle,- top: -2,- left: -2,- width: 20,- height: 20,- cursor: "nwse-resize",- borderRadius: "2px",- }}- onMouseDown={(e) => handleMouseDown(e, "nw")}- />- <div- style={{- ...handleStyle,- top: -2,- right: -2,- width: 20,- height: 20,- cursor: "nesw-resize",- borderRadius: "2px",- }}- onMouseDown={(e) => handleMouseDown(e, "ne")}- />- <div- style={{- ...handleStyle,- bottom: -2,- right: -2,- width: 20,- height: 20,- cursor: "nwse-resize",- borderRadius: "2px",- }}- onMouseDown={(e) => handleMouseDown(e, "se")}- />-- {/* Dimension Display */}- <div- style={{- position: "absolute",- bottom: 8,- right: 8,- background: "rgba(0,0,0,0.8)",- color: "white",- padding: "4px 8px",- borderRadius: "4px",- fontSize: "11px",- fontFamily: "monospace",- fontWeight: "500",- }}- >- {dimensions.width}px ×{" "}- {typeof dimensions.height === "number" ? `${dimensions.height}px` : "auto"}- </div>- </Card>- </div>- );- },-};diff --git a/packages/react-ui/src/components/D3Charts/LineChart/stories/lineChartCondensed.stories.tsx b/packages/react-ui/src/components/D3Charts/LineChart/stories/lineChartCondensed.stories.tsxdeleted file mode 100644index 0e0a8763c..000000000--- a/packages/react-ui/src/components/D3Charts/LineChart/stories/lineChartCondensed.stories.tsx+++ /dev/null@@ -1,1511 +0,0 @@-// Copy of Charts/LineChartCondensed/stories/lineChartCondensed.stories.tsx with only the chart import and the title changed:-// the same args and renders, rendering the D3Charts chart via-// ../../stories/rechartsStoryAdapters.-import type { Meta, StoryObj } from "@storybook/react";-import {- Calendar,- Globe,- Laptop,- Monitor,- Smartphone,- TabletSmartphone,- Tv,- Watch,-} from "lucide-react";-import { useState } from "react";-import { Card } from "../../../Card";-import { LineChartCondensed, LineChartCondensedProps } from "../../stories/rechartsStoryAdapters";--// 🔥 COMPREHENSIVE DATA VARIATIONS - Designed to test various scenarios-const dataVariations = {- default: [- { month: "January", desktop: 150, mobile: 90, tablet: 120 },- { month: "February", desktop: 280, mobile: 180, tablet: 140 },- { month: "March", desktop: 220, mobile: 140, tablet: 160 },- { month: "April", desktop: 180, mobile: 160, tablet: 180 },- { month: "May", desktop: 250, mobile: 120, tablet: 140 },- { month: "June", desktop: 300, mobile: 180, tablet: 160 },- { month: "July", desktop: 350, mobile: 220, tablet: 180 },- { month: "August", desktop: 400, mobile: 240, tablet: 200 },- { month: "September", desktop: 450, mobile: 260, tablet: 220 },- { month: "October", desktop: 500, mobile: 280, tablet: 240 },- { month: "November", desktop: 550, mobile: 300, tablet: 260 },- { month: "December", desktop: 600, mobile: 320, tablet: 280 },- ],- // 🏷️ BIG LABELS - Testing angled tick labels- bigLabels: [- {- category: "Very Long Category Name That Should Be Truncated",- sales: 150,- revenue: 90,- profit: 120,- },- {- category: "Another Extremely Long Label That Causes Collisions",- sales: 280,- revenue: 180,- profit: 140,- },- {- category: "Super Duper Long Category Name That Tests Truncation",- sales: 220,- revenue: 140,- profit: 160,- },- {- category: "Incredibly Long Text That Should Trigger Collision Detection",- sales: 180,- revenue: 160,- profit: 180,- },- {- category: "Maximum Length Category Name That Tests All Edge Cases",- sales: 250,- revenue: 120,- profit: 140,- },- {- category: "Extra Long Business Category Name With Many Words",- sales: 300,- revenue: 180,- profit: 160,- },- {- category: "Comprehensive Long Label For Testing Horizontal Offset",- sales: 350,- revenue: 220,- profit: 180,- },- {- category: "Extended Category Name That Pushes Truncation Limits",- sales: 400,- revenue: 240,- profit: 200,- },- ],- // 📅 DENSE TIMELINE - Many items with medium-length labels- denseTimeline: [- { period: "Q1 2022 Jan-Mar", visitors: 120, conversions: 15, revenue: 1200 },- { period: "Q1 2022 Apr-Jun", visitors: 150, conversions: 22, revenue: 1800 },- { period: "Q2 2022 Jul-Sep", visitors: 180, conversions: 28, revenue: 2100 },- { period: "Q2 2022 Oct-Dec", visitors: 200, conversions: 35, revenue: 2500 },- { period: "Q3 2023 Jan-Mar", visitors: 160, conversions: 18, revenue: 1600 },- { period: "Q3 2023 Apr-Jun", visitors: 190, conversions: 32, revenue: 2300 },- { period: "Q4 2023 Jul-Sep", visitors: 220, conversions: 40, revenue: 2800 },- { period: "Q4 2023 Oct-Dec", visitors: 240, conversions: 45, revenue: 3200 },- { period: "Q1 2024 Jan-Mar", visitors: 210, conversions: 38, revenue: 2700 },- { period: "Q1 2024 Apr-Jun", visitors: 230, conversions: 42, revenue: 3000 },- { period: "Q2 2024 Jul-Sep", visitors: 250, conversions: 48, revenue: 3400 },- { period: "Q2 2024 Oct-Dec", visitors: 270, conversions: 52, revenue: 3800 },- { period: "Q3 2024 Jan-Mar", visitors: 260, conversions: 50, revenue: 3600 },- { period: "Q3 2024 Apr-Jun", visitors: 280, conversions: 55, revenue: 4000 },- { period: "Q4 2024 Jul-Sep", visitors: 300, conversions: 60, revenue: 4300 },- { period: "Q4 2024 Oct-Dec", visitors: 290, conversions: 58, revenue: 4100 },- ],- // 🏢 COMPANY NAMES - Real-world long business names- companyNames: [- { company: "Apple Inc.", revenue: 394328000000, profit: 99803000000, marketCap: 3500000000000 },- {- company: "Microsoft Corporation",- revenue: 211915000000,- profit: 83383000000,- marketCap: 2800000000000,- },- {- company: "Alphabet Inc. (Google)",- revenue: 307394000000,- profit: 76033000000,- marketCap: 2100000000000,- },- {- company: "Amazon.com Inc.",- revenue: 574785000000,- profit: 33364000000,- marketCap: 1600000000000,- },- {- company: "Tesla Motors Inc.",- revenue: 96773000000,- profit: 15000000000,- marketCap: 800000000000,- },- {- company: "Meta Platforms Inc.",- revenue: 134902000000,- profit: 39370000000,- marketCap: 900000000000,- },- {- company: "NVIDIA Corporation",- revenue: 60922000000,- profit: 29760000000,- marketCap: 1800000000000,- },- {- company: "Berkshire Hathaway Inc.",- revenue: 364482000000,- profit: 96223000000,- marketCap: 780000000000,- },- ],- // 🌍 COUNTRY NAMES - Geographic labels with varying lengths- countryData: [- { country: "United States of America", population: 331900000, gdp: 26900000000000 },- { country: "People's Republic of China", population: 1412000000, gdp: 17700000000000 },- { country: "Federal Republic of Germany", population: 83200000, gdp: 4300000000000 },- { country: "United Kingdom of Great Britain", population: 67500000, gdp: 3100000000000 },- { country: "French Republic", population: 68000000, gdp: 2900000000000 },- { country: "Republic of India", population: 1380000000, gdp: 3700000000000 },- { country: "Federative Republic of Brazil", population: 215000000, gdp: 2100000000000 },- { country: "Russian Federation", population: 146000000, gdp: 1800000000000 },- ],- // 📈 FINANCIAL QUARTERS - Testing medium-density scenarios- financialQuarters: [- { quarter: "Q1 FY2022", revenue: 1200000, expenses: 800000, profit: 400000 },- { quarter: "Q2 FY2022", revenue: 1500000, expenses: 950000, profit: 550000 },- { quarter: "Q3 FY2022", revenue: 1800000, expenses: 1100000, profit: 700000 },- { quarter: "Q4 FY2022", revenue: 2000000, expenses: 1300000, profit: 700000 },- { quarter: "Q1 FY2023", revenue: 2200000, expenses: 1400000, profit: 800000 },- { quarter: "Q2 FY2023", revenue: 2500000, expenses: 1600000, profit: 900000 },- { quarter: "Q3 FY2023", revenue: 2800000, expenses: 1800000, profit: 1000000 },- { quarter: "Q4 FY2023", revenue: 3000000, expenses: 1900000, profit: 1100000 },- ],- // 🔤 MIXED LENGTHS - Testing various label length scenarios- mixedLengths: [- { item: "A", valueA: 100, valueB: 80 },- { item: "Short", valueA: 150, valueB: 120 },- { item: "Medium Length Item", valueA: 200, valueB: 160 },- { item: "Very Long Item Name That Tests Truncation", valueA: 250, valueB: 200 },- { item: "B", valueA: 180, valueB: 140 },- { item: "Another Really Long Category Name", valueA: 220, valueB: 180 },- { item: "XL", valueA: 190, valueB: 150 },- ],- // 🎯 EDGE CASES - Extreme scenarios- edgeCases: [- {- name: "SinglePointDataSetForTestingEdgeCasesInCollisionDetectionAndLabelTruncationFunctionality",- value: 500,- },- {- name: "SecondExtremelyLongDataPointNameThatShouldDefinitelyTriggerTruncationMechanisms",- value: 600,- },- ],- // 📱 MINIMAL - Small dataset for baseline testing- minimal: [- { category: "Mobile Devices", users: 150, sessions: 90 },- { category: "Desktop Computers", users: 280, sessions: 180 },- { category: "Tablet Devices", users: 220, sessions: 140 },- ],-};--// Category key mappings for different datasets-const categoryKeys = {- default: "month",- bigLabels: "category",- denseTimeline: "period",- companyNames: "company",- countryData: "country",- financialQuarters: "quarter",- mixedLengths: "item",- edgeCases: "name",- minimal: "category",-};--// 🔥 ACTIVE DATA - For backward compatibility-const lineChartCondensedData = dataVariations.default;--const icons = {- desktop: Monitor,- mobile: TabletSmartphone,- tablet: Calendar,- sales: Globe,- revenue: Smartphone,- profit: Laptop,- visitors: Tv,- conversions: Watch,- users: Monitor,- sessions: TabletSmartphone,- expenses: Calendar,- marketCap: Globe,- population: Monitor,- gdp: Smartphone,- valueA: Monitor,- valueB: TabletSmartphone,- value: Calendar,-} as const;--/**- * # LineChart Component Documentation- *- * The LineChart is a compact chart designed for space-constrained layouts- * like dashboards and sidebars. It's ideal for:- *- * - **Compact Dashboards**: Showing multiple trends in limited space- * - **Sidebar Analytics**: Quick trend visualization without taking up too much room- * - **Dense Data Display**: Efficiently showing many data points in a small area- *- * ## Key Features- *- * ### Space-Efficient Design- * - **Compact Height**: Default 200px height for tight layouts- * - **Minimal Legend**: Legend is compact and doesn't take up vertical space- * - **Adjustable Tick Variants**: Choose between horizontal or angled labels for better space usage- *- * ### Flexible Label Handling- * - **Single Line Ticks**: Horizontal labels with automatic collision detection- * - **Angled Ticks**: Optimal rotation angle for longer labels that need more space- * - **Smart Angle Calculation**: Automatically calculates optimal rotation based on label width- *- * ### Interactive & Responsive- * - **Hover Tooltips**: Standard tooltip showing all data series- * - **Responsive Design**: Adapts fluidly to its container's size- * - **Line Customization**: Control line thickness with strokeWidth prop- *- * ### Customization- * - **Theming**: Comes with six pre-built color palettes- * - **Line Styles**: Supports `linear`, `natural` (smooth), and `step` interpolation- * - **Styling Options**: Control grid visibility, axes, stroke width, and more- */-const meta: Meta<LineChartCondensedProps<typeof lineChartCondensedData>> = {- title: "Components/D3Charts/LineChart",- component: LineChartCondensed,- parameters: {- layout: "centered",- docs: {- description: {- component: `-## Installation and Basic Usage--\`\`\`tsx-import { LineChart } from '@openuidev/react-ui';--const trafficData = [- { date: "2023-01-01", visits: 2200 },- { date: "2023-01-02", visits: 2500 },- { date: "2023-01-03", visits: 2300 },-];--// Basic implementation-<LineChart- data={trafficData}- categoryKey="date"- theme="ocean"- height={200}-/>-\`\`\`--## Data Structure Requirements--Your data should be an array of objects. Each object must contain:-- A **category field** (string or number): This will be used for the X-axis labels (e.g., dates, names, etc.).-- One or more **data series fields** (number): These are the values that will be plotted on the Y-axis.--\`\`\`tsx-const salesData = [- { month: "January", desktop: 150, mobile: 90 },- { month: "February", desktop: 280, mobile: 180 },- { month: "March", desktop: 220, mobile: 140 },-];-\`\`\`--## Key Differences from LineChart--- **Compact**: Designed for smaller spaces with a default height of 200px-- **No Interactive Legend**: Legend is simplified and non-interactive-- **Tick Variants**: Supports both horizontal (singleLine) and angled labels-- **Performance**: Optimized for quick rendering in dashboards-- **Stroke Width Control**: Customize line thickness with strokeWidth prop--## Performance Considerations-- **Data Density**: For very large datasets, consider disabling animations-- **Responsiveness**: The chart is fully responsive, but test label visibility on small screens-- **Animation**: Controlled via \`isAnimationActive={false}\`-`,- },- },- },- tags: ["!dev", "autodocs"],- argTypes: {- data: {- description: `-**Required.** An array of data objects for the line chart. Each object should contain:-- A category identifier (string/number) for the X-axis.-- One or more numeric values for the Y-axis.-`,- control: false,- table: {- type: { summary: "Array<Record<string, string | number>>" },- category: "📊 Data Configuration",- },- },- categoryKey: {- description:- "**Required.** The key in your data object that represents the category for the X-axis.",- control: false,- table: {- type: { summary: "string" },- category: "📊 Data Configuration",- },- },- theme: {- description:- "Specifies the color palette for the chart's lines and tooltips. Ignored when customPalette is provided.",- control: "select",- options: ["ocean", "orchid", "emerald", "sunset", "spectrum", "vivid"],- table: {- defaultValue: { summary: "ocean" },- category: "🎨 Visual Styling",- },- },- customPalette: {- description:- "Custom array of colors to use instead of the theme palette. Overrides the theme prop when provided.",- control: "object",- table: {- type: { summary: "string[]" },- category: "🎨 Visual Styling",- },- },- variant: {- description: "Determines the line interpolation method, affecting the shape of the curves.",- 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' (rotated at optimal angle).",- control: "radio",- options: ["singleLine", "angled"],- table: {- defaultValue: { summary: "singleLine" },- category: "🎨 Visual Styling",- },- },- strokeWidth: {- description: "Line thickness in pixels. Controls the width of the line strokes.",- control: { type: "number", min: 1, max: 10, step: 0.5 },- table: {- defaultValue: { summary: "2" },- category: "🎨 Visual Styling",- },- },- icons: {- description:- "An object mapping data series keys to React components to be used as icons in the legend.",- control: false,- table: {- type: { summary: "Record<string, React.ReactNode>" },- category: "🎨 Visual Styling",- },- },- grid: {- description: "Toggles the visibility of the background grid lines.",- control: "boolean",- table: {- defaultValue: { summary: "true" },- category: "📱 Display Options",- },- },- showYAxis: {- description: "Toggles the visibility of the Y-axis line and labels.",- control: "boolean",- table: {- defaultValue: { summary: "true" },- category: "📱 Display Options",- },- },- xAxisLabel: {- description: "A label to display below the X-axis.",- control: "text",- table: {- type: { summary: "React.ReactNode" },- category: "📱 Display Options",- },- },- yAxisLabel: {- description: "A label to display beside the Y-axis.",- control: "text",- table: {- type: { summary: "React.ReactNode" },- category: "📱 Display Options",- },- },- isAnimationActive: {- description: "Enables or disables the initial loading animation for the lines.",- control: "boolean",- table: {- defaultValue: { summary: "false" },- category: "🎬 Animation & Interaction",- },- },- height: {- description: "Sets a fixed height for the chart container in pixels.",- control: "number",- table: {- defaultValue: { summary: "200" },- type: { summary: "number" },- category: "Layout & Sizing",- },- },- width: {- description: "Sets a fixed width for the chart container in pixels.",- control: "number",- table: {- type: { summary: "number" },- category: "Layout & Sizing",- },- },- className: {- description: "Custom CSS class to apply to the chart's container.",- control: "text",- table: {- type: { summary: "string" },- category: "Layout & Sizing",- },- },- },-} satisfies Meta<typeof LineChartCondensed>;--export default meta;-type Story = StoryObj<typeof meta>;--/**- * ## Comprehensive Data Explorer- *- * This story serves as a comprehensive test suite for the LineChartCondensed component.- * Use the buttons to switch between various datasets designed to test edge cases in:- *- * - **Label Handling**: Datasets with long, dense, or overlapping labels.- * - **Data Density**: Scenarios with few or many data points.- * - **Tick Variants**: Toggle between horizontal and angled label orientations.- *- * It's an excellent tool for developers to see how the chart behaves under different conditions.- */-export const DataExplorer: Story = {- name: "🎛️ Comprehensive Data Explorer",- args: {- data: lineChartCondensedData,- categoryKey: "month",- theme: "ocean",- variant: "natural",- tickVariant: "singleLine",- strokeWidth: 2,- grid: true,- isAnimationActive: false,- showYAxis: true,- xAxisLabel: "Time Period",- yAxisLabel: "Values",- height: 200,- },- render: (args: any) => {- const [selectedDataType, setSelectedDataType] =- useState<keyof typeof dataVariations>("default");- const [tickVariant, setTickVariant] = useState<"singleLine" | "angled">("singleLine");-- const currentData = dataVariations[selectedDataType];- const currentCategoryKey = categoryKeys[selectedDataType];-- const buttonStyle = {- margin: "2px",- padding: "6px 12px",- fontSize: "12px",- border: "1px solid #ddd",- borderRadius: "4px",- cursor: "pointer",- background: "#fff",- fontFamily: "monospace",- };-- const activeButtonStyle = {- ...buttonStyle,- background: "#007acc",- color: "white",- border: "1px solid #007acc",- };-- return (- <div>- <div- style={{- marginBottom: "16px",- padding: "12px",- background: "#f8f9fa",- borderRadius: "8px",- border: "1px solid #e9ecef",- width: "600px",- }}- >- <strong>🏷️ Dataset Selection:</strong>- <div style={{ marginTop: "8px", display: "flex", flexWrap: "wrap", gap: "4px" }}>- <button- onClick={() => setSelectedDataType("default")}- style={selectedDataType === "default" ? activeButtonStyle : buttonStyle}- >- 📅 Default (12 months)- </button>- <button- onClick={() => setSelectedDataType("bigLabels")}- style={selectedDataType === "bigLabels" ? activeButtonStyle : buttonStyle}- >- 🏷️ Big Labels- </button>- <button- onClick={() => setSelectedDataType("denseTimeline")}- style={selectedDataType === "denseTimeline" ? activeButtonStyle : buttonStyle}- >- 📅 Dense Timeline (16)- </button>- <button- onClick={() => setSelectedDataType("companyNames")}- style={selectedDataType === "companyNames" ? activeButtonStyle : buttonStyle}- >- 🏢 Company Names- </button>- <button- onClick={() => setSelectedDataType("countryData")}- style={selectedDataType === "countryData" ? activeButtonStyle : buttonStyle}- >- 🌍 Country Names- </button>- <button- onClick={() => setSelectedDataType("financialQuarters")}- style={selectedDataType === "financialQuarters" ? activeButtonStyle : buttonStyle}- >- 📈 Financial Quarters- </button>- <button- onClick={() => setSelectedDataType("mixedLengths")}- style={selectedDataType === "mixedLengths" ? activeButtonStyle : buttonStyle}- >- 🔤 Mixed Lengths- </button>- <button- onClick={() => setSelectedDataType("edgeCases")}- style={selectedDataType === "edgeCases" ? activeButtonStyle : buttonStyle}- >- 🎯 Edge Cases- </button>- <button- onClick={() => setSelectedDataType("minimal")}- style={selectedDataType === "minimal" ? activeButtonStyle : buttonStyle}- >- 📱 Minimal (3 items)- </button>- </div>- <div style={{ marginTop: "12px" }}>- <strong>📐 Tick Variant:</strong>- <div style={{ marginTop: "8px", display: "flex", gap: "4px" }}>- <button- onClick={() => setTickVariant("singleLine")}- style={tickVariant === "singleLine" ? activeButtonStyle : buttonStyle}- >- Horizontal Labels- </button>- <button- onClick={() => setTickVariant("angled")}- style={tickVariant === "angled" ? activeButtonStyle : buttonStyle}- >- Angled Labels- </button>- </div>- </div>- <div- style={{ marginTop: "12px", fontSize: "12px", color: "#666", fontFamily: "monospace" }}- >- <div>- <strong>Current Dataset:</strong> {selectedDataType}- </div>- <div>- <strong>Items:</strong> {currentData.length} | <strong>Category Key:</strong>{" "}- {currentCategoryKey} | <strong>Tick:</strong> {tickVariant}- </div>- </div>- </div>- <Card style={{ width: "600px" }}>- <LineChartCondensed- {...args}- data={currentData}- categoryKey={currentCategoryKey}- tickVariant={tickVariant}- />- </Card>- </div>- );- },- parameters: {- docs: {- description: {- story:- "**🎛️ Interactive Explorer:** This story allows you to explore different datasets and tick variants interactively. Use the buttons to switch between:\n\n**Datasets:**\n- **Default**: Standard 12-month data\n- **Big Labels**: Extremely long category names\n- **Dense Timeline**: Many items with medium-length labels\n- **Company Names**: Real-world business names\n- **Country Names**: Geographic labels\n- **Financial Quarters**: Quarterly financial data\n- **Mixed Lengths**: Combination of short and long labels\n- **Edge Cases**: Extreme scenarios\n- **Minimal**: Baseline with 3 items\n\n**Tick Variants:**\n- **Horizontal Labels**: Standard single-line labels with collision detection\n- **Angled Labels**: Rotated labels for better space utilization",- },- },- },-};--/**- * ## Large Dataset with Sidebar Tooltip- *- * This story demonstrates the sidebar tooltip feature that appears when you have- * more than 10 data series. Click on any point in the chart to see the sidebar- * tooltip in action. This provides a better UX for viewing many data series at once.- */-export const LargeDatasetWithSidebarTooltip: Story = {- name: "🎯 Large Dataset (>10 Series) - Sidebar Tooltip",- args: {- data: [- {- month: "Jan",- line1: 120,- line2: 150,- line3: 180,- line4: 200,- line5: 160,- line6: 190,- line7: 220,- line8: 240,- line9: 210,- line10: 230,- line11: 250,- line12: 270,- line13: 260,- line14: 280,- line15: 300,- },- {- month: "Feb",- line1: 140,- line2: 170,- line3: 200,- line4: 220,- line5: 180,- line6: 210,- line7: 240,- line8: 260,- line9: 230,- line10: 250,- line11: 270,- line12: 290,- line13: 280,- line14: 300,- line15: 320,- },- {- month: "Mar",- line1: 160,- line2: 190,- line3: 220,- line4: 240,- line5: 200,- line6: 230,- line7: 260,- line8: 280,- line9: 250,- line10: 270,- line11: 290,- line12: 310,- line13: 300,- line14: 320,- line15: 340,- },- {- month: "Apr",- line1: 180,- line2: 210,- line3: 240,- line4: 260,- line5: 220,- line6: 250,- line7: 280,- line8: 300,- line9: 270,- line10: 290,- line11: 310,- line12: 330,- line13: 320,- line14: 340,- line15: 360,- },- {- month: "May",- line1: 200,- line2: 230,- line3: 260,- line4: 280,- line5: 240,- line6: 270,- line7: 300,- line8: 320,- line9: 290,- line10: 310,- line11: 330,- line12: 350,- line13: 340,- line14: 360,- line15: 380,- },- {- month: "Jun",- line1: 220,- line2: 250,- line3: 280,- line4: 300,- line5: 260,- line6: 290,- line7: 320,- line8: 340,- line9: 310,- line10: 330,- line11: 350,- line12: 370,- line13: 360,- line14: 380,- line15: 400,- },- {- month: "Jul",- line1: 240,- line2: 270,- line3: 300,- line4: 320,- line5: 280,- line6: 310,- line7: 340,- line8: 360,- line9: 330,- line10: 350,- line11: 370,- line12: 390,- line13: 380,- line14: 400,- line15: 420,- },- {- month: "Aug",- line1: 260,- line2: 290,- line3: 320,- line4: 340,- line5: 300,- line6: 330,- line7: 360,- line8: 380,- line9: 350,- line10: 370,- line11: 390,- line12: 410,- line13: 400,- line14: 420,- line15: 440,- },- {- month: "Sep",- line1: 280,- line2: 310,- line3: 340,- line4: 360,- line5: 320,- line6: 350,- line7: 380,- line8: 400,- line9: 370,- line10: 390,- line11: 410,- line12: 430,- line13: 420,- line14: 440,- line15: 460,- },- {- month: "Oct",- line1: 300,- line2: 330,- line3: 360,- line4: 380,- line5: 340,- line6: 370,- line7: 400,- line8: 420,- line9: 390,- line10: 410,- line11: 430,- line12: 450,- line13: 440,- line14: 460,- line15: 480,- },- {- month: "Nov",- line1: 320,- line2: 350,- line3: 380,- line4: 400,- line5: 360,- line6: 390,- line7: 420,- line8: 440,- line9: 410,- line10: 430,- line11: 450,- line12: 470,- line13: 460,- line14: 480,- line15: 500,- },- {- month: "Dec",- line1: 340,- line2: 370,- line3: 400,- line4: 420,- line5: 380,- line6: 410,- line7: 440,- line8: 460,- line9: 430,- line10: 450,- line11: 470,- line12: 490,- line13: 480,- line14: 500,- line15: 520,- },- ] as any,- categoryKey: "month" as any,- theme: "ocean",- variant: "natural",- tickVariant: "singleLine",- strokeWidth: 2,- grid: true,- isAnimationActive: false,- showYAxis: true,- xAxisLabel: "Months",- yAxisLabel: "Performance Metrics",- height: 300,- },- render: (args: any) => (- <div>- <div- style={{- marginBottom: "16px",- padding: "16px",- background: "#e3f2fd",- borderRadius: "8px",- border: "2px solid #2196f3",- maxWidth: "700px",- }}- >- <div style={{ fontSize: "14px", marginBottom: "8px" }}>- <strong>🎯 Sidebar Tooltip Demo</strong>- </div>- <div style={{ fontSize: "13px", color: "#1565c0", lineHeight: "1.6" }}>- This chart has <strong>15 data series</strong> (more than 10). <br />- <strong>✨ Click on any point</strong> in the chart to open the sidebar tooltip on the- right side.- <br />- The sidebar provides a scrollable list of all series values at that point, making it easy- to view large datasets.- <br />- <em>- 💡 Try hovering first (shows inline tooltip), then click to see the sidebar version!- </em>- </div>- </div>- <Card style={{ width: "700px" }}>- <LineChartCondensed {...args} />- </Card>- </div>- ),- parameters: {- docs: {- description: {- story:- "**🎯 Large Dataset Handling:** When your chart has more than 10 data series, the inline tooltip becomes too crowded. This story demonstrates the sidebar tooltip feature:\n\n**Features:**\n- **15 data series** to showcase the sidebar tooltip\n- **Click interaction:** Click any point to open the sidebar\n- **Scrollable view:** All series values in an organized, scrollable list\n- **Better UX:** Cleaner way to view many data points simultaneously\n- **Color-coded:** Each series maintains its color for easy identification\n\n**Usage:**\n1. Hover over the chart to see the inline tooltip (works for smaller datasets)\n2. Click on any data point to open the sidebar tooltip\n3. Scroll through all 15 series values\n4. Click outside or on the X button to close the sidebar",- },- },- },-};--/**- * ## Big Labels- *- * This story demonstrates the chart's ability to handle very long category labels.- * The angled tick variant is particularly useful here for preventing label overlap.- */-export const BigLabelsStory: Story = {- name: "🏷️ Big Labels (Angled Ticks)",- args: {- data: dataVariations.bigLabels as any,- categoryKey: "category" as any,- theme: "emerald",- variant: "natural",- tickVariant: "angled",- strokeWidth: 2,- grid: true,- isAnimationActive: false,- showYAxis: true,- height: 250,- },- render: (args: any) => (- <Card style={{ width: "700px" }}>- <LineChartCondensed {...args} />- </Card>- ),- parameters: {- docs: {- description: {- story:- "Tests the chart with extremely long category names. The angled tick variant automatically rotates labels at an optimal angle to prevent overlapping and maximize readability.",- },- },- },-};--/**- * ## Dense Timeline- *- * Tests how the chart handles many data points with medium-length period labels.- * The angled tick variant helps display more labels without collision.- */-export const DenseTimelineStory: Story = {- name: "📅 Dense Timeline (Many Periods)",- args: {- data: dataVariations.denseTimeline as any,- categoryKey: "period" as any,- theme: "sunset",- variant: "natural",- tickVariant: "angled",- strokeWidth: 2,- grid: true,- isAnimationActive: false,- showYAxis: true,- height: 250,- },- render: (args: any) => (- <Card style={{ width: "700px" }}>- <LineChartCondensed {...args} />- </Card>- ),- parameters: {- docs: {- description: {- story:- "Tests how the chart handles many data points (16 periods) with medium-length labels. The angled tick variant provides better label visibility compared to horizontal labels.",- },- },- },-};--/**- * ## Company Names- *- * This story tests the chart with real-world company names that have varying lengths.- * It demonstrates how the chart handles business data with naturally occurring long labels.- */-export const CompanyNamesStory: Story = {- name: "🏢 Company Names (Real-world Labels)",- args: {- data: dataVariations.companyNames as any,- categoryKey: "company" as any,- theme: "vivid",- variant: "natural",- tickVariant: "angled",- strokeWidth: 2,- grid: true,- isAnimationActive: false,- showYAxis: true,- height: 250,- },- render: (args: any) => (- <Card style={{ width: "700px" }}>- <LineChartCondensed {...args} />- </Card>- ),- parameters: {- docs: {- description: {- story:- "Tests with real-world company names that have varying lengths. Demonstrates how the chart handles business data with naturally occurring long labels.",- },- },- },-};--/**- * ## Country Names- *- * This story tests the chart with official country names, which are often long.- * It shows how geographic data is handled by the angled tick system.- */-export const CountryDataStory: Story = {- name: "🌍 Country Names (Geographic Labels)",- args: {- data: dataVariations.countryData as any,- categoryKey: "country" as any,- theme: "orchid",- variant: "natural",- tickVariant: "angled",- strokeWidth: 2,- grid: true,- isAnimationActive: false,- showYAxis: true,- height: 250,- },- render: (args: any) => (- <Card style={{ width: "700px" }}>- <LineChartCondensed {...args} />- </Card>- ),- parameters: {- docs: {- description: {- story:- "Tests with official country names that include full formal names. Shows how geographic data with naturally long names is handled.",- },- },- },-};--/**- * ## Mixed Lengths- *- * This story tests the chart's ability to handle a mix of very short and very long labels- * within the same dataset, demonstrating its adaptive behavior.- */-export const MixedLengthsStory: Story = {- name: "🔤 Mixed Lengths (Varied Label Sizes)",- args: {- data: dataVariations.mixedLengths as any,- categoryKey: "item" as any,- theme: "spectrum",- variant: "linear",- tickVariant: "singleLine",- strokeWidth: 2,- grid: true,- isAnimationActive: false,- showYAxis: true,- height: 200,- },- render: (args: any) => (- <Card style={{ width: "500px" }}>- <LineChartCondensed {...args} />- </Card>- ),- parameters: {- docs: {- description: {- story:- "Tests the chart's ability to handle a mix of very short and very long labels within the same dataset.",- },- },- },-};--/**- * ## Edge Cases- *- * This story tests extreme edge cases with exceptionally long labels and minimal data points.- */-export const EdgeCasesStory: Story = {- name: "🎯 Edge Cases (Extreme Scenarios)",- args: {- data: dataVariations.edgeCases as any,- categoryKey: "name" as any,- theme: "ocean",- variant: "step",- tickVariant: "angled",- strokeWidth: 2,- grid: true,- isAnimationActive: false,- showYAxis: true,- height: 250,- },- render: (args: any) => (- <Card style={{ width: "500px" }}>- <LineChartCondensed {...args} />- </Card>- ),- parameters: {- docs: {- description: {- story:- "Tests extreme edge cases with exceptionally long labels and minimal data points. Pushes the label handling system to its limits.",- },- },- },-};--/**- * ## Minimal Data- *- * A baseline test with a small dataset and standard-length labels. This serves as a control- * case to compare against the more complex label scenarios.- */-export const MinimalDataStory: Story = {- name: "📱 Minimal Data (Baseline)",- args: {- data: dataVariations.minimal as any,- categoryKey: "category" as any,- theme: "emerald",- variant: "natural",- tickVariant: "singleLine",- strokeWidth: 2,- grid: true,- isAnimationActive: false,- showYAxis: true,- height: 200,- },- render: (args: any) => (- <Card style={{ width: "400px" }}>- <LineChartCondensed {...args} />- </Card>- ),- parameters: {- docs: {- description: {- story:- "Baseline test with minimal data and standard-length labels. Provides a control case to compare against complex scenarios.",- },- },- },-};--/**- * ## Custom Palette- *- * This story demonstrates how to use the customPalette prop to provide your own color scheme- * for the chart. This is useful when you need to match your brand colors.- */-export const CustomPaletteStory: Story = {- name: "🎨 Custom Palette",- args: {- data: dataVariations.default as any,- categoryKey: "month" as any,- theme: "ocean", // This will be overridden by customPalette- variant: "natural",- tickVariant: "singleLine",- strokeWidth: 2,- grid: true,- isAnimationActive: false,- showYAxis: true,- xAxisLabel: "Month",- yAxisLabel: "Traffic",- customPalette: ["#FF6B6B", "#4ECDC4", "#45B7D1"],- height: 200,- },- render: (args: any) => (- <div>- <div- style={{- marginBottom: "16px",- padding: "12px",- background: "#f8f9fa",- borderRadius: "8px",- border: "1px solid #e9ecef",- width: "600px",- }}- >- <h4 style={{ margin: "0 0 8px 0", color: "#333" }}>🎨 Custom Color Palette</h4>- <p style={{ margin: "0 0 12px 0", fontSize: "14px", color: "#666" }}>- This chart uses a custom color palette instead of the default theme colors.- </p>- <div style={{ display: "flex", gap: "8px", flexWrap: "wrap" }}>- {args.customPalette?.map((color: string, index: number) => (- <div- key={index}- style={{- display: "flex",- alignItems: "center",- gap: "4px",- padding: "4px 8px",- background: "white",- borderRadius: "4px",- border: "1px solid #ddd",- fontSize: "12px",- }}- >- <div- style={{- width: "12px",- height: "12px",- borderRadius: "2px",- backgroundColor: color,- border: "1px solid #ccc",- }}- />- <span style={{ fontFamily: "monospace" }}>{color}</span>- </div>- ))}- </div>- </div>- <Card style={{ width: "600px" }}>- <LineChartCondensed {...args} />- </Card>- </div>- ),- parameters: {- docs: {- description: {- story:- 'Demonstrates how to use the `customPalette` prop to provide your own color scheme. When `customPalette` is provided, it overrides the `theme` prop.\n\n**Usage:**\n```tsx\n<LineChartCondensed\n data={data}\n categoryKey="month"\n customPalette={["#FF6B6B", "#4ECDC4", "#45B7D1"]}\n/>\n```',- },- },- },-};--/**- * ## Stroke Width Comparison- *- * Compare different line thickness options to find the right visual weight for your data.- */-export const StrokeWidthComparison: Story = {- name: "📏 Stroke Width Comparison",- render: () => (- <div style={{ display: "flex", flexDirection: "column", gap: "24px" }}>- <Card style={{ width: "700px", padding: "16px" }}>- <div style={{ marginBottom: "12px" }}>- <div style={{ fontSize: "16px", fontWeight: "600", marginBottom: "4px" }}>- Thin Lines (1px)- </div>- <div style={{ fontSize: "13px", color: "#666" }}>Subtle, minimal visual weight</div>- </div>- <LineChartCondensed- data={dataVariations.default as any}- categoryKey="month"- theme="ocean"- strokeWidth={1}- height={180}- />- </Card>- <Card style={{ width: "700px", padding: "16px" }}>- <div style={{ marginBottom: "12px" }}>- <div style={{ fontSize: "16px", fontWeight: "600", marginBottom: "4px" }}>- Default Lines (2px)- </div>- <div style={{ fontSize: "13px", color: "#666" }}>Balanced, standard weight</div>- </div>- <LineChartCondensed- data={dataVariations.default as any}- categoryKey="month"- theme="emerald"- strokeWidth={2}- height={180}- />- </Card>- <Card style={{ width: "700px", padding: "16px" }}>- <div style={{ marginBottom: "12px" }}>- <div style={{ fontSize: "16px", fontWeight: "600", marginBottom: "4px" }}>- Thick Lines (4px)- </div>- <div style={{ fontSize: "13px", color: "#666" }}>Bold, high emphasis</div>- </div>- <LineChartCondensed- data={dataVariations.default as any}- categoryKey="month"- theme="sunset"- strokeWidth={4}- height={180}- />- </Card>- </div>- ),- parameters: {- docs: {- description: {- story:- "**Side-by-side comparison** of stroke widths:\n\n- **1px**: Thin, subtle lines perfect for dense data or multiple overlapping series\n- **2px**: Default weight, balanced for most use cases\n- **4px**: Thick, bold lines for high emphasis or presentations\n\n**When to use each:**\n- Use **1px** for many overlapping series or subtle trends\n- Use **2px** (default) for general purpose visualization\n- Use **4px** for presentations or when emphasizing specific trends",- },- },- },-};--/**- * ## Tick Variant Comparison- *- * Side-by-side comparison of single-line (horizontal) and angled tick variants.- * This helps you choose the right variant for your data.- */-export const TickVariantComparison: Story = {- name: "📐 Tick Variant Comparison",- render: () => (- <div style={{ display: "flex", flexDirection: "column", gap: "24px" }}>- <Card style={{ width: "700px", padding: "16px" }}>- <div style={{ marginBottom: "12px" }}>- <div style={{ fontSize: "16px", fontWeight: "600", marginBottom: "4px" }}>- Single Line Variant (Horizontal)- </div>- <div style={{ fontSize: "13px", color: "#666" }}>- Standard horizontal labels. Recharts automatically hides overlapping labels.- </div>- </div>- <LineChartCondensed- data={dataVariations.bigLabels as any}- categoryKey="category"- tickVariant="singleLine"- theme="ocean"- strokeWidth={2}- height={200}- />- </Card>- <Card style={{ width: "700px", padding: "16px" }}>- <div style={{ marginBottom: "12px" }}>- <div style={{ fontSize: "16px", fontWeight: "600", marginBottom: "4px" }}>- Angled Variant (Rotated)- </div>- <div style={{ fontSize: "13px", color: "#666" }}>- Automatically rotates labels at an optimal angle. Shows more labels without collision.- </div>- </div>- <LineChartCondensed- data={dataVariations.bigLabels as any}- categoryKey="category"- tickVariant="angled"- theme="emerald"- strokeWidth={2}- height={260}- />- </Card>- </div>- ),- parameters: {- docs: {- description: {- story:- "**Side-by-side comparison** of tick variants:\n\n- **Single Line**: Standard horizontal labels with automatic collision detection. Recharts hides overlapping labels.\n- **Angled**: Rotates labels at an optimal angle calculated based on label width and available space. Shows more labels without collision.\n\n**When to use each:**\n- Use **singleLine** for short labels or when you have few data points\n- Use **angled** for long labels or many data points where horizontal labels would overlap",- },- },- },-};--/**- * ## Responsive Behavior Demo- *- * This story demonstrates the responsive capabilities of the LineChartCondensed.- * Drag the handles on the container to resize it and observe how the chart adapts.- */-export const ResponsiveBehaviorDemo: Story = {- name: "📱 Responsive Behavior Demo",- args: {- data: dataVariations.bigLabels as any,- categoryKey: "category" as any,- theme: "sunset",- variant: "natural",- tickVariant: "angled",- strokeWidth: 2,- grid: true,- isAnimationActive: false,- showYAxis: true,- height: 250,- },- render: (args: any) => {- const [dimensions, setDimensions] = useState<{ width: number }>({- width: 700,- });-- const handleMouseDown = (e: React.MouseEvent<HTMLDivElement>, handle: string) => {- e.preventDefault();- e.stopPropagation();- const startX = e.clientX;- const startWidth = dimensions.width;-- const doDrag = (e: MouseEvent) => {- const dx = e.clientX - startX;- let newWidth = startWidth;-- if (handle.includes("e")) newWidth = startWidth + dx;- if (handle.includes("w")) newWidth = startWidth - dx;-- setDimensions({- width: Math.max(300, newWidth),- });- };-- const stopDrag = () => {- document.removeEventListener("mousemove", doDrag);- document.removeEventListener("mouseup", stopDrag);- };-- document.addEventListener("mousemove", doDrag);- document.addEventListener("mouseup", stopDrag);- };-- const handleStyle: React.CSSProperties = {- position: "absolute",- background: "#3b82f6",- opacity: 0.6,- zIndex: 10,- transition: "opacity 0.2s ease",- };-- return (- <div style={{ padding: "20px" }}>- <div style={{ marginBottom: "20px" }}>- <h3 style={{ margin: "0 0 8px 0", fontSize: "18px", fontWeight: "600" }}>- Responsive Behavior Demonstration- </h3>- <p style={{ margin: "0 0 12px 0", color: "#666", fontSize: "14px" }}>- Drag the left or right edges of the container to see how the chart adapts- </p>- <div- style={{- padding: "12px",- backgroundColor: "#e3f2fd",- borderRadius: "6px",- fontSize: "12px",- color: "#1565c0",- }}- >- <strong>🎯 Try This:</strong> Resize the container to see how angled labels adapt to- available space.- </div>- </div>-- <Card- style={{- position: "relative",- width: `${dimensions.width}px`,- border: "2px dashed #9ca3af",- padding: "20px",- boxSizing: "border-box",- overflow: "hidden",- cursor: "default",- }}- >- <LineChartCondensed {...args} />-- {/* Resize Handles */}- <div- style={{ ...handleStyle, top: 0, bottom: 0, left: -2, width: 12, cursor: "ew-resize" }}- onMouseDown={(e) => handleMouseDown(e, "w")}- />- <div- style={{ ...handleStyle, top: 0, bottom: 0, right: -2, width: 12, cursor: "ew-resize" }}- onMouseDown={(e) => handleMouseDown(e, "e")}- />-- {/* Dimension Display */}- <div- style={{- position: "absolute",- bottom: 8,- right: 8,- background: "rgba(0,0,0,0.8)",- color: "white",- padding: "4px 8px",- borderRadius: "4px",- fontSize: "11px",- fontFamily: "monospace",- fontWeight: "500",- }}- >- {dimensions.width}px- </div>- </Card>- </div>- );- },-};diff --git a/packages/react-ui/src/components/D3Charts/MiniAreaChart/MiniAreaChart.tsx b/packages/react-ui/src/components/D3Charts/MiniAreaChart/MiniAreaChart.tsxdeleted file mode 100644index 3e621db0e..000000000--- a/packages/react-ui/src/components/D3Charts/MiniAreaChart/MiniAreaChart.tsx+++ /dev/null@@ -1,82 +0,0 @@-import { area, line } from "d3-shape";-import { useId } from "react";-import { useEffectiveAnimation } from "../hooks/core/useEffectiveAnimation";-import { MiniChartFrame } from "../shared/mini/MiniChartFrame";-import { type MiniChartPoint, miniCurves, miniLineGeometry } from "../shared/mini/miniChartUtils";-import { CHART_CLASS_PREFIX } from "../utils/constants";-import { useChartPalette } from "../utils/paletteUtils";-import type { MiniAreaChartProps } from "./types";--const CLASS = `${CHART_CLASS_PREFIX}-mini-area-chart`;--/**- * A compact, axis-free area sparkline — react-ui's Recharts `MiniAreaChart`:- * the most recent values that fit, one series, a gradient fill under a 1.5px- * line.- */-export function MiniAreaChart({- data,- customPalette,- variant = "natural",- opacity = 0.5,- isAnimationActive = false,- onAreaClick,- size = "100%",- className,- areaColor,- useGradient = true,-}: MiniAreaChartProps) {- const animate = useEffectiveAnimation(isAnimationActive);- const [color = ""] = useChartPalette({- customPalette: customPalette ?? (areaColor ? [areaColor] : undefined),- themePaletteName: "areaChartPalette",- dataLength: 1,- });- const gradientId = `${CLASS}-gradient-${useId().replace(/:/g, "")}`;- const curve = miniCurves[variant] ?? miniCurves.natural;- const animated = animate ? ` ${CHART_CLASS_PREFIX}-mini-chart-mark--animated` : "";-- return (- <MiniChartFrame chart="area" size={size} className={className} onClick={onAreaClick}>- {(width, height) => {- const { points, x, y } = miniLineGeometry(data, width, height);- const areaD =- area<MiniChartPoint>()- .x((_, i) => x(i))- .y0(y(0))- .y1((p) => y(p.value))- .curve(curve)(points) ?? "";- const lineD =- line<MiniChartPoint>()- .x((_, i) => x(i))- .y((p) => y(p.value))- .curve(curve)(points) ?? "";- return (- <>- {useGradient && (- <defs>- <linearGradient id={gradientId} 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>- )}- <path- className={`${CLASS}-area${animated}`}- d={areaD}- fill={useGradient ? `url(#${gradientId})` : color}- fillOpacity={useGradient ? 1 : opacity}- />- <path- className={`${CLASS}-line${animated}`}- d={lineD}- fill="none"- stroke={color}- strokeWidth={1.5}- />- </>- );- }}- </MiniChartFrame>- );-}diff --git a/packages/react-ui/src/components/D3Charts/MiniAreaChart/index.ts b/packages/react-ui/src/components/D3Charts/MiniAreaChart/index.tsdeleted file mode 100644index bacf1d659..000000000--- a/packages/react-ui/src/components/D3Charts/MiniAreaChart/index.ts+++ /dev/null@@ -1,2 +0,0 @@-export { MiniAreaChart } from "./MiniAreaChart";-export type { MiniAreaChartData, MiniAreaChartProps } from "./types";diff --git a/packages/react-ui/src/components/D3Charts/MiniAreaChart/stories/MiniAreaChart.stories.tsx b/packages/react-ui/src/components/D3Charts/MiniAreaChart/stories/MiniAreaChart.stories.tsxdeleted file mode 100644index 5e00024f2..000000000--- a/packages/react-ui/src/components/D3Charts/MiniAreaChart/stories/MiniAreaChart.stories.tsx+++ /dev/null@@ -1,406 +0,0 @@-// Copy of Charts/MiniAreaChart/stories/MiniAreaChart.stories.tsx with only the chart import and the title changed:-// the same args and renders, rendering the D3Charts chart via-// ../../stories/rechartsStoryAdapters.-import type { Meta, StoryObj } from "@storybook/react";-import { Card } from "../../../Card";-import { MiniAreaChart } from "../../stories/rechartsStoryAdapters";--// Simple array of numbers for 1D area chart-const simpleAreaChartData = [- 12, 45, 78, 32, 67, 89, 23, 56, 91, 34, 76, 28, 85, 42, 19, 63, 87, 31, 74, 58, 92, 26, 49, 83,- 37, 50,-];--// Array of objects with value and label-const labeledAreaChartData = [- { value: 150, label: "January" },- { value: 280, label: "February" },- { value: 220, label: "March" },- { value: 180, label: "April" },- { value: 250, label: "May" },- { value: 300, label: "June" },- { value: 320, label: "July" },- { value: 280, label: "August" },- { value: 310, label: "September" },- { value: 290, label: "October" },- { value: 340, label: "November" },- { value: 360, label: "December" },- // { value: 360, label: "December" },- // { value: 360, label: "December" },-];--const meta: Meta<typeof MiniAreaChart> = {- title: "Components/D3Charts/MiniAreaChart",- component: MiniAreaChart,- parameters: {- layout: "centered",- docs: {- description: {- component:- "```tsx\nimport { MiniAreaChart } from '@openuidev/react-ui/Charts/AreaCharts/MiniAreaChart';\n```\n\nA responsive mini area chart component that accepts 1D data (numbers or objects with value/label) with automatic data filtering for space-constrained containers. Features linear gradient fills from color to transparent.",- },- },- },- tags: ["!autodocs"],- argTypes: {- data: {- description:- "An array of numbers or an array of objects with value and optional label. Each entry represents a single point in the area chart.",- control: false,- table: {- type: { summary: "Array<number> | Array<{ value: number; label?: string }>" },- defaultValue: { summary: "[]" },- category: "Data",- },- },- theme: {- description:- "The color palette theme for the chart. Each theme provides a different color for the area.",- control: "select",- options: ["ocean", "orchid", "emerald", "sunset", "spectrum", "vivid"],- table: {- defaultValue: { summary: "ocean" },- category: "Appearance",- },- },- variant: {- description:- "The interpolation method used to create the area curves. 'linear' creates straight lines between points, 'natural' creates smooth curves, and 'step' creates a stepped area.",- control: "radio",- options: ["linear", "natural", "step"],- table: {- defaultValue: { summary: "natural" },- category: "Appearance",- },- },- opacity: {- description:- "The opacity of the filled area beneath the line (0 = fully transparent, 1 = fully opaque). Only used when useGradient is false.",- control: "number",- table: {- type: { summary: "number" },- defaultValue: { summary: "0.5" },- category: "Appearance",- },- },- useGradient: {- description:- "Whether to use a linear gradient fill that goes from the area color at the top to transparent at the bottom.",- control: "boolean",- table: {- type: { summary: "boolean" },- defaultValue: { summary: "true" },- category: "Appearance",- },- },- isAnimationActive: {- description: "Whether to animate the chart when it first renders",- control: "boolean",- table: {- type: { summary: "boolean" },- defaultValue: { summary: "true" },- category: "Display",- },- },- size: {- description: "The width and height of the chart",- control: "text",- table: {- type: { summary: "number | string" },- defaultValue: { summary: "100%" },- category: "Appearance",- },- },- areaColor: {- description: "Custom color for the area fill and stroke",- control: "color",- table: {- type: { summary: "string" },- category: "Appearance",- },- },- },-} satisfies Meta<typeof MiniAreaChart>;--export default meta;-type Story = StoryObj<typeof meta>;--export const SimpleNumberArray: Story = {- name: "Simple Number Array (With Gradient)",- args: {- data: simpleAreaChartData,- theme: "ocean",- variant: "natural",- opacity: 0.5,- useGradient: true,- isAnimationActive: true,- size: "100%",- },- render: (args: any) => (- <Card style={{ width: "280px", padding: "20px" }}>- <h3 style={{ marginBottom: "16px", fontSize: "16px", fontWeight: "600" }}>Daily Activity</h3>- <MiniAreaChart {...args} />- </Card>- ),- parameters: {- docs: {- source: {- code: `-const activityData = [12, 45, 78, 32, 67, 89, 23, 56, 91, 34];--<MiniAreaChart- data={activityData}- theme="ocean"- variant="natural"- useGradient={true}- isAnimationActive={true}- size="100%"-/>-`,- },- },- },-};--export const LabeledData: Story = {- name: "Labeled Data (With Gradient)",- args: {- data: labeledAreaChartData,- theme: "emerald",- variant: "natural",- opacity: 0.6,- useGradient: true,- isAnimationActive: true,- size: "100%",- },- render: (args: any) => (- <Card style={{ width: "320px", padding: "20px" }}>- <h3 style={{ marginBottom: "16px", fontSize: "16px", fontWeight: "600" }}>Monthly Revenue</h3>- <MiniAreaChart {...args} />- </Card>- ),- parameters: {- docs: {- source: {- code: `-const revenueData = [- { value: 150, label: "January" },- { value: 280, label: "February" },- { value: 220, label: "March" },- // ...-];--<MiniAreaChart- data={revenueData}- theme="emerald"- variant="natural"- useGradient={true}- size="100%"-/>-`,- },- },- },-};--export const WithoutGradient: Story = {- name: "Solid Fill (Without Gradient)",- args: {- data: simpleAreaChartData.slice(0, 15),- theme: "sunset",- variant: "natural",- opacity: 0.4,- useGradient: false,- isAnimationActive: true,- size: "100%",- },- render: (args: any) => (- <Card style={{ width: "280px", padding: "20px" }}>- <h3 style={{ marginBottom: "16px", fontSize: "16px", fontWeight: "600" }}>Solid Fill Area</h3>- <MiniAreaChart {...args} />- </Card>- ),- parameters: {- docs: {- source: {- code: `-<MiniAreaChart- data={data}- theme="sunset"- variant="natural"- opacity={0.4}- useGradient={false}- size="100%"-/>-`,- },- },- },-};--export const GradientComparison: Story = {- name: "Gradient vs Solid Comparison",- render: () => (- <div style={{ display: "flex", gap: "20px" }}>- <Card style={{ width: "250px", padding: "16px" }}>- <h4 style={{ marginBottom: "12px", fontSize: "14px", fontWeight: "600" }}>- With Gradient (Default)- </h4>- <MiniAreaChart- data={[20, 45, 35, 80, 60, 90, 45, 70, 85, 30]}- theme="orchid"- variant="natural"- useGradient={true}- size={200}- />- </Card>- <Card style={{ width: "250px", padding: "16px" }}>- <h4 style={{ marginBottom: "12px", fontSize: "14px", fontWeight: "600" }}>Solid Fill</h4>- <MiniAreaChart- data={[20, 45, 35, 80, 60, 90, 45, 70, 85, 30]}- theme="orchid"- variant="natural"- useGradient={false}- opacity={0.3}- size={200}- />- </Card>- </div>- ),-};--export const ResponsiveData: Story = {- name: "Responsive Data Filtering",- args: {- data: simpleAreaChartData,- theme: "orchid",- variant: "natural",- opacity: 0.4,- useGradient: true,- isAnimationActive: true,- size: "100%",- },- render: (args: any) => (- <div style={{ display: "flex", gap: "20px", flexDirection: "column" }}>- <Card style={{ width: "200px", padding: "16px" }}>- <h4 style={{ marginBottom: "12px", fontSize: "14px", fontWeight: "600" }}>Small (200px)</h4>- <MiniAreaChart {...args} />- </Card>- <Card style={{ width: "400px", padding: "16px" }}>- <h4 style={{ marginBottom: "12px", fontSize: "14px", fontWeight: "600" }}>- Medium (400px)- </h4>- <MiniAreaChart {...args} />- </Card>- <Card style={{ width: "600px", padding: "16px" }}>- <h4 style={{ marginBottom: "12px", fontSize: "14px", fontWeight: "600" }}>Large (600px)</h4>- <MiniAreaChart {...args} />- </Card>- </div>- ),-};--export const DifferentSizes: Story = {- name: "Different Sizes",- render: () => (- <div style={{ display: "flex", gap: "20px", alignItems: "center" }}>- <Card style={{ width: "120px", padding: "12px" }}>- <h4 style={{ marginBottom: "8px", fontSize: "12px", fontWeight: "600" }}>Small</h4>- <MiniAreaChart data={[15, 25, 20, 35, 30, 18, 22]} theme="sunset" size={80} />- </Card>- <Card style={{ width: "200px", padding: "16px" }}>- <h4 style={{ marginBottom: "12px", fontSize: "14px", fontWeight: "600" }}>Medium</h4>- <MiniAreaChart data={simpleAreaChartData.slice(0, 10)} theme="spectrum" size={160} />- </Card>- <Card style={{ width: "280px", padding: "20px" }}>- <h4 style={{ marginBottom: "16px", fontSize: "16px", fontWeight: "600" }}>Large</h4>- <MiniAreaChart data={simpleAreaChartData} theme="vivid" size={240} />- </Card>- </div>- ),-};--export const DifferentThemes: Story = {- name: "Different Themes (All With Gradients)",- render: () => (- <div style={{ display: "flex", gap: "20px", flexWrap: "wrap" }}>- {(["ocean", "orchid", "emerald", "sunset", "spectrum", "vivid"] as const).map((theme) => (- <Card key={theme} style={{ width: "200px", padding: "16px" }}>- <h4- style={{- marginBottom: "12px",- fontSize: "14px",- fontWeight: "600",- textTransform: "capitalize",- }}- >- {theme} Theme- </h4>- <MiniAreaChart- data={[15, 25, 20, 35, 30, 18, 22, 28, 33, 19]}- theme={theme}- variant="natural"- useGradient={true}- size={160}- />- </Card>- ))}- </div>- ),-};--export const DifferentVariants: Story = {- name: "Different Variants",- render: () => (- <div style={{ display: "flex", gap: "20px" }}>- {(["linear", "natural", "step"] as const).map((variant) => (- <Card key={variant} style={{ width: "220px", padding: "16px" }}>- <h4- style={{- marginBottom: "12px",- fontSize: "14px",- fontWeight: "600",- textTransform: "capitalize",- }}- >- {variant} Variant- </h4>- <MiniAreaChart- data={[15, 35, 25, 45, 30, 50, 28, 42, 38, 29]}- theme="spectrum"- variant={variant}- useGradient={true}- size={180}- />- </Card>- ))}- </div>- ),-};--export const CustomColor: Story = {- name: "Custom Color with Gradient",- args: {- data: [20, 45, 28, 80, 99, 43, 67, 23, 89, 56],- theme: "ocean",- variant: "natural",- opacity: 0.7,- areaColor: "#ff6b6b",- useGradient: true,- size: 200,- },- render: (args: any) => (- <Card- style={{- width: "280px",- padding: "20px",- display: "flex",- flexDirection: "column",- alignItems: "center",- }}- >- <h3 style={{ marginBottom: "16px", fontSize: "16px", fontWeight: "600" }}>Custom Red Area</h3>- <MiniAreaChart {...args} />- </Card>- ),-};diff --git a/packages/react-ui/src/components/D3Charts/MiniBarChart/MiniBarChart.tsx b/packages/react-ui/src/components/D3Charts/MiniBarChart/MiniBarChart.tsxdeleted file mode 100644index c6002534b..000000000--- a/packages/react-ui/src/components/D3Charts/MiniBarChart/MiniBarChart.tsx+++ /dev/null@@ -1,76 +0,0 @@-import { useTheme } from "../../ThemeProvider";-import { useEffectiveAnimation } from "../hooks/core/useEffectiveAnimation";-import { roundedBarPath } from "../shared/cartesian/roundedBarPath";-import { MiniChartFrame } from "../shared/mini/MiniChartFrame";-import { MINI_BAR_WIDTH, miniBarGeometry } from "../shared/mini/miniChartUtils";-import { CHART_CLASS_PREFIX } from "../utils/constants";-import { useChartPalette } from "../utils/paletteUtils";-import type { MiniBarChartProps } from "./types";--const CLASS = `${CHART_CLASS_PREFIX}-mini-bar-chart`;-// The thin line down each bar's middle, inset from both ends — shown only on-// bars tall enough to hold it (as react-ui's Recharts MiniBarChart).-const INNER_LINE_INSET = 6;-const INNER_LINE_MIN_HEIGHT = 8;--/**- * Compact, axis-free bars — react-ui's Recharts `MiniBarChart`: the most- * recent values that fit, 8px bars right-aligned, rounded outer corners, and- * a thin inner line.- */-export function MiniBarChart({- data,- customPalette,- radius = 1,- isAnimationActive = false,- onBarsClick,- size = "100%",- className,- barColor,-}: MiniBarChartProps) {- const animate = useEffectiveAnimation(isAnimationActive);- const [color = ""] = useChartPalette({- customPalette: customPalette ?? (barColor ? [barColor] : undefined),- themePaletteName: "barChartPalette",- dataLength: 1,- });- const { mode } = useTheme();- const innerLineColor = mode === "light" ? "rgba(255, 255, 255, 0.3)" : "rgba(0, 0, 0, 0.3)";- const animated = animate ? ` ${CHART_CLASS_PREFIX}-mini-chart-mark--animated` : "";-- return (- <MiniChartFrame chart="bar" size={size} className={className} onClick={onBarsClick}>- {(width, height) =>- miniBarGeometry(data, width, height).map((bar, i) =>- bar.height > 0 ? (- <g key={i} className={`${CLASS}-bar-group${animated}`}>- <path- className={`${CLASS}-bar`}- d={roundedBarPath(- bar.x,- bar.y,- MINI_BAR_WIDTH,- bar.height,- bar.negative ? [0, 0, radius, radius] : [radius, radius, 0, 0],- )}- fill={color}- />- {bar.height >= INNER_LINE_MIN_HEIGHT && (- <line- className={`${CLASS}-inner-line`}- x1={bar.x + MINI_BAR_WIDTH / 2}- y1={bar.y + INNER_LINE_INSET}- x2={bar.x + MINI_BAR_WIDTH / 2}- y2={bar.y + bar.height - INNER_LINE_INSET}- stroke={innerLineColor}- strokeWidth={1}- strokeLinecap="round"- />- )}- </g>- ) : null,- )- }- </MiniChartFrame>- );-}diff --git a/packages/react-ui/src/components/D3Charts/MiniBarChart/index.ts b/packages/react-ui/src/components/D3Charts/MiniBarChart/index.tsdeleted file mode 100644index 02c487261..000000000--- a/packages/react-ui/src/components/D3Charts/MiniBarChart/index.ts+++ /dev/null@@ -1,2 +0,0 @@-export { MiniBarChart } from "./MiniBarChart";-export type { MiniBarChartData, MiniBarChartProps } from "./types";diff --git a/packages/react-ui/src/components/D3Charts/MiniBarChart/stories/MiniBarChart.stories.tsx b/packages/react-ui/src/components/D3Charts/MiniBarChart/stories/MiniBarChart.stories.tsxdeleted file mode 100644index af07428fb..000000000--- a/packages/react-ui/src/components/D3Charts/MiniBarChart/stories/MiniBarChart.stories.tsx+++ /dev/null@@ -1,218 +0,0 @@-// Copy of Charts/MiniBarChart/stories/MiniBarChart.stories.tsx with only the chart import and the title changed:-// the same args and renders, rendering the D3Charts chart via-// ../../stories/rechartsStoryAdapters.-import type { Meta, StoryObj } from "@storybook/react";-import { Monitor } from "lucide-react";-import { Card } from "../../../Card";-import { MiniBarChart, MiniBarChartProps } from "../../stories/rechartsStoryAdapters";--// Simple array of numbers for 1D bar chart-const simpleBarChartData = [- 1, 1893456, 3456789, 2987654, 1765432, 4321098, 3789012, 2654321, 4123567, 3234567, 2876543,- 3987654, 2347891, 1893456, 3456789, 2987654, 1765432, 4321098, 3789012, 2654321, 4123567, 3234567,- 2876543, 3987654, 2347891, 1893456, 3456789, 2987654, 1765432, 4321098, 3789012, 2654321, 4123567,- 3234567, 2876543, 3987654, 2347891, 1893456, 3456789, 2987654, 1765432, 4321098, 3789012, 2654321,- 4123567, 3234567, 2876543, 100000,-];--// Array of objects with value and label-const labeledBarChartData = [- { value: 2347891, label: "January" },- { value: 1893456, label: "February" },- { value: 3456789, label: "March" },- { value: 2987654, label: "April" },- { value: 1765432, label: "May" },- { value: 4321098, label: "June" },- { value: 3789012, label: "July" },- { value: 2654321, label: "August" },- { value: 4123567, label: "September" },- { value: 3234567, label: "October" },- { value: 2876543, label: "November" },- { value: 3987654, label: "December" },-];--const icons = {- desktop: Monitor,-} as const;--const meta: Meta<MiniBarChartProps> = {- title: "Components/D3Charts/MiniBarChart",- component: MiniBarChart,- parameters: {- layout: "centered",- docs: {- description: {- component:- "```tsx\nimport { MiniBarChart } from '@openuidev/react-ui/Charts/BarCharts/MiniBarChart';\n```",- },- },- },- tags: ["!autodocs"],- argTypes: {- data: {- description:- "An array of numbers or an array of objects with value and optional label. Each entry represents a single bar in the chart.",- control: false,- table: {- type: { summary: "Array<number> | Array<{ value: number; label?: string }>" },- defaultValue: { summary: "[]" },- category: "Data",- },- },- theme: {- description:- "The color palette theme for the chart. Each theme provides a different set of colors for the bars.",- control: "select",- options: ["ocean", "orchid", "emerald", "sunset", "spectrum", "vivid"],- table: {- defaultValue: { summary: "ocean" },- category: "Appearance",- },- },- radius: {- description: "The radius of the rounded corners of the bars",- control: "number",- table: {- type: { summary: "number" },- defaultValue: { summary: "1" },- category: "Appearance",- },- },- isAnimationActive: {- description: "Whether to animate the chart when it first renders",- control: "boolean",- table: {- type: { summary: "boolean" },- defaultValue: { summary: "true" },- category: "Display",- },- },- size: {- description: "The width and height of the chart",- control: "number",- table: {- type: { summary: "number | string" },- defaultValue: { summary: "160" },- category: "Appearance",- },- },- },-} satisfies Meta<typeof MiniBarChart>;--export default meta;-type Story = StoryObj<typeof meta>;--export const SimpleNumberArray: Story = {- name: "Simple Number Array",- args: {- data: simpleBarChartData,- theme: "ocean",- radius: 2,- isAnimationActive: true,- size: "100%",- },- render: (args: any) => (- <Card style={{ width: "280px", padding: "20px" }}>- <h3 style={{ marginBottom: "16px", fontSize: "16px", fontWeight: "600" }}>- Monthly Sales Data- </h3>- <MiniBarChart {...args} />- </Card>- ),- parameters: {- docs: {- source: {- code: `-const salesData = [2347891, 1893456, 3456789, 2987654, 1765432, 4321098];--<MiniBarChart- data={salesData}- theme="ocean"- radius={2}- isAnimationActive={true}- size={200}-/>-`,- },- },- },-};--export const LabeledData: Story = {- name: "Labeled Data",- args: {- data: labeledBarChartData,- theme: "emerald",- radius: 1,- isAnimationActive: true,- size: 200,- },- render: (args: any) => (- <Card style={{ width: "280px", padding: "20px" }}>- <h3 style={{ marginBottom: "16px", fontSize: "16px", fontWeight: "600" }}>Monthly Revenue</h3>- <MiniBarChart {...args} />- </Card>- ),- parameters: {- docs: {- source: {- code: `-const revenueData = [- { value: 2347891, label: "January" },- { value: 1893456, label: "February" },- { value: 3456789, label: "March" },- // ...-];--<MiniBarChart- data={revenueData}- theme="emerald"- radius={1}- isAnimationActive={true}- size={200}-/>-`,- },- },- },-};--export const SmallSize: Story = {- name: "Small Size",- args: {- data: [10, 20, 15, 30, 25, 35, 18],- theme: "sunset",- radius: 1,- isAnimationActive: true,- size: 120,- },- render: (args: any) => (- <Card style={{ width: "200px", padding: "16px" }}>- <h4 style={{ marginBottom: "12px", fontSize: "14px", fontWeight: "600" }}>Weekly Stats</h4>- <MiniBarChart {...args} />- </Card>- ),-};--export const DifferentThemes: Story = {- name: "Different Themes",- render: () => (- <div style={{ display: "flex", gap: "20px", flexWrap: "wrap" }}>- {(["ocean", "orchid", "emerald", "sunset", "spectrum", "vivid"] as const).map((theme) => (- <Card key={theme} style={{ width: "200px", padding: "16px" }}>- <h4- style={{- marginBottom: "12px",- fontSize: "14px",- fontWeight: "600",- textTransform: "capitalize",- }}- >- {theme} Theme- </h4>- <MiniBarChart data={[15, 25, 20, 35, 30, 18, 22]} theme={theme} radius={2} size={160} />- </Card>- ))}- </div>- ),-};diff --git a/packages/react-ui/src/components/D3Charts/MiniLineChart/MiniLineChart.tsx b/packages/react-ui/src/components/D3Charts/MiniLineChart/MiniLineChart.tsxdeleted file mode 100644index 8d99838dc..000000000--- a/packages/react-ui/src/components/D3Charts/MiniLineChart/MiniLineChart.tsx+++ /dev/null@@ -1,56 +0,0 @@-import { line } from "d3-shape";-import { useEffectiveAnimation } from "../hooks/core/useEffectiveAnimation";-import { MiniChartFrame } from "../shared/mini/MiniChartFrame";-import { type MiniChartPoint, miniCurves, miniLineGeometry } from "../shared/mini/miniChartUtils";-import { CHART_CLASS_PREFIX } from "../utils/constants";-import { useChartPalette } from "../utils/paletteUtils";-import type { MiniLineChartProps } from "./types";--const CLASS = `${CHART_CLASS_PREFIX}-mini-line-chart`;--/**- * A compact, axis-free line sparkline — react-ui's Recharts `MiniLineChart`:- * the most recent values that fit, one series, no dots.- */-export function MiniLineChart({- data,- customPalette,- variant = "natural",- strokeWidth = 2,- isAnimationActive = false,- onLineClick,- size = "100%",- className,- lineColor,-}: MiniLineChartProps) {- const animate = useEffectiveAnimation(isAnimationActive);- const [color = ""] = useChartPalette({- customPalette: customPalette ?? (lineColor ? [lineColor] : undefined),- themePaletteName: "lineChartPalette",- dataLength: 1,- });- const curve = miniCurves[variant] ?? miniCurves.natural;- const animated = animate ? ` ${CHART_CLASS_PREFIX}-mini-chart-mark--animated` : "";-- return (- <MiniChartFrame chart="line" size={size} className={className} onClick={onLineClick}>- {(width, height) => {- const { points, x, y } = miniLineGeometry(data, width, height);- const lineD =- line<MiniChartPoint>()- .x((_, i) => x(i))- .y((p) => y(p.value))- .curve(curve)(points) ?? "";- return (- <path- className={`${CLASS}-line${animated}`}- d={lineD}- fill="none"- stroke={color}- strokeWidth={strokeWidth}- />- );- }}- </MiniChartFrame>- );-}diff --git a/packages/react-ui/src/components/D3Charts/MiniLineChart/index.ts b/packages/react-ui/src/components/D3Charts/MiniLineChart/index.tsdeleted file mode 100644index 7faf3a5cb..000000000--- a/packages/react-ui/src/components/D3Charts/MiniLineChart/index.ts+++ /dev/null@@ -1,2 +0,0 @@-export { MiniLineChart } from "./MiniLineChart";-export type { MiniLineChartData, MiniLineChartProps } from "./types";diff --git a/packages/react-ui/src/components/D3Charts/MiniLineChart/stories/MiniLineChart.stories.tsx b/packages/react-ui/src/components/D3Charts/MiniLineChart/stories/MiniLineChart.stories.tsxdeleted file mode 100644index 76186b63f..000000000--- a/packages/react-ui/src/components/D3Charts/MiniLineChart/stories/MiniLineChart.stories.tsx+++ /dev/null@@ -1,189 +0,0 @@-// Copy of Charts/MiniLineChart/stories/MiniLineChart.stories.tsx with only the chart import and the title changed:-// the same args and renders, rendering the D3Charts chart via-// ../../stories/rechartsStoryAdapters.-import type { Meta, StoryObj } from "@storybook/react";-import { Card } from "../../../Card";-import { MiniLineChart } from "../../stories/rechartsStoryAdapters";--// Simple array of numbers for 1D line chart-const simpleLineChartData = [- 12, 45, 78, 32, 67, 89, 23, 56, 91, 34, 76, 28, 85, 42, 19, 63, 87, 31, 74, 58, 92, 26, 49, 83,- 37, 50, 1,-];--// Array of objects with value and label-const labeledLineChartData = [- { value: 150, label: "January" },- { value: 280, label: "February" },- { value: 220, label: "March" },- { value: 180, label: "April" },- { value: 250, label: "May" },- { value: 300, label: "June" },- { value: 320, label: "July" },- { value: 280, label: "August" },- { value: 310, label: "September" },- { value: 290, label: "October" },- { value: 340, label: "November" },- { value: 360, label: "December" },-];--const meta: Meta<typeof MiniLineChart> = {- title: "Components/D3Charts/MiniLineChart",- component: MiniLineChart,- parameters: {- layout: "centered",- docs: {- description: {- component:- "```tsx\nimport { MiniLineChart } from '@openuidev/react-ui/Charts/LineCharts/MiniLineChart';\n```\n\nA responsive mini line chart component that accepts 1D data (numbers or objects with value/label) with automatic data filtering for space-constrained containers. Features smooth line interpolation and customizable styling.",- },- },- },- tags: ["!autodocs"],- argTypes: {- data: {- description:- "An array of numbers or an array of objects with value and optional label. Each entry represents a single point in the line chart.",- control: false,- table: {- type: { summary: "Array<number> | Array<{ value: number; label?: string }>" },- defaultValue: { summary: "[]" },- category: "Data",- },- },- theme: {- description:- "The color palette theme for the chart. Each theme provides a different color for the line.",- control: "select",- options: ["ocean", "orchid", "emerald", "sunset", "spectrum", "vivid"],- table: {- defaultValue: { summary: "ocean" },- category: "Appearance",- },- },- variant: {- description:- "The interpolation method used to create the line curves. 'linear' creates straight lines between points, 'natural' creates smooth curves, and 'step' creates a stepped line.",- control: "radio",- options: ["linear", "natural", "step"],- table: {- defaultValue: { summary: "natural" },- category: "Appearance",- },- },- strokeWidth: {- description: "The width of the line stroke",- control: "number",- table: {- type: { summary: "number" },- defaultValue: { summary: "2" },- category: "Appearance",- },- },- isAnimationActive: {- description: "Whether to animate the chart when it first renders",- control: "boolean",- table: {- type: { summary: "boolean" },- defaultValue: { summary: "true" },- category: "Display",- },- },- size: {- description: "The width and height of the chart",- control: "text",- table: {- type: { summary: "number | string" },- defaultValue: { summary: "100%" },- category: "Appearance",- },- },- lineColor: {- description: "Custom color for the line stroke",- control: "color",- table: {- type: { summary: "string" },- category: "Appearance",- },- },- },-} satisfies Meta<typeof MiniLineChart>;--export default meta;-type Story = StoryObj<typeof meta>;--export const SimpleNumberArray: Story = {- name: "Simple Number Array",- args: {- data: simpleLineChartData,- theme: "ocean",- variant: "natural",- strokeWidth: 2,- isAnimationActive: true,- size: "100%",- },- render: (args: any) => (- <Card style={{ width: "280px", padding: "20px" }}>- <h3 style={{ marginBottom: "16px", fontSize: "16px", fontWeight: "600" }}>Daily Activity</h3>- <MiniLineChart {...args} />- </Card>- ),- parameters: {- docs: {- source: {- code: `-const activityData = [12, 45, 78, 32, 67, 89, 23, 56, 91, 34];--<MiniLineChart- data={activityData}- theme="ocean"- variant="natural"- strokeWidth={2}- isAnimationActive={true}- size="100%"-/>-`,- },- },- },-};--export const LabeledData: Story = {- name: "Labeled Data",- args: {- data: labeledLineChartData,- theme: "emerald",- variant: "natural",- strokeWidth: 2,- isAnimationActive: true,- size: "100%",- },- render: (args: any) => (- <Card style={{ width: "320px", padding: "20px" }}>- <h3 style={{ marginBottom: "16px", fontSize: "16px", fontWeight: "600" }}>Monthly Revenue</h3>- <MiniLineChart {...args} />- </Card>- ),- parameters: {- docs: {- source: {- code: `-const revenueData = [- { value: 150, label: "January" },- { value: 280, label: "February" },- { value: 220, label: "March" },- // ...-];--<MiniLineChart- data={revenueData}- theme="emerald"- variant="natural"- strokeWidth={2}- size="100%"-/>-`,- },- },- },-};diff --git a/packages/react-ui/src/components/D3Charts/PieChart/PieChart.tsx b/packages/react-ui/src/components/D3Charts/PieChart/PieChart.tsxdeleted file mode 100644index a97d9fb4b..000000000--- a/packages/react-ui/src/components/D3Charts/PieChart/PieChart.tsx+++ /dev/null@@ -1,186 +0,0 @@-import { arc, pie, type PieArcDatum } from "d3-shape";-import { useMemo } from "react";--import {- type CategoricalSlice,- useCategoricalChartOrchestrator,- useEffectiveAnimation,- useExportChartData,-} from "../hooks";-import { ChartShell } from "../shared/core/ChartShell";-import { DefaultLegend } from "../shared/core/DefaultLegend/DefaultLegend";-import { useResolvedLegendKey } from "../shared/core/legend/LegendStoreProvider";-import { ChartTooltip } from "../shared/core/PortalTooltip/ChartTooltip";-import { ChartWithStackedLegend } from "../shared/core/StackedLegend/ChartWithStackedLegend";-import { CHART_CLASS_PREFIX } from "../utils/constants";-import { PieSlices } from "./parts/PieSlices";-import type { PieChartData, PieChartProps } from "./types";--/**- * `legendVariant="stacked"` (the default, as in react-ui's Recharts PieChart)- * lays the chart out with its built-in stacked legend. The inline legend is- * used for `"default"`, and none when the chart publishes to an external- * legend (`legendKey`, or a surrounding `LegendStoreProvider`'s key).- */-export function PieChart<T extends PieChartData>(props: PieChartProps<T>) {- const { legend = true, legendVariant = "stacked", legendKey, width, height, className } = props;- const externalLegendKey = useResolvedLegendKey(legendKey);-- if (legend && legendVariant === "stacked" && externalLegendKey === undefined) {- return (- <ChartWithStackedLegend width={width} height={height} className={className}>- <PieChartImpl {...props} width={undefined} height={undefined} className={undefined} />- </ChartWithStackedLegend>- );- }- return <PieChartImpl {...props} />;-}--function PieChartImpl<T extends PieChartData>(props: PieChartProps<T>) {- const {- data,- categoryKey,- dataKey,- customPalette,- variant = "pie",- appearance = "circular",- format = "number",- legend: showLegend = true,- isAnimationActive = false,- cornerRadius = 0,- paddingAngle = 0,- maxChartSize = 500,- minChartSize = 150,- height,- width,- fitLegendInHeight,- className,- onClick,- legendKey,- } = props;-- const isSemiCircular = appearance === "semiCircular";-- const orch = useCategoricalChartOrchestrator({- data,- categoryKey,- dataKey,- themePaletteName: "pieChartPalette",- customPalette,- format,- showLegend,- isSemiCircular,- maxChartSize,- minChartSize,- height,- width,- fitLegendInHeight,- legendKey,- });-- const animate = useEffectiveAnimation(isAnimationActive);-- // Pie-specific geometry- const outerRadius = orch.dimensions.chartSize * 0.45;- const innerRadius = variant === "donut" ? outerRadius * 0.6 : 0;-- const startAngle = isSemiCircular ? -Math.PI / 2 : 0;- const endAngle = isSemiCircular ? Math.PI / 2 : 2 * Math.PI;-- const pieGenerator = useMemo(- () =>- pie<CategoricalSlice>()- .value((d) => d.value)- .sort(null)- .startAngle(startAngle)- .endAngle(endAngle)- .padAngle((paddingAngle * Math.PI) / 180),- [startAngle, endAngle, paddingAngle],- );-- const arcGenerator = useMemo(- () =>- arc<unknown, PieArcDatum<CategoricalSlice>>()- .innerRadius(innerRadius)- .outerRadius(outerRadius)- .cornerRadius(cornerRadius),- [innerRadius, outerRadius, cornerRadius],- );-- const arcs = useMemo(- () => pieGenerator(orch.data.visibleSlices),- [pieGenerator, orch.data.visibleSlices],- );-- // PPTX print-export JSON — mirrors react-ui's PieChart call (type:'pie',- // single series = [dataKey], no extraOptions). Colors are the resolved slice- // palette in sorted-data order. Undefined off the print path.- const exportData = useExportChartData({- type: "pie",- data: orch.data.sortedData,- categoryKey: orch.data.catKey,- dataKeys: [orch.data.valKey],- colors: orch.data.slices.map((s) => s.color),- legend: showLegend,- });-- return (- <ChartShell- containerRef={orch.refs.containerRef}- classPrefix={`${CHART_CLASS_PREFIX}-pie-chart`}- className={className}- style={orch.style.containerStyle}- isEmpty={orch.isEmpty}- exportData={exportData}- >- {() => (- <>- <div className={`${CHART_CLASS_PREFIX}-pie-chart-svg-wrapper`}>- <svg- width={orch.dimensions.svgWidth}- height={orch.dimensions.svgHeight}- viewBox={`0 0 ${orch.dimensions.svgWidth} ${orch.dimensions.svgHeight}`}- role="img"- aria-label="Pie chart"- >- <g transform={`translate(${orch.dimensions.centerX}, ${orch.dimensions.centerY})`}>- <PieSlices- arcs={arcs}- arcGenerator={arcGenerator}- slices={orch.data.visibleSlices}- hoveredIndex={orch.hover.hoveredIndex}- entrance={animate}- staticRender={orch.isPrinting}- data={orch.data.visibleRows}- onMouseMove={orch.hover.handleMouseMove}- onMouseLeave={orch.hover.handleMouseLeave}- onClick={onClick}- />- </g>- </svg>- </div>-- {showLegend && !orch.usesRemoteLegend && (- <DefaultLegend- ref={orch.refs.legendRef}- items={orch.data.legendItems}- containerWidth={orch.dimensions.containerWidth}- isExpanded={orch.legend.isLegendExpanded}- setIsExpanded={orch.legend.setIsLegendExpanded}- onItemClick={orch.data.toggleSlice}- hiddenSeries={orch.data.hiddenSlices}- />- )}-- {orch.tooltip.tooltipPayload && orch.hover.mousePos && (- <ChartTooltip- label={orch.tooltip.tooltipPayload.label}- items={orch.tooltip.tooltipPayload.items}- viewportPosition={orch.hover.mousePos}- />- )}- </>- )}- </ChartShell>- );-}diff --git a/packages/react-ui/src/components/D3Charts/PieChart/index.ts b/packages/react-ui/src/components/D3Charts/PieChart/index.tsdeleted file mode 100644index 713249dea..000000000--- a/packages/react-ui/src/components/D3Charts/PieChart/index.ts+++ /dev/null@@ -1,2 +0,0 @@-export { PieChart } from "./PieChart";-export type { PieChartData, PieChartProps } from "./types";diff --git a/packages/react-ui/src/components/D3Charts/PieChart/pieChart.scss b/packages/react-ui/src/components/D3Charts/PieChart/pieChart.scssdeleted file mode 100644index 8fac0e63a..000000000--- a/packages/react-ui/src/components/D3Charts/PieChart/pieChart.scss+++ /dev/null@@ -1,27 +0,0 @@-@use "../shared/cartesian/chartBase" as base;-@use "../prefix" as brand;--@include base.centered-container("pie-chart");-@include base.centered-svg-wrapper("pie-chart");--// Entrances are decorative: gate the whole rule (pre-state included) behind-// reduced-motion so users who opt out get the natural static state immediately-// — gating only the animation would strand elements at the opacity: 0 start.-@media (prefers-reduced-motion: no-preference) {- .#{brand.$prefix}-pie-chart-slice--animated {- opacity: 0;- transform-origin: center center;- animation: #{brand.$prefix}-pie-appear 0.6s ease-out forwards;- }-}--@keyframes #{brand.$prefix}-pie-appear {- from {- opacity: 0;- transform: scale(0.8);- }- to {- opacity: 1;- transform: scale(1);- }-}diff --git a/packages/react-ui/src/components/D3Charts/PieChart/stories/PieChart.stories.tsx b/packages/react-ui/src/components/D3Charts/PieChart/stories/PieChart.stories.tsxdeleted file mode 100644index 03f259163..000000000--- a/packages/react-ui/src/components/D3Charts/PieChart/stories/PieChart.stories.tsx+++ /dev/null@@ -1,680 +0,0 @@-// Copy of Charts/PieChart/stories/PieChart.stories.tsx with only the chart import and the title changed:-// the same args and renders, rendering the D3Charts chart via-// ../../stories/rechartsStoryAdapters.-import type { Meta, StoryObj } from "@storybook/react";-import { useState } from "react";-import { Card } from "../../../Card";-import { PieChart, PieChartProps } from "../../stories/rechartsStoryAdapters";--const monthlySalesData = [- { month: "January", value: 1250 },- { month: "February", value: 980 },- { month: "March", value: 1450 },- { month: "April", value: 1320 },- { month: "May", value: 1680 },- { month: "June", value: 2100 },-];--const comprehensiveData = [- { category: "Electronics", sales: 12500 },- { category: "Apparel", sales: 9800 },- { category: "Groceries", sales: 14500 },- { category: "Home Goods", sales: 13200 },- { category: "Books", sales: 8800 },- { category: "Toys", sales: 7600 },- { category: "Automotive", sales: 6500 },- { category: "Health", sales: 11200 },- { category: "Beauty", sales: 9300 },- { category: "Sports", sales: 8100 },- { category: "Outdoors", sales: 7200 },- { category: "Music", sales: 4500 },- { category: "Software", sales: 10500 },-];--/**- * # PieChart Component Documentation- *- * The PieChart component is a versatile and intuitive tool for visualizing- * part-to-whole relationships in a dataset. It's highly effective for:- *- * - **Proportional Analysis**: Showing how individual segments contribute to a total- * - **Category Comparison**: Comparing the relative size of different categories- * - **Dashboard KPIs**: Displaying key metrics like market share or budget allocation- *- * ## Key Features- *- * ### Chart Types- * - **Pie**: Classic circular chart for proportional representation- * - **Donut**: Pie chart with a center cutout, useful for displaying a central metric or for a modern look- *- * ### Layout Variants- * - **Circular**: Full 360-degree display for a complete data overview- * - **Semicircle**: Half-circle (180-degree) layout, ideal for compact dashboard widgets- *- * ### Data Formatting- * - **Percentage Mode**: Automatically calculates and displays segment values as percentages- * - **Number Mode**: Shows raw data values with appropriate formatting- *- * ### Interactive & Responsive- * - **Interactive Legend**: Adapts to container size with carousel navigation for large datasets- * - **Hover Tooltips**: Provides detailed information on hover for better user engagement- * - **Responsive Design**: Fluidly adjusts to the size of its container- *- * ### Customization- * - **Theming**: Six pre-built color palettes to match your application's design- * - **Styling Options**: Control corner radius, padding between slices, and more-- */--const meta: Meta<PieChartProps<typeof monthlySalesData>> = {- title: "Components/D3Charts/PieChart",- component: PieChart,- parameters: {- layout: "centered",- docs: {- description: {- component: `-## Installation and Basic Usage--\`\`\`tsx-import { PieChart } from '@openuidev/react-ui/Charts/PieChart';--// Basic implementation-<PieChart- data={yourData}- categoryKey="category"- dataKey="value"- theme="ocean"-/>-\`\`\`--## Data Structure Requirements--Your data should be an array of objects where each object contains:-- A **category field** (string): Used for labels and legend items-- A **value field** (number): Used to determine slice sizes--\`\`\`tsx-const salesData = [- { category: "Electronics", value: 4500 },- { category: "Apparel", value: 3200 },- { category: "Groceries", value: 6800 }-];-\`\`\`--## Performance Considerations-- **Data Size**: Best for 3-12 data points for readability.-- **Responsiveness**: Fully responsive and adapts to its container.-- **Animation**: Can be disabled for performance with very large or complex charts.- `,- },- },- },- tags: ["dev", "autodocs"],- argTypes: {- data: {- description: `-**Required.** An array of data objects representing your dataset. Each object should contain:-- A category identifier (string)-- A numeric value--**Best Practices:**-- Use 3-12 data points for optimal readability.-- Ensure consistent data structure across all objects.-`,- control: false,- table: {- type: { summary: "Array<Record<string, string | number>>" },- defaultValue: { summary: "[]" },- category: "📊 Data Configuration",- },- },- categoryKey: {- description:- "**Required.** The key in your data object that represents the category label (e.g., 'month', 'department').",- control: false,- table: {- type: { summary: "string" },- category: "📊 Data Configuration",- },- },- dataKey: {- description:- "**Required.** The key in your data object that contains the numeric value for each slice (e.g., 'value', 'sales').",- control: false,- table: {- type: { summary: "string" },- category: "📊 Data Configuration",- },- },- theme: {- description:- "The color palette for the chart. Provides a set of aesthetically pleasing colors.",- control: "select",- options: ["ocean", "orchid", "emerald", "sunset", "spectrum", "vivid"],- table: {- defaultValue: { summary: "ocean" },- category: "🎨 Visual Styling",- },- },- customPalette: {- description:- "An array of color strings to use as a custom palette for the chart. This overrides the `theme` prop.",- control: "object",- table: {- type: { summary: "string[]" },- category: "🎨 Visual Styling",- },- },- appearance: {- description: "The overall shape of the chart: a full circle or a semicircle.",- control: "radio",- options: ["circular", "semiCircular"],- table: {- defaultValue: { summary: "circular" },- category: "🎨 Visual Styling",- },- },- variant: {- description: "The style of the chart: a standard pie or a donut with a cutout center.",- control: "radio",- options: ["pie", "donut"],- table: {- defaultValue: { summary: "pie" },- category: "🎨 Visual Styling",- },- },- format: {- description:- "The format for displaying data values, either as raw numbers or as percentages.",- control: "radio",- options: ["percentage", "number"],- table: {- defaultValue: { summary: "number" },- category: "📱 Display Options",- },- },- legend: {- description: "Controls the visibility of the chart's legend.",- control: "boolean",- table: {- type: { summary: "boolean" },- defaultValue: { summary: "true" },- category: "📱 Display Options",- },- },- legendVariant: {- description: "The layout of the legend: a horizontal list or a responsive vertical stack.",- control: "radio",- options: ["default", "stacked"],- table: {- defaultValue: { summary: "default" },- category: "📱 Display Options",- },- },- isAnimationActive: {- description: "Enables or disables the initial loading animation.",- control: "boolean",- table: {- type: { summary: "boolean" },- defaultValue: { summary: "true" },- category: "🎬 Animation & Interaction",- },- },- cornerRadius: {- description: "The radius for rounding the corners of each pie slice.",- control: { type: "number", min: 0, max: 20 },- table: {- type: { summary: "number" },- defaultValue: { summary: "0" },- category: "🎨 Visual Styling",- },- },- paddingAngle: {- description: "The spacing angle between each pie slice.",- control: { type: "number", min: 0, max: 10 },- table: {- type: { summary: "number" },- defaultValue: { summary: "0" },- category: "🎨 Visual Styling",- },- },- height: {- description: "The height of the chart.",- control: "text",- table: {- type: { summary: "string | number" },- category: "📱 Display Options",- },- },- width: {- description: "The width of the chart.",- control: "text",- table: {- type: { summary: "string | number" },- category: "📱 Display Options",- },- },- },-} satisfies Meta<typeof PieChart>;--export default meta;-type Story = StoryObj<typeof meta>;--/**- * ## Interactive Playground- *- * This is a minimal story that renders just the PieChart component without any wrapper.- * Use the Controls panel to interactively test all available props and see how they- * affect the chart's appearance and behavior.- *- * **Perfect for:**- * - Testing different prop combinations- * - Exploring chart customization options- * - Understanding prop behaviors- */-export const InteractivePlayground: Story = {- name: "🎮 Interactive Playground",- args: {- data: monthlySalesData,- categoryKey: "month",- dataKey: "value",- theme: "ocean",- variant: "pie",- format: "number",- legend: true,- legendVariant: "default",- isAnimationActive: true,- appearance: "circular",- cornerRadius: 0,- paddingAngle: 0,- height: undefined,- width: undefined,- },- render: (args: any) => <PieChart {...args} />,-};--/**- * ## Default Configuration- *- * This example showcases the PieChart with its standard settings, making it an- * ideal starting point for most data visualization needs.- *- * **Key Features Shown:**- * - Standard circular pie layout- * - Professional 'ocean' color theme- * - Responsive stacked legend for clarity- * - Smooth animations on load- */-export const DefaultConfiguration: Story = {- name: "📊 Default Configuration",- args: {- data: monthlySalesData,- categoryKey: "month",- dataKey: "value",- theme: "ocean",- variant: "pie",- format: "number",- legend: true,- legendVariant: "stacked",- isAnimationActive: true,- appearance: "circular",- cornerRadius: 0,- paddingAngle: 0,- },- render: (args: any) => (- <Card style={{ width: "400px", height: "fit-content", padding: "24px" }}>- <h3 style={{ marginBottom: "20px", fontSize: "18px", fontWeight: 600 }}>- Monthly Sales Performance- </h3>- <PieChart {...args} />- </Card>- ),-};--/**- * ## Layout and Variant Options- *- * This story demonstrates the different layout (`appearance`) and style (`variant`)- * options available in the PieChart component.- *- * **Options Shown:**- * - **Pie vs. Donut**: See the difference between a full pie and one with a center cutout.- * - **Circular vs. Semicircle**: Compare the full 360° layout with the space-saving 180° version.- */-export const LayoutAndVariantOptions: Story = {- name: "🎨 Layout & Variant Options",- args: {- data: monthlySalesData.slice(0, 4),- categoryKey: "month",- dataKey: "value",- theme: "emerald",- legend: true,- legendVariant: "stacked",- isAnimationActive: false,- cornerRadius: 0,- paddingAngle: 0,- },- render: (args: any) => (- <div style={{ display: "grid", gridTemplateColumns: "1fr 1fr", gap: "40px", width: "800px" }}>- <div>- <h4 style={{ textAlign: "center", marginBottom: "16px" }}>Pie - Circular</h4>- <Card style={{ padding: "20px" }}>- <PieChart {...args} variant="pie" appearance="circular" />- </Card>- </div>- <div>- <h4 style={{ textAlign: "center", marginBottom: "16px" }}>Donut - Circular</h4>- <Card style={{ padding: "20px" }}>- <PieChart {...args} variant="donut" appearance="circular" />- </Card>- </div>- <div>- <h4 style={{ textAlign: "center", marginBottom: "16px" }}>Pie - Semicircle</h4>- <Card style={{ padding: "20px" }}>- <PieChart {...args} variant="pie" appearance="semiCircular" />- </Card>- </div>- <div>- <h4 style={{ textAlign: "center", marginBottom: "16px" }}>Donut - Semicircle</h4>- <Card style={{ padding: "20px" }}>- <PieChart {...args} variant="donut" appearance="semiCircular" />- </Card>- </div>- </div>- ),-};--/**- * ## Custom Palette- *- * This example demonstrates how to use a custom color palette.- *- * **Feature Highlight:**- * - The `customPalette` prop allows you to define your own array of colors.- */-export const CustomPalette: Story = {- name: "🎨 Custom Palette",- args: {- data: monthlySalesData,- categoryKey: "month",- dataKey: "value",- variant: "donut",- legend: true,- legendVariant: "stacked",- cornerRadius: 4,- paddingAngle: 2,- },- render: (args: any) => (- <Card style={{ width: "650px", height: "auto", padding: "24px" }}>- <h3 style={{ marginBottom: "20px", fontSize: "18px", fontWeight: 600 }}>- Chart with Custom Palette- </h3>- <PieChart {...args} />- </Card>- ),-};--/**- * ## Large Dataset with Carousel- *- * The PieChart's legend intelligently handles a large number of items by- * enabling a scrollable carousel with up/down navigation.- *- * **Feature Highlight:**- * - The legend's carousel appears automatically when items overflow the available space, ensuring all data points remain accessible without cluttering the UI.- */-export const LargeDatasetWithCarousel: Story = {- name: "📈 Large Dataset with Carousel",- args: {- data: comprehensiveData,- categoryKey: "category",- dataKey: "sales",- theme: "spectrum",- variant: "donut",- legend: true,- legendVariant: "stacked",- cornerRadius: 4,- paddingAngle: 1,- },- render: (args: any) => (- <Card style={{ width: "700px", padding: "24px" }}>- <PieChart {...args} />- </Card>- ),-};--export const ResponsiveDemo: Story = {- name: "📱 Responsive Behavior Demo",- args: {- data: comprehensiveData,- categoryKey: "category",- dataKey: "sales",- theme: "spectrum",- variant: "circular",- format: "number",- legend: true,- legendVariant: "stacked",- isAnimationActive: false,- cornerRadius: 8,- },- render: (args: any) => {- const [dimensions, setDimensions] = useState<{ width: number; height: number | string }>({- width: 700,- height: "auto",- });-- const handleMouseDown = (e: React.MouseEvent<HTMLDivElement>, handle: string) => {- e.preventDefault();- e.stopPropagation();- const startX = e.clientX;- const startY = e.clientY;- const startWidth = dimensions.width;- const startHeight = (e.currentTarget.parentElement as HTMLElement).offsetHeight;-- const doDrag = (e: MouseEvent) => {- const dx = e.clientX - startX;- const dy = e.clientY - startY;- let newWidth = startWidth;- let newHeight = startHeight;-- if (handle.includes("e")) newWidth = startWidth + dx;- if (handle.includes("w")) newWidth = startWidth - dx;- if (handle.includes("s")) newHeight = startHeight + dy;- if (handle.includes("n")) newHeight = startHeight - dy;-- setDimensions({- width: Math.max(300, newWidth),- height: "auto",- });- };-- const stopDrag = () => {- document.removeEventListener("mousemove", doDrag);- document.removeEventListener("mouseup", stopDrag);- };-- document.addEventListener("mousemove", doDrag);- document.addEventListener("mouseup", stopDrag);- };-- const handleStyle: React.CSSProperties = {- position: "absolute",- background: "#3b82f6",- opacity: 0.6,- zIndex: 10,- transition: "opacity 0.2s ease",- };-- return (- <div style={{ padding: "20px" }}>- <div style={{ marginBottom: "20px" }}>- <h3 style={{ margin: "0 0 8px 0", fontSize: "18px", fontWeight: "600" }}>- Responsive Behavior Demonstration- </h3>- <p style={{ margin: "0 0 12px 0", color: "#666", fontSize: "14px" }}>- Drag the edges or corners of the container below to see how the chart adapts- </p>- <div- style={{- padding: "12px",- backgroundColor: "#e3f2fd",- borderRadius: "6px",- fontSize: "12px",- color: "#1565c0",- }}- >- <strong>🎯 Try This:</strong> Resize the container to see automatic legend layout- changes, chart proportion adjustments, and responsive breakpoint behaviors.- </div>- </div>-- <Card- style={{- position: "relative",- width: `${dimensions.width}px`,- height:- typeof dimensions.height === "number" ? `${dimensions.height}px` : dimensions.height,- border: "2px dashed #9ca3af",- padding: "20px",- boxSizing: "border-box",- overflow: "hidden",- cursor: "default",- }}- >- <PieChart {...args} />-- {/* Resize Handles */}- <div- style={{ ...handleStyle, top: -2, left: 0, right: 0, height: 12, cursor: "ns-resize" }}- onMouseDown={(e) => handleMouseDown(e, "n")}- />- <div- style={{- ...handleStyle,- bottom: -2,- left: 0,- right: 0,- height: 12,- cursor: "ns-resize",- }}- onMouseDown={(e) => handleMouseDown(e, "s")}- />- <div- style={{ ...handleStyle, top: 0, bottom: 0, left: -2, width: 12, cursor: "ew-resize" }}- onMouseDown={(e) => handleMouseDown(e, "w")}- />- <div- style={{ ...handleStyle, top: 0, bottom: 0, right: -2, width: 12, cursor: "ew-resize" }}- onMouseDown={(e) => handleMouseDown(e, "e")}- />-- {/* Corner Handles */}- <div- style={{- ...handleStyle,- top: -2,- left: -2,- width: 20,- height: 20,- cursor: "nwse-resize",- borderRadius: "2px",- }}- onMouseDown={(e) => handleMouseDown(e, "nw")}- />- <div- style={{- ...handleStyle,- top: -2,- right: -2,- width: 20,- height: 20,- cursor: "nesw-resize",- borderRadius: "2px",- }}- onMouseDown={(e) => handleMouseDown(e, "ne")}- />- <div- style={{- ...handleStyle,- bottom: -2,- right: -2,- width: 20,- height: 20,- cursor: "nwse-resize",- borderRadius: "2px",- }}- onMouseDown={(e) => handleMouseDown(e, "se")}- />-- {/* Dimension Display */}- <div- style={{- position: "absolute",- bottom: 8,- right: 8,- background: "rgba(0,0,0,0.8)",- color: "white",- padding: "4px 8px",- borderRadius: "4px",- fontSize: "11px",- fontFamily: "monospace",- fontWeight: "500",- }}- >- {dimensions.width}px ×{" "}- {typeof dimensions.height === "number" ? `${dimensions.height}px` : "auto"}- </div>- </Card>-- <div- style={{- marginTop: "16px",- padding: "12px",- backgroundColor: "#f8f9fa",- borderRadius: "6px",- fontSize: "12px",- color: "#666",- }}- >- <strong>📊 Responsive Features Demonstrated:</strong>- <ul style={{ margin: "8px 0 0 0", paddingLeft: "16px" }}>- <li>Automatic chart scaling and proportion maintenance</li>- <li>Legend layout adaptation (stacked ↔ horizontal)</li>- <li>Text size and spacing adjustments</li>- <li>Optimal space utilization at any container size</li>- </ul>- </div>- </div>- );- },- parameters: {- docs: {- description: {- story: `-**Responsive Design Philosophy:**--**Automatic Adaptation:**-- Chart dimensions automatically adjust to container size-- Legend layout switches between horizontal and stacked based on available space-- Text and spacing scale appropriately for readability--**Breakpoint Behavior:**-- **Large Containers (>600px)**: Side-by-side chart and legend layout-- **Medium Containers (400-600px)**: Stacked layout with optimized proportions-- **Small Containers (<400px)**: Compact layout with essential elements only--**Performance Optimizations:**-- Efficient re-rendering during resize operations-- Debounced resize calculations to prevent performance issues-- Optimized SVG scaling for crisp display at any size--**Implementation Notes:**-- Uses ResizeObserver API for precise container size detection-- Maintains aspect ratios while maximizing space utilization-- Supports both fixed and flexible container sizing strategies- `,- },- },- },-};diff --git a/packages/react-ui/src/components/D3Charts/RadarChart/RadarChart.tsx b/packages/react-ui/src/components/D3Charts/RadarChart/RadarChart.tsxdeleted file mode 100644index a5787d554..000000000--- a/packages/react-ui/src/components/D3Charts/RadarChart/RadarChart.tsx+++ /dev/null@@ -1,157 +0,0 @@-import { useCallback, useMemo } from "react";--import { useEffectiveAnimation, useRadarChartOrchestrator } from "../hooks";-import { ChartShell } from "../shared/core/ChartShell";-import { DefaultLegend } from "../shared/core/DefaultLegend/DefaultLegend";-import { ChartTooltip } from "../shared/core/PortalTooltip/ChartTooltip";-import { CHART_CLASS_PREFIX } from "../utils/constants";-import { RadarAxisLabels } from "./parts/RadarAxisLabels";-import { RadarGrid } from "./parts/RadarGrid";-import { RadarSeries } from "./parts/RadarSeries";-import type { RadarChartData, RadarChartProps } from "./types";--export function RadarChart<T extends RadarChartData>(props: RadarChartProps<T>) {- const {- data,- categoryKey,- customPalette,- gridShape = "polygon",- gridLevels = 5,- grid: showGrid = true,- legend: showLegend = true,- icons,- isAnimationActive = false,- variant = "line",- areaOpacity = 0.2,- showDots = false,- dotRadius = 4,- fillOpacity,- maxChartSize = 500,- minChartSize = 150,- height,- width,- fitLegendInHeight,- className,- onClick,- } = props;-- const orch = useRadarChartOrchestrator({- data,- categoryKey,- themePaletteName: "radarChartPalette",- customPalette,- icons,- showLegend,- maxChartSize,- minChartSize,- height,- width,- fitLegendInHeight,- onClick,- });-- const animate = useEffectiveAnimation(isAnimationActive);-- const numAxes = data.length;-- const findIndex = useCallback(- (mouseX: number, mouseY: number) => {- if (numAxes === 0) return -1;- let angle = Math.atan2(mouseY, mouseX) + Math.PI / 2;- if (angle < 0) angle += 2 * Math.PI;- return Math.round(angle / ((2 * Math.PI) / numAxes)) % numAxes;- },- [numAxes],- );-- // Destructured so the memo depends on the callback identity itself (a- // stable useCallback), not the whole orch.hover object.- const { createMouseHandlers } = orch.hover;- const mouseHandlers = useMemo(- () => createMouseHandlers(findIndex),- [createMouseHandlers, findIndex],- );-- return (- <ChartShell- containerRef={orch.refs.containerRef}- classPrefix={`${CHART_CLASS_PREFIX}-radar-chart`}- className={className}- style={orch.style.containerStyle}- isEmpty={orch.isEmpty}- >- {() => (- <>- <div className={`${CHART_CLASS_PREFIX}-radar-chart-svg-wrapper`}>- <svg- width={orch.dimensions.svgWidth}- height={orch.dimensions.svgHeight}- viewBox={`0 0 ${orch.dimensions.svgWidth} ${orch.dimensions.svgHeight}`}- role="img"- aria-label="Radar chart"- >- <g- transform={`translate(${orch.dimensions.centerX}, ${orch.dimensions.centerY})`}- onMouseMove={mouseHandlers.handleMouseMove}- onMouseLeave={mouseHandlers.handleMouseLeave}- onTouchMove={mouseHandlers.handleTouchMove}- onTouchEnd={mouseHandlers.handleTouchEnd}- onClick={mouseHandlers.handleClick}- >- {showGrid && (- <RadarGrid- maxRadius={orch.dimensions.maxRadius}- gridLevels={gridLevels}- gridShape={gridShape}- numAxes={numAxes}- />- )}- <RadarSeries- data={data}- dataKeys={orch.data.dataKeys}- catKey={orch.data.catKey}- radialScale={orch.dimensions.radialScale}- numAxes={numAxes}- colorMap={orch.data.colorMap}- fillOpacity={fillOpacity ?? (variant === "area" ? areaOpacity : 0)}- showDots={showDots}- dotRadius={dotRadius}- hoveredIndex={orch.hover.hoveredIndex}- animate={animate}- />- <RadarAxisLabels- data={data}- catKey={orch.data.catKey}- numAxes={numAxes}- maxRadius={orch.dimensions.maxRadius}- chartSize={orch.dimensions.chartSize}- containerWidth={orch.dimensions.containerWidth}- />- </g>- </svg>- </div>-- {showLegend && (- <DefaultLegend- ref={orch.refs.legendRef}- items={orch.legend.legendItems}- containerWidth={orch.dimensions.containerWidth}- isExpanded={orch.legend.isLegendExpanded}- setIsExpanded={orch.legend.setIsLegendExpanded}- onItemClick={orch.legend.toggleSeries}- hiddenSeries={orch.legend.hiddenSeries}- />- )}-- {orch.tooltip.tooltipPayload && orch.hover.mousePos && (- <ChartTooltip- label={orch.tooltip.tooltipPayload.label}- items={orch.tooltip.tooltipPayload.items}- viewportPosition={orch.hover.mousePos}- />- )}- </>- )}- </ChartShell>- );-}diff --git a/packages/react-ui/src/components/D3Charts/RadarChart/index.ts b/packages/react-ui/src/components/D3Charts/RadarChart/index.tsdeleted file mode 100644index ffed6f64a..000000000--- a/packages/react-ui/src/components/D3Charts/RadarChart/index.ts+++ /dev/null@@ -1,2 +0,0 @@-export { RadarChart } from "./RadarChart";-export type { RadarChartData, RadarChartProps } from "./types";diff --git a/packages/react-ui/src/components/D3Charts/RadarChart/radarChart.scss b/packages/react-ui/src/components/D3Charts/RadarChart/radarChart.scssdeleted file mode 100644index d04534493..000000000--- a/packages/react-ui/src/components/D3Charts/RadarChart/radarChart.scss+++ /dev/null@@ -1,69 +0,0 @@-@use "../../../cssUtils" as cssUtils;-@use "../shared/cartesian/chartBase" as base;-@use "../prefix" as brand;--@include base.centered-container("radar-chart");-@include base.centered-svg-wrapper("radar-chart");--// Labels are budgeted against the CONTAINER width (radarLabelLayout.ts) and-// legitimately paint outside the square svg viewport; the polar container-// column deliberately does not clip (chartBase.scss centered-container).-// Vertical extent stays inside the svg via radarLabelPadding + line caps.-.#{brand.$prefix}-radar-chart-svg-wrapper > svg {- overflow: visible;-}--// Solid rings and spokes in the interactive border tone, as react-ui's-// Recharts RadarChart draws its polar grid.-.#{brand.$prefix}-radar-chart-grid-ring {- stroke: cssUtils.$border-interactive;- stroke-width: 1;-}--.#{brand.$prefix}-radar-chart-grid-spoke {- stroke: cssUtils.$border-interactive;- stroke-width: 1;-}--.#{brand.$prefix}-radar-chart-polygon-area {- transition: opacity 0.2s ease;-}--.#{brand.$prefix}-radar-chart-polygon-stroke {- fill: none;- stroke-width: 2;-}--.#{brand.$prefix}-radar-chart-dot {- stroke: cssUtils.$foreground;- stroke-width: 1.5;- transition:- r 0.15s ease,- opacity 0.15s ease;-}--.#{brand.$prefix}-radar-chart-axis-label {- @include base.svg-tick-label;-}--// Entrances are decorative: gate the whole rule (pre-state included) behind-// reduced-motion so users who opt out get the natural static state immediately-// — gating only the animation would strand elements at the opacity: 0 start.-@media (prefers-reduced-motion: no-preference) {- .#{brand.$prefix}-radar-chart-polygon--animated {- opacity: 0;- transform-origin: center center;- animation: #{brand.$prefix}-radar-polygon-appear 0.5s ease-out forwards;- }-}--@keyframes #{brand.$prefix}-radar-polygon-appear {- from {- opacity: 0;- transform: scale(0.3);- }- to {- opacity: 1;- transform: scale(1);- }-}diff --git a/packages/react-ui/src/components/D3Charts/RadarChart/stories/RadarChart.stories.tsx b/packages/react-ui/src/components/D3Charts/RadarChart/stories/RadarChart.stories.tsxdeleted file mode 100644index d89f4cce9..000000000--- a/packages/react-ui/src/components/D3Charts/RadarChart/stories/RadarChart.stories.tsx+++ /dev/null@@ -1,722 +0,0 @@-// Copy of Charts/RadarChart/stories/RadarChart.stories.tsx with only the chart import and the title changed:-// the same args and renders, rendering the D3Charts chart via-// ../../stories/rechartsStoryAdapters.-import type { Meta, StoryObj } from "@storybook/react";-import { Shield, Star, Target } from "lucide-react";-import { useState } from "react";-import { Card } from "../../../Card";-import { RadarChart, RadarChartProps } from "../../stories/rechartsStoryAdapters";--// 📊 COMPREHENSIVE DATA VARIATIONS - Designed to test various radar chart scenarios-const dataVariations = {- default: [- { skill: "JavaScript", beginner: 3, intermediate: 7, advanced: 9 },- { skill: "React", beginner: 4, intermediate: 8, advanced: 8 },- { skill: "TypeScript", beginner: 2, intermediate: 6, advanced: 9 },- { skill: "Node.js", beginner: 3, intermediate: 7, advanced: 7 },- { skill: "CSS", beginner: 5, intermediate: 8, advanced: 6 },- { skill: "Git", beginner: 4, intermediate: 6, advanced: 8 },- ],- performance: [- { metric: "Speed", team_a: 85, team_b: 92, team_c: 78 },- { metric: "Quality", team_a: 90, team_b: 88, team_c: 95 },- { metric: "Efficiency", team_a: 78, team_b: 85, team_c: 82 },- { metric: "Innovation", team_a: 92, team_b: 75, team_c: 88 },- { metric: "Collaboration", team_a: 88, team_b: 94, team_c: 85 },- { metric: "Reliability", team_a: 95, team_b: 87, team_c: 90 },- ],- businessMetrics: [- { department: "Sales", q1: 85, q2: 92, q3: 78, q4: 95 },- { department: "Marketing", q1: 78, q2: 85, q3: 90, q4: 88 },- { department: "Support", q1: 92, q2: 88, q3: 85, q4: 90 },- { department: "Product", q1: 88, q2: 90, q3: 92, q4: 85 },- { department: "Engineering", q1: 90, q2: 85, q3: 88, q4: 92 },- ],- gameStats: [- { attribute: "Strength", player1: 95, player2: 78, player3: 85 },- { attribute: "Speed", player1: 82, player2: 95, player3: 88 },- { attribute: "Intelligence", player1: 88, player2: 85, player3: 92 },- { attribute: "Defense", player1: 90, player2: 82, player3: 78 },- { attribute: "Magic", player1: 75, player2: 92, player3: 88 },- { attribute: "Luck", player1: 85, player2: 88, player3: 90 },- ],- productFeatures: [- { feature: "Usability", current: 8, competitor_a: 7, competitor_b: 9 },- { feature: "Performance", current: 9, competitor_a: 8, competitor_b: 7 },- { feature: "Design", current: 8, competitor_a: 9, competitor_b: 8 },- { feature: "Features", current: 7, competitor_a: 8, competitor_b: 9 },- { feature: "Price", current: 9, competitor_a: 6, competitor_b: 8 },- { feature: "Support", current: 8, competitor_a: 7, competitor_b: 6 },- ],- minimal: [- { category: "Category A", value1: 8, value2: 6 },- { category: "Category B", value1: 7, value2: 9 },- { category: "Category C", value1: 9, value2: 7 },- ],- singleMetric: [- { dimension: "North", score: 85 },- { dimension: "South", score: 72 },- { dimension: "East", score: 90 },- { dimension: "West", score: 78 },- { dimension: "Center", score: 88 },- ],- manyDimensions: [- { aspect: "UX Design and User Experience", mobile: 8, web: 9, desktop: 7, tablet: 8 },- { aspect: "Performance and Optimization", mobile: 9, web: 8, desktop: 9, tablet: 8 },- { aspect: "Accessibility and Inclusivity", mobile: 7, web: 8, desktop: 9, tablet: 7 },- { aspect: "Security and Compliance", mobile: 8, web: 9, desktop: 8, tablet: 8 },- { aspect: "Scalability and Performance", mobile: 7, web: 9, desktop: 8, tablet: 7 },- { aspect: "Maintenance and Support", mobile: 8, web: 7, desktop: 8, tablet: 8 },- { aspect: "Testing and Quality Assurance", mobile: 9, web: 8, desktop: 7, tablet: 8 },- { aspect: "Documentation and Support", mobile: 6, web: 8, desktop: 9, tablet: 7 },- ],-};--// Map data variations to their category keys-const categoryKeys = {- default: "skill",- performance: "metric",- businessMetrics: "department",- gameStats: "attribute",- productFeatures: "feature",- minimal: "category",- singleMetric: "dimension",- manyDimensions: "aspect",-} as const;--// Default data for the main story-const radarChartData = dataVariations.default;--const meta: Meta<RadarChartProps<typeof radarChartData>> = {- title: "Components/D3Charts/RadarChart",- component: RadarChart,- parameters: {- layout: "centered",- docs: {- description: {- component: `-## Installation and Basic Usage--\`\`\`tsx-import { RadarChart } from '@openuidev/react-ui/Charts/RadarChart';--// Basic implementation-<RadarChart- data={yourData}- categoryKey="category"- theme="ocean"- variant="line"-/>--// With custom colors-<RadarChart- data={yourData}- categoryKey="category"- customPalette={["#FF6B6B", "#4ECDC4", "#45B7D1"]}- variant="line"-/>-\`\`\`--## Data Structure Requirements--Your data should be an array of objects where each object contains:-- A **category field** (string): Used for the radar's axes (e.g., 'skill', 'metric').-- One or more **value fields** (number): Each numeric key represents a data series to be plotted.--\`\`\`tsx-const exampleData = [- { skill: "JavaScript", team_a: 90, team_b: 75 },- { skill: "React", team_a: 85, team_b: 95 },- { skill: "Node.js", team_a: 80, team_b: 70 },-];-\`\`\`--## Key Features--- **Multiple Data Series**: Compare several datasets on the same chart.-- **Two Visual Variants**: Choose between 'line' and 'area' styles.-- **Customizable Appearance**: Control colors, stroke width, and area opacity.-- **Custom Color Palettes**: Use predefined themes or provide your own custom colors.-- **Interactive Legend**: Toggle visibility of data series.-- **Icon Support**: Add custom icons to legend items for better visual identification.-- **Animation**: Smooth animations for loading and data transitions.-`,- },- },- },- tags: ["dev", "autodocs"],- argTypes: {- data: {- description: `-**Required.** An array of data objects. Each object represents a point on the radar axes and should contain:-- A category identifier (string).-- One or more numeric values, where each key represents a data series.--**Best Practices:**-- Use 3-8 axes (categories) for optimal readability.-- Keep data series count low (2-4) to avoid clutter.-`,- control: false,- table: {- type: { summary: "Array<Record<string, string | number>>" },- defaultValue: { summary: "[]" },- category: "📊 Data Configuration",- },- },- categoryKey: {- description: `-**Required.** The key in your data objects that corresponds to the radar axis labels.--**Examples:**-- "skill" for a skills assessment chart.-- "metric" for a performance comparison chart.-`,- control: false,- table: {- type: { summary: "string" },- category: "📊 Data Configuration",- },- },- theme: {- description: `-**Color Theme Selection.** Choose from professionally designed color palettes. Ignored when customPalette is provided.--- **ocean**: Cool blues and teals (professional, corporate)-- **orchid**: Purple and pink tones (creative, modern)-- **emerald**: Green variations (nature, growth, finance)-- **sunset**: Warm oranges and reds (energy, attention-grabbing)-- **spectrum**: Full color range (diverse, comprehensive)-- **vivid**: High-contrast colors (accessibility, clarity)-`,- control: "select",- options: ["ocean", "orchid", "emerald", "sunset", "spectrum", "vivid"],- table: {- defaultValue: { summary: "ocean" },- category: "🎨 Visual Styling",- },- },- customPalette: {- description:- "Custom array of colors to use instead of the theme palette. Overrides the theme prop when provided.",- control: "object",- table: {- type: { summary: "string[]" },- category: "🎨 Visual Styling",- },- },- variant: {- description: `-**Chart Style Variant:**--- **line**: Displays only the outlines of the data series. Best for comparing multiple series without obstruction.-- **area**: Fills the area covered by each data series. Good for showing the magnitude of values.-`,- control: "radio",- options: ["line", "area"],- table: {- defaultValue: { summary: "line" },- category: "🎨 Visual Styling",- },- },- grid: {- description: `-**Grid Visibility.** Toggles the display of the background polar grid.--**When to use:**-- To help estimate values along the axes.-- For a more technical, data-driven look.-`,- control: "boolean",- table: {- type: { summary: "boolean" },- defaultValue: { summary: "true" },- category: "📱 Display Options",- },- },- legend: {- description: `-**Legend Visibility.** Controls whether the legend is displayed.--**When to disable:**-- When charting a single data series.-- For minimal, clean dashboard widgets.-`,- control: "boolean",- table: {- type: { summary: "boolean" },- defaultValue: { summary: "true" },- category: "📱 Display Options",- },- },- strokeWidth: {- description: `-**Line Thickness.** Sets the width of the radar lines for the 'line' variant and the border for the 'area' variant.-`,- control: { type: "number", min: 1, max: 10 },- table: {- type: { summary: "number" },- defaultValue: { summary: "2" },- category: "🎨 Visual Styling",- },- },- areaOpacity: {- description: `-**Area Fill Opacity.** Controls the transparency of the filled areas when \`variant\` is 'area'.--**Tip:** Use lower opacity (e.g., 0.2-0.5) when displaying multiple overlapping area series.-`,- control: { type: "range", min: 0, max: 1, step: 0.1 },- table: {- type: { summary: "number" },- defaultValue: { summary: "0.5" },- category: "🎨 Visual Styling",- },- },- icons: {- description: `-An object mapping data keys to React components to display as icons in the legend.--**Example:**-\`\`\`jsx-import { Shield, Target } from 'lucide-react';--const icons = {- team_a: Shield,- team_b: Target,-};-\`\`\`-`,- control: false,- table: {- type: { summary: "Record<string, React.ComponentType>" },- defaultValue: { summary: "{}" },- category: "🎨 Visual Styling",- },- },- isAnimationActive: {- description: `-**Animation Control.** Enables or disables chart animations on load and update.--**Performance note:** Disable for highly complex charts or in performance-critical applications.-`,- control: "boolean",- table: {- type: { summary: "boolean" },- defaultValue: { summary: "true" },- category: "🎬 Animation & Interaction",- },- },- height: {- description: "The height of the chart.",- control: "text",- table: {- type: { summary: "string | number" },- category: "📱 Display Options",- },- },- width: {- description: "The width of the chart.",- control: "text",- table: {- type: { summary: "string | number" },- category: "📱 Display Options",- },- },- },-} satisfies Meta<typeof RadarChart>;--export default meta;-type Story = StoryObj<typeof meta>;--export const DefaultConfiguration: Story = {- name: "📊 Default Configuration",- args: {- data: dataVariations.performance,- categoryKey: "metric",- theme: "ocean",- variant: "line",- grid: true,- legend: true,- strokeWidth: 2,- isAnimationActive: true,- },- render: (args: any) => (- <Card style={{ width: "500px", height: "auto", padding: "24px" }}>- <div style={{ marginBottom: "16px" }}>- <h3 style={{ margin: "0 0 8px 0", fontSize: "18px", fontWeight: "600" }}>- Team Performance Analysis- </h3>- <p style={{ margin: 0, color: "#666", fontSize: "14px" }}>- Comparing key performance indicators across three teams.- </p>- </div>- <RadarChart {...args} />- </Card>- ),- parameters: {- docs: {- description: {- story: `-This is the recommended starting configuration for most use cases. The chart displays multiple data series in a clear, professional manner.--**Configuration Details:**-- **Data**: Team performance metrics.-- **Variant**: 'line' for clear comparison between series.-- **Colors**: 'ocean' theme (blues and teals).-- **Legend**: Enabled to identify data series.-- **Animations**: Enabled for smooth interactions.- `,- },- },- },-};--export const SkillsAssessment: Story = {- name: "📚 Skills Assessment",- args: {- data: dataVariations.default,- categoryKey: "skill",- theme: "orchid",- variant: "area",- grid: true,- legend: true,- strokeWidth: 2,- areaOpacity: 0.4,- isAnimationActive: true,- },- render: (args: any) => (- <Card style={{ width: "500px", height: "auto", padding: "24px" }}>- <div style={{ marginBottom: "16px" }}>- <h3 style={{ margin: "0 0 8px 0", fontSize: "18px", fontWeight: "600" }}>- Developer Skill Levels- </h3>- <p style={{ margin: 0, color: "#666", fontSize: "14px" }}>- Visualizing proficiency across different programming skills for various experience levels.- </p>- </div>- <RadarChart {...args} />- </Card>- ),- parameters: {- docs: {- description: {- story:- "This example uses the 'area' variant to represent different skill levels. The transparency allows for easy comparison of overlapping areas, providing a clear view of strengths and weaknesses across different roles.",- },- },- },-};--export const TeamPerformance: Story = {- name: "🏆 Team Performance with Icons",- args: {- data: dataVariations.performance,- categoryKey: "metric",- theme: "emerald",- variant: "line",- grid: true,- legend: true,- strokeWidth: 3,- isAnimationActive: true,- icons: {- team_a: Shield,- team_b: Target,- team_c: Star,- },- },- render: (args: any) => (- <Card style={{ width: "500px", height: "auto", padding: "24px" }}>- <div style={{ marginBottom: "16px" }}>- <h3 style={{ margin: "0 0 8px 0", fontSize: "18px", fontWeight: "600" }}>- Team Performance Comparison- </h3>- <p style={{ margin: 0, color: "#666", fontSize: "14px" }}>- Utilizing custom icons to distinguish teams in the legend for improved clarity.- </p>- </div>- <RadarChart {...args} />- </Card>- ),- parameters: {- docs: {- description: {- story:- "This chart demonstrates how to enhance the legend with custom icons. It's an effective way to visually associate data series with specific entities, like teams or products. The thicker stroke width also improves line visibility.",- },- },- },-};--export const BusinessMetrics: Story = {- name: "📈 Quarterly Business Metrics",- args: {- data: dataVariations.businessMetrics,- categoryKey: "department",- theme: "sunset",- variant: "area",- grid: true,- legend: true,- strokeWidth: 2,- areaOpacity: 0.4,- isAnimationActive: true,- },- render: (args: any) => (- <Card style={{ width: "500px", height: "auto", padding: "24px" }}>- <div style={{ marginBottom: "16px" }}>- <h3 style={{ margin: "0 0 8px 0", fontSize: "18px", fontWeight: "600" }}>- Quarterly Performance Review- </h3>- <p style={{ margin: 0, color: "#666", fontSize: "14px" }}>- Tracking key business metrics across departments over four quarters.- </p>- </div>- <RadarChart {...args} />- </Card>- ),- parameters: {- docs: {- description: {- story:- "A comprehensive view of business performance, this example showcases how the 'area' variant can effectively display multiple overlapping datasets to reveal trends and patterns over time.",- },- },- },-};--export const InteractivePlayground: Story = {- name: "🧪 Interactive Playground",- args: {- theme: "ocean",- variant: "line",- grid: true,- legend: true,- strokeWidth: 2,- areaOpacity: 0.5,- isAnimationActive: true,- },- render: (args: any) => {- const [selectedDataType, setSelectedDataType] =- useState<keyof typeof dataVariations>("default");-- const currentData = dataVariations[selectedDataType];- const currentCategoryKey = categoryKeys[selectedDataType];-- const buttonStyle: React.CSSProperties = {- margin: "2px",- padding: "6px 12px",- fontSize: "12px",- border: "1px solid #ddd",- borderRadius: "4px",- cursor: "pointer",- background: "#fff",- color: "#333",- fontFamily: "monospace",- transition: "all 0.2s",- };-- const activeButtonStyle: React.CSSProperties = {- ...buttonStyle,- background: "#3b82f6",- color: "white",- border: "1px solid #3b82f6",- fontWeight: 600,- };-- return (- <div style={{ width: "700px" }}>- <Card style={{ padding: "20px", marginBottom: "20px" }}>- <h3 style={{ margin: "0 0 12px 0", fontSize: "16px", fontWeight: "600" }}>- 🕸️ Radar Chart Test Suite- </h3>- <div style={{ display: "flex", flexWrap: "wrap", gap: "6px" }}>- {(Object.keys(dataVariations) as Array<keyof typeof dataVariations>).map((key) => (- <button- key={key}- onClick={() => setSelectedDataType(key)}- style={selectedDataType === key ? activeButtonStyle : buttonStyle}- >- {key.replace(/([A-Z])/g, " $1").replace(/^./, (str) => str.toUpperCase())}- </button>- ))}- </div>- <div style={{ marginTop: "12px", fontSize: "12px", color: "#666" }}>- <strong>Current Dataset:</strong> {selectedDataType} | <strong>Axes:</strong>{" "}- {currentData.length} | <strong>Category Key:</strong> {currentCategoryKey}- </div>- </Card>- <Card- style={{- height: "400px",- padding: "24px",- resize: "both",- overflow: "hidden",- minWidth: "400px",- minHeight: "400px",- }}- >- <RadarChart {...args} data={currentData} categoryKey={currentCategoryKey} />- </Card>- </div>- );- },- parameters: {- docs: {- description: {- story: `-Use the buttons to switch between different datasets and explore how the RadarChart adapts.-You can also use the Storybook controls to change theme, variant, and other properties in real-time.-This playground is designed for testing various configurations and edge cases.-`,- },- },- },-};--export const ThemeShowcase: Story = {- name: "🎨 Theme Showcase",- args: {- data: dataVariations.productFeatures,- categoryKey: "feature",- variant: "area",- grid: true,- legend: true,- strokeWidth: 2,- areaOpacity: 0.6,- isAnimationActive: false,- },- render: (args: any) => (- <div- style={{- display: "grid",- gridTemplateColumns: "repeat(3, 1fr)",- gap: "24px",- width: "900px",- }}- >- {(["ocean", "orchid", "emerald", "sunset", "spectrum", "vivid"] as const).map((theme) => (- <div key={theme}>- <h4- style={{- textAlign: "center",- marginBottom: "12px",- textTransform: "capitalize",- fontSize: "14px",- fontWeight: 600,- }}- >- {theme}- </h4>- <Card style={{ height: "fit-content", padding: "12px" }}>- <RadarChart {...args} theme={theme} />- </Card>- </div>- ))}- </div>- ),- parameters: {- docs: {- description: {- story:- "This story showcases all available color themes. Each theme provides a professionally curated palette suitable for different branding and data contexts. Animations are disabled for quicker comparison.",- },- },- },-};--/**- * ## Custom Palette- *- * This story demonstrates how to use the customPalette prop to provide your own color scheme- * for the chart. This is useful when you need to match your brand colors or create- * specific visual themes.- */-export const CustomPaletteStory: Story = {- name: "🎨 Custom Palette",- args: {- data: dataVariations.productFeatures,- categoryKey: "metric",- customPalette: [- "#0A0E60",- "#14197B",- "#272DA6",- "#383FC9",- "#444CE7",- "#5F67F4",- "#7884FF",- "#97A9FF",- "#B4C6FF",- "#CBD7FF",- ],- theme: "ocean", // This will be overridden by customPalette- variant: "area",- grid: true,- legend: true,- strokeWidth: 3,- isAnimationActive: true,- },- render: (args: any) => (- <div>- <div- style={{- marginBottom: "16px",- padding: "12px",- background: "#f8f9fa",- borderRadius: "8px",- border: "1px solid #e9ecef",- }}- >- <h4 style={{ margin: "0 0 8px 0", color: "#333" }}>🎨 Custom Color Palette</h4>- <p style={{ margin: "0 0 12px 0", fontSize: "14px", color: "#666" }}>- This radar chart uses a custom color palette instead of the default theme colors.- </p>- <div style={{ display: "flex", gap: "8px", flexWrap: "wrap" }}>- {args.customPalette?.map((color: string, index: number) => (- <div- key={index}- style={{- display: "flex",- alignItems: "center",- gap: "4px",- padding: "4px 8px",- background: "white",- borderRadius: "4px",- border: "1px solid #ddd",- fontSize: "12px",- }}- >- <div- style={{- width: "12px",- height: "12px",- borderRadius: "2px",- backgroundColor: color,- border: "1px solid #ccc",- }}- />- <span style={{ fontFamily: "monospace" }}>{color}</span>- </div>- ))}- </div>- </div>- <Card style={{ width: "500px", height: "auto", padding: "24px" }}>- <div style={{ marginBottom: "16px" }}>- <h3 style={{ margin: "0 0 8px 0", fontSize: "18px", fontWeight: "600" }}>- Team Performance with Custom Colors- </h3>- <p style={{ margin: 0, color: "#666", fontSize: "14px" }}>- Using custom brand colors to match your application's design system.- </p>- </div>- <RadarChart {...args} />- </Card>- </div>- ),- parameters: {- docs: {- description: {- story:- 'Demonstrates how to use the `customPalette` prop to provide your own color scheme for the radar chart. When `customPalette` is provided, it overrides the `theme` prop and uses your specified colors instead of the predefined theme palettes.\n\n**Key Features:**\n- 🎨 **Custom Colors**: Override default theme colors with your own palette\n- 🔄 **Theme Override**: The `theme` prop is ignored when `customPalette` is provided\n- 📊 **Consistent Distribution**: Colors are distributed evenly across data series\n- 🎯 **Brand Matching**: Perfect for matching your application\'s brand colors\n\n**Usage:**\n```tsx\n<RadarChart\n data={data}\n categoryKey="metric"\n customPalette={["#FF6B6B", "#4ECDC4", "#45B7D1"]}\n // theme prop is ignored when customPalette is provided\n/>\n```',- },- },- },-};diff --git a/packages/react-ui/src/components/D3Charts/RadialChart/RadialChart.tsx b/packages/react-ui/src/components/D3Charts/RadialChart/RadialChart.tsxdeleted file mode 100644index 0724318c5..000000000--- a/packages/react-ui/src/components/D3Charts/RadialChart/RadialChart.tsx+++ /dev/null@@ -1,181 +0,0 @@-import { useMemo } from "react";--import {- useCategoricalChartOrchestrator,- useEffectiveAnimation,- useExportChartData,-} from "../hooks";-import { ChartShell } from "../shared/core/ChartShell";-import { DefaultLegend } from "../shared/core/DefaultLegend/DefaultLegend";-import { useResolvedLegendKey } from "../shared/core/legend/LegendStoreProvider";-import { ChartTooltip } from "../shared/core/PortalTooltip/ChartTooltip";-import { ChartWithStackedLegend } from "../shared/core/StackedLegend/ChartWithStackedLegend";-import { CHART_CLASS_PREFIX } from "../utils/constants";-import { RadialBars } from "./parts/RadialBars";-import { RadialGrid } from "./parts/RadialGrid";-import type { RadialChartData, RadialChartProps } from "./types";--const BAR_GAP = 2;--/**- * `legendVariant="stacked"` (the default, as in react-ui's Recharts RadialChart)- * lays the chart out with its built-in stacked legend. The inline legend is- * used for `"default"`, and none when the chart publishes to an external- * legend (`legendKey`, or a surrounding `LegendStoreProvider`'s key).- */-export function RadialChart<T extends RadialChartData>(props: RadialChartProps<T>) {- const { legend = true, legendVariant = "stacked", legendKey, width, height, className } = props;- const externalLegendKey = useResolvedLegendKey(legendKey);-- if (legend && legendVariant === "stacked" && externalLegendKey === undefined) {- return (- <ChartWithStackedLegend width={width} height={height} className={className}>- <RadialChartImpl {...props} width={undefined} height={undefined} className={undefined} />- </ChartWithStackedLegend>- );- }- return <RadialChartImpl {...props} />;-}--function RadialChartImpl<T extends RadialChartData>(props: RadialChartProps<T>) {- const {- data,- categoryKey,- dataKey,- customPalette,- variant = "circular",- format = "number",- legend: showLegend = true,- grid: showGrid = false,- isAnimationActive = false,- cornerRadius = 10,- maxChartSize = 500,- minChartSize = 150,- height,- width,- fitLegendInHeight,- className,- onClick,- legendKey,- } = props;-- const isSemiCircular = variant === "semiCircular";-- const orch = useCategoricalChartOrchestrator({- data,- categoryKey,- dataKey,- themePaletteName: "radialChartPalette",- customPalette,- format,- showLegend,- isSemiCircular,- maxChartSize,- minChartSize,- height,- width,- fitLegendInHeight,- legendKey,- });-- const animate = useEffectiveAnimation(isAnimationActive);-- // Radial-specific geometry- const maxRadius = orch.dimensions.chartSize * 0.45;- const minRadius = maxRadius * 0.25;- // semiCircular viewport shows the TOP half-plane (centerY sits at the bottom- // edge), so the sweep must run 9→12→3 o'clock (d3 angles: 0 = 12 o'clock,- // clockwise) — same convention as PieChart's semiCircular.- const startAngle = isSemiCircular ? -Math.PI / 2 : 0;- const endAngle = isSemiCircular ? Math.PI / 2 : 2 * Math.PI;-- const maxValue = useMemo(- () => Math.max(...orch.data.visibleSlices.map((s) => s.value), 0),- [orch.data.visibleSlices],- );-- // PPTX print-export JSON — mirrors react-ui's RadialChart call, which (like- // its PieChart) emits type:'pie' with a single series = [dataKey] and no- // extraOptions. Colors are the resolved slice palette in sorted-data order.- // Undefined off the print path.- const exportData = useExportChartData({- type: "pie",- data: orch.data.sortedData,- categoryKey: orch.data.catKey,- dataKeys: [orch.data.valKey],- colors: orch.data.slices.map((s) => s.color),- legend: showLegend,- });-- return (- <ChartShell- containerRef={orch.refs.containerRef}- classPrefix={`${CHART_CLASS_PREFIX}-radial-chart`}- className={className}- style={orch.style.containerStyle}- isEmpty={orch.isEmpty}- exportData={exportData}- >- {() => (- <>- <div className={`${CHART_CLASS_PREFIX}-radial-chart-svg-wrapper`}>- <svg- width={orch.dimensions.svgWidth}- height={orch.dimensions.svgHeight}- viewBox={`0 0 ${orch.dimensions.svgWidth} ${orch.dimensions.svgHeight}`}- role="img"- aria-label="Radial chart"- >- <g transform={`translate(${orch.dimensions.centerX}, ${orch.dimensions.centerY})`}>- {showGrid && (- <RadialGrid- maxRadius={maxRadius}- minRadius={minRadius}- startAngle={startAngle}- endAngle={endAngle}- />- )}- <RadialBars- slices={orch.data.visibleSlices}- maxValue={maxValue}- maxRadius={maxRadius}- minRadius={minRadius}- startAngle={startAngle}- endAngle={endAngle}- cornerRadius={cornerRadius}- barGap={BAR_GAP}- hoveredIndex={orch.hover.hoveredIndex}- animate={animate}- data={orch.data.visibleRows}- onMouseMove={orch.hover.handleMouseMove}- onMouseLeave={orch.hover.handleMouseLeave}- onClick={onClick}- />- </g>- </svg>- </div>-- {showLegend && !orch.usesRemoteLegend && (- <DefaultLegend- ref={orch.refs.legendRef}- items={orch.data.legendItems}- containerWidth={orch.dimensions.containerWidth}- isExpanded={orch.legend.isLegendExpanded}- setIsExpanded={orch.legend.setIsLegendExpanded}- onItemClick={orch.data.toggleSlice}- hiddenSeries={orch.data.hiddenSlices}- />- )}-- {orch.tooltip.tooltipPayload && orch.hover.mousePos && (- <ChartTooltip- label={orch.tooltip.tooltipPayload.label}- items={orch.tooltip.tooltipPayload.items}- viewportPosition={orch.hover.mousePos}- />- )}- </>- )}- </ChartShell>- );-}diff --git a/packages/react-ui/src/components/D3Charts/RadialChart/index.ts b/packages/react-ui/src/components/D3Charts/RadialChart/index.tsdeleted file mode 100644index d4da77b01..000000000--- a/packages/react-ui/src/components/D3Charts/RadialChart/index.ts+++ /dev/null@@ -1,2 +0,0 @@-export { RadialChart } from "./RadialChart";-export type { RadialChartData, RadialChartProps } from "./types";diff --git a/packages/react-ui/src/components/D3Charts/RadialChart/radialChart.scss b/packages/react-ui/src/components/D3Charts/RadialChart/radialChart.scssdeleted file mode 100644index 29489faaf..000000000--- a/packages/react-ui/src/components/D3Charts/RadialChart/radialChart.scss+++ /dev/null@@ -1,22 +0,0 @@-@use "../../../cssUtils" as cssUtils;-@use "../shared/cartesian/chartBase" as base;-@use "../prefix" as brand;--@include base.centered-container("radial-chart");-@include base.centered-svg-wrapper("radial-chart");--.#{brand.$prefix}-radial-chart-grid-circle {- stroke: cssUtils.$border-default;- stroke-width: 1;- stroke-dasharray: 4 4;-}--// Entrances are decorative: gate the whole rule (pre-state included) behind-// reduced-motion so users who opt out get the natural static state immediately-// — gating only the animation would strand elements at the opacity: 0 start.-@media (prefers-reduced-motion: no-preference) {- .#{brand.$prefix}-radial-chart-bar--animated {- opacity: 0;- animation: #{brand.$prefix}-fade-appear 0.5s ease-out forwards;- }-}diff --git a/packages/react-ui/src/components/D3Charts/RadialChart/stories/RadialChart.stories.tsx b/packages/react-ui/src/components/D3Charts/RadialChart/stories/RadialChart.stories.tsxdeleted file mode 100644index 5a8086c82..000000000--- a/packages/react-ui/src/components/D3Charts/RadialChart/stories/RadialChart.stories.tsx+++ /dev/null@@ -1,953 +0,0 @@-// Copy of Charts/RadialChart/stories/RadialChart.stories.tsx with only the chart import and the title changed:-// the same args and renders, rendering the D3Charts chart via-// ../../stories/rechartsStoryAdapters.-import type { Meta, StoryObj } from "@storybook/react";-import { useState } from "react";-import { Card } from "../../../Card";-import { RadialChart, RadialChartProps } from "../../stories/rechartsStoryAdapters";--/**- * Sample data sets for demonstrating various RadialChart configurations- * These data structures represent common use cases in business applications- */--// Basic monthly sales data - ideal for business dashboards-const monthlyRevenueData = [- { month: "January", value: 1250 },- { month: "February", value: 980 },- { month: "March", value: 1450 },- { month: "April", value: 1320 },- { month: "May", value: 1680 },- { month: "June", value: 2100 },- { month: "July", value: 1950 },- { month: "August", value: 1820 },- { month: "September", value: 1650 },- { month: "October", value: 1480 },- { month: "November", value: 1350 },- { month: "December", value: 1200 },-];--// Extended dataset for demonstrating carousel functionality-const comprehensiveFinancialData = [- { category: "Base Salary", amount: 75000 },- { category: "Q1 Bonus", amount: 8500 },- { category: "Q2 Bonus", amount: 9200 },- { category: "Q3 Bonus", amount: 7800 },- { category: "Q4 Bonus", amount: 11000 },- { category: "Holiday Pay", amount: 6500 },- { category: "Overtime", amount: 4200 },- { category: "Commission", amount: 8900 },- { category: "Performance Incentive", amount: 7200 },- { category: "Stock Options", amount: 12000 },- { category: "Healthcare Benefits", amount: 4800 },- { category: "Retirement Match", amount: 3600 },- { category: "Professional Development", amount: 2400 },- { category: "Transportation Allowance", amount: 1800 },- { category: "Meal Vouchers", amount: 1200 },-];--// Custom color palette for demonstration--const customColorPalette = [- "#0A0E60",- "#14197B",- "#272DA6",- "#383FC9",- "#444CE7",- "#5F67F4",- "#7884FF",- "#97A9FF",- "#B4C6FF",- "#CBD7FF",-];--/**- * # RadialChart Component Documentation- *- * The RadialChart component is a powerful and flexible visualization tool for displaying- * categorical data in a circular format. It's particularly effective for showing:- *- * - **Proportional Relationships**: How different categories relate to each other- * - **Part-to-Whole Analysis**: Understanding individual contributions to a total- * - **Comparative Data**: Quickly comparing values across multiple categories- * - **Dashboard Metrics**: Essential KPIs in executive dashboards- *- * ## Key Features- *- * ### Visual Variants- * - **Circular**: Full 360-degree display for comprehensive data visualization- * - **Semicircle**: Half-circle display for space-efficient layouts- *- * ### Data Formatting- * - **Percentage Mode**: Automatically calculates and displays percentages- * - **Number Mode**: Shows raw values with customizable formatting- *- * ### Interactive Elements- * - **Responsive Legend**: Adapts to container size with carousel navigation- * - **Hover States**: Interactive feedback for enhanced user experience- * - **Animation Support**: Smooth transitions and loading animations- *- * ### Customization Options- * - **Theme System**: Pre-built color palettes (ocean, orchid, emerald, sunset, spectrum, vivid)-- * - **Layout Flexibility**: Responsive design that adapts to container dimensions- */--const meta: Meta<RadialChartProps<typeof monthlyRevenueData>> = {- title: "Components/D3Charts/RadialChart",- component: RadialChart,- parameters: {- layout: "centered",- docs: {- description: {- component: `-## Installation and Basic Usage--\`\`\`tsx-import { RadialChart } from '@openuidev/react-ui/Charts/RadialChart';--// Basic implementation-<RadialChart- data={yourData}- categoryKey="category"- dataKey="value"- theme="ocean"- variant="circular"-/>-\`\`\`--## Data Structure Requirements--Your data should be an array of objects where each object contains:-- A **category field** (string): Used for labels and legend items-- A **value field** (number): Used to determine segment sizes--\`\`\`tsx-const exampleData = [- { category: "Sales", value: 45000 },- { category: "Marketing", value: 32000 },- { category: "Operations", value: 28000 },- { category: "Support", value: 15000 }-];-\`\`\`--## Performance Considerations--- **Data Size**: Optimized for 3-20 data points for best readability-- **Responsive**: Automatically adjusts to container dimensions-- **Animation**: Can be disabled for better performance with large datasets- `,- },- },- },- tags: ["dev", "autodocs"],- argTypes: {- data: {- description: `-**Required.** An array of data objects representing your dataset. Each object should contain:-- A category identifier (string)-- One or more numeric values--**Best Practices:**-- Use 3-12 data points for optimal readability-- Ensure consistent data structure across all objects-- Use meaningful category names for better user experience- `,- control: false,- table: {- type: { summary: "Array<Record<string, string | number>>" },- defaultValue: { summary: "[]" },- category: "📊 Data Configuration",- },- },- categoryKey: {- description: `-**Required.** Specifies which field in your data objects should be used as category labels.--**Examples:**-- "month" for time-series data-- "department" for organizational data-- "product" for sales data- `,- control: false,- table: {- type: { summary: "string" },- category: "📊 Data Configuration",- },- },- dataKey: {- description: `-**Required.** Specifies which field contains the numeric values for visualization.--**Examples:**-- "value", "amount", "revenue", "count"-- Values should be positive numbers-- Supports both integers and decimals- `,- control: false,- table: {- type: { summary: "string" },- category: "📊 Data Configuration",- },- },- theme: {- description: `-**Color Theme Selection.** Choose from professionally designed color palettes:--- **ocean**: Cool blues and teals (professional, corporate)-- **orchid**: Purple and pink tones (creative, modern)-- **emerald**: Green variations (nature, growth, finance)-- **sunset**: Warm oranges and reds (energy, attention-grabbing)-- **spectrum**: Full color range (diverse, comprehensive)-- **vivid**: High-contrast colors (accessibility, clarity)- `,- control: "select",- options: ["ocean", "orchid", "emerald", "sunset", "spectrum", "vivid"],- table: {- defaultValue: { summary: "ocean" },- category: "🎨 Visual Styling",- },- },- customPalette: {- description: `-**Custom Color Palette.** Override the theme colors with your own color array.--**Usage:**-- Provide an array of hex color strings-- Colors will be applied in order to chart segments-- Takes precedence over theme colors when provided-- Useful for brand-specific color requirements--**Example:**-\`["#FF6B6B", "#4ECDC4", "#45B7D1", "#96CEB4"]\`- `,- control: false,- table: {- type: { summary: "string[]" },- defaultValue: { summary: "undefined" },- category: "🎨 Visual Styling",- },- },- variant: {- description: `-**Chart Layout Style:**--- **circular**: Full 360° display - best for comprehensive data overview-- **semicircle**: Half-circle display - space-efficient for dashboards- `,- control: "radio",- options: ["semicircle", "circular"],- table: {- defaultValue: { summary: "circular" },- category: "🎨 Visual Styling",- },- },- format: {- description: `-**Data Display Format:**--- **percentage**: Automatically calculates percentages from your data-- **number**: Shows raw numeric values with smart formatting- `,- control: "radio",- options: ["percentage", "number"],- table: {- defaultValue: { summary: "number" },- category: "📱 Display Options",- },- },- legend: {- description: `-**Legend Visibility.** Controls whether the legend is displayed.--**When to disable:**-- Minimal dashboard widgets-- When labels are embedded in the chart-- Space-constrained layouts- `,- control: "boolean",- table: {- type: { summary: "boolean" },- defaultValue: { summary: "true" },- category: "📱 Display Options",- },- },- legendVariant: {- description: `-**Legend Layout Style:**--- **stacked**: Vertical layout with responsive behavior (recommended)-- **default**: Horizontal layout at bottom (classic style)- `,- control: "radio",- options: ["default", "stacked"],- table: {- defaultValue: { summary: "stacked" },- category: "📱 Display Options",- },- },- grid: {- description: `-**Polar Grid Lines.** Adds concentric circles for value reference.--**Use cases:**-- Data analysis and comparison-- Scientific or technical presentations-- When precise value reading is important- `,- control: "boolean",- table: {- type: { summary: "boolean" },- defaultValue: { summary: "false" },- category: "📱 Display Options",- },- },- isAnimationActive: {- description: `-**Animation Control.** Enables smooth loading and transition animations.--**Performance note:** Disable for large datasets or performance-critical applications.- `,- control: "boolean",- table: {- type: { summary: "boolean" },- defaultValue: { summary: "true" },- category: "🎬 Animation & Interaction",- },- },- cornerRadius: {- description: `-**Corner Rounding.** Controls the roundness of radial bar ends.--**Design impact:**-- 0: Sharp, technical appearance-- 5-10: Subtle modern look (recommended)-- 15+: Highly rounded, friendly appearance- `,- control: { type: "number", min: 0, max: 20 },- table: {- type: { summary: "number" },- defaultValue: { summary: "10" },- category: "🎨 Visual Styling",- },- },- height: {- description: "The height of the chart.",- control: "text",- table: {- type: { summary: "string | number" },- category: "📱 Display Options",- },- },- width: {- description: "The width of the chart.",- control: "text",- table: {- type: { summary: "string | number" },- category: "📱 Display Options",- },- },- },-} satisfies Meta<typeof RadialChart>;--export default meta;-type Story = StoryObj<typeof meta>;--/**- * ## Default Configuration- *- * This example demonstrates the RadialChart with its default settings - the most common- * configuration for business dashboards and data visualization applications.- *- * **Key Features Shown:**- * - Standard circular layout with full 360° display- * - Professional ocean color theme- * - Stacked legend for optimal space utilization- * - Smooth animations for polished user experience- * - Number format for clear value display- */-export const DefaultConfiguration: Story = {- name: "📊 Default Configuration",- args: {- data: monthlyRevenueData,- categoryKey: "month",- dataKey: "value",- theme: "ocean",- variant: "circular",- format: "number",- legend: true,- legendVariant: "stacked",- grid: false,- isAnimationActive: true,- cornerRadius: 10,- },- render: (args: any) => (- <Card style={{ width: "700px", height: "auto", padding: "24px" }}>- <div style={{ marginBottom: "16px" }}>- <h3 style={{ margin: "0 0 8px 0", fontSize: "18px", fontWeight: "600" }}>- Monthly Revenue Analysis- </h3>- <p style={{ margin: 0, color: "#666", fontSize: "14px" }}>- Comprehensive view of revenue distribution across 12 months- </p>- </div>- <RadialChart {...args} />- </Card>- ),- parameters: {- docs: {- description: {- story: `-This is the recommended starting configuration for most use cases. The chart displays data-in a clear, professional manner with optimal default settings for readability and user experience.--**Configuration Details:**-- **Data**: 12 months of revenue data-- **Layout**: Full circular display-- **Colors**: Ocean theme (blues and teals)-- **Legend**: Stacked layout for space efficiency-- **Animations**: Enabled for smooth interactions- `,- },- },- },-};--/**- * ## Theme Showcase- *- * RadialChart includes six professionally designed color themes, each optimized- * for different contexts and brand requirements.- */-export const ThemeShowcase: Story = {- name: "🎨 Theme Variations",- args: {- data: monthlyRevenueData.slice(0, 6),- categoryKey: "month",- dataKey: "value",- theme: "emerald",- variant: "circular",- format: "number",- legend: true,- legendVariant: "stacked",- grid: false,- isAnimationActive: true,- cornerRadius: 10,- },- render: (args: any) => (- <Card style={{ width: "600px", height: "auto", padding: "24px" }}>- <div style={{ marginBottom: "20px" }}>- <h3 style={{ margin: "0 0 8px 0", fontSize: "18px", fontWeight: "600" }}>- Financial Growth Metrics- </h3>- <p style={{ margin: 0, color: "#666", fontSize: "14px" }}>- Using the emerald theme for finance-related data visualization- </p>- </div>- <RadialChart {...args} />- </Card>- ),- parameters: {- docs: {- description: {- story: `-**Theme Selection Guide:**--- **Ocean** 🌊: Corporate, professional, trustworthy (recommended for business)-- **Orchid** 🌸: Creative, modern, innovative (great for design/marketing)-- **Emerald** 🍃: Growth, finance, nature (perfect for financial data)-- **Sunset** 🌅: Energy, attention, warmth (ideal for alerts/important metrics)-- **Spectrum** 🌈: Diverse, comprehensive (when you need many distinct colors)-- **Vivid** ⚡: High contrast, accessible (optimized for accessibility requirements)--**Best Practice:** Choose themes that align with your brand colors and data context.- `,- },- },- },-};--/**- * ## Advanced Visual Enhancement- *- * This example showcases percentage formatting to create visually striking and informative charts.- */-export const VisualEnhancement: Story = {- name: "✨ Visual Enhancement",- args: {- data: monthlyRevenueData.slice(0, 6),- categoryKey: "month",- dataKey: "value",- theme: "sunset",- variant: "circular",- format: "percentage",- legend: true,- legendVariant: "stacked",- grid: false,- isAnimationActive: true,- cornerRadius: 15,- },- render: (args: any) => (- <Card style={{ width: "500px", padding: "24px" }}>- <div style={{ marginBottom: "20px" }}>- <h3 style={{ margin: "0 0 8px 0", fontSize: "18px", fontWeight: "600" }}>- Revenue Distribution- </h3>- <p style={{ margin: 0, color: "#666", fontSize: "14px" }}>- Enhanced with percentage display- </p>- </div>- <RadialChart {...args} />- </Card>- ),- parameters: {- docs: {- description: {- story: `-**Visual Enhancement Features:**--- **Percentage Display**: Shows data as percentages for better comparison-- **Modern Aesthetic**: Aligns with contemporary design trends-- **Theme Integration**: Uses theme colors for consistent visual design-- **Performance Optimized**: Efficiently rendered for smooth interactions--**When to Use Percentage Format:**-- Executive dashboards and presentations-- Marketing materials and public-facing reports-- When relative comparisons are important-- With 3-8 data points for optimal readability--**Technical Note:** Percentages are automatically calculated from the data values,-providing clear relative comparisons across all chart segments.- `,- },- },- },-};--/**- * ## Custom Color Palette- *- * This example demonstrates how to use a custom color palette to override- * the default theme colors with brand-specific or custom color schemes.- */-export const CustomPalette: Story = {- name: "🎨 Custom Color Palette",- args: {- data: monthlyRevenueData.slice(0, 8),- categoryKey: "month",- dataKey: "value",- customPalette: customColorPalette,- variant: "circular",- format: "number",- legend: true,- legendVariant: "stacked",- grid: false,- isAnimationActive: true,- cornerRadius: 12,- },- render: (args: any) => (- <Card style={{ width: "600px", padding: "24px" }}>- <div style={{ marginBottom: "20px" }}>- <h3 style={{ margin: "0 0 8px 0", fontSize: "18px", fontWeight: "600" }}>- Brand-Specific Color Scheme- </h3>- <p style={{ margin: 0, color: "#666", fontSize: "14px" }}>- Using custom colors that align with your brand identity- </p>- </div>- <RadialChart {...args} />- <div- style={{- marginTop: "16px",- padding: "12px",- backgroundColor: "#f8f9fa",- borderRadius: "6px",- fontSize: "12px",- color: "#666",- }}- >- <strong>🎨 Custom Palette:</strong>{" "}- {customColorPalette.slice(0, 8).map((color, index) => (- <span- key={index}- style={{- display: "inline-block",- width: "16px",- height: "16px",- backgroundColor: color,- borderRadius: "3px",- marginLeft: "4px",- marginRight: "4px",- border: "1px solid #ddd",- verticalAlign: "middle",- }}- />- ))}- </div>- </Card>- ),- parameters: {- docs: {- description: {- story: `-**Custom Palette Features:**--- **Brand Alignment**: Use your exact brand colors for consistent visual identity-- **Override Themes**: Takes precedence over theme-based color selection-- **Flexible Array**: Provide any number of colors - they'll cycle automatically for larger datasets-- **Hex Color Support**: Standard hex color format (#RRGGBB)--**Implementation Example:**-\`\`\`tsx-const brandColors = [- "#FF6B6B", // Primary brand color- "#4ECDC4", // Secondary brand color- "#45B7D1", // Accent color 1- "#96CEB4", // Accent color 2- // ... more colors as needed-];--<RadialChart- data={data}- categoryKey="category"- dataKey="value"- customPalette={brandColors}-/>-\`\`\`--**Best Practices:**-- Ensure sufficient contrast between adjacent colors-- Test color accessibility for users with color vision differences-- Provide at least as many colors as data points for optimal display-- Consider color psychology and brand associations when selecting colors--**Technical Notes:**-- Colors are applied in array order to data segments-- If fewer colors than data points, colors will cycle automatically- `,- },- },- },-};--/**- * ## Large Dataset Management- *- * When working with extensive datasets, RadialChart provides intelligent- * legend management with carousel navigation to maintain usability.- */-export const LargeDatasetDemo: Story = {- name: "📈 Large Dataset with Carousel",- args: {- data: comprehensiveFinancialData,- categoryKey: "category",- dataKey: "amount",- theme: "spectrum",- variant: "circular",- format: "number",- legend: true,- legendVariant: "stacked",- grid: false,- isAnimationActive: true,- cornerRadius: 8,- },- render: (args: any) => (- <Card style={{ width: "700px", height: "auto", padding: "24px" }}>- <div style={{ marginBottom: "20px" }}>- <h3 style={{ margin: "0 0 8px 0", fontSize: "18px", fontWeight: "600" }}>- Comprehensive Compensation Analysis- </h3>- <p style={{ margin: 0, color: "#666", fontSize: "14px" }}>- Complete breakdown of 15 compensation categories with carousel navigation- </p>- </div>- <RadialChart {...args} />- <div- style={{- marginTop: "16px",- padding: "12px",- backgroundColor: "#f8f9fa",- borderRadius: "6px",- fontSize: "12px",- color: "#666",- }}- >- <strong>💡 Carousel Feature:</strong> When legend items exceed available space, up/down- navigation arrows automatically appear. Use the arrows to scroll through all legend items- while maintaining chart visibility.- </div>- </Card>- ),- parameters: {- docs: {- description: {- story: `-**Large Dataset Management:**--**Automatic Carousel Detection:**-- Activates when legend content exceeds container height-- Provides smooth scrolling navigation-- Maintains chart proportions and visibility--**Navigation Features:**-- **Up/Down Arrows**: Navigate through legend items-- **Smooth Scrolling**: Polished user experience-- **Visual Indicators**: Clear navigation state--**Performance Optimizations:**-- Virtual scrolling for datasets with 50+ items-- Efficient rendering of visible legend items only-- Optimized color cycling for unlimited data points--**Best Practices for Large Datasets:**-- Consider data aggregation for better readability-- Use meaningful category names-- Test carousel functionality in your target container sizes-- Consider alternative visualizations for 25+ categories- `,- },- },- },-};--/**- * ## Interactive Responsiveness Demo- *- * This advanced example demonstrates RadialChart's responsive capabilities- * with a resizable container to show real-time adaptation.- */-export const ResponsiveDemo: Story = {- name: "📱 Responsive Behavior Demo",- args: {- data: monthlyRevenueData,- categoryKey: "month",- dataKey: "value",- theme: "spectrum",- variant: "circular",- format: "number",- legend: true,- legendVariant: "stacked",- isAnimationActive: false,- cornerRadius: 8,- },- render: (args: any) => {- const [dimensions, setDimensions] = useState<{ width: number; height: number | string }>({- width: 650,- height: "auto",- });-- const handleMouseDown = (e: React.MouseEvent<HTMLDivElement>, handle: string) => {- e.preventDefault();- e.stopPropagation();- const startX = e.clientX;- const startY = e.clientY;- const startWidth = dimensions.width;- const startHeight = (e.currentTarget.parentElement as HTMLElement).offsetHeight;-- const doDrag = (e: MouseEvent) => {- const dx = e.clientX - startX;- const dy = e.clientY - startY;- let newWidth = startWidth;- let newHeight = startHeight;-- if (handle.includes("e")) newWidth = startWidth + dx;- if (handle.includes("w")) newWidth = startWidth - dx;- if (handle.includes("s")) newHeight = startHeight + dy;- if (handle.includes("n")) newHeight = startHeight - dy;-- setDimensions({- width: Math.max(300, newWidth),- height: "auto",- });- };-- const stopDrag = () => {- document.removeEventListener("mousemove", doDrag);- document.removeEventListener("mouseup", stopDrag);- };-- document.addEventListener("mousemove", doDrag);- document.addEventListener("mouseup", stopDrag);- };-- const handleStyle: React.CSSProperties = {- position: "absolute",- background: "#3b82f6",- opacity: 0.6,- zIndex: 10,- transition: "opacity 0.2s ease",- };-- return (- <div style={{ padding: "20px" }}>- <div style={{ marginBottom: "20px" }}>- <h3 style={{ margin: "0 0 8px 0", fontSize: "18px", fontWeight: "600" }}>- Responsive Behavior Demonstration- </h3>- <p style={{ margin: "0 0 12px 0", color: "#666", fontSize: "14px" }}>- Drag the edges or corners of the container below to see how the chart adapts- </p>- <div- style={{- padding: "12px",- backgroundColor: "#e3f2fd",- borderRadius: "6px",- fontSize: "12px",- color: "#1565c0",- }}- >- <strong>🎯 Try This:</strong> Resize the container to see automatic legend layout- changes, chart proportion adjustments, and responsive breakpoint behaviors.- </div>- </div>-- <Card- style={{- position: "relative",- width: `${dimensions.width}px`,- height:- typeof dimensions.height === "number" ? `${dimensions.height}px` : dimensions.height,- border: "2px dashed #9ca3af",- padding: "20px",- boxSizing: "border-box",- overflow: "hidden",- cursor: "default",- }}- >- <RadialChart {...args} />-- {/* Resize Handles */}- <div- style={{ ...handleStyle, top: -2, left: 0, right: 0, height: 12, cursor: "ns-resize" }}- onMouseDown={(e) => handleMouseDown(e, "n")}- />- <div- style={{- ...handleStyle,- bottom: -2,- left: 0,- right: 0,- height: 12,- cursor: "ns-resize",- }}- onMouseDown={(e) => handleMouseDown(e, "s")}- />- <div- style={{ ...handleStyle, top: 0, bottom: 0, left: -2, width: 12, cursor: "ew-resize" }}- onMouseDown={(e) => handleMouseDown(e, "w")}- />- <div- style={{ ...handleStyle, top: 0, bottom: 0, right: -2, width: 12, cursor: "ew-resize" }}- onMouseDown={(e) => handleMouseDown(e, "e")}- />-- {/* Corner Handles */}- <div- style={{- ...handleStyle,- top: -2,- left: -2,- width: 20,- height: 20,- cursor: "nwse-resize",- borderRadius: "2px",- }}- onMouseDown={(e) => handleMouseDown(e, "nw")}- />- <div- style={{- ...handleStyle,- top: -2,- right: -2,- width: 20,- height: 20,- cursor: "nesw-resize",- borderRadius: "2px",- }}- onMouseDown={(e) => handleMouseDown(e, "ne")}- />- <div- style={{- ...handleStyle,- bottom: -2,- right: -2,- width: 20,- height: 20,- cursor: "nwse-resize",- borderRadius: "2px",- }}- onMouseDown={(e) => handleMouseDown(e, "se")}- />-- {/* Dimension Display */}- <div- style={{- position: "absolute",- bottom: 8,- right: 8,- background: "rgba(0,0,0,0.8)",- color: "white",- padding: "4px 8px",- borderRadius: "4px",- fontSize: "11px",- fontFamily: "monospace",- fontWeight: "500",- }}- >- {dimensions.width}px ×{" "}- {typeof dimensions.height === "number" ? `${dimensions.height}px` : "auto"}- </div>- </Card>-- <div- style={{- marginTop: "16px",- padding: "12px",- backgroundColor: "#f8f9fa",- borderRadius: "6px",- fontSize: "12px",- color: "#666",- }}- >- <strong>📊 Responsive Features Demonstrated:</strong>- <ul style={{ margin: "8px 0 0 0", paddingLeft: "16px" }}>- <li>Automatic chart scaling and proportion maintenance</li>- <li>Legend layout adaptation (stacked ↔ horizontal)</li>- <li>Text size and spacing adjustments</li>- <li>Optimal space utilization at any container size</li>- </ul>- </div>- </div>- );- },- parameters: {- docs: {- description: {- story: `-**Responsive Design Philosophy:**--**Automatic Adaptation:**-- Chart dimensions automatically adjust to container size-- Legend layout switches between horizontal and stacked based on available space-- Text and spacing scale appropriately for readability--**Breakpoint Behavior:**-- **Large Containers (>600px)**: Side-by-side chart and legend layout-- **Medium Containers (400-600px)**: Stacked layout with optimized proportions-- **Small Containers (<400px)**: Compact layout with essential elements only--**Performance Optimizations:**-- Efficient re-rendering during resize operations-- Debounced resize calculations to prevent performance issues-- Optimized SVG scaling for crisp display at any size--**Implementation Notes:**-- Uses ResizeObserver API for precise container size detection-- Maintains aspect ratios while maximizing space utilization-- Supports both fixed and flexible container sizing strategies- `,- },- },- },-};diff --git a/packages/react-ui/src/components/D3Charts/ScatterChart/ScatterChart.tsx b/packages/react-ui/src/components/D3Charts/ScatterChart/ScatterChart.tsxdeleted file mode 100644index facd06171..000000000--- a/packages/react-ui/src/components/D3Charts/ScatterChart/ScatterChart.tsx+++ /dev/null@@ -1,165 +0,0 @@-import { useEffectiveAnimation, useScatterChartOrchestrator } from "../hooks";-import { NumericXAxis } from "../shared/cartesian/axes/NumericXAxis";-import { YAxis } from "../shared/cartesian/axes/YAxis";-import { Grid } from "../shared/cartesian/Grid";-import { VerticalGrid } from "../shared/cartesian/VerticalGrid";-import { ChartShell } from "../shared/core/ChartShell";-import { DefaultLegend } from "../shared/core/DefaultLegend/DefaultLegend";-import { ChartTooltip } from "../shared/core/PortalTooltip/ChartTooltip";-import { CHART_CLASS_PREFIX } from "../utils/constants";-import { ScatterDots } from "./parts/ScatterDots";-import type { ScatterChartProps } from "./types";--export function ScatterChart(props: ScatterChartProps) {- const {- data,- customPalette,- grid: showGrid = true,- verticalGrid: showVerticalGrid = true,- legend: showLegend = true,- showYAxis = true,- xAxisLabel,- yAxisLabel,- isAnimationActive = false,- dotRadius = 4,- className,- height,- width,- fitLegendInHeight,- onClick,- } = props;-- const orch = useScatterChartOrchestrator({- data,- themePaletteName: "defaultChartPalette",- customPalette,- showLegend,- showYAxis,- height,- width,- fitLegendInHeight,- xAxisLabel: typeof xAxisLabel === "string" ? xAxisLabel : undefined,- yAxisLabel: typeof yAxisLabel === "string" ? yAxisLabel : undefined,- onClick,- });-- const animate = useEffectiveAnimation(isAnimationActive);-- const {- dimensions: {- effectiveYAxisWidth,- chartAreaWidth,- chartInnerHeight,- totalSvgWidth,- totalSvgHeight,- xAxisHeight,- CHART_MARGIN_TOP: marginTop,- },- scales: { xScale, yScale },- } = orch;-- return (- <ChartShell- containerRef={orch.refs.containerRef}- classPrefix={`${CHART_CLASS_PREFIX}-scatter-chart`}- className={className}- style={orch.style.containerStyle}- isEmpty={orch.isEmpty}- >- {() => (- <>- <svg- width={totalSvgWidth}- height={totalSvgHeight}- style={{ overflow: "visible" }}- role="img"- aria-label="Scatter chart"- >- {showYAxis && (- <g transform={`translate(0, ${marginTop})`}>- <YAxis- scale={yScale}- width={effectiveYAxisWidth}- chartHeight={chartInnerHeight}- className={`${CHART_CLASS_PREFIX}-scatter-chart-y-axis`}- tickClassName={`${CHART_CLASS_PREFIX}-scatter-chart-y-tick`}- />- </g>- )}-- <g- transform={`translate(${effectiveYAxisWidth}, ${marginTop})`}- onMouseMove={orch.hover.handleMouseMove}- onMouseLeave={orch.hover.handleMouseLeave}- onTouchMove={orch.hover.handleTouchMove}- onTouchEnd={orch.hover.handleTouchEnd}- onClick={orch.hover.handleClick}- >- <rect width={chartAreaWidth} height={chartInnerHeight} fill="transparent" />-- {showGrid && (- <Grid- yScale={yScale}- chartWidth={chartAreaWidth}- chartHeight={chartInnerHeight}- className={`${CHART_CLASS_PREFIX}-scatter-chart-grid`}- />- )}-- {showVerticalGrid && (- <VerticalGrid- xScale={xScale}- chartWidth={chartAreaWidth}- chartHeight={chartInnerHeight}- className={`${CHART_CLASS_PREFIX}-scatter-chart-grid-vertical`}- />- )}-- <ScatterDots- datasets={orch.data.visibleDatasets}- xScale={xScale}- yScale={yScale}- colorMap={orch.data.colorMap}- dotRadius={dotRadius}- hoveredPoint={orch.hover.hoveredPoint}- animate={animate}- />- </g>-- <g transform={`translate(${effectiveYAxisWidth}, ${chartInnerHeight + marginTop})`}>- <NumericXAxis- scale={xScale}- chartWidth={chartAreaWidth}- height={xAxisHeight}- className={`${CHART_CLASS_PREFIX}-scatter-chart-x-axis`}- tickClassName={`${CHART_CLASS_PREFIX}-scatter-chart-x-tick`}- />- </g>- </svg>-- {showLegend && (- <DefaultLegend- ref={orch.refs.legendRef}- items={orch.legend.legendItems}- containerWidth={orch.dimensions.containerWidth}- isExpanded={orch.legend.isLegendExpanded}- setIsExpanded={orch.legend.setIsLegendExpanded}- onItemClick={orch.legend.toggleSeries}- hiddenSeries={orch.legend.hiddenSeries}- xAxisLabel={xAxisLabel}- yAxisLabel={yAxisLabel}- />- )}-- {orch.tooltip.tooltipPayload && orch.hover.mousePos && (- <ChartTooltip- label={orch.tooltip.tooltipPayload.label}- items={orch.tooltip.tooltipPayload.items}- viewportPosition={orch.hover.mousePos}- />- )}- </>- )}- </ChartShell>- );-}diff --git a/packages/react-ui/src/components/D3Charts/ScatterChart/index.ts b/packages/react-ui/src/components/D3Charts/ScatterChart/index.tsdeleted file mode 100644index cc7932d85..000000000--- a/packages/react-ui/src/components/D3Charts/ScatterChart/index.ts+++ /dev/null@@ -1,2 +0,0 @@-export { ScatterChart } from "./ScatterChart";-export type { ScatterChartData, ScatterChartProps } from "./types";diff --git a/packages/react-ui/src/components/D3Charts/ScatterChart/scatterChart.scss b/packages/react-ui/src/components/D3Charts/ScatterChart/scatterChart.scssdeleted file mode 100644index b4c959bc4..000000000--- a/packages/react-ui/src/components/D3Charts/ScatterChart/scatterChart.scss+++ /dev/null@@ -1,56 +0,0 @@-@use "../../../cssUtils" as cssUtils;-@use "../shared/cartesian/chartBase" as base;-@use "../prefix" as brand;--@include base.centered-container("scatter-chart");--.#{brand.$prefix}-scatter-chart-grid line {- stroke: cssUtils.$border-default;- stroke-dasharray: 3 3;-}--.#{brand.$prefix}-scatter-chart-grid line.#{brand.$prefix}-grid-zero-line {- stroke-dasharray: none;-}--.#{brand.$prefix}-scatter-chart-grid-vertical line {- stroke: cssUtils.$border-default;- stroke-dasharray: 3 3;-}--.#{brand.$prefix}-scatter-chart-y-tick {- @include base.svg-tick-label;-}--.#{brand.$prefix}-scatter-chart-x-tick {- @include base.svg-tick-label;-}--.#{brand.$prefix}-scatter-chart-dot {- stroke: cssUtils.$foreground;- stroke-width: 1.5;- transition:- r 0.15s ease,- fill-opacity 0.15s ease,- stroke-opacity 0.15s ease;-}--// Entrances are decorative: gate the whole rule (pre-state included) behind-// reduced-motion so users who opt out get the natural static state immediately-// — gating only the animation would strand elements at the opacity: 0 start.-@media (prefers-reduced-motion: no-preference) {- .#{brand.$prefix}-scatter-chart-dot--animated {- opacity: 0;- animation: #{brand.$prefix}-scatter-dot-appear 0.4s ease-out forwards;- }-}--@keyframes #{brand.$prefix}-scatter-dot-appear {- from {- opacity: 0;- r: 0;- }- to {- opacity: 1;- }-}diff --git a/packages/react-ui/src/components/D3Charts/ScatterChart/stories/ScatterChart.stories.tsx b/packages/react-ui/src/components/D3Charts/ScatterChart/stories/ScatterChart.stories.tsxdeleted file mode 100644index e6ed06ed5..000000000--- a/packages/react-ui/src/components/D3Charts/ScatterChart/stories/ScatterChart.stories.tsx+++ /dev/null@@ -1,823 +0,0 @@-// Copy of Charts/ScatterChart/stories/ScatterChart.stories.tsx with only the chart import and the title changed:-// the same args and renders, rendering the D3Charts chart via-// ../../stories/rechartsStoryAdapters.-import type { Meta, StoryObj } from "@storybook/react";-import {- Calendar,- Globe,- Laptop,- Monitor,- Smartphone,- TabletSmartphone,- Tv,- Watch,-} from "lucide-react";-import { useState } from "react";-import { Card } from "../../../Card";-import { ScatterChart, ScatterChartProps } from "../../stories/rechartsStoryAdapters";--const customColorPalette = [- "#0A0E60",- "#14197B",- "#272DA6",- "#383FC9",- "#444CE7",- "#5F67F4",- "#7884FF",- "#97A9FF",- "#B4C6FF",- "#CBD7FF",-];--// Sample scatter chart datasets-const dataVariations = {- default: [- {- name: "A school",- data: [- { x: 100, y: 200, z: 200 },- { x: 120, y: 100, z: 260 },- { x: 170, y: 300, z: 400 },- { x: 140, y: 250, z: 280 },- { x: 150, y: 400, z: 500 },- { x: 110, y: 280, z: 200 },- ],- },- {- name: "B school",- data: [- { x: 200, y: 180, z: 240 },- { x: 180, y: 350, z: 220 },- { x: 160, y: 320, z: 250 },- { x: 190, y: 150, z: 210 },- ],- },- ],- correlation: [- {- name: "Revenue",- data: [- { x: 1000, y: 1200 },- { x: 1200, y: 1400 },- { x: 1700, y: 2100 },- { x: 1400, y: 1800 },- { x: 1500, y: 1950 },- { x: 1100, y: 1300 },- { x: 2000, y: 2500 },- { x: 1800, y: 2200 },- { x: 1600, y: 1850 },- { x: 1900, y: 2350 },- { x: 1300, y: 1600 },- { x: 2200, y: 2800 },- ],- },- {- name: "Profit",- data: [- { x: 1000, y: 200 },- { x: 1200, y: 280 },- { x: 1700, y: 420 },- { x: 1400, y: 350 },- { x: 1500, y: 380 },- { x: 1100, y: 240 },- { x: 2000, y: 500 },- { x: 1800, y: 450 },- { x: 1600, y: 390 },- { x: 1900, y: 470 },- { x: 1300, y: 320 },- { x: 2200, y: 580 },- ],- },- ],- multipleDatasets: [- {- name: "Desktop",- data: [- { x: 1, y: 4 },- { x: 2, y: 2 },- { x: 3, y: 7 },- { x: 4, y: 5 },- { x: 5, y: 8 },- { x: 6, y: 3 },- { x: 7, y: 9 },- { x: 8, y: 6 },- { x: 9, y: 10 },- { x: 10, y: 1 },- ],- },- {- name: "Mobile",- data: [- { x: 1, y: 3 },- { x: 2, y: 5 },- { x: 3, y: 4 },- { x: 4, y: 7 },- { x: 5, y: 6 },- { x: 6, y: 8 },- { x: 7, y: 5 },- { x: 8, y: 9 },- { x: 9, y: 7 },- { x: 10, y: 8 },- ],- },- {- name: "Tablet",- data: [- { x: 1, y: 2 },- { x: 2, y: 6 },- { x: 3, y: 3 },- { x: 4, y: 4 },- { x: 5, y: 7 },- { x: 6, y: 5 },- { x: 7, y: 6 },- { x: 8, y: 8 },- { x: 9, y: 4 },- { x: 10, y: 9 },- ],- },- ],- performance: [- {- name: "Performance",- data: [- { x: 30, y: 1200 },- { x: 35, y: 1500 },- { x: 40, y: 1800 },- { x: 45, y: 2100 },- { x: 50, y: 2400 },- { x: 55, y: 2700 },- { x: 60, y: 3000 },- { x: 25, y: 900 },- { x: 65, y: 3300 },- { x: 70, y: 3600 },- ],- },- {- name: "Efficiency",- data: [- { x: 30, y: 1100 },- { x: 35, y: 1350 },- { x: 40, y: 1650 },- { x: 45, y: 1950 },- { x: 50, y: 2200 },- { x: 55, y: 2500 },- { x: 60, y: 2850 },- { x: 25, y: 800 },- { x: 65, y: 3150 },- { x: 70, y: 3450 },- ],- },- ],- comprehensive: [- {- name: "North America Sales",- data: [- { x: 1200, y: 8500, z: 120 },- { x: 1350, y: 9200, z: 140 },- { x: 1100, y: 7800, z: 95 },- { x: 1450, y: 10200, z: 160 },- { x: 1250, y: 8900, z: 130 },- { x: 1600, y: 11500, z: 180 },- { x: 1050, y: 7600, z: 85 },- { x: 1700, y: 12800, z: 200 },- { x: 1300, y: 9100, z: 135 },- { x: 1500, y: 10800, z: 170 },- { x: 1150, y: 8200, z: 110 },- { x: 1750, y: 13200, z: 210 },- { x: 1400, y: 9800, z: 150 },- { x: 1650, y: 12100, z: 190 },- { x: 1220, y: 8700, z: 125 },- { x: 1800, y: 13800, z: 220 },- { x: 1180, y: 8100, z: 105 },- { x: 1550, y: 11100, z: 175 },- { x: 1280, y: 9000, z: 128 },- { x: 1620, y: 11800, z: 185 },- { x: 1120, y: 7900, z: 100 },- { x: 1720, y: 13000, z: 205 },- { x: 1380, y: 9500, z: 145 },- { x: 1680, y: 12500, z: 195 },- { x: 1240, y: 8800, z: 120 },- ],- },- {- name: "Europe Sales",- data: [- { x: 980, y: 7200, z: 88 },- { x: 1150, y: 8400, z: 115 },- { x: 1020, y: 7500, z: 95 },- { x: 1280, y: 9200, z: 140 },- { x: 1080, y: 7800, z: 105 },- { x: 1420, y: 10100, z: 165 },- { x: 950, y: 6900, z: 80 },- { x: 1520, y: 11200, z: 185 },- { x: 1120, y: 8200, z: 120 },- { x: 1380, y: 9800, z: 155 },- { x: 1050, y: 7600, z: 100 },- { x: 1580, y: 11800, z: 195 },- { x: 1180, y: 8600, z: 130 },- { x: 1480, y: 10700, z: 175 },- { x: 1000, y: 7300, z: 90 },- { x: 1620, y: 12200, z: 205 },- { x: 1060, y: 7700, z: 102 },- { x: 1320, y: 9400, z: 145 },- { x: 1100, y: 8000, z: 115 },- { x: 1450, y: 10400, z: 170 },- { x: 970, y: 7100, z: 85 },- { x: 1550, y: 11500, z: 190 },- { x: 1140, y: 8300, z: 125 },- { x: 1680, y: 12600, z: 200 },- { x: 1040, y: 7500, z: 98 },- ],- },- {- name: "Asia Pacific Sales",- data: [- { x: 1800, y: 15200, z: 280 },- { x: 1950, y: 16800, z: 320 },- { x: 1650, y: 13800, z: 240 },- { x: 2100, y: 18200, z: 360 },- { x: 1750, y: 14800, z: 260 },- { x: 2250, y: 19500, z: 400 },- { x: 1600, y: 13200, z: 220 },- { x: 2350, y: 20200, z: 420 },- { x: 1900, y: 16200, z: 300 },- { x: 2150, y: 18500, z: 380 },- { x: 1700, y: 14200, z: 250 },- { x: 2400, y: 20800, z: 440 },- { x: 2000, y: 17200, z: 340 },- { x: 2200, y: 18800, z: 390 },- { x: 1820, y: 15500, z: 290 },- { x: 2450, y: 21200, z: 460 },- { x: 1720, y: 14500, z: 255 },- { x: 2050, y: 17500, z: 350 },- { x: 1870, y: 15800, z: 295 },- { x: 2300, y: 19800, z: 410 },- { x: 1780, y: 15000, z: 275 },- { x: 2500, y: 21800, z: 480 },- { x: 1920, y: 16400, z: 310 },- { x: 2070, y: 17700, z: 355 },- { x: 1830, y: 15600, z: 285 },- ],- },- {- name: "Latin America Sales",- data: [- { x: 650, y: 4200, z: 55 },- { x: 780, y: 5100, z: 75 },- { x: 720, y: 4800, z: 65 },- { x: 850, y: 5800, z: 90 },- { x: 690, y: 4500, z: 60 },- { x: 920, y: 6300, z: 105 },- { x: 620, y: 4000, z: 50 },- { x: 980, y: 6800, z: 120 },- { x: 750, y: 5000, z: 70 },- { x: 880, y: 6000, z: 95 },- { x: 670, y: 4400, z: 58 },- { x: 1020, y: 7100, z: 130 },- { x: 730, y: 4900, z: 68 },- { x: 950, y: 6500, z: 110 },- { x: 640, y: 4100, z: 52 },- { x: 1100, y: 7500, z: 150 },- { x: 700, y: 4700, z: 62 },- { x: 860, y: 5900, z: 92 },- { x: 680, y: 4600, z: 56 },- { x: 930, y: 6400, z: 108 },- { x: 610, y: 3900, z: 48 },- { x: 1050, y: 7200, z: 140 },- { x: 740, y: 4950, z: 69 },- { x: 970, y: 6650, z: 118 },- { x: 660, y: 4300, z: 54 },- ],- },- {- name: "Middle East & Africa",- data: [- { x: 450, y: 2800, z: 35 },- { x: 580, y: 3700, z: 55 },- { x: 520, y: 3300, z: 45 },- { x: 680, y: 4400, z: 70 },- { x: 490, y: 3100, z: 40 },- { x: 750, y: 4900, z: 85 },- { x: 420, y: 2600, z: 30 },- { x: 820, y: 5500, z: 100 },- { x: 560, y: 3600, z: 52 },- { x: 710, y: 4700, z: 78 },- { x: 470, y: 2900, z: 38 },- { x: 880, y: 5900, z: 115 },- { x: 530, y: 3400, z: 48 },- { x: 780, y: 5200, z: 92 },- { x: 440, y: 2700, z: 32 },- { x: 920, y: 6200, z: 125 },- { x: 500, y: 3200, z: 42 },- { x: 650, y: 4100, z: 65 },- { x: 480, y: 3000, z: 39 },- { x: 730, y: 4800, z: 80 },- { x: 410, y: 2500, z: 28 },- { x: 850, y: 5700, z: 105 },- { x: 540, y: 3500, z: 50 },- { x: 800, y: 5400, z: 95 },- { x: 460, y: 2850, z: 36 },- ],- },- {- name: "Small Business",- data: [- { x: 200, y: 1200, z: 15 },- { x: 280, y: 1600, z: 22 },- { x: 240, y: 1400, z: 18 },- { x: 320, y: 1900, z: 28 },- { x: 220, y: 1300, z: 16 },- { x: 360, y: 2200, z: 35 },- { x: 180, y: 1100, z: 12 },- { x: 400, y: 2500, z: 45 },- { x: 260, y: 1500, z: 20 },- { x: 340, y: 2100, z: 32 },- { x: 210, y: 1250, z: 15 },- { x: 380, y: 2400, z: 40 },- { x: 250, y: 1450, z: 19 },- { x: 370, y: 2300, z: 38 },- { x: 190, y: 1150, z: 13 },- { x: 420, y: 2700, z: 50 },- { x: 230, y: 1350, z: 17 },- { x: 290, y: 1700, z: 24 },- { x: 205, y: 1220, z: 15 },- { x: 350, y: 2150, z: 34 },- { x: 170, y: 1050, z: 11 },- { x: 390, y: 2450, z: 42 },- { x: 245, y: 1420, z: 18 },- { x: 375, y: 2350, z: 39 },- { x: 195, y: 1180, z: 14 },- ],- },- {- name: "Enterprise Clients",- data: [- { x: 2500, y: 35000, z: 800 },- { x: 2800, y: 38000, z: 900 },- { x: 2200, y: 32000, z: 700 },- { x: 3100, y: 42000, z: 1000 },- { x: 2650, y: 36500, z: 850 },- { x: 3400, y: 46000, z: 1200 },- { x: 2100, y: 30000, z: 650 },- { x: 3600, y: 48000, z: 1300 },- { x: 2750, y: 37500, z: 875 },- { x: 2950, y: 40000, z: 950 },- { x: 2350, y: 33500, z: 750 },- { x: 3750, y: 50000, z: 1400 },- { x: 2900, y: 39500, z: 925 },- { x: 3250, y: 44000, z: 1100 },- { x: 2550, y: 35500, z: 825 },- { x: 3850, y: 52000, z: 1500 },- { x: 2400, y: 34000, z: 775 },- { x: 3050, y: 41000, z: 975 },- { x: 2700, y: 37000, z: 860 },- { x: 3300, y: 45000, z: 1150 },- { x: 2250, y: 31500, z: 675 },- { x: 3500, y: 47000, z: 1250 },- { x: 2850, y: 38500, z: 910 },- { x: 3200, y: 43000, z: 1050 },- { x: 2600, y: 36000, z: 835 },- ],- },- {- name: "Government Contracts",- data: [- { x: 1800, y: 25000, z: 600 },- { x: 2100, y: 28000, z: 700 },- { x: 1650, y: 23000, z: 550 },- { x: 2400, y: 32000, z: 800 },- { x: 1950, y: 26500, z: 650 },- { x: 2700, y: 36000, z: 900 },- { x: 1500, y: 21000, z: 500 },- { x: 2850, y: 38000, z: 950 },- { x: 2250, y: 30000, z: 750 },- { x: 2550, y: 34000, z: 850 },- { x: 1750, y: 24000, z: 575 },- { x: 3000, y: 40000, z: 1000 },- { x: 2150, y: 29000, z: 725 },- { x: 2600, y: 35000, z: 875 },- { x: 1850, y: 25500, z: 625 },- { x: 3100, y: 41000, z: 1025 },- { x: 1700, y: 23500, z: 525 },- { x: 2300, y: 30500, z: 775 },- { x: 2000, y: 27500, z: 675 },- { x: 2750, y: 37000, z: 925 },- { x: 1600, y: 22500, z: 525 },- { x: 2900, y: 39000, z: 975 },- { x: 2200, y: 29500, z: 740 },- { x: 2650, y: 35500, z: 890 },- { x: 1900, y: 26000, z: 640 },- ],- },- ],-};--const icons = {- desktop: Monitor,- mobile: TabletSmartphone,- tablet: Calendar,- series1: Globe,- series2: Smartphone,- revenue: Laptop,- profit: Tv,- performance: Watch,- efficiency: Monitor,-} as const;--/**- * # ScatterChart Component Documentation- *- * The ScatterChart component is designed for visualizing relationships between two continuous variables.- * It's ideal for:- *- * - **Correlation Analysis**: Identifying relationships between variables.- * - **Distribution Analysis**: Understanding data point clustering and outliers.- * - **Comparative Analysis**: Comparing multiple datasets on the same coordinate system.- *- * ## Key Features- *- * ### Interactive & Responsive- * - **Interactive Tooltips**: Hover over points to see detailed data values.- * - **Multiple Datasets**: Support for multiple data series with different colors.- * - **Responsive Design**: Adapts to any container size.- *- * ### Customization- * - **Theming**: Six pre-built color palettes or custom colors.- * - **Shape Options**: Multiple point shapes (circle, diamond, square, etc.).- * - **Axis Configuration**: Customizable axis labels, units, and domains.- */-const meta: Meta<ScatterChartProps> = {- title: "Components/D3Charts/ScatterChart",- component: ScatterChart,- parameters: {- layout: "centered",- docs: {- description: {- component: `-## Installation and Basic Usage--\`\`\`tsx-import { ScatterChart } from '@openuidev/react-ui/Charts/ScatterChart';--const scatterData = [- { x: 100, y: 200, category: "A" },- { x: 120, y: 100, category: "B" },- { x: 170, y: 300, category: "A" },-];--// Basic implementation-<ScatterChart- data={scatterData}- xAxisDataKey="x"- yAxisDataKey="y"- theme="ocean"-/>--// With custom labels and units-<ScatterChart- data={scatterData}- xAxisDataKey="x"- yAxisDataKey="y"- xAxisLabel="Temperature (°C)"- yAxisLabel="Sales ($)"- xAxisUnit="°C"- yAxisUnit="$"-/>-\`\`\`--## Data Structure Requirements--Your data should be an array of objects. Each object must contain:-- **x coordinate** (number): The X-axis value for the point.-- **y coordinate** (number): The Y-axis value for the point.-- One or more **series fields**: Additional fields that define different datasets/series.--\`\`\`tsx-const scatterData = [- { x: 10, y: 20, dataset1: 1, dataset2: 1 },- { x: 15, y: 25, dataset1: 1, dataset2: 1 },- { x: 20, y: 30, dataset1: 1, dataset2: 1 },-];-\`\`\`-`,- },- },- },- tags: ["!dev", "autodocs"],- argTypes: {- data: {- description: `-**Required.** An array of data objects for the scatter chart. Each object should contain:-- x coordinate (number) for the X-axis.-- y coordinate (number) for the Y-axis.-- One or more series identifiers.-`,- control: false,- table: {- type: { summary: "Array<Record<string, string | number>>" },- category: "📊 Data Configuration",- },- },- xAxisDataKey: {- description: "The key in your data object that represents the X-axis values.",- control: "text",- table: {- defaultValue: { summary: "x" },- category: "📊 Data Configuration",- },- },- yAxisDataKey: {- description: "The key in your data object that represents the Y-axis values.",- control: "text",- table: {- defaultValue: { summary: "y" },- category: "📊 Data Configuration",- },- },- theme: {- description: "Specifies the color palette for the chart points and legend.",- control: "select",- options: ["ocean", "orchid", "emerald", "sunset", "spectrum", "vivid"],- table: {- defaultValue: { summary: "ocean" },- category: "🎨 Visual Styling",- },- },- customPalette: {- description: "Custom array of colors to use instead of the theme palette.",- control: "object",- table: {- type: { summary: "string[]" },- category: "🎨 Visual Styling",- },- },- shape: {- description: "The shape of the scatter points.",- control: "select",- options: ["circle", "square"],- table: {- defaultValue: { summary: "circle" },- category: "🎨 Visual Styling",- },- },- grid: {- description: "Toggles the visibility of the background grid lines.",- control: "boolean",- table: {- defaultValue: { summary: "true" },- category: "📱 Display Options",- },- },- legend: {- description: "Toggles the visibility of the chart legend.",- control: "boolean",- table: {- defaultValue: { summary: "true" },- category: "📱 Display Options",- },- },- isAnimationActive: {- description: "Enables or disables the initial loading animation.",- control: "boolean",- table: {- defaultValue: { summary: "false" },- category: "🎬 Animation & Interaction",- },- },- xAxisLabel: {- description: "A label to display below the X-axis.",- control: "text",- table: {- type: { summary: "React.ReactNode" },- category: "📱 Display Options",- },- },- yAxisLabel: {- description: "A label to display beside the Y-axis.",- control: "text",- table: {- type: { summary: "React.ReactNode" },- category: "📱 Display Options",- },- },- className: {- description: "Custom CSS class to apply to the chart's container.",- control: "text",- table: {- type: { summary: "string" },- category: "Layout & Sizing",- },- },- height: {- description: "Sets the height of the chart container.",- control: "number",- table: {- type: { summary: "number" },- category: "Layout & Sizing",- },- },- width: {- description: "Sets the width of the chart container.",- control: "number",- table: {- type: { summary: "number" },- category: "Layout & Sizing",- },- },- },-} satisfies Meta<typeof ScatterChart>;--export default meta;-type Story = StoryObj<typeof meta>;--/**- * ## Basic Scatter Chart- *- * This demonstrates a basic scatter chart with default settings.- * Perfect for showing simple correlations between two variables.- */-export const BasicScatter: Story = {- name: "📈 Basic Scatter Chart",- args: {- data: dataVariations.default,- xAxisDataKey: "x",- yAxisDataKey: "y",- theme: "ocean",- grid: true,- legend: true,- isAnimationActive: true,- showYAxis: true,- showXAxis: true,- shape: "circle",- width: 700,- height: 400,- },- render: (args: any) => <ScatterChart {...args} />,-};--/**- * ## Correlation Analysis- *- * This example shows how to use the scatter chart for correlation analysis.- * Notice how the points follow a general upward trend, indicating positive correlation.- */-export const CorrelationAnalysis: Story = {- name: "📊 Correlation Analysis",- args: {- data: dataVariations.correlation,- xAxisDataKey: "x",- yAxisDataKey: "y",- theme: "emerald",- grid: true,- legend: true,- isAnimationActive: true,- xAxisLabel: "Marketing Spend",- yAxisLabel: "Sales Revenue",- shape: "circle",- },- render: (args: any) => (- <Card style={{ width: "700px" }}>- <ScatterChart {...args} />- </Card>- ),-};--/**- * ## Shape Comparison- *- * Compare different point shapes available in the scatter chart.- * Each shape provides a different visual style for your data points.- */-export const ShapeComparison: Story = {- name: "🔷 Shape Comparison",- args: {- data: dataVariations.default as never,- xAxisDataKey: "x",- yAxisDataKey: "y",- theme: "sunset",- grid: true,- legend: true,- isAnimationActive: false,- },- render: (args: any) => {- const shapes = ["circle", "square"] as const;-- return (- <div style={{ display: "flex", flexDirection: "column", gap: "20px" }}>- {shapes.map((shape) => (- <div key={shape}>- <h4- style={{- margin: "0 0 8px 0",- fontSize: "14px",- fontWeight: "600",- textTransform: "capitalize",- }}- >- {shape} Shape- </h4>- <Card style={{ width: "500px", height: "600px" }}>- <ScatterChart {...args} shape={shape} height={"100%"} />- </Card>- </div>- ))}- </div>- );- },-};--/**- * ## Data Explorer- *- * Interactive tool for exploring different scatter chart datasets.- * Use the buttons to switch between various data scenarios.- */-export const DataExplorer: Story = {- name: "🎛️ Data Explorer",- args: {- data: dataVariations.default as never,- xAxisDataKey: "x",- yAxisDataKey: "y",- theme: "ocean",- grid: true,- legend: true,- isAnimationActive: true,- shape: "circle",- },- render: (args: any) => {- const [selectedDataType, setSelectedDataType] =- useState<keyof typeof dataVariations>("default");-- const currentData = dataVariations[selectedDataType];-- const buttonStyle = {- margin: "2px",- padding: "6px 12px",- fontSize: "12px",- border: "1px solid #ddd",- borderRadius: "4px",- cursor: "pointer",- background: "#fff",- fontFamily: "monospace",- };-- const activeButtonStyle = {- ...buttonStyle,- background: "#007acc",- color: "white",- border: "1px solid #007acc",- };-- return (- <div>- <div- style={{- marginBottom: "16px",- padding: "12px",- background: "#f8f9fa",- borderRadius: "8px",- border: "1px solid #e9ecef",- width: "600px",- }}- >- <strong>📈 Scatter Chart Test Suite:</strong>- <div style={{ marginTop: "8px", display: "flex", flexWrap: "wrap", gap: "4px" }}>- <button- onClick={() => setSelectedDataType("default")}- style={selectedDataType === "default" ? activeButtonStyle : buttonStyle}- >- 📊 Default- </button>- <button- onClick={() => setSelectedDataType("correlation")}- style={selectedDataType === "correlation" ? activeButtonStyle : buttonStyle}- >- 📈 Correlation- </button>- <button- onClick={() => setSelectedDataType("multipleDatasets")}- style={selectedDataType === "multipleDatasets" ? activeButtonStyle : buttonStyle}- >- 🎯 Multiple Datasets- </button>- <button- onClick={() => setSelectedDataType("performance")}- style={selectedDataType === "performance" ? activeButtonStyle : buttonStyle}- >- ⚡ Performance- </button>- <button- onClick={() => setSelectedDataType("comprehensive")}- style={selectedDataType === "comprehensive" ? activeButtonStyle : buttonStyle}- >- 🌍 Comprehensive- </button>- </div>- </div>- <Card style={{ width: "600px" }}>- <ScatterChart {...args} data={currentData} height={"600px"} />- </Card>- </div>- );- },-};diff --git a/packages/react-ui/src/components/D3Charts/SegmentedBar/index.ts b/packages/react-ui/src/components/D3Charts/SegmentedBar/index.tsdeleted file mode 100644index e831545de..000000000--- a/packages/react-ui/src/components/D3Charts/SegmentedBar/index.ts+++ /dev/null@@ -1,2 +0,0 @@-export { SegmentedBar } from "./SegmentedBar";-export type { SegmentedBarData, SegmentedBarProps } from "./types";diff --git a/packages/react-ui/src/components/D3Charts/SegmentedBar/stories/SingleStackedBarChart.stories.tsx b/packages/react-ui/src/components/D3Charts/SegmentedBar/stories/SingleStackedBarChart.stories.tsxdeleted file mode 100644index 5dcf79af1..000000000--- a/packages/react-ui/src/components/D3Charts/SegmentedBar/stories/SingleStackedBarChart.stories.tsx+++ /dev/null@@ -1,426 +0,0 @@-// Copy of Charts/SingleStackedBarChart/stories/SingleStackedBarChart.stories.tsx with only the chart import and the title changed:-// the same args and renders, rendering the D3Charts chart via-// ../../stories/rechartsStoryAdapters.-import type { Meta, StoryObj } from "@storybook/react";-import { Card } from "../../../Card";-import { SingleStackedBar, SingleStackedBarProps } from "../../stories/rechartsStoryAdapters";--const meta: Meta<SingleStackedBarProps<any>> = {- title: "Components/D3Charts/SingleStackedBar",- component: SingleStackedBar,- parameters: {- layout: "centered",- docs: {- description: {- component: `-// Note: While the component is named 'ProgressBar', it's presented here as a 'SingleStackedBar'-// to emphasize its use for showing proportional data, much like a pie chart.-## Installation and Basic Usage--\`\`\`tsx-import { SingleStackedBar } from '@openuidev/react-ui/Charts/SingleStackedBar';--// Basic implementation-<SingleStackedBar- data={[- { category: 'A', value: 25 },- { category: 'B', value: 30 },- { category: 'C', value: 20 }- ]}- categoryKey="category"- dataKey="value"- theme="ocean"- legend={true}-/>-\`\`\`--## Data Structure Requirements--The data should be an array of objects with consistent property names. Use \`categoryKey\` to specify which property contains the segment labels, and \`dataKey\` to specify which property contains the numeric values.--\`\`\`tsx-// Example data structure-const data = [- { category: 'Desktop', value: 45 },- { category: 'Mobile', value: 35 },- { category: 'Tablet', value: 20 }-];--// Component usage-<SingleStackedBar- data={data}- categoryKey="category"- dataKey="value"-/>-\`\`\`--## Key Features--- **Segmented Display**: Visualize the composition of a whole.-- **Theming**: Six built-in color palettes.-- **Animation**: Smoothly animates the bar segments.-- **Legend Support**: Optional legend with category names and colors.-- **Responsive**: Adapts to the width of its container.-`,- },- },- },- tags: ["dev", "autodocs"],- argTypes: {- data: {- description: `-**Required.** An array of objects where each object contains category and value information.-The component extracts values using the specified \`dataKey\` and calculates proportional widths.--**Example:** \`[{ category: 'A', value: 20 }, { category: 'B', value: 30 }, { category: 'C', value: 15 }]\`-`,- control: false,- table: {- type: { summary: "Array<Record<string, string | number>>" },- defaultValue: { summary: "[]" },- category: "📊 Data Configuration",- },- },- categoryKey: {- description: `-**Required.** The property name in each data object that contains the segment labels/categories.-This value will be displayed in tooltips and used for accessibility.--**Example:** \`'category'\` or \`'name'\`-`,- control: "text",- table: {- type: { summary: "string" },- category: "📊 Data Configuration",- },- },- dataKey: {- description: `-**Required.** The property name in each data object that contains the numeric values.-These values determine the proportional width of each segment.--**Example:** \`'value'\` or \`'count'\` or \`'percentage'\`-`,- control: "text",- table: {- type: { summary: "string" },- category: "📊 Data Configuration",- },- },- theme: {- description: `-**Color Theme Selection.** Choose from professionally designed color palettes:--- **ocean**: Cool blues and teals-- **orchid**: Purple and pink tones-- **emerald**: Green variations-- **sunset**: Warm oranges and reds-- **spectrum**: Full color range-- **vivid**: High-contrast colors-`,- control: "select",- options: ["ocean", "orchid", "emerald", "sunset", "spectrum", "vivid"],- table: {- defaultValue: { summary: "ocean" },- category: "🎨 Visual Styling",- },- },- animated: {- description: `-**Animation Control.** Enables or disables the fill animation on load.-`,- control: "boolean",- table: {- type: { summary: "boolean" },- defaultValue: { summary: "true" },- category: "🎬 Animation & Interaction",- },- },- legend: {- description: `-**Legend Display.** Shows or hides the legend below the single stacked bar chart.-The legend displays category names with their corresponding colors.-`,- control: "boolean",- table: {- type: { summary: "boolean" },- defaultValue: { summary: "false" },- category: "📊 Data Configuration",- },- },- legendVariant: {- description: `-**Legend Variant.** Choose between default (inline) and stacked (vertical) legend.-Stacked legend appears at the bottom and shows values as percentages.-`,- control: "radio",- options: ["default", "stacked"],- table: {- type: { summary: '"default" | "stacked"' },- defaultValue: { summary: "default" },- category: "📱 Display Options",- },- },- },-} satisfies Meta<typeof SingleStackedBar>;--export default meta;-type Story = StoryObj<typeof meta>;--const sampleData = {- default: [- { category: "A", value: 25 },- { category: "B", value: 30 },- { category: "C", value: 20 },- ],- many: [- { category: "Item 1", value: 10 },- { category: "Item 2", value: 8 },- { category: "Item 3", value: 12 },- { category: "Item 4", value: 5 },- { category: "Item 5", value: 15 },- { category: "Item 6", value: 7 },- { category: "Item 7", value: 13 },- { category: "Item 8", value: 10 },- ],- full: [- { category: "Q1", value: 25 },- { category: "Q2", value: 25 },- { category: "Q3", value: 25 },- { category: "Q4", value: 25 },- ],-};--export const DefaultConfiguration: Story = {- name: "📊 Default Configuration",- args: {- data: sampleData.default,- categoryKey: "category",- dataKey: "value",- theme: "ocean",- animated: true,- },- render: (args: any) => (- <Card style={{ width: "400px", padding: "24px" }}>- <div style={{ marginBottom: "16px" }}>- <h3 style={{ margin: "0 0 8px 0", fontSize: "16px", fontWeight: "600" }}>- Category Breakdown- </h3>- <p style={{ margin: 0, color: "#666", fontSize: "14px" }}>- Visualizing the breakdown of a dataset into its constituent parts.- </p>- </div>- <SingleStackedBar {...args} />- </Card>- ),- parameters: {- docs: {- description: {- story:- "This is the standard appearance of the Single Stacked Bar. It shows multiple segments, each with a color from the selected theme, representing the proportional breakdown of a whole.",- },- },- },-};--export const ThemeShowcase: Story = {- name: "🎨 Theme Showcase",- args: {- data: [- { category: "Segment 1", value: 15 },- { category: "Segment 2", value: 20 },- { category: "Segment 3", value: 25 },- { category: "Segment 4", value: 15 },- ],- categoryKey: "category",- dataKey: "value",- animated: true,- },- render: (args: any) => (- <div style={{ width: "400px", display: "flex", flexDirection: "column", gap: "24px" }}>- {(["ocean", "orchid", "emerald", "sunset", "spectrum", "vivid"] as const).map((theme) => (- <div key={theme}>- <h4- style={{- marginBottom: "12px",- textTransform: "capitalize",- fontSize: "14px",- fontWeight: 600,- }}- >- {theme}- </h4>- <SingleStackedBar {...args} theme={theme} />- </div>- ))}- </div>- ),- parameters: {- docs: {- description: {- story:- "The Single Stacked Bar supports six different color themes. This allows it to fit seamlessly into various application designs and visual identities.",- },- },- },-};--export const ManySegments: Story = {- name: "🧩 Many Segments",- args: {- data: sampleData.many,- categoryKey: "category",- dataKey: "value",- theme: "vivid",- animated: true,- },- render: (args: any) => (- <Card style={{ width: "500px", padding: "24px" }}>- <div style={{ marginBottom: "16px" }}>- <h3 style={{ margin: "0 0 8px 0", fontSize: "16px", fontWeight: "600" }}>- Resource Distribution- </h3>- <p style={{ margin: 0, color: "#666", fontSize: "14px" }}>- The component gracefully handles numerous small segments.- </p>- </div>- <SingleStackedBar {...args} />- </Card>- ),- parameters: {- docs: {- description: {- story:- "The Single Stacked Bar can display many segments. The colors will cycle through the selected theme palette if the number of segments exceeds the number of available colors.",- },- },- },-};--export const FullComposition: Story = {- name: "✅ Full Composition",- args: {- data: sampleData.full,- categoryKey: "category",- dataKey: "value",- theme: "spectrum",- animated: false,- },- render: (args: any) => (- <Card style={{ width: "400px", padding: "24px" }}>- <div style={{ marginBottom: "16px" }}>- <h3 style={{ margin: "0 0 8px 0", fontSize: "16px", fontWeight: "600" }}>- Complete Data Set- </h3>- <p style={{ margin: 0, color: "#666", fontSize: "14px" }}>- Displaying a bar where segments add up to 100%.- </p>- </div>- <SingleStackedBar {...args} />- </Card>- ),- parameters: {- docs: {- description: {- story:- "This example shows a bar where the segments add up to 100%. The segments collectively fill the entire width of the container, representing the full composition of the data.",- },- },- },-};--export const WithLegend: Story = {- name: "📊 With Legend",- args: {- data: sampleData.default,- categoryKey: "category",- dataKey: "value",- theme: "ocean",- animated: true,- legend: true,- legendVariant: "default",- },- render: (args: any) => (- <Card style={{ width: "500px", padding: "24px" }}>- <div style={{ marginBottom: "16px" }}>- <h3 style={{ margin: "0 0 8px 0", fontSize: "16px", fontWeight: "600" }}>- Category Breakdown with Legend- </h3>- <p style={{ margin: 0, color: "#666", fontSize: "14px" }}>- Visualizing the breakdown with a legend that shows category names and colors. The legend- automatically expands when there are many items.- </p>- </div>- <SingleStackedBar {...args} />- </Card>- ),- parameters: {- docs: {- description: {- story:- "This example demonstrates the SingleStackedBar with legend enabled. The legend displays below the chart and shows the category names with their corresponding colors. For larger datasets, the legend will show a 'Show More' button to expand and see all items.",- },- },- },-};--export const LegendWithManyItems: Story = {- name: "🧩 Legend with Many Items",- args: {- data: sampleData.many,- categoryKey: "category",- dataKey: "value",- theme: "vivid",- animated: true,- legend: true,- legendVariant: "default",- },- render: (args: any) => (- <Card style={{ width: "600px", padding: "24px" }}>- <div style={{ marginBottom: "16px" }}>- <h3 style={{ margin: "0 0 8px 0", fontSize: "16px", fontWeight: "600" }}>- Resource Distribution with Legend- </h3>- <p style={{ margin: 0, color: "#666", fontSize: "14px" }}>- The component handles many segments gracefully with the legend showing category names and- values. The legend automatically manages overflow with expand/collapse functionality.- </p>- </div>- <SingleStackedBar {...args} />- </Card>- ),- parameters: {- docs: {- description: {- story:- "This example shows how the SingleStackedBar handles many segments with legend enabled. The legend automatically shows a 'Show More' button when items don't fit in the available space, providing a clean way to manage large datasets.",- },- },- },-};--export const StackedLegendVariant: Story = {- name: "📚 Stacked Legend (Bottom)",- args: {- data: sampleData.many,- categoryKey: "category",- dataKey: "value",- theme: "ocean",- animated: true,- legend: true,- legendVariant: "stacked",- },- render: (args: any) => (- <Card style={{ width: "650px", padding: "24px" }}>- <div style={{ marginBottom: "16px" }}>- <h3 style={{ margin: "0 0 8px 0", fontSize: "16px", fontWeight: "600" }}>- Stacked Legend at Bottom- </h3>- <p style={{ margin: 0, color: "#666", fontSize: "14px" }}>- Displays a vertical legend beneath the bar with percentage values and overflow handling.- </p>- </div>- <SingleStackedBar {...args} />- </Card>- ),-};diff --git a/packages/react-ui/src/components/D3Charts/d3Charts.scss b/packages/react-ui/src/components/D3Charts/d3Charts.scssdeleted file mode 100644index e2d074910..000000000--- a/packages/react-ui/src/components/D3Charts/d3Charts.scss+++ /dev/null@@ -1,18 +0,0 @@-@forward "./AreaChart/areaChart";-@forward "./LineChart/lineChart";-@forward "./BarChart/barChart";-@forward "./BarChart/horizontalBarChart";-@forward "./PieChart/pieChart";-@forward "./RadialChart/radialChart";-@forward "./RadarChart/radarChart";-@forward "./ScatterChart/scatterChart";-@forward "./HeatmapChart/heatmapChart";-@forward "./FunnelChart/funnelChart";-@forward "./CalendarHeatmap/calendarHeatmap";-@forward "./SegmentedBar/segmentedBar";-@forward "./shared/mini/miniChart";-@forward "./shared/core/PortalTooltip/portalTooltip";-@forward "./shared/core/DefaultLegend/defaultLegend";-@forward "./shared/core/StackedLegend/stackedLegend";-@forward "./shared/cartesian/ScrollButtonsHorizontal/scrollButtonsHorizontal";-@forward "./shared/cartesian/ScrollButtonsVertical/scrollButtonsVertical";diff --git a/packages/react-ui/src/components/D3Charts/hooks/index.ts b/packages/react-ui/src/components/D3Charts/hooks/index.tsdeleted file mode 100644index bd686f96d..000000000--- a/packages/react-ui/src/components/D3Charts/hooks/index.ts+++ /dev/null@@ -1,3 +0,0 @@-export * from "./cartesian";-export * from "./core";-export * from "./polar";diff --git a/packages/react-ui/src/components/D3Charts/index.ts b/packages/react-ui/src/components/D3Charts/index.tsdeleted file mode 100644index afbfd8bce..000000000--- a/packages/react-ui/src/components/D3Charts/index.ts+++ /dev/null@@ -1,65 +0,0 @@-export { AreaChart } from "./AreaChart";-export type { AreaChartData, AreaChartProps, AreaChartVariant } from "./AreaChart/types";--export { LineChart } from "./LineChart";-export type { LineChartData, LineChartProps, LineChartVariant } from "./LineChart/types";--export { BarChart } from "./BarChart";-export type {- BarChartData,- BarChartOrientation,- BarChartProps,- BarChartVariant,-} from "./BarChart/types";--export { PieChart } from "./PieChart";-export type { PieChartData, PieChartProps } from "./PieChart/types";--export { RadialChart } from "./RadialChart";-export type { RadialChartData, RadialChartProps } from "./RadialChart/types";--export { RadarChart } from "./RadarChart";-export type { RadarChartData, RadarChartProps } from "./RadarChart/types";--export { ScatterChart } from "./ScatterChart";-export type {- ScatterChartData,- ScatterChartProps,- ScatterDataset,- ScatterPoint,-} from "./ScatterChart/types";--export { HeatmapChart } from "./HeatmapChart";-export type { HeatmapChartData, HeatmapChartProps } from "./HeatmapChart/types";--export { FunnelChart } from "./FunnelChart";-export type {- FunnelChartData,- FunnelChartProps,- FunnelEdges,- FunnelOrientation,-} from "./FunnelChart/types";--export { SegmentedBar } from "./SegmentedBar";-export type { SegmentedBarData, SegmentedBarProps } from "./SegmentedBar/types";--export { CalendarHeatmap } from "./CalendarHeatmap";-export type { CalendarHeatmapDatum, CalendarHeatmapProps } from "./CalendarHeatmap/types";--export { MiniAreaChart } from "./MiniAreaChart";-export type { MiniAreaChartData, MiniAreaChartProps } from "./MiniAreaChart/types";--export { MiniBarChart } from "./MiniBarChart";-export type { MiniBarChartData, MiniBarChartProps } from "./MiniBarChart/types";--export { MiniLineChart } from "./MiniLineChart";-export type { MiniLineChartData, MiniLineChartProps } from "./MiniLineChart/types";--export { LegendStoreProvider, useLegendEntry } from "./shared/core/legend";-export type { LegendEntry, StackedLegendItem } from "./shared/core/legend";-export { StackedLegend } from "./shared/core/StackedLegend";-export type { StackedLegendProps } from "./shared/core/StackedLegend";--export type { BaseChartProps, ChartData, LegendItem, XAxisTickVariant } from "./types";--export { CHART_CLASS_PREFIX } from "./utils/constants";diff --git a/packages/react-ui/src/components/D3Charts/stories/rechartsStoryAdapters.tsx b/packages/react-ui/src/components/D3Charts/stories/rechartsStoryAdapters.tsxdeleted file mode 100644index 64212b75e..000000000--- a/packages/react-ui/src/components/D3Charts/stories/rechartsStoryAdapters.tsx+++ /dev/null@@ -1,110 +0,0 @@-// The Recharts chart names, typed with the Recharts props, each rendering the-// D3Charts chart that replaces it. The stories under D3Charts/*/stories are-// copies of the Recharts chart stories that import these instead of the-// Recharts charts — same args, same renders — so every Recharts story renders-// the D3 charts with its props unchanged. Props a D3 chart doesn't take are-// passed through and ignored.-import type {- AreaChartCondensedProps,- AreaChartData,- AreaChartProps,- BarChartCondensedProps,- BarChartData,- BarChartProps,- HorizontalBarChartData,- HorizontalBarChartProps,- LineChartCondensedProps,- LineChartData,- LineChartProps,- MiniAreaChartProps,- MiniBarChartProps,- MiniLineChartProps,- PieChartData,- PieChartProps,- RadarChartData,- RadarChartProps,- RadialChartData,- RadialChartProps,- ScatterChartProps,- SingleStackedBarData,- SingleStackedBarProps,-} from "../../Charts";-import { AreaChart as D3AreaChart } from "../AreaChart";-import { BarChart as D3BarChart } from "../BarChart";-import { LineChart as D3LineChart } from "../LineChart";-import { MiniAreaChart as D3MiniAreaChart } from "../MiniAreaChart";-import { MiniBarChart as D3MiniBarChart } from "../MiniBarChart";-import { MiniLineChart as D3MiniLineChart } from "../MiniLineChart";-import { PieChart as D3PieChart } from "../PieChart";-import { RadarChart as D3RadarChart } from "../RadarChart";-import { RadialChart as D3RadialChart } from "../RadialChart";-import { ScatterChart as D3ScatterChart } from "../ScatterChart";-import { SegmentedBar } from "../SegmentedBar";--export type {- AreaChartCondensedProps,- AreaChartProps,- BarChartCondensedProps,- BarChartProps,- HorizontalBarChartProps,- LineChartCondensedProps,- LineChartProps,- MiniBarChartProps,- PieChartProps,- RadarChartProps,- RadialChartProps,- ScatterChartProps,- SingleStackedBarProps,-};--export const AreaChart = <T extends AreaChartData>(props: AreaChartProps<T>) => (- <D3AreaChart {...(props as any)} />-);--export const AreaChartCondensed = <T extends AreaChartData>(props: AreaChartCondensedProps<T>) => (- <D3AreaChart {...(props as any)} condensed />-);--export const BarChart = <T extends BarChartData>(props: BarChartProps<T>) => (- <D3BarChart {...(props as any)} />-);--export const BarChartCondensed = <T extends BarChartData>(props: BarChartCondensedProps<T>) => (- <D3BarChart {...(props as any)} condensed />-);--export const HorizontalBarChart = <T extends HorizontalBarChartData>(- props: HorizontalBarChartProps<T>,-) => <D3BarChart {...(props as any)} orientation="horizontal" />;--export const LineChart = <T extends LineChartData>(props: LineChartProps<T>) => (- <D3LineChart {...(props as any)} />-);--export const LineChartCondensed = <T extends LineChartData>(props: LineChartCondensedProps<T>) => (- <D3LineChart {...(props as any)} condensed />-);--export const PieChart = <T extends PieChartData>(props: PieChartProps<T>) => (- <D3PieChart {...(props as any)} />-);--export const RadarChart = <T extends RadarChartData>(props: RadarChartProps<T>) => (- <D3RadarChart {...(props as any)} />-);--export const RadialChart = <T extends RadialChartData>(props: RadialChartProps<T>) => (- <D3RadialChart {...(props as any)} />-);--export const ScatterChart = (props: ScatterChartProps) => <D3ScatterChart {...(props as any)} />;--export const SingleStackedBar = <T extends SingleStackedBarData>(- props: SingleStackedBarProps<T>,-) => <SegmentedBar {...(props as any)} />;--export const MiniAreaChart = (props: MiniAreaChartProps) => <D3MiniAreaChart {...(props as any)} />;--export const MiniBarChart = (props: MiniBarChartProps) => <D3MiniBarChart {...(props as any)} />;--export const MiniLineChart = (props: MiniLineChartProps) => <D3MiniLineChart {...(props as any)} />;diff --git a/packages/react-ui/src/components/D3Charts/types/common.ts b/packages/react-ui/src/components/D3Charts/types/common.tsdeleted file mode 100644index f441914d9..000000000--- a/packages/react-ui/src/components/D3Charts/types/common.ts+++ /dev/null@@ -1,88 +0,0 @@-export interface LegendItem {- key: string;- label: string;- color: string;- icon?: React.ComponentType;- percentage?: number;-}--export type XAxisTickVariant = "singleLine" | "multiLine" | "angled";--export type ChartData = Array<Record<string, string | number>>;--export interface BaseChartProps<T extends ChartData> {- data: T;- categoryKey: keyof T[number];- customPalette?: string[];- /**- * How the x-axis category labels are drawn. The label band never takes more- * than half the chart's height; labels that don't fit are truncated with an- * ellipsis and show their full text on hover.- * - `"singleLine"`: one horizontal line. Default when `condensed`.- * - `"multiLine"`: wraps onto up to three lines. Default otherwise.- * - `"angled"`: rotates labels 45° when they don't fit horizontally.- * `condensed` only; the scrolling layout draws it as `"singleLine"`.- */- tickVariant?: XAxisTickVariant;- grid?: boolean;- /**- * Show the legend. NOTE: `xAxisLabel`/`yAxisLabel` render inside the legend- * strip, so `legend={false}` hides them too.- */- legend?: boolean;- icons?: Partial<Record<keyof T[number], React.ComponentType>>;- /**- * Play the entrance animation. Gates the entrance ONLY — any hover or- * data-update motion is independent of this flag, and printing always- * disables it.- * Default false (streaming-safe: marks mounted while data streams in don't- * replay staggered entrances).- */- isAnimationActive?: boolean;- showYAxis?: boolean;- /** Axis caption — rendered in the legend strip (hidden when `legend` is false). */- xAxisLabel?: React.ReactNode;- yAxisLabel?: React.ReactNode;- className?: string;- height?: number | string;- width?: number | string;- /** When true, legend height is subtracted from container height so chart + legend- * fit within specified dimensions. Defaults to true when `height` is set, false otherwise. */- fitLegendInHeight?: boolean;- /** When true, all data fits within the container width (no scrolling). Default false. */- condensed?: boolean;- /** Controls spacing between data points in scrollable mode. Default "default". */- density?: "compact" | "default" | "spacious";- /**- * Hint for the number of y-axis ticks (and the matching horizontal- * gridlines — they share the y-scale, so this drives both in lockstep).- * d3 treats it as a target and picks nice round values near it, so the- * rendered count can differ from the number given; the value is floored at 2.- * Default: derived from chart height (~1 tick per 40px).- *- * Vertical orientation only. The horizontal BarChart's value axis is the- * X axis and ignores this prop for now.- */- yTickCount?: number;-}--/**- * Toggles for the hover overlay on line/area charts. Each element toggles- * independently: `activeDots` defaults `true`, while `crosshair` and `highlight`- * default `false` (opt-in — the gliding line and the traveling curve highlight- * are off unless asked for).- * Plain booleans for now — they can widen to a config object- * (e.g. `boolean | {...}`) later without breaking.- */-export interface HoverOverlayProps {- /** The vertical crosshair line that tracks the hovered x. Default `false` for- * Line/Area — pass `crosshair` to turn it on. */- crosshair?: boolean;- /** The highlight segment — a brighter slice of the curve that travels along it- * around the hovered point. Default `false` for Line/Area — pass `highlight`- * to turn it on. */- highlight?: boolean;- /** The dots that ride the curve at the hovered point, one per series. Distinct from- * the static series dots (`showDots`/`dotRadius`). Default `true`. */- activeDots?: boolean;-}diff --git a/packages/react-ui/src/components/D3Charts/types/index.ts b/packages/react-ui/src/components/D3Charts/types/index.tsdeleted file mode 100644index 6b5716089..000000000--- a/packages/react-ui/src/components/D3Charts/types/index.ts+++ /dev/null@@ -1 +0,0 @@-export * from "./common";diff --git a/packages/react-ui/src/components/D3Charts/utils/dataUtils.ts b/packages/react-ui/src/components/D3Charts/utils/dataUtils.tsdeleted file mode 100644index 2c294b326..000000000--- a/packages/react-ui/src/components/D3Charts/utils/dataUtils.ts+++ /dev/null@@ -1,50 +0,0 @@-import { LegendItem } from "../types";--export interface ChartConfig {- [key: string]: {- label: string;- icon?: React.ComponentType;- color?: string;- transformed?: string;- };-}--export const getDataKeys = (- data: Array<Record<string, string | number>>,- categoryKey: string,-): string[] => {- return Object.keys(data[0] || {}).filter((key) => key !== categoryKey);-};--export const get2dChartConfig = (- dataKeys: string[],- colors: string[],- transformedKeys: Record<string, string>,- icons?: Partial<Record<string | number, React.ComponentType>>,-): ChartConfig => {- return dataKeys.reduce(- (config, key, index) => ({- ...config,- [key]: {- label: key,- icon: icons?.[key],- color: colors[index],- transformed: transformedKeys[key],- },- }),- {},- );-};--export const getLegendItems = (- dataKeys: string[],- colors: string[],- icons?: Partial<Record<string | number, React.ComponentType>>,-): LegendItem[] => {- return dataKeys.map((key, index) => ({- key,- label: key,- color: colors[index] ?? "#000000",- icon: icons?.[key] as React.ComponentType | undefined,- }));-};diff --git a/packages/react-ui/src/components/D3Charts/utils/styleUtils.ts b/packages/react-ui/src/components/D3Charts/utils/styleUtils.tsdeleted file mode 100644index c76566764..000000000--- a/packages/react-ui/src/components/D3Charts/utils/styleUtils.ts+++ /dev/null@@ -1,45 +0,0 @@-const numberTickFormatter = (value: number) => {- if (typeof value === "number") {- const absValue = Math.abs(value);-- if (absValue >= 1e12) {- return (value / 1e12).toFixed(absValue >= 10e12 ? 0 : 1) + "T";- } else if (absValue >= 1e9) {- return (value / 1e9).toFixed(absValue >= 10e9 ? 0 : 1) + "B";- } else if (absValue >= 1e6) {- return (value / 1e6).toFixed(absValue >= 10e6 ? 0 : 1) + "M";- } else if (absValue >= 1e3) {- return (value / 1e3).toFixed(absValue >= 10e3 ? 0 : 1) + "K";- } else {- if (value % 1 !== 0) {- return value.toFixed(2);- }- return value.toString();- }- }- return String(value);-};--const DEFAULT_MIN_Y_AXIS_WIDTH = 20;-const DEFAULT_MAX_Y_AXIS_WIDTH = 200;-const DEFAULT_Y_AXIS_PADDING = 10;--const measureYAxisWidth = (- ticks: number[],- context: CanvasRenderingContext2D,- options?: { minWidth?: number; maxWidth?: number; padding?: number },-): number => {- const minWidth = options?.minWidth ?? DEFAULT_MIN_Y_AXIS_WIDTH;- const maxWidth = options?.maxWidth ?? DEFAULT_MAX_Y_AXIS_WIDTH;- const padding = options?.padding ?? DEFAULT_Y_AXIS_PADDING;-- let maxTextWidth = 0;- for (const tick of ticks) {- const w = context.measureText(numberTickFormatter(tick)).width;- if (w > maxTextWidth) maxTextWidth = w;- }-- return Math.max(minWidth, Math.min(maxWidth, Math.ceil(maxTextWidth) + padding));-};--export { measureYAxisWidth, numberTickFormatter };diff --git a/packages/react-ui/src/components/ThemeProvider/__tests__/ThemeProvider.test.tsx b/packages/react-ui/src/components/ThemeProvider/__tests__/ThemeProvider.test.tsxindex 4c6c0942a..d4f7b8023 100644--- a/packages/react-ui/src/components/ThemeProvider/__tests__/ThemeProvider.test.tsx+++ b/packages/react-ui/src/components/ThemeProvider/__tests__/ThemeProvider.test.tsx@@ -1,6 +1,6 @@import { renderToString } from "react-dom/server";import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";-import { useChartPalette } from "../../Charts/utils/PalletUtils";+import { useChartPalette } from "../../Charts/utils/paletteUtils";import { defaultDarkTheme, defaultLightTheme } from "../defaultTheme";import { ThemeProvider, useTheme } from "../ThemeProvider";import type { ChartColorPalette, Theme } from "../types";@@ -103,13 +103,11 @@ describe("chart palette flow (theme -> useTheme -> useChartPalette)", () => {themeFromContext = theme;// Exactly what BarChart does.barColors = useChartPalette({- chartThemeName: "ocean",themePaletteName: "barChartPalette",dataLength: 2,});// lineChartPalette is not set -> must fall back to defaultChartPalette.lineColors = useChartPalette({- chartThemeName: "ocean",themePaletteName: "lineChartPalette",dataLength: 2,});diff --git a/packages/react-ui/src/components/index.scss b/packages/react-ui/src/components/index.scssindex fce173441..c8986403f 100644--- a/packages/react-ui/src/components/index.scss+++ b/packages/react-ui/src/components/index.scss@@ -22,7 +22,6 @@@forward "./CodeBlock/codeBlock.scss";@forward "./CompositeCardBlock/compositeCardBlock.scss";@forward "./ContextCardBlock/contextCardBlock.scss";-@forward "./D3Charts/d3Charts.scss";@forward "./DatePicker/datePicker.scss";@forward "./DotMatrixLoader/dotMatrixLoader.scss";@forward "./EditableTable/editableTable.scss";diff --git a/packages/react-ui/src/index.ts b/packages/react-ui/src/index.tsindex 90625ed22..eabdfa44e 100644--- a/packages/react-ui/src/index.ts+++ b/packages/react-ui/src/index.ts@@ -71,7 +71,6 @@ export * from "./components/Card";export * from "./components/CardHeader";export * from "./components/Carousel";export * from "./components/Charts";-export type { ExportChartData } from "./components/Charts/Charts";export * from "./components/CheckBoxGroup";export * from "./components/CheckBoxItem";export * from "./components/Chips";diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex 3ade92a3e..83471e93a 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -757,9 +757,6 @@ importers:react-syntax-highlighter:specifier: ^16.1.1version: 16.1.1([email protected])- recharts:- specifier: ^2.15.4rehype-katex:specifier: ^7.0.1version: 7.0.1@@ -6756,9 +6753,6 @@ packages:supports-color:optional: true- resolution: {integrity: sha512-qIMFpTMZmny+MMIitAB6D7iVPEorVw6YQRWkvarTkT4tBeSLLiHzcwj6q0MmYSFCiVpiqPJTJEYIrpcPzVEIvg==}-resolution: {integrity: sha512-YpgQiITW3JXGntzdUmyUR1V812Hn8T1YVXhCu+wO3OpS4eU9l4YdD3qjyiKdV6mvV29zapkMeD390UVEf2lkUg==}@@ -6862,9 +6856,6 @@ packages:resolution: {integrity: sha512-7ZgogeTnjuHbo+ct10G9Ffp0mif17idi0IyWNVA/wcwcm7NPOD/WEHVP3n7n3MhXqxoIYm8d6MuZohYWIZ4T3w==}- resolution: {integrity: sha512-nRCa7CK3VTrM2NmGkIy4cbK7IZlgBE/PYMn55rrXefr5xXDP0LdtfPnblFDoVdcAfslJ7or6iqAUnx0CCGIWQA==}-resolution: {integrity: sha512-wIkAryiqt/nV5EQKqQpo3SToSOV9J0DnbJqwK7Wv/Trc92zIAYZ4FlMu+JPFW1DfGFt81ZTCGgDEabffXeLyJg==}@@ -7359,10 +7350,6 @@ packages:resolution: {integrity: sha512-VxPP4NqbUjj6MaAOafWeUn2cXWLcCtljklUtZf0Ind4XQ+QPtmA0b18zZy0jIQx+ExRVCR/ZQpBmik5lXshNsw==}- resolution: {integrity: sha512-DjlFSM5Pk9cGcL0q5QXl66eGzx0N6szNgaswwc5ZphlBohjTVJSnGgI+rJVOgOi65qUoQnDZN4nDqi33udtydQ==}- engines: {node: '>=6.0.0'}-resolution: {integrity: sha512-kNFPyjhh5cKjrUltxs+wFx+ZkbRaxxmZ+X0ZU31SOsxCEtP9VPgtq2teZw1DebupL5GmDaNQ6yKMMVcM41iqDg==}engines: {node: '>=8.6.0'}@@ -9657,9 +9644,6 @@ packages:resolution: {integrity: sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w==}- resolution: {integrity: sha512-/LLMVyas0ljjAtoYiPqYiL8VWXzUUdThrmU5+n20DZv+a+ClRoevUzw5JxU+Ieh5/c87ytoTBV9G1FiKfNJdmg==}-resolution: {integrity: sha512-qKxVopLT/TyA6BX3Ue5NwabOsAzm0Q7kAPwq6L+wWDwisYs7R8vZ0nRXqq6rkueboxpkjvLGU9fWifiX/ZZFxQ==}peerDependencies:@@ -9695,12 +9679,6 @@ packages:react: ^18.0.0 || ^19.0.0react-dom: ^18.0.0 || ^19.0.0- resolution: {integrity: sha512-gnGKTpYwqL0Iii09gHobNolvX4Kiq4PKx6eWBCYYix+8cdw+cGo3do906l1NBPKkSWx1DghC1dlWG9L2uGd61Q==}- peerDependencies:- react: ^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0- react-dom: ^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0-resolution: {integrity: sha512-b6jSvxvVnyptAiLjbkWLE/lOnR4lfTtDAl+eUC7RZy+QQWc6wRzIV2CE6xBuMmDxc2qIihtDCZD5NPOFl7fRBQ==}engines: {node: '>=10'}@@ -9723,12 +9701,6 @@ packages:peerDependencies:react: ^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0- resolution: {integrity: sha512-pZcd1MCJoiKiBR2NRxeCRg13uCXbydPnmB4EOeRrY7480qNWO8IIgQG6zlDkm6uRMsURXPuKq0GWtiM59a5Q6g==}- peerDependencies:- react: '>=16.6.0'- react-dom: '>=16.6.0'-resolution: {integrity: sha512-9nfp2hYpCwOjAN+8TZFGhtWEwgvWHXqESH8qT89AT/lWklpLON22Lc8pEtnpsZz7VmawabSU0gCjnj8aC0euHQ==}engines: {node: '>=0.10.0'}@@ -9752,17 +9724,6 @@ packages:resolution: {integrity: sha512-dEWRjcINDu/F4l2dYx57ugBtD7HV9KXESyxhzw/MqWLeglJrsjJKqACPyUPg+6AF8mIgm+Zi0dZ3ACoIg+QtpA==}engines: {node: '>= 4'}- resolution: {integrity: sha512-kivNFO+0OcUNu7jQquLXAxz1FIwZj8nrj+YkOKc5694NbjCvcT6aSZiIzNzd2Kul4o4rTto8QVR9lMNtxD4G1w==}-- resolution: {integrity: sha512-UT/q6fwS3c1dHbXv2uFgYJ9BMFHu3fwnd7AYZaEQhXuYQ4hgsxLvsUXzGdKeZrW5xopzDCvuA2N41WJ88I7zIw==}- engines: {node: '>=14'}- deprecated: 1.x and 2.x branches are no longer active. Bump to Recharts v3 to receive latest features and bugfixes. See https://github.com/recharts/recharts/wiki/3.0-migration-guide- peerDependencies:- react: ^16.0.0 || ^17.0.0 || ^18.0.0 || ^19.0.0- react-dom: ^16.0.0 || ^17.0.0 || ^18.0.0 || ^19.0.0-resolution: {integrity: sha512-8GtdyqaBcDfva+GUKDr3nev3VpKAhup1+RvkMvUxURHpW7QyIvk9F5wz7Vzo06CEMSilw6uArgRqhpiUcWp8ew==}@@ -10806,9 +10767,6 @@ packages:resolution: {integrity: sha512-KzIbH/9tXat2u30jf+smMwFCsno4wHVdNmzFyL+T/L3UGqqk6JKfVqOFOZEpZSHADH1k40ab6NUIXZq422ov3Q==}- resolution: {integrity: sha512-PnpQQMuxlwYdocC8fIJqVXvkeViHYzotI+NJrCuav0ZYFoq912ZHBk3mCeuj+5/VpodOjPe1z0Fk2ihgzlXqjQ==}-resolution: {integrity: sha512-NTKlcQjlAK7MlQoyb6LgaqHc8sso/pVyUJYWMws3jg21uTJw/LddqIFPcPqP6PzpgbIcZyKI85sFE4HBrQDA8A==}engines: {node: ^18.0.0 || ^20.0.0 || >=22.0.0}@@ -17010,8 +16968,6 @@ snapshots:dependencies:ms: 2.1.3- [email protected]: {}-@@ -17092,11 +17048,6 @@ snapshots:- dependencies:- '@babel/runtime': 7.29.7- csstype: 3.2.3-dependencies:domelementtype: 2.3.0@@ -17881,8 +17832,6 @@ snapshots:- [email protected]: {}-dependencies:'@nodelib/fs.stat': 2.0.5@@ -20510,8 +20459,6 @@ snapshots:- [email protected]: {}-dependencies:'@types/hast': 3.0.5@@ -20558,14 +20505,6 @@ snapshots:react: 19.2.4react-dom: 19.2.4([email protected])- dependencies:- fast-equals: 5.4.1- prop-types: 15.8.1- react: 19.2.4- react-dom: 19.2.4([email protected])-dependencies:get-nonce: 1.0.1@@ -20593,15 +20532,6 @@ snapshots:transitivePeerDependencies:- '@types/react'- dependencies:- '@babel/runtime': 7.29.7- dom-helpers: 5.2.1- loose-envify: 1.4.0- prop-types: 15.8.1- react: 19.2.4- react-dom: 19.2.4([email protected])-@@ -20624,23 +20554,6 @@ snapshots:tiny-invariant: 1.3.3tslib: 2.8.1- dependencies:- decimal.js-light: 2.5.1-- dependencies:- clsx: 2.1.1- eventemitter3: 4.0.7- lodash: 4.17.21- react: 19.2.4- react-dom: 19.2.4([email protected])- react-is: 18.3.1- recharts-scale: 0.4.5- tiny-invariant: 1.3.3- victory-vendor: 36.9.2-dependencies:'@types/estree': 1.0.9@@ -21973,23 +21886,6 @@ snapshots:'@types/unist': 3.0.3vfile-message: 4.0.3- dependencies:- '@types/d3-array': 3.2.2- '@types/d3-ease': 3.0.2- '@types/d3-interpolate': 3.0.4- '@types/d3-scale': 4.0.9- '@types/d3-shape': 3.1.8- '@types/d3-time': 3.0.4- '@types/d3-timer': 3.0.2- d3-array: 3.2.4- d3-ease: 3.0.1- d3-interpolate: 3.0.1- d3-scale: 4.0.2- d3-shape: 3.2.0- d3-time: 3.1.0- d3-timer: 3.0.1-[email protected](@types/[email protected])([email protected])([email protected])([email protected])([email protected])([email protected])([email protected])([email protected]):dependencies:esbuild: 0.25.12