protected createScale()

in packages/util-scales/src/discrete/PointScale.ts [53:78]


	protected createScale(args: ScaleCreationContext): Scales {
		const scale = scalePoint()
			.domain(this.getDomain(args))
			.range(this.getRange(args))

		if (this.paddingValue !== undefined) {
			scale.padding(this.paddingValue)
		}

		if (this.alignValue !== undefined) {
			scale.align(this.alignValue)
		}

		if (this.roundValue !== undefined) {
			scale.round(this.roundValue)
		}

		if (!this.nameValue) {
			throw new Error('scale name must be defined')
		}
		const result: Scales = { [this.nameValue]: scale }
		if (this.stepNameValue) {
			result[this.stepNameValue as string] = scale.step as Scale<any, number>
		}
		return result
	}