Skip to content

Commit

Permalink
fix: donut statistic auto size Closes #850
Browse files Browse the repository at this point in the history
  • Loading branch information
paleface001 committed Mar 26, 2020
1 parent a3f0103 commit 6ce2a11
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
8 changes: 5 additions & 3 deletions src/plots/donut/component/ring-statistic.ts
Expand Up @@ -107,9 +107,11 @@ export default class RingStatistic extends StatisticHtml {
}

private getStatisticSize() {
const radius = (this.view.getCoordinate() as any).getRadius();
const { radius: radiusCfg, innerRadius: innerRadiusCfg } = this.plot.options;
return (radius / radiusCfg) * innerRadiusCfg * 2;
const viewRange = this.plot.view.coordinateBBox;
const { radius, innerRadius } = this.plot.options;
const minContainerSize = Math.min(viewRange.width, viewRange.height);
const size = minContainerSize * radius * innerRadius;
return size;
}

private getStatisticHtmlString(data): string {
Expand Down
8 changes: 6 additions & 2 deletions src/plots/donut/component/statistic.ts
@@ -1,15 +1,15 @@
import { each, deepMix, clone, find, isElement } from '@antv/util';
import { deepMix, isElement } from '@antv/util';
import { createDom, modifyCSS, getOuterWidth, getOuterHeight } from '@antv/dom-util';

export interface IStaticticHtml {
x?: number;
y?: number;
html?: string;
[key: string]: any;
alignX?: string;
alignY?: string;
container?: any;
statisticClass?: string;
[key: string]: any;
}

export default class StatisticHtml {
Expand Down Expand Up @@ -47,6 +47,8 @@ export default class StatisticHtml {
}

public updatePosition(x, y) {
this.x = x;
this.y = y;
this.setDomPosition(x, y);
}

Expand All @@ -58,6 +60,8 @@ export default class StatisticHtml {
return {
x: 0,
y: 0,
width: 0,
height: 0,
html: '',
container: null,
alignX: 'middle',
Expand Down

0 comments on commit 6ce2a11

Please sign in to comment.