protected createScale()

in packages/util-scales/src/discrete/BandScale.ts [100:134]


	protected createScale(args: ScaleCreationContext): Scales {
		const domain = this.getDomain(args)
		const range = this.getRange(args)
		const bandscale = scaleBand()
			.domain(domain.map(d => '' + d))
			.range(range)

		if (this.alignValue) {
			bandscale.align(this.alignValue)
		}
		if (this.paddingValue) {
			bandscale.padding(this.paddingValue)
		}
		if (this.paddingOuterValue) {
			bandscale.paddingOuter(this.paddingOuterValue)
		}
		if (this.paddingInnerValue) {
			bandscale.paddingInner(this.paddingInnerValue)
		}
		if (this.roundValue) {
			bandscale.round(this.roundValue)
		}

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