From 7937a91f28e7b0885018dec1182ca3924bb2fd9f Mon Sep 17 00:00:00 2001 From: Ville Brofeldt <33317356+villebro@users.noreply.github.com> Date: Mon, 26 Apr 2021 11:48:32 +0300 Subject: [PATCH] fix(plugin-chart-echarts): remove label line if below threshold (#1071) --- .../plugin-chart-echarts/src/Pie/transformProps.ts | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/superset-frontend/temporary_superset_ui/superset-ui/plugins/plugin-chart-echarts/src/Pie/transformProps.ts b/superset-frontend/temporary_superset_ui/superset-ui/plugins/plugin-chart-echarts/src/Pie/transformProps.ts index eb4da7b335f2f..9b3ca9de70e5d 100644 --- a/superset-frontend/temporary_superset_ui/superset-ui/plugins/plugin-chart-echarts/src/Pie/transformProps.ts +++ b/superset-frontend/temporary_superset_ui/superset-ui/plugins/plugin-chart-echarts/src/Pie/transformProps.ts @@ -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({ @@ -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, @@ -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,