import { SignalRef } from '../index.js'; import { Color } from './color.js'; import { Cursor, StrokeCap, StrokeJoin } from './config.d.js'; import { TitleAnchor } from './title.js'; export type Field = string | SignalRef | DatumFieldRef | GroupFieldRef | ParentFieldRef; export interface DatumFieldRef { datum: Field; } export interface GroupFieldRef { group: Field; level?: number; } export interface ParentFieldRef { parent: Field; level?: number; } export type BaseValueRef = | SignalRef | { value: T | null; } | { field: Field; }; export type ScaledValueRef = | BaseValueRef | { scale: Field; value: boolean | number | string | null; } | { scale: Field; field: Field; } | { scale: Field; band: boolean | number; } | { scale: Field; range: number | boolean; }; export type NumericValueRef = (ScaledValueRef | {}) & { exponent?: number | NumericValueRef; mult?: number | NumericValueRef; offset?: number | NumericValueRef; round?: boolean; extra?: boolean; }; export type StringValueRef = ScaledValueRef; export type SymbolShapeValueRef = ScaledValueRef; export type FontWeightValueRef = ScaledValueRef; export type FontStyleValueRef = ScaledValueRef; export type AlignValueRef = ScaledValueRef; export type StrokeCapValueRef = ScaledValueRef; export type AnchorValueRef = ScaledValueRef; export type OrientValueRef = ScaledValueRef; export type TextBaselineValueRef = ScaledValueRef; export type TextValueRef = ScaledValueRef; export type BooleanValueRef = ScaledValueRef; export type ArrayValueRef = ScaledValueRef; export type ArbitraryValueRef = NumericValueRef | ColorValueRef | ScaledValueRef; export interface ColorRGB { r: NumericValueRef; g: NumericValueRef; b: NumericValueRef; } export interface ColorHSL { h: NumericValueRef; s: NumericValueRef; l: NumericValueRef; } export interface ColorLAB { l: NumericValueRef; a: NumericValueRef; b: NumericValueRef; } export interface ColorHCL { h: NumericValueRef; c: NumericValueRef; l: NumericValueRef; } export interface BaseGradient { /** * The type of gradient. */ gradient: 'linear' | 'radial'; } export interface GradientStop { /** * The offset fraction for the color stop, indicating its position within the gradient. */ offset: number; /** * The color value at this point in the gradient. */ color: Color; } export type Gradient = LinearGradient | RadialGradient; export interface LinearGradient extends BaseGradient { /** * The type of gradient. Use `"linear"` for a linear gradient. */ gradient: 'linear'; /** * An array of gradient stops defining the gradient color sequence. */ stops: GradientStop[]; id?: string; /** * The starting x-coordinate, in normalized [0, 1] coordinates, of the linear gradient. * * __Default value:__ `0` */ x1?: number; /** * The starting y-coordinate, in normalized [0, 1] coordinates, of the linear gradient. * * __Default value:__ `0` */ y1?: number; /** * The ending x-coordinate, in normalized [0, 1] coordinates, of the linear gradient. * * __Default value:__ `1` */ x2?: number; /** * The ending y-coordinate, in normalized [0, 1] coordinates, of the linear gradient. * * __Default value:__ `0` */ y2?: number; } export interface RadialGradient extends BaseGradient { /** * The type of gradient. Use `"radial"` for a radial gradient. */ gradient: 'radial'; /** * An array of gradient stops defining the gradient color sequence. */ stops: GradientStop[]; id?: string; /** * The x-coordinate, in normalized [0, 1] coordinates, for the center of the inner circle for the gradient. * * __Default value:__ `0.5` */ x1?: number; /** * The y-coordinate, in normalized [0, 1] coordinates, for the center of the inner circle for the gradient. * * __Default value:__ `0.5` */ y1?: number; /** * The radius length, in normalized [0, 1] coordinates, of the inner circle for the gradient. * * __Default value:__ `0` */ r1?: number; /** * The x-coordinate, in normalized [0, 1] coordinates, for the center of the outer circle for the gradient. * * __Default value:__ `0.5` */ x2?: number; /** * The y-coordinate, in normalized [0, 1] coordinates, for the center of the outer circle for the gradient. * * __Default value:__ `0.5` */ y2?: number; /** * The radius length, in normalized [0, 1] coordinates, of the outer circle for the gradient. * * __Default value:__ `0.5` */ r2?: number; } export type ColorValueRef = | ScaledValueRef | { value: LinearGradient | RadialGradient } | { gradient: Field; start?: number[]; stop?: number[]; count?: number; } | { color: ColorRGB | ColorHSL | ColorLAB | ColorHCL; }; export type ProductionRule = | T | ({ test?: string; } & T)[]; export type Blend = | null | 'multiply' | 'screen' | 'overlay' | 'darken' | 'lighten' | 'color-dodge' | 'color-burn' | 'hard-light' | 'soft-light' | 'difference' | 'exclusion' | 'hue' | 'saturation' | 'color' | 'luminosity'; export interface EncodeEntry { x?: ProductionRule; x2?: ProductionRule; xc?: ProductionRule; width?: ProductionRule; y?: ProductionRule; y2?: ProductionRule; yc?: ProductionRule; height?: ProductionRule; opacity?: ProductionRule; fill?: ProductionRule; fillOpacity?: ProductionRule; stroke?: ProductionRule; strokeWidth?: ProductionRule; strokeOpacity?: ProductionRule; strokeDash?: ProductionRule>; strokeDashOffset?: ProductionRule; strokeCap?: ProductionRule>; strokeJoin?: ProductionRule>; strokeMiterLimit?: ProductionRule; blend?: ProductionRule>; cursor?: ProductionRule>; tooltip?: ProductionRule; zindex?: ProductionRule; /** * A boolean flag indicating if [ARIA attributes](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA) should be included (SVG output only). * If `false`, the "aria-hidden" attribute will be set on the output SVG element, removing the mark item from the ARIA accessibility tree. */ aria?: ProductionRule; /** * Sets the type of user interface element of the mark item for [ARIA accessibility](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA) (SVG output only). * If specified, this property determines the "role" attribute. * Warning: this property is experimental and may be changed in the future. */ ariaRole?: ProductionRule; /** * A human-readable, author-localized description for the role of the mark item for [ARIA accessibility](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA) (SVG output only). * If specified, this property determines the "aria-roledescription" attribute. * Warning: this property is experimental and may be changed in the future. */ ariaRoleDescription?: ProductionRule; /** * A text description of the mark item for [ARIA accessibility](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA) (SVG output only). * If specified, this property determines the ["aria-label" attribute](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Techniques/Using_the_aria-label_attribute). */ description?: ProductionRule; [k: string]: ProductionRule | undefined; } export type Align = 'left' | 'center' | 'right'; export interface AlignProperty { align?: ProductionRule>; } export type Orient = 'left' | 'right' | 'top' | 'bottom'; export interface DefinedProperty { defined?: ProductionRule; } export interface ThetaProperty { theta?: ProductionRule; } export interface ArcEncodeEntry extends EncodeEntry { startAngle?: ProductionRule; endAngle?: ProductionRule; padAngle?: ProductionRule; innerRadius?: ProductionRule; outerRadius?: ProductionRule; cornerRadius?: ProductionRule; } export type Orientation = 'horizontal' | 'vertical'; export interface AreaEncodeEntry extends LineEncodeEntry { orient?: ProductionRule>; } export interface GroupEncodeEntry extends RectEncodeEntry { clip?: ProductionRule; strokeForeground?: ProductionRule; strokeOffset?: ProductionRule; } export type Baseline = 'top' | 'middle' | 'bottom'; export interface ImageEncodeEntry extends EncodeEntry, AlignProperty { url?: ProductionRule; aspect?: ProductionRule; baseline?: ProductionRule>; smooth?: ProductionRule; } export type Interpolate = | 'basis' | 'basis-open' | 'basis-closed' | 'bundle' | 'cardinal' | 'cardinal-open' | 'cardinal-closed' | 'catmull-rom' | 'linear' | 'linear-closed' | 'monotone' | 'natural' | 'step' | 'step-before' | 'step-after'; export interface LineEncodeEntry extends EncodeEntry, DefinedProperty { interpolate?: ProductionRule>; tension?: ProductionRule; } export interface PathEncodeEntry extends EncodeEntry { path?: ProductionRule; angle?: ProductionRule; scaleX?: ProductionRule; scaleY?: ProductionRule; } export interface RectEncodeEntry extends EncodeEntry { cornerRadius?: ProductionRule; cornerRadiusTopLeft?: ProductionRule; cornerRadiusTopRight?: ProductionRule; cornerRadiusBottomRight?: ProductionRule; cornerRadiusBottomLeft?: ProductionRule; } export type RuleEncodeEntry = EncodeEntry; export interface ShapeEncodeEntry extends EncodeEntry { shape?: ProductionRule; } export type SymbolShape = | 'circle' | 'square' | 'cross' | 'diamond' | 'triangle-up' | 'triangle-down' | 'triangle-right' | 'triangle-left' | 'arrow' | 'triangle' | 'wedge' | 'stroke' | string; export interface SymbolEncodeEntry extends EncodeEntry { size?: ProductionRule; shape?: ProductionRule>; angle?: ProductionRule; } export type Text = string | string[]; export type TextBaseline = 'alphabetic' | Baseline | 'line-top' | 'line-bottom'; export type TextDirection = 'ltr' | 'rtl'; export type FontWeight = | 'normal' | 'bold' | 'lighter' | 'bolder' | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900; // see https://developer.mozilla.org/en-US/docs/Web/CSS/font-style#Values export type FontStyle = 'normal' | 'italic' | 'oblique' | string; export interface TextEncodeEntry extends EncodeEntry, AlignProperty, ThetaProperty { text?: ProductionRule; angle?: ProductionRule; baseline?: ProductionRule; dir?: ProductionRule>; dx?: ProductionRule; dy?: ProductionRule; ellipsis?: ProductionRule; font?: ProductionRule; fontSize?: ProductionRule; fontWeight?: ProductionRule; fontStyle?: ProductionRule; limit?: ProductionRule; lineBreak?: ProductionRule; /** * The height, in pixels, of each line of text in a multi-line text mark or a text mark with `"line-top"` or `"line-bottom"` baseline. */ lineHeight?: ProductionRule; radius?: ProductionRule; } export interface TrailEncodeEntry extends EncodeEntry, DefinedProperty {} export interface Encodable { encode?: Encode; } export type Encode = Partial>; export type EncodeEntryName = | 'enter' | 'update' | 'exit' | 'hover' | 'leave' | 'select' | 'release';