Skip to content

Commit

Permalink
Merge pull request #3682 from ag-grid/AG-14185-donut-inner-radius
Browse files Browse the repository at this point in the history
AG-14185 Add default donut inner radius ratio
  • Loading branch information
alantreadway authored Feb 27, 2025
2 parents 466fdf6 + c750091 commit 53c2548
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 18 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type SeriesModuleDefinition, ValidationError, validate } from 'ag-charts-core';
import { type SeriesModuleDefinition } from 'ag-charts-core';
import type { AgDonutSeriesOptions } from 'ag-charts-types';

import type { SeriesModule } from '../../../module/coreModules';
Expand Down Expand Up @@ -29,15 +29,4 @@ export const NewDonutSeriesModule: SeriesModuleDefinition<AgDonutSeriesOptions>
options: donutSeriesOptionsDef,

create: (ctx: ModuleContext) => new DonutSeries(ctx),
validate(options, optionsDefs, path) {
const result = validate(options, optionsDefs, path);

if (result.valid?.innerRadiusRatio == null && result.valid?.innerRadiusOffset == null) {
const extendPath = (key: string) => (path ? `${path}.${key}` : key);
const message = `Either \`${extendPath('innerRadiusRatio')}\` or \`${extendPath('innerRadiusOffset')}\` is required.`;
result.errors.push(new ValidationError(message, path, true));
}

return result;
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export const donutTheme: ExtensibleTheme<'donut'> = {
lineDashOffset: 0,
rotation: 0,
sectorSpacing: 1,
innerRadiusRatio: { $if: [{ $eq: [{ $path: './innerRadiusOffset' }, undefined] }, 0.7, undefined] },
shadow: {
enabled: false,
color: DEFAULT_SHADOW_COLOUR,
Expand Down
8 changes: 2 additions & 6 deletions packages/ag-charts-types/src/series/polar/donutOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,9 @@ export interface AgDonutSeriesThemeableOptions<TDatum = any>
outerRadiusOffset?: PixelSize;
/** The ratio of the outer radius of the series. Used to adjust the outer radius proportionally to the automatically calculated value. */
outerRadiusRatio?: Ratio;
/** The offset in pixels of the inner radius of the series.
*
* __Note:__ An `innerRadiusRatio` or an `innerRadiusOffset` must be provided in order to render a Donut series. */
/** The offset in pixels of the inner radius of the series. */
innerRadiusOffset?: PixelSize;
/** The ratio of the inner radius of the series.
*
* __Note:__ An `innerRadiusRatio` or an `innerRadiusOffset` must be provided in order to render a Donut series. */
/** The ratio of the inner radius of the series. */
innerRadiusRatio?: Ratio;
/** Override of the automatically determined minimum radiusKey value from the data. */
radiusMin?: number;
Expand Down

0 comments on commit 53c2548

Please # to comment.