The Scale component draw graduation.
The number of ticks is set by the steps prop of the parent Knob component.
The single scale tick can be a SVG rect or circle. Additionally a render
function can be passed as a prop, that will render each tick.
This is useful if the scale ticks should have different colors, or different tick length for every 10th tick for example.
<Knob size={200} angleOffset={220} angleRange={280} min={0} max={100} steps={10} // amount of intervals > <Scale tickWidth={5} tickHeight={10} radius={45} color="#FC5A96" activeColor="#180094" /> </Knob>
Properties
| Prop | Description |
|---|---|
type | Can be |
radius | Outer radius where the ticks ends. |
tickWidth | Width of a single tick. Used as radius if type is circle. |
tickHeight | Height of a single tick. Is ignored when type is circle. |
color | Will be passed as color prop to the render SVG element of a tick or to the custom render function. |
activeColor | Color for the tick that indicates the same value as the current knob value. |
className | Will be passed as prop to the render SVG element of a tick or to the custom render function. |
activeClassName |
|
fn | Function that can be used to have the full control over how a tick is rendered. The function needs to return a SVG element. See details bellow. |
Custom function
The property fn can be used to have the full control over how a tick is rendered.
The function needs to return a SVG element.
The function will get the following props passed:
activeactiveClassNameactiveColorangleOffsetcenterclassNamecolorstepSizetickHeighttranslateXtranslateYtickWidthpercentagesteps
Most of them are just passed down from the Pointer or the Knob.
Additional are:
center, the half of thesizeof theKnobstepSize, the size of the angle of one step in degreetranslateX,translateYthat are needed to put the tick on the correct position using the transform prop e.g:transform={`translate(${translateX} ${translateY})`}iwhich is the index of the current tick.