diff --git a/superset-frontend/packages/superset-ui-demo/storybook/stories/plugins/plugin-chart-echarts/Pie/Pie.stories.tsx b/superset-frontend/packages/superset-ui-demo/storybook/stories/plugins/plugin-chart-echarts/Pie/Pie.stories.tsx index 73b25a2f7cf42..228d5792175aa 100644 --- a/superset-frontend/packages/superset-ui-demo/storybook/stories/plugins/plugin-chart-echarts/Pie/Pie.stories.tsx +++ b/superset-frontend/packages/superset-ui-demo/storybook/stories/plugins/plugin-chart-echarts/Pie/Pie.stories.tsx @@ -23,7 +23,7 @@ import { EchartsPieChartPlugin, PieTransformProps, } from '@superset-ui/plugin-chart-echarts'; -import { weekday, population } from './data'; +import { weekday, population, sales } from './data'; import { withResizableChartDemo } from '../../../../shared/components/ResizableChartDemo'; new EchartsPieChartPlugin().configure({ key: 'echarts-pie' }).register(); @@ -193,3 +193,91 @@ PopulationPie.argTypes = { }, }, }; + +export const SalesPie = ( + { + donut, + innerRadius, + outerRadius, + labelsOutside, + labelLine, + showLabels, + showLegend, + labelType, + roseType, + }: { + donut: boolean; + innerRadius: number; + outerRadius: number; + labelsOutside: boolean; + labelLine: boolean; + showLabels: boolean; + showLegend: boolean; + labelType: string; + roseType: string; + }, + { width, height }: { width: number; height: number }, +) => ( + +); + +SalesPie.args = { + roseType: 'area', + donut: false, + innerRadius: 30, + outerRadius: 70, + labelsOutside: false, + labelLine: true, + showLabels: true, + showLegend: false, + labelType: 'key', +}; + +SalesPie.argTypes = { + roseType: { + control: { + type: 'select', + options: ['area', 'radius'], + }, + }, + donut: { control: 'boolean' }, + innerRadius: { control: 'number' }, + outerRadius: { control: 'number' }, + labelsOutside: { control: 'boolean' }, + labelLine: { control: 'boolean' }, + showLabels: { control: 'boolean' }, + showLegend: { control: 'boolean' }, + labelType: { + control: { + type: 'select', + options: [ + 'key', + 'value', + 'percent', + 'key_value', + 'key_percent', + 'key_value_percent', + ], + }, + }, +}; diff --git a/superset-frontend/packages/superset-ui-demo/storybook/stories/plugins/plugin-chart-echarts/Pie/data.ts b/superset-frontend/packages/superset-ui-demo/storybook/stories/plugins/plugin-chart-echarts/Pie/data.ts index 8959a1fc6c552..33fdb2c6b8d8f 100644 --- a/superset-frontend/packages/superset-ui-demo/storybook/stories/plugins/plugin-chart-echarts/Pie/data.ts +++ b/superset-frontend/packages/superset-ui-demo/storybook/stories/plugins/plugin-chart-echarts/Pie/data.ts @@ -240,3 +240,14 @@ export const population = [ { Country: 'Sint Maarten (Dutch part)', Population: 597781 }, { Country: 'Tuvalu', Population: 466709 }, ]; + +export const sales = [ + { Product: 'Laptop', 'SUM(AMOUNT)': 30 }, + { Product: 'Workstation', 'SUM(AMOUNT)': 28 }, + { Product: 'Phone', 'SUM(AMOUNT)': 26 }, + { Product: 'Tablet', 'SUM(AMOUNT)': 24 }, + { Product: 'PDA', 'SUM(AMOUNT)': 22 }, + { Product: 'Ink Pad', 'SUM(AMOUNT)': 20 }, + { Product: 'Accessories', 'SUM(AMOUNT)': 18 }, + { Product: 'Pad', 'SUM(AMOUNT)': 16 }, +]; diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/Pie/controlPanel.tsx b/superset-frontend/plugins/plugin-chart-echarts/src/Pie/controlPanel.tsx index 1afc64924bb3d..b197c9743bfe8 100644 --- a/superset-frontend/plugins/plugin-chart-echarts/src/Pie/controlPanel.tsx +++ b/superset-frontend/plugins/plugin-chart-echarts/src/Pie/controlPanel.tsx @@ -40,6 +40,7 @@ const { outerRadius, numberFormat, showLabels, + roseType, } = DEFAULT_FORM_DATA; const config: ControlPanelConfig = { @@ -87,6 +88,23 @@ const config: ControlPanelConfig = { }, }, ], + [ + { + name: 'roseType', + config: { + type: 'SelectControl', + label: t('Rose Type'), + default: roseType, + renderTrigger: true, + choices: [ + ['area', t('Area')], + ['radius', t('Radius')], + [null, t('None')], + ], + description: t('Whether to show as Nightingale chart.'), + }, + }, + ], ...legendSection, // eslint-disable-next-line react/jsx-key [{t('Labels')}], diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/Pie/images/Pie3.jpg b/superset-frontend/plugins/plugin-chart-echarts/src/Pie/images/Pie3.jpg index 45299bab7c52c..5ad62baa6917f 100644 Binary files a/superset-frontend/plugins/plugin-chart-echarts/src/Pie/images/Pie3.jpg and b/superset-frontend/plugins/plugin-chart-echarts/src/Pie/images/Pie3.jpg differ diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/Pie/images/Pie4.jpg b/superset-frontend/plugins/plugin-chart-echarts/src/Pie/images/Pie4.jpg index 165c5726d36c3..072a1265f2502 100644 Binary files a/superset-frontend/plugins/plugin-chart-echarts/src/Pie/images/Pie4.jpg and b/superset-frontend/plugins/plugin-chart-echarts/src/Pie/images/Pie4.jpg differ diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/Pie/index.ts b/superset-frontend/plugins/plugin-chart-echarts/src/Pie/index.ts index 6c022ec723521..4d4c6940c31ad 100644 --- a/superset-frontend/plugins/plugin-chart-echarts/src/Pie/index.ts +++ b/superset-frontend/plugins/plugin-chart-echarts/src/Pie/index.ts @@ -75,6 +75,7 @@ export default class EchartsPieChartPlugin extends EchartsChartPlugin< t('Popular'), t('Proportional'), t('ECharts'), + t('Nightingale'), ], thumbnail, }, diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/Pie/transformProps.ts b/superset-frontend/plugins/plugin-chart-echarts/src/Pie/transformProps.ts index 031b072b449de..2b02e3e2fb8fe 100644 --- a/superset-frontend/plugins/plugin-chart-echarts/src/Pie/transformProps.ts +++ b/superset-frontend/plugins/plugin-chart-echarts/src/Pie/transformProps.ts @@ -175,6 +175,7 @@ export default function transformProps( showLabelsThreshold, sliceId, showTotal, + roseType, }: EchartsPieFormData = { ...DEFAULT_LEGEND_FORM_DATA, ...DEFAULT_PIE_FORM_DATA, @@ -284,6 +285,7 @@ export default function transformProps( type: 'pie', ...chartPadding, animation: false, + roseType: roseType || undefined, radius: [`${donut ? innerRadius : 0}%`, `${outerRadius}%`], center: ['50%', '50%'], avoidLabelOverlap: true, diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/Pie/types.ts b/superset-frontend/plugins/plugin-chart-echarts/src/Pie/types.ts index 631c1c7de3568..c72da1feed07f 100644 --- a/superset-frontend/plugins/plugin-chart-echarts/src/Pie/types.ts +++ b/superset-frontend/plugins/plugin-chart-echarts/src/Pie/types.ts @@ -45,6 +45,7 @@ export type EchartsPieFormData = QueryFormData & numberFormat: string; dateFormat: string; showLabelsThreshold: number; + roseType: 'radius' | 'area' | null; }; export enum EchartsPieLabelType { @@ -78,6 +79,7 @@ export const DEFAULT_FORM_DATA: EchartsPieFormData = { labelsOutside: true, showLabelsThreshold: 5, dateFormat: 'smart_date', + roseType: null, }; export type PieChartTransformedProps =