Point scales are a special case of band scales that the bandwidth always fixed to zero.
import { Point, PointOptions } from '@antv/scale';
const options: PointOptions = {
domain: ["A", "B", "C", "D"],
padding: 0.5,
round: true,
range: [0, 600]
}
const x = new Point(options);
scale.map('A') // 75
scale.getStep(); // 150
scale.getBandWidth(); // always 0
Key | Description | Type | Default |
---|---|---|---|
domain | Sets the scale’s domain to the specified array of values. | number[] | string[] | Date[] |
[] |
range | Sets the scale’s range to the specified array of values. | number[] |
[0, 1] |
unknown | Sets the output value of the scale for undefined (or NaN ) input values. |
any |
undefined |
round | If round option is truthy, the start and stop of each point will be integers. | boolean |
false |
padding | Set the scale's padding. In fact, this is the outerPadding of the band option. For more info about this, please see example. |
number |
0 |
align | The align option specifies how outer padding is distributed in the range, the value should in the range [0, 1]. For example, value of 0.5 means that points should be centered within the range, value of 0 or 1 may be used to shift the points to one side. |
number |
0.5 |
compare | Sets the comparator for sorting the domain before mapping. | (a: string or number, b: string or number) => number |
undefined |
We can easily find that point scale's bandwidth is always zero.
PO = Padding = PaddingInner
domain = ["A", "B", "C"]
|<------------------------------------------- range ------------------------------------------->|
| | | | |
|<--step*PO-->|<--------------step------------->|<--------------step------------->|<--step*PO-->|
| | | | |
| A B C |
|-----------------------------------------------------------------------------------------------|
# map(x: number | string): number
Given a value in the input domain, returns the corresponding value in the output range if it is not undefined
(or NaN
), otherwise options.unknown
# invert(x: number): number | string
Given a value from the range, returns the corresponding value from the domain.
# update(options: PointOptions): void
Update the scale's options and rescale.
# getOptions(): PointOptions
Returns the scale's current options.
# clone(): Point
Returns a new point scale with the independent and same options as the original one.
# getStep(): number
Returns point scale's step, for more info about this, please see example.
# getBandWidth(): number
Returns point scale's bandWidth
, In fact, the value is always 0. For more info about this, please
see example.
# getRange(): number[]
Returns band scale's adjusted range example.