Shared TypeScript library for the Lightdash platform containing common types, utilities, and business logic for analytics workflows
Overall
score
72%
Evaluation — 72%
↑ 1.09xAgent success when using this tile
A utility for calculating border radius values for bar chart elements that adapts based on chart orientation, stacking, and bar dimensions.
Implement a function that calculates border radius for bars in a chart. The radius should be applied only to the "end" corners of bars:
For stacked bars, only bars at the stack end (topmost or rightmost segment) should have rounded corners.
The radius value should be calculated proportionally to the bar width to maintain visual balance. Bar width depends on:
Default chart dimensions should be assumed as 500 pixels if not provided.
@generates
export interface BarStyleConfig {
orientation?: 'horizontal' | 'vertical';
stacking?: 'normal' | 'percent' | null;
dataPointCount: number;
seriesCount: number;
chartWidth?: number;
chartHeight?: number;
}
export interface StackEndInfo {
isStackEnd: boolean;
isPositive: boolean;
}
/**
* Calculates the appropriate border radius for bar chart elements.
*
* @param config - Configuration object containing chart properties
* @param stackInfo - Optional information about stack positioning
* @returns Array of four radius values [topLeft, topRight, bottomRight, bottomLeft]
*/
export function calculateBarRadius(
config: BarStyleConfig,
stackInfo?: StackEndInfo
): [number, number, number, number];[radius, radius, 0, 0] where radius > 0 @test[0, radius, radius, 0] where radius > 0 @testisStackEnd is true, returns rounded top corners; when false, returns no rounding [0, 0, 0, 0] @testProvides chart configuration types and utilities for Business Intelligence visualizations.
@satisfied-by
Install with Tessl CLI
npx tessl i tessl/npm-lightdash--commondocs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10
scenario-11
scenario-12
scenario-13
scenario-14
scenario-15
scenario-16
scenario-17
scenario-18
scenario-19
scenario-20