Skip to content

Commit

Permalink
fix(plugin-chart-echarts): remove label line if below threshold (#1071)
Browse files Browse the repository at this point in the history
  • Loading branch information
villebro authored and zhaoyongjie committed Nov 26, 2021
1 parent d97d706 commit 31ca397
Showing 1 changed file with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ export default function transformProps(chartProps: EchartsPieChartProps): PieCha
emitFilter,
}: EchartsPieFormData = { ...DEFAULT_LEGEND_FORM_DATA, ...DEFAULT_PIE_FORM_DATA, ...formData };
const metricLabel = getMetricLabel(metric);
const minShowLabelAngle = (showLabelsThreshold || 0) * 3.6;

const keys = data.map(datum =>
extractGroupbyLabel({
Expand Down Expand Up @@ -157,15 +158,12 @@ export default function transformProps(chartProps: EchartsPieChartProps): PieCha
{},
);

const formatter = (params: CallbackDataParams) => {
if (params.percent && params.percent < showLabelsThreshold) return '';

return formatPieLabel({
const formatter = (params: CallbackDataParams) =>
formatPieLabel({
params,
numberFormatter,
labelType,
});
};

const defaultLabel = {
formatter,
Expand All @@ -182,6 +180,7 @@ export default function transformProps(chartProps: EchartsPieChartProps): PieCha
center: ['50%', '50%'],
avoidLabelOverlap: true,
labelLine: labelsOutside && labelLine ? { show: true } : { show: false },
minShowLabelAngle,
label: labelsOutside
? {
...defaultLabel,
Expand Down

0 comments on commit 31ca397

Please sign in to comment.