Skip to content

Commit

Permalink
Merge pull request #257 from Jeffy2012/fix-pie-label-bug
Browse files Browse the repository at this point in the history
Fix pie label bug
  • Loading branch information
paleface001 committed Nov 18, 2019
2 parents 7b618f9 + d2a566f commit 5d3a812
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
7 changes: 5 additions & 2 deletions src/components/label/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@ import * as _ from '@antv/util';
export default class LabelParser {
public config: DataPointType = {};
private plot: any;
private originConfig: any;

constructor(cfg) {
this.plot = cfg.plot;
const { plot, ...rest } = cfg;
this.plot = plot;
this.originConfig = rest;
this._init(cfg);
}

Expand All @@ -18,7 +21,7 @@ export default class LabelParser {
}

private _parseCallBack(val) {
const labelProps = this.plot.options.label;
const labelProps = this.originConfig;
const theme = this.plot.getPlotTheme();
const config: DataPointType = { ...labelProps };
this._parseOffset(labelProps, config);
Expand Down
6 changes: 3 additions & 3 deletions src/plots/pie/layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,13 +162,13 @@ export default class PieLayer<T extends PieLayerConfig = PieLayerConfig> extends

private label() {
const props = this.options;
const labelConfig = props.label as Label;
const labelConfig = { ...props.label } as Label;
if (!this.showLabel()) {
this.pie.label = false;
return;
}
if (labelConfig.type === 'inner') {
const offsetBase = -4;
const offsetBase = -8;
labelConfig.offset = labelConfig.offset ? offsetBase + labelConfig.offset : offsetBase;
}

Expand All @@ -179,7 +179,7 @@ export default class PieLayer<T extends PieLayerConfig = PieLayerConfig> extends
}
this.pie.label = getComponent('label', {
plot: this,
// labelType,
labelType,
fields: props.colorField ? [props.angleField, props.colorField] : [props.angleField],
...labelConfig,
});
Expand Down

0 comments on commit 5d3a812

Please sign in to comment.