@visactor/vchart
Version:
charts lib based @visactor/VGrammar
71 lines (55 loc) • 2.72 kB
JavaScript
import { BandScale } from "@visactor/vscale";
import { ComponentTypeEnum } from "../../interface/type";
import { PolarAxis } from "./axis";
import { mixin } from "@visactor/vutils";
import { BandAxisMixin } from "../mixin/band-axis-mixin";
import { Factory } from "../../../core/factory";
import { registerAxis } from "../base-axis";
import { registerDataSetInstanceTransform } from "../../../data/register";
import { CircleAxis, CircleAxisGrid, LineAxis, LineAxisGrid, polarAngleAxisDiscreteTicks } from "@visactor/vrender-components";
import { GridEnum, AxisEnum } from "../interface";
import { commonAxis } from "../../../theme/builtin/common/component/axis/common-axis";
import { axisBand } from "../../../theme/builtin/common/component/axis/band-axis";
import { axisAngle, axisRadius } from "../../../theme/builtin/common/component/axis/polar-axis";
export class PolarBandAxis extends PolarAxis {
constructor() {
super(...arguments), this.type = ComponentTypeEnum.polarBandAxis, this._scale = new BandScale;
}
computeDomain(data) {
return this.computeBandDomain(data);
}
updateScaleRange() {
const isChanged = super.updateScaleRange();
return this.updateGroupScaleRange(), isChanged;
}
axisHelper() {
const helper = super.axisHelper();
return Object.assign(Object.assign({}, helper), {
getBandwidth: depth => helper.getScale(depth).bandwidth()
});
}
initScales() {
super.initScales(), this.calcScales(this._defaultBandInnerPadding, this._defaultBandOuterPadding);
}
registerTicksTransform() {
const name = `${this.type}-ticks`;
return registerDataSetInstanceTransform(this._option.dataSet, name, polarAngleAxisDiscreteTicks),
name;
}
transformScaleDomain() {}
}
PolarBandAxis.type = ComponentTypeEnum.polarBandAxis, PolarBandAxis.specKey = "axes",
PolarBandAxis.builtInTheme = {
axis: commonAxis,
axisBand: axisBand,
axisAngle: axisAngle,
axisRadius: axisRadius
}, mixin(PolarBandAxis, BandAxisMixin);
export const registerPolarBandAxis = () => {
Factory.registerGraphicComponent(AxisEnum.lineAxis, ((attrs, options) => new LineAxis(attrs, options))),
Factory.registerGraphicComponent(GridEnum.lineAxisGrid, ((attrs, options) => new LineAxisGrid(attrs, options))),
Factory.registerGraphicComponent(AxisEnum.circleAxis, ((attrs, options) => new CircleAxis(attrs, options))),
Factory.registerGraphicComponent(GridEnum.circleAxisGrid, ((attrs, options) => new CircleAxisGrid(attrs, options))),
registerAxis(), Factory.registerComponent(PolarBandAxis.type, PolarBandAxis);
};
//# sourceMappingURL=band-axis.js.map