Skip to content

Commit

Permalink
fix(core): chart pie legend (#33)
Browse files Browse the repository at this point in the history
  • Loading branch information
yevhenii1337 authored Nov 8, 2024
1 parent d6bec4d commit 9a18a80
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ export default function transformProps(
sliceId,
showTotal,
pieChartLegend,
pieChartLegendsTopPosition,
}: EchartsPieFormData = {
...DEFAULT_LEGEND_FORM_DATA,
...DEFAULT_PIE_FORM_DATA,
Expand Down Expand Up @@ -330,11 +331,15 @@ export default function transformProps(
legend: {
...getLegendProps(legendType, legendOrientation, showLegend, theme),
data: keys,
...(pieChartLegendsTopPosition
? { top: pieChartLegendsTopPosition }
: {}),
},
graphic: showTotal
? {
type: 'text',
...getTotalValuePadding({ chartPadding, donut, width, height }),
left: 'center',
style: {
text: `${pieChartLegend} ${numberFormatter(totalValue)}`,
fontSize: 16,
Expand Down
14 changes: 14 additions & 0 deletions superset-frontend/plugins/plugin-chart-echarts/src/controls.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,19 @@ const pieChartLegend: ControlSetItem = {
},
};

const pieChartLegendsTopPosition: ControlSetItem = {
name: 'pieChartLegendsTopPosition',
config: {
type: 'TextControl',
label: 'Pie Chart Legends Top Position',
renderTrigger: true,
default: 0,
initialValue: 0,
isFloat: true,
description: 'Pie Chart Legends Top Position',
},
};

export const showLoaderSection: ControlSetRow[] = [
[<ControlSubSectionHeader>{t('Loader')}</ControlSubSectionHeader>],
[showLoader],
Expand All @@ -183,6 +196,7 @@ export const showLoaderSection: ControlSetRow[] = [
export const pieChartLegendrSection: ControlSetRow[] = [
[<ControlSubSectionHeader>{t('Pie Chart Legend')}</ControlSubSectionHeader>],
[pieChartLegend],
[pieChartLegendsTopPosition],
];

export const legendModalSection: ControlSetRow[] = [
Expand Down

0 comments on commit 9a18a80

Please sign in to comment.