import { GaugeType, defaultGaugeProps } from './GaugeComponentProps'; import { Tooltip } from './Tooltip'; /** Configuration for the outer decorative arc (Grafana style) */ export interface OuterArcConfig { /** Corner radius for outer arc (max effective value ~2 due to thin arc). Unit: SVG units. */ cornerRadius?: number, /** Padding between outer arc segments. Unit: radians. */ padding?: number, /** Width of the outer arc. Unit: pixels (default: 5). */ width?: number, /** Visual effects for the outer arc (inherits from arc.effects if not set) */ effects?: ArcEffects } /** Drop shadow effect configuration */ export interface DropShadowConfig { /** Shadow offset X. Unit: pixels (default: 0). */ dx?: number, /** Shadow offset Y. Unit: pixels (default: 2). */ dy?: number, /** Shadow blur. Unit: pixels (default: 3). */ blur?: number, /** Shadow color (default: rgba(0,0,0,0.3)). */ color?: string, /** Shadow opacity. Unit: ratio 0-1 (default: 0.3). */ opacity?: number } export interface Arc { /** The corner radius of the arc. Unit: SVG units. */ cornerRadius?: number, /** The padding between subArcs. Unit: radians (default: 0.01). */ padding?: number, /** Remove padding from start and end of the arc (first and last subArcs). */ padEndpoints?: boolean, /** The width of the arc. Unit: ratio of radius (0-1, e.g., 0.25 = 25% of radius). */ width?: number, /** The number of subArcs, this overrides "subArcs" limits. */ nbSubArcs?: number, /** Enables gradient mode, drawing a single arc with smooth color transitions. */ gradient?: boolean, /** The colors of the arcs, this overrides "subArcs" colors. */ colorArray?: Array, /** Color of the grafana's empty subArc */ emptyColor?: string, /** List of sub arcs segments of the whole arc. */ subArcs?: Array, /** Settings for Grafana's outer decorative arc (only applies to grafana type) */ outerArc?: OuterArcConfig, /** Stroke/border width for all subArcs. Unit: pixels. */ subArcsStrokeWidth?: number, /** Stroke/border color for all subArcs */ subArcsStrokeColor?: string, /** CSS/SVG effects for the arc */ effects?: ArcEffects } export interface ArcEffects { /** Enable glow effect on arcs */ glow?: boolean, /** Glow color (defaults to arc color if not set) */ glowColor?: string, /** Glow intensity/blur radius. Unit: pixels (default: 10). */ glowBlur?: number, /** Glow spread. Unit: pixels (default: 3). */ glowSpread?: number, /** Custom SVG filter ID to apply */ filterUrl?: string, /** Drop shadow effect */ dropShadow?: DropShadowConfig, /** Inner shadow/inset effect for 3D look */ innerShadow?: boolean } /** Effects that can be applied to individual SubArcs - inherits from arc.effects if not specified */ export interface SubArcEffects extends ArcEffects { /** Override to disable inherited effects from arc.effects */ inherit?: boolean } export interface SubArc { /** The limit of the subArc, in accord to the gauge value. Unit: gauge value units. */ limit?: number, /** The color of the subArc. */ color?: string | number, /** The length of the subArc. Unit: ratio (0-1, e.g., 0.5 = 50% of arc). */ length?: number, // needleColorWhenWithinLimit?: string, //The color of the needle when it is within the subArc /** Whether or not to show the tick */ showTick?: boolean, /** Tooltip that appears onHover of the subArc */ tooltip?: Tooltip, /** This will trigger onClick of the subArc */ onClick?: () => void, /** This will trigger onMouseMove of the subArc */ onMouseMove?: () => void, /** This will trigger onMouseMove of the subArc */ onMouseLeave?: () => void, /** Visual effects for this specific subArc (inherits from arc.effects if not set) */ effects?: SubArcEffects } export const defaultSubArcs: SubArc[] = [ { limit: 33, color: "#5BE12C" }, // needleColorWhenWithinLimit: "#AA4128"}, { limit: 66, color: "#F5CD19" }, { color: "#EA4228" }, ]; export const getArcWidthByType = (type: string): number => { let gaugeTypesWidth: Record = { [GaugeType.Grafana]: 0.25, [GaugeType.Semicircle]: 0.15, [GaugeType.Radial]: 0.2, }; if(!type) type = defaultGaugeProps.type as string; return gaugeTypesWidth[type as string]; } export const defaultArc: Arc = { padding: 0.01, width: 0.25, cornerRadius: 1, nbSubArcs: undefined, emptyColor: "#5C5C5C", colorArray: undefined, subArcs: defaultSubArcs, gradient: false, subArcsStrokeWidth: 0, subArcsStrokeColor: undefined };