zz-chart
Version:
Alauda Chart components by Alauda Frontend Team
49 lines • 1.43 kB
JavaScript
import { get } from 'lodash-es';
import { getSeriesPathType } from '../../strategy/utils.js';
import { ShapeType } from '../../utils/index.js';
import { Shape } from './index.js';
/**
* Line 折线图
*/
export default class Line extends Shape {
constructor(ctrl, opt = {}) {
super(ctrl, opt);
this.type = ShapeType.Line;
this.ctrl.setShape(this.type, this);
const option = get(this.ctrl.getOption(), this.type);
if (typeof option === 'object' && option.step) {
this.stepType = option.step;
}
}
map(name) {
this.mapName = name;
return this;
}
step(type) {
this.stepType = type;
}
getSeries() {
const baseSeries = this.getBaseSeries();
return this.getData().map(({ color, name }) => {
return {
stroke: color,
label: name,
spanGaps: this.connectNulls,
...getSeriesPathType(this.type, color, this.option, this.stepType),
...this.option,
...(baseSeries.points && {
points: {
...baseSeries.points,
fill: color,
space: 0,
},
}),
};
});
}
destroy() {
this.stepType = null;
super.destroy();
}
}
//# sourceMappingURL=line.js.map