Skip to content

Commit

Permalink
fix: lineLabel & areaLabel cutomize style Closes #779
Browse files Browse the repository at this point in the history
  • Loading branch information
paleface001 committed Mar 19, 2020
1 parent 57f6d11 commit 132892b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
9 changes: 5 additions & 4 deletions src/plots/line/component/label/line-label.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,14 @@ export default class LineLabel {
const formatter = this.options.formatter;
const content = formatter ? formatter(shapeInfo.name) : shapeInfo.name;
this.container.addShape('text', {
attrs: deepMix({}, style, {
attrs: deepMix({}, {
x: shapeInfo.x + offsetX,
y: shapeInfo.y + offsetY,
text: content,
fill: shapeInfo.color,
textAlign: 'left',
textBaseline: 'middle',
}),
},style),
name: 'label',
});
});
Expand Down Expand Up @@ -87,11 +87,12 @@ export default class LineLabel {

private getDefaultOptions() {
const { theme } = this.plot;
const labelStyle = theme.label.style;
const labelStyle = clone(theme.label.style);
delete labelStyle.fill;
return {
offsetX: DEFAULT_OFFSET,
offsetY: 0,
style: clone(labelStyle),
style: labelStyle,
};
}

Expand Down
5 changes: 3 additions & 2 deletions src/plots/stacked-area/component/label/area-label.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,15 +108,15 @@ export default class AreaLabel {
const formatter = this.options.formatter;
const content = formatter ? formatter(p._origin[stackField]) : p._origin[stackField];
const text = this.container.addShape('text', {
attrs: deepMix({}, style, {
attrs: deepMix({}, {
x: p.x + offsetX,
y: p.y + offsetY,
text: content,
fill: p.color,
fontSize: labelSize,
textAlign: 'center',
textBaseline: 'top',
}),
}, style),
name: 'label',
});
labelShapes.push(text);
Expand Down Expand Up @@ -153,6 +153,7 @@ export default class AreaLabel {
const { theme } = this.plot;
const labelStyle = clone(theme.label.style);
labelStyle.stroke = null;
delete labelStyle.fill;
return {
offsetX: 0,
offsetY: 0,
Expand Down

0 comments on commit 132892b

Please sign in to comment.