The Open Standard for Generative UI
Charts-fixes (#193)
Ankit Das62a16c5f7e30
diff --git a/js/packages/react-ui/package.json b/js/packages/react-ui/package.jsonindex e5173e996..70b55af3b 100644--- a/js/packages/react-ui/package.json+++ b/js/packages/react-ui/package.json@@ -2,7 +2,7 @@"type": "module","name": "@crayonai/react-ui","license": "MIT",- "version": "0.8.42",+ "version": "0.8.43","description": "Component library for Generative UI SDK","main": "dist/index.js","types": "dist/index.d.ts",diff --git a/js/packages/react-ui/src/components/Charts/AreaChart/AreaChart.tsx b/js/packages/react-ui/src/components/Charts/AreaChart/AreaChart.tsxindex 5730196a1..a4e949e9b 100644--- a/js/packages/react-ui/src/components/Charts/AreaChart/AreaChart.tsx+++ b/js/packages/react-ui/src/components/Charts/AreaChart/AreaChart.tsx@@ -310,7 +310,10 @@ const AreaChartComponent = <T extends AreaChartData>({style={{ width: dataWidth, minWidth: "100%", height: chartHeight }}rechartsProps={{width: "100%",- height: chartHeight,+ height: "100%",+ minHeight: 1,+ minWidth: 1,+ initialDimension: { width: 1, height: 1 },}}><RechartsAreaChartdiff --git a/js/packages/react-ui/src/components/Charts/BarChart/BarChart.tsx b/js/packages/react-ui/src/components/Charts/BarChart/BarChart.tsxindex e65a54668..3f4c68796 100644--- a/js/packages/react-ui/src/components/Charts/BarChart/BarChart.tsx+++ b/js/packages/react-ui/src/components/Charts/BarChart/BarChart.tsx@@ -422,7 +422,10 @@ const BarChartComponent = <T extends BarChartData>({style={{ width: dataWidth, minWidth: "100%", height: chartHeight }}rechartsProps={{width: "100%",- height: chartHeight,+ height: "100%",+ minHeight: 1,+ minWidth: 1,+ initialDimension: { width: 1, height: 1 },}}><RechartsBarChartdiff --git a/js/packages/react-ui/src/components/Charts/Charts.tsx b/js/packages/react-ui/src/components/Charts/Charts.tsxindex e29b855b4..ccd29b3a2 100644--- a/js/packages/react-ui/src/components/Charts/Charts.tsx+++ b/js/packages/react-ui/src/components/Charts/Charts.tsx@@ -141,13 +141,23 @@ const ChartContainer = forwardRef<{"--crayon-container-fills": theme.containerFills,"--crayon-primary-text": theme.primaryText,+ width: "100%",+ height: "100%",...style,} as React.CSSProperties}{...props}><ChartStyle id={chartId} config={config} />- <RechartsPrimitive.ResponsiveContainer {...rechartsProps}>+ <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>diff --git a/js/packages/react-ui/src/components/Charts/LineChart/LineChart.tsx b/js/packages/react-ui/src/components/Charts/LineChart/LineChart.tsxindex 509f9992c..0b90aeb45 100644--- a/js/packages/react-ui/src/components/Charts/LineChart/LineChart.tsx+++ b/js/packages/react-ui/src/components/Charts/LineChart/LineChart.tsx@@ -320,7 +320,10 @@ export const LineChart = <T extends LineChartData>({style={{ width: dataWidth, minWidth: "100%", height: chartHeight }}rechartsProps={{width: "100%",- height: chartHeight,+ height: "100%",+ minHeight: 1,+ minWidth: 1,+ initialDimension: { width: 1, height: 1 },}}><RechartsLineChartdiff --git a/js/packages/react-ui/src/components/Charts/PieChart/PieChart.tsx b/js/packages/react-ui/src/components/Charts/PieChart/PieChart.tsxindex eb474c3af..92523f080 100644--- a/js/packages/react-ui/src/components/Charts/PieChart/PieChart.tsx+++ b/js/packages/react-ui/src/components/Charts/PieChart/PieChart.tsx@@ -39,6 +39,9 @@ export interface PieChartProps<T extends PieChartData> {className?: string;maxChartSize?: number;minChartSize?: number;+ // Add height and width props+ height?: number | string;+ width?: number | string;}const STACKED_LEGEND_BREAKPOINT = 400;@@ -65,6 +68,8 @@ const PieChartComponent = <T extends PieChartData>({className,maxChartSize = MAX_CHART_SIZE,minChartSize = MIN_CHART_SIZE,+ height,+ width,}: PieChartProps<T>) => {const wrapperRef = useRef<HTMLDivElement>(null);const [wrapperRect, setWrapperRect] = useState({ width: 0, height: 0 });@@ -102,19 +107,31 @@ const PieChartComponent = <T extends PieChartData>({// Calculate chart dimensions based on the smaller dimension of the containerconst chartSize = useMemo(() => {- let size;- if (isRowLayout) {- const chartContainerWidth = (effectiveWidth - 20) / 2; // Subtract gap- size = Math.min(chartContainerWidth, effectiveHeight);- } else {- size = Math.min(effectiveWidth, effectiveHeight);- }+ // 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]);const chartSizeStyle = useMemo(() => ({ width: chartSize, height: chartSize }), [chartSize]);- const rechartsProps = useMemo(() => ({ width: "100%", height: "100%" }), []);+ const rechartsProps = useMemo(+ () => ({+ width: "100%",+ height: "100%",+ minWidth: 1,+ minHeight: 1,+ initialDimension: { width: 1, height: 1 },+ }),+ [],+ );// Memoize expensive data transformations and configurationsconst transformedData = useMemo(@@ -387,8 +404,23 @@ const PieChartComponent = <T extends PieChartData>({[className, legend, legendVariant, isRowLayout],);+ 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),+ };++ return dimensions;+ }, [width, height]);+return (- <div ref={wrapperRef} className={wrapperClassName}>+ <div ref={wrapperRef} className={wrapperClassName} style={wrapperStyle}><div className="crayon-pie-chart-container"><div className="crayon-pie-chart-container-inner"><div style={chartSizeStyle}>diff --git a/js/packages/react-ui/src/components/Charts/PieChart/pieChart.scss b/js/packages/react-ui/src/components/Charts/PieChart/pieChart.scssindex 9e9a51c67..19f8ab96a 100644--- a/js/packages/react-ui/src/components/Charts/PieChart/pieChart.scss+++ b/js/packages/react-ui/src/components/Charts/PieChart/pieChart.scss@@ -35,6 +35,8 @@display: flex;align-items: center;justify-content: center;+ width: 100%;+ height: 100%;position: relative;// When in a row layout, the chart container should be flexiblediff --git a/js/packages/react-ui/src/components/Charts/PieChart/stories/PieChart.stories.tsx b/js/packages/react-ui/src/components/Charts/PieChart/stories/PieChart.stories.tsxindex beb115e3e..bf5b4cb90 100644--- a/js/packages/react-ui/src/components/Charts/PieChart/stories/PieChart.stories.tsx+++ b/js/packages/react-ui/src/components/Charts/PieChart/stories/PieChart.stories.tsx@@ -107,7 +107,7 @@ const salesData = [},},},- tags: ["!dev", "autodocs"],+ tags: ["dev", "autodocs"],argTypes: {data: {description: `@@ -236,12 +236,61 @@ const salesData = [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*@@ -271,7 +320,7 @@ export const DefaultConfiguration: Story = {paddingAngle: 0,},render: (args: any) => (- <Card style={{ width: "650px", height: "auto", padding: "24px" }}>+ <Card style={{ width: "400px", height: "fit-content", padding: "24px" }}><h3 style={{ marginBottom: "20px", fontSize: "18px", fontWeight: 600 }}>Monthly Sales Performance</h3>diff --git a/js/packages/react-ui/src/components/Charts/PieChart/utils/PieChartUtils.ts b/js/packages/react-ui/src/components/Charts/PieChart/utils/PieChartUtils.tsindex 48c80dcbc..71b5a9e48 100644--- a/js/packages/react-ui/src/components/Charts/PieChart/utils/PieChartUtils.ts+++ b/js/packages/react-ui/src/components/Charts/PieChart/utils/PieChartUtils.ts@@ -60,7 +60,7 @@ const calculatePercentage = (value: number, total: number): number => {* @returns Object containing outer and inner radius values*/const calculateChartDimensions = (width: number, variant: string): ChartDimensions => {- const baseRadiusPercentage = 0.4; // 40% of container width+ const baseRadiusPercentage = 0.45; // Prefer a larger base to better utilize available widthlet outerRadius = Math.round(width * baseRadiusPercentage);// Set minimum and maximum bounds for radius@@ -81,7 +81,7 @@ const calculateChartDimensions = (width: number, variant: string): ChartDimensio* @returns Object containing outer, middle, and inner radius values*/const calculateTwoLevelChartDimensions = (width: number): TwoLevelChartDimensions => {- const baseRadiusPercentage = 0.4; // 40% of container width+ const baseRadiusPercentage = 0.45; // Prefer a larger base to better utilize available widthlet outerRadius = Math.round(width * baseRadiusPercentage);// Set minimum and maximum bounds for radiusdiff --git a/js/packages/react-ui/src/components/Charts/RadarChart/RadarChart.tsx b/js/packages/react-ui/src/components/Charts/RadarChart/RadarChart.tsxindex 6fa5db042..e9b7e7e7c 100644--- a/js/packages/react-ui/src/components/Charts/RadarChart/RadarChart.tsx+++ b/js/packages/react-ui/src/components/Charts/RadarChart/RadarChart.tsx@@ -1,6 +1,12 @@import clsx from "clsx";import React, { memo, useEffect, useMemo, useRef, useState } from "react";-import { PolarAngleAxis, PolarGrid, Radar, RadarChart as RechartsRadarChart } from "recharts";+import {+ PolarAngleAxis,+ PolarGrid,+ Radar,+ RadarChart as RechartsRadarChart,+ ResponsiveContainer,+} from "recharts";import { ChartConfig, ChartContainer, ChartTooltip } from "../Charts";import { SideBarTooltipProvider } from "../context/SideBarTooltipContext";import { useTransformedKeys } from "../hooks/useTransformKey";@@ -26,6 +32,8 @@ export interface RadarChartProps<T extends RadarChartData> {areaOpacity?: number;icons?: Partial<Record<keyof T[number], React.ComponentType>>;isAnimationActive?: boolean;+ height?: number;+ width?: number;}const RadarChartComponent = <T extends RadarChartData>({@@ -40,6 +48,8 @@ const RadarChartComponent = <T extends RadarChartData>({areaOpacity = 0.2,icons = {},isAnimationActive = false,+ height,+ width,}: RadarChartProps<T>) => {const dataKeys = useMemo(() => {return getDataKeys(data, categoryKey as string);@@ -93,7 +103,16 @@ const RadarChartComponent = <T extends RadarChartData>({}, [wrapperRect]);const chartSizeStyle = useMemo(() => ({ width: chartSize, height: chartSize }), [chartSize]);- const rechartsProps = useMemo(() => ({ width: "100%", height: "100%" }), [chartSize]);+ const rechartsProps: Omit<React.ComponentProps<typeof ResponsiveContainer>, "children"> = useMemo(+ () => ({+ width: "100%",+ height: "100%",+ minWidth: 1,+ minHeight: 1,+ initialDimension: { width: 1, height: 1 },+ }),+ [],+ );const radars = useMemo(() => {return dataKeys.map((key) => {@@ -137,6 +156,29 @@ const RadarChartComponent = <T extends RadarChartData>({[],);+ 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 (<SideBarTooltipProviderisSideBarTooltipOpen={false}@@ -144,7 +186,7 @@ const RadarChartComponent = <T extends RadarChartData>({data={undefined}setData={() => {}}>- <div ref={wrapperRef} className={wrapperClassName}>+ <div ref={wrapperRef} className={wrapperClassName} style={wrapperStyle}><div className="crayon-radar-chart-container"><div className="crayon-radar-chart-container-inner"><div style={chartSizeStyle}>diff --git a/js/packages/react-ui/src/components/Charts/RadarChart/radarChart.scss b/js/packages/react-ui/src/components/Charts/RadarChart/radarChart.scssindex a1a5bfe7b..9fe36d3f9 100644--- a/js/packages/react-ui/src/components/Charts/RadarChart/radarChart.scss+++ b/js/packages/react-ui/src/components/Charts/RadarChart/radarChart.scss@@ -45,4 +45,5 @@pointer-events: none;@include cssUtils.typography(label, 2-extra-small);color: cssUtils.$secondary-text;+ white-space: nowrap;}diff --git a/js/packages/react-ui/src/components/Charts/RadarChart/stories/RadarChart.stories.tsx b/js/packages/react-ui/src/components/Charts/RadarChart/stories/RadarChart.stories.tsxindex 446b1977c..903caa986 100644--- a/js/packages/react-ui/src/components/Charts/RadarChart/stories/RadarChart.stories.tsx+++ b/js/packages/react-ui/src/components/Charts/RadarChart/stories/RadarChart.stories.tsx@@ -58,14 +58,14 @@ const dataVariations = {{ dimension: "Center", score: 88 },],manyDimensions: [- { aspect: "UX Design", mobile: 8, web: 9, desktop: 7, tablet: 8 },- { aspect: "Performance", mobile: 9, web: 8, desktop: 9, tablet: 8 },- { aspect: "Accessibility", mobile: 7, web: 8, desktop: 9, tablet: 7 },- { aspect: "Security", mobile: 8, web: 9, desktop: 8, tablet: 8 },- { aspect: "Scalability", mobile: 7, web: 9, desktop: 8, tablet: 7 },- { aspect: "Maintenance", mobile: 8, web: 7, desktop: 8, tablet: 8 },- { aspect: "Testing", mobile: 9, web: 8, desktop: 7, tablet: 8 },- { aspect: "Documentation", mobile: 6, web: 8, desktop: 9, tablet: 7 },+ { 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 },],};@@ -141,7 +141,7 @@ const exampleData = [},},},- tags: ["!dev", "autodocs"],+ tags: ["dev", "autodocs"],argTypes: {data: {description: `@@ -303,6 +303,22 @@ const icons = {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>;@@ -490,6 +506,7 @@ export const InteractivePlayground: Story = {borderRadius: "4px",cursor: "pointer",background: "#fff",+ color: "#333",fontFamily: "monospace",transition: "all 0.2s",};@@ -526,7 +543,7 @@ export const InteractivePlayground: Story = {</Card><Cardstyle={{- height: "500px",+ height: "400px",padding: "24px",resize: "both",overflow: "hidden",diff --git a/js/packages/react-ui/src/components/Charts/RadialChart/RadialChart.tsx b/js/packages/react-ui/src/components/Charts/RadialChart/RadialChart.tsxindex 02bb8fead..8b1ef34e5 100644--- a/js/packages/react-ui/src/components/Charts/RadialChart/RadialChart.tsx+++ b/js/packages/react-ui/src/components/Charts/RadialChart/RadialChart.tsx@@ -1,6 +1,6 @@import clsx from "clsx";import { useCallback, useEffect, useMemo, useRef, useState } from "react";-import { Cell, PolarGrid, RadialBar, RadialBarChart } from "recharts";+import { Cell, PolarGrid, RadialBar, RadialBarChart, ResponsiveContainer } from "recharts";import { ChartContainer, ChartTooltip, ChartTooltipContent } from "../Charts";import { useTransformedKeys } from "../hooks";import { DefaultLegend } from "../shared/DefaultLegend/DefaultLegend";@@ -37,6 +37,8 @@ export interface RadialChartProps<T extends RadialChartData> {className?: string;maxChartSize?: number;minChartSize?: number;+ height?: number | string;+ width?: number | string;}const STACKED_LEGEND_BREAKPOINT = 400;@@ -62,6 +64,8 @@ export const RadialChart = <T extends RadialChartData>({className,maxChartSize = MAX_CHART_SIZE,minChartSize = MIN_CHART_SIZE,+ height,+ width,}: RadialChartProps<T>) => {const wrapperRef = useRef<HTMLDivElement>(null);const [wrapperRect, setWrapperRect] = useState({ width: 0, height: 0 });@@ -99,17 +103,15 @@ export const RadialChart = <T extends RadialChartData>({// Calculate chart dimensions based on the smaller dimension of the containerconst chartSize = useMemo(() => {- let size;- // When in a row layout, the chart and legend are side-by-side.- if (isRowLayout) {- // The chart container takes up roughly half the width. We subtract the gap between items.- const chartContainerWidth = (effectiveWidth - 20) / 2;- // The size of the chart is the smaller of its container's width or the total available height.- size = Math.min(chartContainerWidth, effectiveHeight);- } else {- // In a column layout, the chart's size is constrained by the smaller of the total container's width or height.- size = Math.min(effectiveWidth, effectiveHeight);- }+ // 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]);@@ -122,10 +124,13 @@ export const RadialChart = <T extends RadialChartData>({[chartSize],);- const rechartsProps = useMemo(+ const rechartsProps: Omit<React.ComponentProps<typeof ResponsiveContainer>, "children"> = useMemo(() => ({width: "100%",height: "100%",+ minWidth: 1,+ minHeight: 1,+ initialDimension: { width: 1, height: 1 },}),[],);@@ -295,8 +300,35 @@ export const RadialChart = <T extends RadialChartData>({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}>+ <div+ ref={wrapperRef}+ className={wrapperClassName}+ style={wrapperStyle}+ aria-description="radial-chart-wrapper"+ ><div className="crayon-radial-chart-container"><div className="crayon-radial-chart-container-inner"><div style={chartSizeStyle}>diff --git a/js/packages/react-ui/src/components/Charts/RadialChart/radialChart.scss b/js/packages/react-ui/src/components/Charts/RadialChart/radialChart.scssindex a89a478a3..4dc1e2df6 100644--- a/js/packages/react-ui/src/components/Charts/RadialChart/radialChart.scss+++ b/js/packages/react-ui/src/components/Charts/RadialChart/radialChart.scss@@ -36,6 +36,8 @@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 & {diff --git a/js/packages/react-ui/src/components/Charts/RadialChart/stories/RadialChart.stories.tsx b/js/packages/react-ui/src/components/Charts/RadialChart/stories/RadialChart.stories.tsxindex 32b58354e..7e1ee1142 100644--- a/js/packages/react-ui/src/components/Charts/RadialChart/stories/RadialChart.stories.tsx+++ b/js/packages/react-ui/src/components/Charts/RadialChart/stories/RadialChart.stories.tsx@@ -137,7 +137,7 @@ const exampleData = [},},},- tags: ["!dev", "autodocs"],+ tags: ["dev", "autodocs"],argTypes: {data: {description: `@@ -328,6 +328,22 @@ const exampleData = [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>;diff --git a/js/packages/react-ui/src/components/Charts/RadialChart/utils/RadialChartUtils.ts b/js/packages/react-ui/src/components/Charts/RadialChart/utils/RadialChartUtils.tsindex 126be9488..19236297f 100644--- a/js/packages/react-ui/src/components/Charts/RadialChart/utils/RadialChartUtils.ts+++ b/js/packages/react-ui/src/components/Charts/RadialChart/utils/RadialChartUtils.ts@@ -59,13 +59,14 @@ export const calculatePercentage = (value: number, total: number): number => {* @returns Object containing outer and inner radius values*/export const calculateRadialChartDimensions = (width: number): RadialChartDimensions => {- const baseRadiusPercentage = 0.4; // 40% of container width+ // 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);- // Set minimum and maximum bounds for radius- outerRadius = Math.max(50, Math.min(outerRadius, width / 2 - 10));+ // Clamp radius within sensible bounds and leave ~10px margin from the edge+ outerRadius = Math.max(50, Math.min(outerRadius, Math.round(width / 2) - 10));- // Calculate inner radius - consistent ratio regardless of layout+ // The inner radius is 30% of the outer radiusconst innerRadius = Math.round(outerRadius * 0.3);return { outerRadius, innerRadius };