Y-axis
Component that creates an y-axis in reference to its parent Graphic
or Section
’s local coordinate system.
<script>
import { Graphic, YAxis } from '@snlab/florence'
</script>
<Graphic width={200} height={200} scaleY={[0, 10]} padding={20}>
<YAxis />
</Graphic>
Properties
Positioning
Prop |
Required |
Type(s) |
Default |
Unit(s) |
hjust |
false |
String , Number |
'left' |
See explanation |
xOffset |
false |
Number |
0 |
Pixel |
flip |
false |
Boolean |
false |
- |
hjust
can either be a String
with the one of the values 'left'
, 'right'
, or 'center'
, or a Number
where 0
corresponds to 'left'
, 1
corresponds to 'right'
, and 0.5
to 'center'
. This is the main way to determine where in the Section
the YAxis
will be positioned.
xOffset
allows shifting the axis a few pixels right (when it is negative) or left (when it is positive) from where it has been positioned using hjust
.
- setting
flip
to true
will make the ticks
and labels
switch sides accross the axis.
Baseline
Prop |
Required |
Type(s) |
Default |
Unit(s) |
baseLine |
false |
Boolean |
true |
- |
baseLineColor |
false |
String |
'black' |
Named, hex, rgb or hsl color |
baseLineOpacity |
false |
Number |
1 |
Number between 0 and 1 |
baseLineWidth |
false |
Number |
1 |
Pixel |
- setting
baseLine
to false
will hide the horizontal axis line.
- the rest should be self-explanatory.
Ticks
Prop |
Required |
Type(s) |
Default |
Unit(s) |
ticks |
false |
Boolean |
true |
- |
tickCount |
false |
Number |
10 |
- |
tickExtra |
false |
Boolean |
false |
- |
tickValues |
false |
Array |
undefined |
Local coordinate |
tickSize |
false |
Number |
5 |
Pixel |
tickWidth |
false |
Number |
0.5 |
Pixel |
tickColor |
false |
String |
'black' |
Named, hex, rgb or hsl color |
tickOpacity |
false |
Number |
1 |
Number between 0 and 1 |
- setting
ticks
to false
will hide the ticks.
tickCount
will determine the number of ticks.
tickExtra
will add an extra tick to mark the lower end of the domain.
tickValues
can be used to manually place ticks, and will override tickCount
and tickExtra
.
tickSize
refers to the length of the ticks.
tickWidth
refers to the line width of the ticks.
tickOpacity
refers to the opacity of the ticks.
Tick labels
Prop |
Required |
Type(s) |
Default |
Unit(s) |
labelFormat |
false |
Function |
undefined |
- |
labelOffset |
false |
Number |
2 |
Pixel |
labelRotate |
false |
Number |
0 |
Radian |
labelFont |
false |
String |
'Helvetica' |
Font |
labelFontSize |
false |
Number |
10 |
Pixel |
labelFontWeight |
false |
String |
'normal' |
See Label Mark |
labelOpacity |
false |
Number |
1 |
Number between 0 and 1 |
labelColor |
false |
String |
'black' |
Named, hex, rgb or hsl color |
labelFormat
is a Function
that receives a tick value, and can return a formatted tick value (for example, passing Math.floor
to labelFormat
in a numeric domain will coerce all tick values into integers).
labelOffset
allows shifting the labels a few pixels up (negative) or down (positive).
labelRotate
allows rotating the tick labels. This can be useful when the tick labels are close together.
- the rest should be self-explanatory.
Title
Prop |
Required |
Type(s) |
Default |
Unit(s) |
titleVjust |
false |
String , Number |
'center' |
See explanation |
titleYOffset |
false |
Number |
0 |
Pixel |
titleHjust |
false |
String , Number |
'axis' |
See explanation |
titleXOffset |
false |
String , Number |
'axis' |
See explanation |
title |
false |
String |
'' |
- |
titleColor |
false |
String |
'black' |
Named, hex, rgb or hsl color |
titleFont |
false |
String |
'Helvetica' |
Font |
titleFontSize |
false |
Number |
12 |
Pixel |
titleFontWeight |
false |
String |
'normal' |
See explanation |
titleOpacity |
false |
Number |
1 |
Number between 0 and 1 |
titleRotate |
false |
Number |
0 |
Radian |
titleAnchorPoint |
false |
String |
't' |
See explanation |
titleVjust
, titleYOffset
, titleHjust
and titleXOffset
can be used to position the axis title similar to the YAxis
’s hjust
and xOffset
props. The titleHjust
and titleXOffset
props, however, also allow a String
with the value 'axis'
, which automatically places the title in a reasonable default position. For an explanation of titleAnchorPoint
, see the anchorPoint
explanation in the Label Mark documentation.
Other
Prop |
Required |
Type(s) |
Default |
Unit(s) |
clip |
false |
String , undefined |
'outer' |
Either 'padding' , 'outer' or undefined |
Can be used to override the clip mode of the parent Graphic
, Section
or Glyph
. When undefined
, inherits from the parent Section
or Graphic
.