diff --git a/__tests__/integration/snapshots/static/mockPieSpiderExceed.svg b/__tests__/integration/snapshots/static/mockPieSpiderExceed.svg new file mode 100644 index 0000000000..d4c86f0172 --- /dev/null +++ b/__tests__/integration/snapshots/static/mockPieSpiderExceed.svg @@ -0,0 +1,1525 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 微博A + + + + + + + + + + + + + + + + + + + + 其他A + + + + + + + + + + + + + + + + + + + + 论坛A + + + + + + + + + + + + + + + + + + + + 网站A + + + + + + + + + + + + + + + + + + + + 微信A + + + + + + + + + + + + + + + + + + + + 客户A + + + + + + + + + + + + + + + + + + + + 新闻A + + + + + + + + + + + + + + + + + + + + 视频A + + + + + + + + + + + + + + + + + + + + 博客A + + + + + + + + + + + + + + + + + + + + 报刊A + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 微博A (93.33) + + + + + + + + + + + + + 其他A (6.67) + + + + + + + + + + + + + 论坛A (4.77) + + + + + + + + + + + + + 网站A (1.44) + + + + + + + + + + + + + 微信A (1.12) + + + + + + + + + + + + + 客户A (1.05) + + + + + + + + + + + + + 新闻A (0.81) + + + + + + + + + + + + + 视频A (0.39) + + + + + + + + + + + + + 博客A (0.37) + + + + + + + + + + + + + 报刊A (0.17) + + + + + + + + + + + + \ No newline at end of file diff --git a/__tests__/plots/static/index.ts b/__tests__/plots/static/index.ts index 8c83accb7f..94b9d57016 100644 --- a/__tests__/plots/static/index.ts +++ b/__tests__/plots/static/index.ts @@ -341,3 +341,4 @@ export { mockPieSpider } from './mock-pie-spider'; export { mockPieSpiderRight } from './mock-pie-spider-right'; export { mockPieSpiderMany } from './mock-pie-spider-many'; export { mockPieSpiderHide } from './mock-pie-spider-hide'; +export { mockPieSpiderExceed } from './mock-pie-spider-exceed'; diff --git a/__tests__/plots/static/mock-pie-spider-exceed.ts b/__tests__/plots/static/mock-pie-spider-exceed.ts new file mode 100644 index 0000000000..1b84d11d4a --- /dev/null +++ b/__tests__/plots/static/mock-pie-spider-exceed.ts @@ -0,0 +1,34 @@ +import { G2Spec } from '../../../src'; + +export function mockPieSpiderExceed(): G2Spec { + return { + type: 'interval', + width: 340, + height: 250, + data: [ + { type: '微博A', value: 93.33 }, + { type: '其他A', value: 6.67 }, + { type: '论坛A', value: 4.77 }, + { type: '网站A', value: 1.44 }, + { type: '微信A', value: 1.12 }, + { type: '客户A', value: 1.05 }, + { type: '新闻A', value: 0.81 }, + { type: '视频A', value: 0.39 }, + { type: '博客A', value: 0.37 }, + { type: '报刊A', value: 0.17 }, + ], + encode: { + y: 'value', + color: 'type', + }, + labels: [ + { + position: 'spider', + transform: [{ type: 'exceedAdjust' }], + text: (obj) => `${obj.type} (${obj.value})`, + }, + ], + transform: [{ type: 'stackY' }], + coordinate: { type: 'theta' }, + }; +} diff --git a/src/label-transform/exceedAdjust.ts b/src/label-transform/exceedAdjust.ts index a169a7daac..bc60d436a3 100644 --- a/src/label-transform/exceedAdjust.ts +++ b/src/label-transform/exceedAdjust.ts @@ -52,6 +52,11 @@ export const ExceedAdjust: LLC = () => { [width, height], ], ); + // For label with connectorPoints + if (l.style.connector && l.style.connectorPoints) { + l.style.connectorPoints[0][0] -= changeValue[0]; + l.style.connectorPoints[0][1] -= changeValue[1]; + } l.style.x += changeValue[0]; l.style.y += changeValue[1]; });