import "@arcgis/common-components/components/arcgis-ticks";- Inheritance
- ArcgisTicks→
HTMLElement
- Since
- ArcGIS Maps SDK for JavaScript 5.0
The ticks component displays visual markers along a line to indicate scale, intervals, or specific values. It is often used in conjunction with the Slider component. Ticks help users understand the slider’s range and make more precise selections.
Tick placement is controlled by the mode, which defines how the values are parsed and translated into positions along the line. Tick positions are derived from the component’s min and max range, with optional non-linear scaling via interpolationExponent. Ticks can be displayed in vertical or horizontal layout, with optional showLabels and a showBaseline. The component can also be made interactive to respond to user clicks on individual ticks. The labelFormatter property allows customization of tick label formatting.
Demos
- Example
The following example creates a vertical slider with ticks. The ticks are positioned at the end of the slider and displayed every 10 units from 0 to 100.
<arcgis-slider id="sliderComponent" min="0" max="100" show-range-labels values="50" layout="vertical"><arcgis-ticks slot="content-end" style="flex:1;"min="0" max="100"mode="value"show-labelslabel-placement="end"values="0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100"layout="vertical"></arcgis-ticks></arcgis-slider>
Properties
| Property | Attribute | Type |
|---|---|---|
| reflected | interactive | |
| interpolation-exponent | ||
| | ||
| reflected | label-placement | "end" | "start" |
| reflected | layout | |
| max | ||
| min | ||
| reflected | mirrored | |
| mode | ||
| show-baseline | ||
| show-labels | ||
| values |
interactive
- Type
- boolean
When true, ticks are clickable and the component emits @arcgisTickClick when the user selects a tick.
- See also
- Attribute
- interactive
- Default value
- false
interpolationExponent
- Type
- number
The exponent used to interpolate the position of ticks along the component.
A value of 0 indicates linear interpolation. Positive values indicate exponential interpolation, and negative values indicate logarithmic interpolation.
Set this property when the range of values is large and users need precision in the lower range of values (for an exponential interpolation), or in the higher range (for a logarithmic interpolation).
<arcgis-ticks interpolation-exponent={14} min={1} max={5518000} mode="value" values={[1, 11500, 5518000]} />- Attribute
- interpolation-exponent
- Default value
- 0
layout
- Type
- Layout
Determines the layout/orientation of the ticks component. By default, the ticks will render horizontally.
When set to vertical, the ticks will render vertically.
- Attribute
- layout
- Default value
- "horizontal"
mirrored
- Type
- boolean
When true, the values are displayed from high to low.
- Attribute
- mirrored
- Default value
- false
mode
- Type
- TickMode
The manner in which ticks are positioned along the component. It determines how values is interpreted.
count: Places a fixed number of ticks (specified in values) at equal intervals.percent: Interprets values as percentages. If it's a single number, that number is the interval between ticks; if it's an array, the array specifies the percentage positions for ticks.value: Places ticks only at the values listed in values.
- See also
- Attribute
- mode
- Default value
- "count"
- Examples
- <!-- Place ticks at each value listed in `values` --><arcgis-slider min="0" max="100" show-range-labels values="20, 50"><arcgis-ticksslot="content-end" style="flex:1;"min="0" max="100"show-labels label-placement="end"mode="value"values="0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100"></arcgis-ticks></arcgis-slider>
In count mode, the values property specifies the number of ticks to render (not a list of tick values). For example, use
11ticks to show 0–100 in intervals of 10 (0, 10, 20, ..., 100).<!-- 11 ticks from 0 to 100 --><arcgis-slider min="0" max="100" show-range-labels values="20, 50"><arcgis-ticksslot="content-end" style="flex:1;"min="0" max="100"show-labels label-placement="end"mode="count"values="11"></arcgis-ticks></arcgis-slider>In percent mode, values are percentages along the track. Use an array to place ticks at specific percentages, or a single number as a repeating interval.
<!-- Ticks at 0%, 25%, 50%, 75%, and 100% --><arcgis-slider min="0" max="200" show-range-labels values="50, 150"><arcgis-ticksslot="content-end" style="flex:1;"min="0" max="200"show-labels label-placement="end"mode="percent"values="0, 25, 50, 75, 100"></arcgis-ticks></arcgis-slider>
showBaseline
- Type
- boolean
Indicates whether to render a line connecting the ticks.
- Attribute
- show-baseline
- Default value
- false
showLabels
- Type
- boolean
Indicates whether to render labels for the ticks.
- Attribute
- show-labels
- Default value
- false
values
- Type
- TickValues
Indicates where ticks are rendered along the component. This can be set as comma-separated
numbers in the attribute (e.g., <arcgis-ticks values="10, 20, 30"></arcgis-ticks>) or programmatically as
either a single number or an array of numbers (e.g., ticks.values = 10, ticks.values = [10, 20, 30]).
See the description for mode for more information about how this property is interpreted by each mode.
- See also
- Attribute
- values
Methods
| Method | Signature |
|---|---|
| inherited | componentOnReady(): Promise<this> |
componentOnReady
- Signature
-
componentOnReady (): Promise<this>
Creates a promise that resolves once the component is fully loaded.
- Returns
- Promise<this>
- Example
- const arcgisTicks = document.createElement("arcgis-ticks");document.body.append(arcgisTicks);await arcgisTicks.componentOnReady();console.log("arcgis-ticks is ready to go!");
Events
| Name | Type |
|---|---|
| CustomEvent<{ value: number; }> |
arcgisTickClick
arcgisTickClick: CustomEvent<{ value: number; }> Fires when the user clicks on one of the ticks. This event is only emitted when the interactive property is set to true.
- See also
- Example
The following example listens for the
arcgisTickClickevent and logs the clicked tick's value.const ticks = document.querySelector("arcgis-ticks");ticks.addEventListener("arcgisTickClick", (event) => {console.log("Clicked tick value:", event.detail.value);});
Styles
| Name | Default | Description |
|---|---|---|
| | Specifies the length of the ticks. | |
| | Specifies the color of the ticks. | |
| | Specifies the gap between the ticks and labels. |