API / Configuration / ChartAxisLabels

Defined in: src/core/types/chart/axis.ts:15

Properties

Property Type Description
autoRotation? boolean For horizontal axes, enable label rotation to prevent overlapping labels. If there is enough space, labels are not rotated. As the chart gets narrower, it will start rotating the labels -45 degrees. Does not apply to html labels. Default true for all axis types except datetime (defaults to false)
dateFormat? string -
dateTimeLabelFormats? Partial<Record<"millisecond" | "second" | "minute" | "hour" | "day" | "week" | "month" | "quarter" | "halfYear" | "year", string>> Per-granularity display formats for the x-axis datetime labels. Ignored when dateFormat is set. Each value is a format string in the same form as the format argument to DateTime#format in @gravity-ui/date-utils (see the FormatInput type there): Day.js–style tokens, e.g. YYYY, MM, DD, HH, mm, ss, SSS, MMM. Additional custom token: B expands to the half-year digit (1 or 2) — B stands for bi-annual since H and h are reserved by Day.js for clock hours. Use Day.js escape syntax for the label prefix, e.g. 'YYYY [H]B'"2024 H1". Mirrors the quarter pattern: 'YYYY [Q]Q'"2024 Q2". Partial objects are merged with the built-in DATETIME_LABEL_FORMATS; omitted keys keep defaults. Examples dateTimeLabelFormats: { day: 'YYYY-MM-DD', hour: 'YYYY-MM-DD HH:mm', minute: 'YYYY-MM-DD HH:mm' } dateTimeLabelFormats: { day: 'MM/DD/YYYY', week: 'MM/DD/YYYY' } dateTimeLabelFormats: { quarter: 'YYYY [Q]Q', halfYear: 'YYYY [H]B' } dateTimeLabelFormats: { month: 'YYYY-MM', year: 'YYYY' } See https://gravity-ui.github.io/date-utils/pages/api/DateTime/overview.html
enabled? boolean Enable or disable the axis labels.
html? boolean Allows to use any html-tags to display labels content. Supports only for axis with type "category". Default false
margin? number The label's pixel distance from the perimeter of the plot area. Default 10
maxWidth? string | number The maximum width of the axis labels(absolute or relative to the chart area). If more than that, it collapses into three points.
numberFormat? FormatNumberOptions -
padding? number The pixel padding for axis labels, to ensure white space between them. Default 4
rotation? number Rotation of the labels in degrees. Does not apply to html labels. Default 0
style? Partial<BaseTextStyle> -