Skip to content

Commit 4ce5987

Browse files
feat: legend axis 根节点 className 兼容
1 parent a0ba2a4 commit 4ce5987

3 files changed

Lines changed: 25 additions & 1 deletion

File tree

src/ui/axis/axis.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,14 @@ export class Axis extends Component<AxisStyleProps> {
6464

6565
render(attributes: RequiredAxisStyleProps, container: Group, specificAnimation?: GenericAnimation) {
6666
const { titleText, data, animate, showTitle, showGrid, dataThreshold, truncRange, classNamePrefix } = attributes;
67+
68+
// Set root container className
69+
if (classNamePrefix) {
70+
container.className = `axis ${classNamePrefix}axis`;
71+
} else {
72+
container.className = 'axis';
73+
}
74+
6775
const sampledData = sampling(data, dataThreshold).filter(({ value }) => {
6876
if (truncRange && value > truncRange[0] && value < truncRange[1]) return false;
6977
return true;

src/ui/legend/category.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,16 @@ export class Category extends Component<CategoryStyleProps> {
8484
}
8585

8686
render(attributes: Required<CategoryStyleProps>, container: Group) {
87-
const { width, height, x = 0, y = 0 } = this.attributes;
87+
const { width, height, x = 0, y = 0, classNamePrefix } = this.attributes;
8888
const ctn = select(container);
89+
90+
// Set root container className
91+
if (classNamePrefix) {
92+
container.className = `legend-category ${classNamePrefix}legend`;
93+
} else {
94+
container.className = 'legend-category';
95+
}
96+
8997
container.style.transform = `translate(${x}, ${y})`;
9098

9199
this.renderTitle(ctn, width!, height!);

src/ui/legend/continuous.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,14 @@ export class Continuous extends Component<ContinuousStyleProps> {
7777
}
7878

7979
public render(attributes: Required<ContinuousStyleProps>, container: Group) {
80+
// Set root container className
81+
const { classNamePrefix } = attributes;
82+
if (classNamePrefix) {
83+
container.className = `legend-continuous ${classNamePrefix}legend`;
84+
} else {
85+
container.className = 'legend-continuous';
86+
}
87+
8088
// 渲染顺序
8189
// 1. 绘制 title, 获得可用空间
8290
// 2. 绘制 label, handle

0 commit comments

Comments
 (0)