AxisRight
Axis preset whose ticks are drawn to the right of the vertical domain path. Accepts everything the base Axis class does.
Basic example
Section titled “Basic example”The same vertical [0, 100] domain over 400px, but with ticks and labels drawn to the right, positioning it as a right-edge y-axis.
Title of the axis.
Configuration
import {AxisRight} from "@d3plus/core";
alignstringDefaultmiddlebarConfigrecordAxis line style.
baselinenumberDefault0The tick the axis's
baselineBreakreturns to. Defaults to0. To start a Plot's value axis at a value, set the chart'sbaselineinstead.baselineBreakbooleanDefaultfalseWhen a linear value axis's domain stops short of the
baseline(e.g.[1100, 2100]with a baseline of0), keeps the baseline tick and breaks the axis between it and the domain, styled bybaselineBreakConfig. Turned off, a Plot'syDomainstretches to the baseline instead. Defaults totruefor Plots whose marks grow from0(BarChart, AreaPlot, Histogram, Lollipop), elsefalse.baselineBreakConfigrecordStyle of the break drawn when
baselineBreakis on and the domain stops short ofbaseline:space(pixels of axis between the baseline tick and the first tick after the break),gap(pixels between the two break marks, where the axis line is not drawn),size(length of each mark, drawn outward from the axis line on the tick side so it never reaches into the plot),angle(degrees each mark tilts from perpendicular),linesandlineConfig(the lines a Plot runs across the plot from each mark, as inbreakConfig),mask(whether a Plot cuts the gap between those lines across the shapes, defaulttrue), plusstroke/stroke-widthand other line styles for the marks.breakfalse|[number, number]|array.<[number, number]>DefaultfalseValue ranges to remove from a linear axis: one
[start, end]pair or a list of them. Each collapses to a short marked gap (styled bybreakConfig); values either side share one scale, and tooltips still show real values. Ranges outside the domain are ignored.breakConfigrecordStyle of the breaks set with
break:space(pixels of axis each break occupies),spaceMin(the leastspacea break shrinks to when the axis is too short to holdspaceand leave twice that for the data; by default such a break is dropped),gap(pixels between its two marks, where the axis line is not drawn; it shrinks with the break),size(length of each mark, drawn outward from the axis line on the tick side so it never reaches into the plot),angle(degrees each mark tilts from perpendicular),lines(whether a Plot runs a line across the plot from each mark, defaulttrue),lineConfig(those lines' style —stroke,stroke-width, … — over the axis line'sbarConfigstyle),mask(whether a Plot cuts the gap between the lines across the shapes, defaulttrue), plusstroke/stroke-widthand other line styles for the marks.classNamestring|array.<string>|undefinedCSS classes added to the outermost element this chart or component draws into, next to its fixed d3plus classes, so page CSS can target it: a chart's root
<svg class="d3plus-viz">(its<canvas>with the Canvas renderer) and a standalone component's<svg>. Takes a space-separated string or an array. A new value replaces the classes the previous one added; unset adds none. Tooltips take their owntooltipConfig.className.colorDefaultscolordefaultsconfigOverrides the default colors used when assigning fills from data and choosing legible text colors:
darkandlight(the text colors picked for contrast against a background),missing(null/undefined values),on/off(true/falsevalues),sequential(the anchor hue for magnitude ramps), andscale(the categorical palette, given as a d3 ordinal scale or an array of colors). Keys are merged into the current defaults, and a Viz passes its overrides down to the shapes and components it draws.configd3plusconfigMethods that correspond to the key/value pairs and returns this class.
dataarray.<unknown>An array of data points, which helps determine which ticks should be shown and which time resolution should be displayed.
domainarray.<string|number|date|undefined>Default[0,10]The axis's domain:
[min, max]on a continuous axis, or the categories to show on a discrete one. In a Plot it overridesxDomain/yDomainand isn't rounded unlessroundingsays so; a single end ([min]or[undefined, max]) pins that end likeyDomain([min]).domainTicksbooleanDefaulttrueWhether the domain's min and max are always shown as ticks, even when they aren't among the scale's own "nice" tick values (the nearest nice tick is dropped when it would crowd them). Defaults to
true; zooming turns it off so a rescaled axis shows only nice values.durationnumberDefault600Animation duration in ms.
exponentnumberDefault1The exponent of a
"pow"axis (scale: "pow"): below 1 it spreads the small values out and squeezes the large ones together (0.5matches a"sqrt"axis), above 1 it does the opposite. Defaults to1, which draws like a linear axis. Only a"pow"axis reads it; on any other scale it has no effect, and a value that isn't a positive number falls back to1. Ticks are spaced evenly along a power axis and rounded to round values.fixedSizenumberExact size of the space that contains the axis tick labels and title. Labels that need more room overflow outward instead of moving the axis line; zooming pins a rescaled axis this way so it doesn't shift.
gridarray.<unknown>Grid values of the axis.
gridConfigrecordGrid config of the axis.
gridLogbooleanDefaultfalsegridSizenumberGrid size of the axis.
heightnumberDefault400Overall height of the visualization in pixels.
labelOffsetfalse|numberDefaultfalselabelRotationnumber|boolean|undefinedWhether to rotate the axis labels, and by how much.
truerotates them -90 degrees andfalsekeeps them flat. Leftundefined(the default), a horizontal axis of categories rotates its labels when any label would not fit its share of the axis whole (a word dropped, cut off, or broken across lines) or would overlap its neighbor: they slant 30 degrees (-30 on a bottom axis, 30 on a top one), or stand at -90 when even slanted they would leave more labels cut short or hidden. A vertical axis never rotates its labels on its own. A number rotates them by that many degrees (clockwise, so-45rises to the right): each label hangs off the axis from the end of its text nearest the axis, which sits across from its tick, so on a bottom axis a negative angle ends each label at its tick and a positive one starts it there. Angles outside -90 to 90 turn a half turn to read left to right (135draws as-45), and0keeps the labels flat. Slanted labels wrap between words onto up to three lines, as many as fit between neighboring labels, so they reach less far from the axis. Labels that still overlap once rotated are thinned evenly.labelsarray.<unknown>Visible tick labels of the axis. Also takes a list of label lists, from the most labels to the fewest: the axis labels the first list whose labels all fit whole without crowding, else the last one, thinned. Its ticks then follow the chosen list unless
ticksis set.localestring|objectThe locale used for all text and number formatting. Supports the locales defined in d3plus-format. The locale can be a complex Object, a locale code (like "en-US"), or a 2-digit language code (like "en"). If a 2-digit code is provided, the "findLocale" function is used to identify the most approximate locale.
maxSizenumber|functionMaximum size allowed for the space that contains the axis tick labels and title: a number of pixels, or a function that is given the room the axis has across its labels and returns that maximum. The room is a horizontal axis's
heightor a vertical axis'swidth; in a chart, it is the chart's height (for a horizontal axis) or width (for a vertical one) inside its margins. A chart can call the function more than once in a draw, so it should depend only on its argument.minSizenumberMinimum size alloted for the space that contains the axis tick labels and title.
onstringEvent listener for the specified event typenames. Mirrors the core d3-selection behavior.
orientstringDefaultrightThe orientation of the shape.
paddingcalloutvalueDefault5Space between the text and the box's edge, in pixels. Defaults to
6.paddingInnernumberDefault0.1paddingOuternumberDefault0.1parentunknownParent config used by the wrapper.
rangearray.<number|undefined>Scale range (in pixels) of the axis. The given array must have 2 values, but one may be
undefinedto allow the default behavior for that value.rangeBreaksfalse|rangebreakrule|array.<rangebreakrule>DefaultfalseStretches of time to hide from a time axis (weekends, nights, holidays), so the data closes up around them: one rule or a list of them.
"weekends";{days: [5, 6]}(0 is Sunday);{hours: [17, 9]}, daily, wrapping past midnight (9.5is 9:30);{values: [date, …]}, whole days; or{bounds: [start, end]}, one range. Rules use local time. A rule'smarkerdraws thebreakmarker at the gap (on by default forboundsonly).renderfunctionRenders the current Axis to the page.
reversebooleanDefaultfalseWhether to flip the axis's direction, so its values run the other way: a horizontal axis from right to left, a vertical one from top to bottom (a Plot's y axis, categories included, normally runs bottom to top, so reversing it lists them from the top). Everything placed on the axis follows it: shapes, tick labels, gridlines, breaks, zooming, and hover badges. Defaults to
false.rotatedTickFormatfunctionTick formatter for labels drawn rotated (see
labelRotation), in place oftickFormat: rotation is decided by measuring the labels this way, so a long label can rotate in a shorter form.rounding"none"|"outside"|"inside"DefaultnoneHow a linear or log axis rounds its domain to "nice" values: "outside" widens each end past the data, "inside" pulls each end in, and "none" keeps it as given. Defaults to "none" on an Axis and "outside" in a Plot. A Plot only rounds the ends a user domain leaves open, unless
roundingis set here.roundingInsideMaxPrefixstringroundingInsideMaxSuffixstringDefault+roundingInsideMinPrefixstringDefault<roundingInsideMinSuffixstringscaleaxisscaleDefaultlinearScale of the axis.
scaleAlignnumberDefault0.5scalePaddingnumberDefault0.5selectstring|htmlelement|null|undefinedThe SVG container element as a d3 selector or DOM element.
Passing
nullorundefineddeliberately leaves the axis unmounted —renderMode("compute")plusselect(null)produces a scene-only axis (no detached SVG fallback). This is the formal contract callers inplotPaintuse to compute axis layout without mounting DOM.shape"line"|"rect"|"circle"DefaultLineThe shape drawn at each tick:
"Line"(the default),"Rect", or"Circle".shapeConfigd3plusconfigConfiguration object with key/value pairs applied as method calls on each shape.
tickFormatfunctionTick formatter, called with the axis as
this. Defaults to the locale's abbreviated number format ("1.5k"), with years printed in full ("1990") when the axis's values are all whole numbers from 1000 through 2999.tickSizenumberDefault8tickSuffixstringDefaultnormaltickTooltipstring|false|axistooltipconfig|functionThe tooltip shown when a tick label is hovered, in a chart: its text (the same on every tick), a function that receives the tick's value (as
tickFormatdoes) and its index and returns the text, or a tooltip config (astooltipConfig) whose accessors receive the same. The index counts the axis's labels from the start of its domain (0 is the bottom label of a y axis, the left one of an x axis). Unset (the default) or when the function returns nothing, a label cut short with an ellipsis shows its whole text;false, set or returned, shows no tooltip.ticksarray.<unknown>Tick values of the axis.
timeLocalerecordDefines a custom locale object to be used in time scales. Must include
dateTime,date,time,periods,days,shortDays,months, andshortMonths(see d3-time-format).titlestringTitle of the axis.
titleConfigrecordTitle configuration of the axis.
titleTooltipstring|false|axistooltipconfig|functionThe tooltip shown when the axis title is hovered, in a chart: the tooltip's text, a function that receives the title and returns it, or a tooltip config (as
tooltipConfig) whose accessors receive the title. Unset (the default) or when the function returns nothing, a title cut short with an ellipsis shows its whole text;false, set or returned, shows no tooltip.translatefunctionDefines how informational text strings should be displayed. By default, this function will try to find the string in question (which is the first argument provided to this function) inside of an internally managed translation Object. If you'd like to override to use custom text, simply pass this method your own custom formatting function.
widthnumberDefault400Overall width of the visualization in pixels.