import { Color, FontSpec, BorderRadius } from 'chart.js'; import { PartialEventContext } from './events'; import { DrawTime, Scriptable, ShadowOptions } from './options'; type percentString = string; export type LabelPosition = 'start' | 'center' | 'end' | percentString; export type LabelTextAlign = 'left' | 'start' | 'center' | 'right' | 'end'; export type CalloutPosition = 'left' | 'top' | 'bottom' | 'right' | 'auto'; export interface LabelPositionObject { x?: LabelPosition, y?: LabelPosition } export interface LabelPadding { top?: number, left?: number, right?: number, bottom?: number, x?: number, y?: number } export interface CalloutOptions { borderCapStyle?: Scriptable, borderColor?: Scriptable, borderDash?: Scriptable, borderDashOffset?: Scriptable, borderJoinStyle?: Scriptable, borderWidth?: Scriptable, display?: Scriptable, margin?: Scriptable, position?: Scriptable, side?: Scriptable, start?: Scriptable, } export interface CoreLabelOptions { drawTime?: Scriptable, font?: FontSpec color?: Scriptable, /** * Padding of label * @default 6 */ padding?: Scriptable, /** * Text alignment when the content of the label is multi-line. * @default 'center' */ textAlign?: Scriptable, textStrokeColor?: Scriptable, textStrokeWidth?: Scriptable, /** * Adjustment along x-axis (left-right) of label relative to above number (can be negative) * For horizontal lines positioned left or right, negative values move * the label toward the edge, and positive values toward the center. * @default 0 */ xAdjust?: Scriptable, /** * Adjustment along y-axis (top-bottom) of label relative to above number (can be negative) * For vertical lines positioned top or bottom, negative values move * the label toward the edge, and positive values toward the center. * @default 0 */ yAdjust?: Scriptable, /** * Text to display in label. Provide an array to display multiple lines */ content: Scriptable, /** * Overrides the width of the image. Could be set in pixel by a number, * or in percentage of current width of image by a string */ width?: Scriptable, /** * Overrides the height of the image. Could be set in pixel by a number, * or in percentage of current height of image by a string */ height?: Scriptable, z?: Scriptable } export interface ContainedLabelOptions extends CoreLabelOptions { backgroundColor?: Scriptable, borderWidth?: Scriptable, borderColor?: Scriptable, /** * Border line cap style. See MDN. * @default 'butt' */ borderCapStyle?: Scriptable, /** * Border line dash. See MDN. * @default [] */ borderDash?: Scriptable, /** * Border line dash offset. See MDN. * @default 0.0 */ borderDashOffset?: Scriptable, /** * Border line join style. See MDN. * @default 'miter' */ borderJoinStyle?: Scriptable, /** * Border radius of the label rectangle * @default 6 */ borderRadius?: Scriptable, callout?: CalloutOptions, } export interface LabelOptions extends ContainedLabelOptions, ShadowOptions { position?: Scriptable, /** * Whether the label should be displayed * @default true */ display?: Scriptable, /** * Rotation of label, in degrees, or 'auto' to use the degrees of the line, default is 0 * @default 90 */ rotation?: Scriptable } export interface BoxLabelOptions extends CoreLabelOptions { position?: Scriptable, /** * Whether the label should be displayed * @default true */ display?: Scriptable, rotation?: Scriptable } export interface LabelTypeOptions extends ContainedLabelOptions { position?: Scriptable, }