@visactor/vchart
Version:
charts lib based @visactor/VGrammar
90 lines (78 loc) • 4.59 kB
JavaScript
import { AttributeLevel } from "../../../constant/attribute";
import { SeriesTypeEnum } from "../../interface/type";
import { FunnelSeries } from "../funnel";
import { registerPyramid3dMark } from "../../../mark/polygon/pyramid-3d";
import { registerTextMark } from "../../../mark/text";
import { registerRuleMark } from "../../../mark/rule";
import { funnel3dSeriesMark } from "../constant";
import { Factory } from "../../../core/factory";
import { Funnel3dSeriesSpecTransformer } from "./funnel-3d-transformer";
export class Funnel3dSeries extends FunnelSeries {
constructor() {
super(...arguments), this.type = SeriesTypeEnum.funnel3d, this._funnelMarkName = "funnel3d",
this._funnelMarkType = "pyramid3d", this._transformMarkName = "transform3d", this._transformMarkType = "pyramid3d",
this.transformerConstructor = Funnel3dSeriesSpecTransformer;
}
initMark() {
var _a, _b, _c, _d, _e, _f, _g, _h;
if (this._funnelMark = this._createMark(Object.assign(Object.assign({}, Funnel3dSeries.mark.funnel3d), {
name: this._funnelMarkName,
type: this._funnelMarkType
}), {
themeSpec: null === (_a = this._theme) || void 0 === _a ? void 0 : _a.funnel3d,
key: this._seriesField,
isSeriesMark: !0
}, {
support3d: !0
}), this._spec.isTransform && (this._funnelTransformMark = this._createMark(Object.assign(Object.assign({}, Funnel3dSeries.mark.transform3d), {
name: this._transformMarkName,
type: this._transformMarkType
}), {
themeSpec: null === (_b = this._theme) || void 0 === _b ? void 0 : _b.transform3d,
key: this._seriesField,
skipBeforeLayouted: !1,
dataView: this._viewDataTransform.getDataView(),
dataProductId: this._viewDataTransform.getProductId()
})), null === (_d = null === (_c = this._spec) || void 0 === _c ? void 0 : _c.outerLabel) || void 0 === _d ? void 0 : _d.visible) {
const {line: line} = null !== (_e = this._spec.outerLabel) && void 0 !== _e ? _e : {}, {line: lineTheme} = null !== (_g = null === (_f = this._theme) || void 0 === _f ? void 0 : _f.outerLabel) && void 0 !== _g ? _g : {};
this._funnelOuterLabelMark.label = this._createMark(Funnel3dSeries.mark.outerLabel, {
themeSpec: null === (_h = this._theme) || void 0 === _h ? void 0 : _h.outerLabel,
key: this._seriesField,
markSpec: this._spec.outerLabel
}), this._funnelOuterLabelMark.line = this._createMark(Funnel3dSeries.mark.outerLabelLine, {
themeSpec: lineTheme,
key: this._seriesField,
markSpec: line,
depend: [ this._funnelOuterLabelMark.label ]
});
}
}
initMarkStyle() {
super.initMarkStyle();
const funnelMark = this._funnelMark;
funnelMark && this.setMarkStyle(funnelMark, {
z: _ => {
if (this._isHorizontal()) return 0;
const points = this.getPoints(_), width = Math.max(Math.abs(points[0].x - points[1].x), Math.abs(points[2].x - points[3].x));
return (this._computeMaxSize() - width) / 2;
}
}, "normal", AttributeLevel.Series);
}
initLabelMarkStyle(labelMark) {
var _a, _b;
super.initLabelMarkStyle(labelMark), this.setMarkStyle(labelMark, {
z: _ => {
if (this._isHorizontal()) return 0;
const points = this.getPoints(_), width = Math.max(Math.abs(points[0].x - points[1].x), Math.abs(points[2].x - points[3].x));
return (this._computeMaxSize() - width) / 2;
}
}, "normal", AttributeLevel.Series), this._labelMark = labelMark, (null === (_a = this._funnelOuterLabelMark) || void 0 === _a ? void 0 : _a.label) && this._funnelOuterLabelMark.label.setDepend(labelMark.getComponent()),
(null === (_b = this._funnelOuterLabelMark) || void 0 === _b ? void 0 : _b.line) && this._funnelOuterLabelMark.line.setDepend(...this._funnelOuterLabelMark.line.getDepend());
}
}
Funnel3dSeries.type = SeriesTypeEnum.funnel3d, Funnel3dSeries.mark = funnel3dSeriesMark,
Funnel3dSeries.transformerConstructor = Funnel3dSeriesSpecTransformer;
export const registerFunnel3dSeries = () => {
registerPyramid3dMark(), registerTextMark(), registerRuleMark(), Factory.registerSeries(Funnel3dSeries.type, Funnel3dSeries);
};
//# sourceMappingURL=funnel-3d.js.map