Skip to content
This repository has been archived by the owner on Dec 10, 2021. It is now read-only.

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 Apr 26, 2021
1 parent ec94457 commit 158a777
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions plugins/plugin-chart-echarts/src/Pie/transformProps.ts
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

1 comment on commit 158a777

@vercel
Copy link

@vercel vercel bot commented on 158a777 Apr 26, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.