mirror of
https://github.com/apache/superset.git
synced 2026-05-12 19:35:17 +00:00
fix: Restore all missing features to Pie control panel
- Added back outer radius slider control with min/max constraints - Added conditional inner radius control that only shows when Donut is checked - Added color palette selector component - Added conditional Label Line control that only shows when Show Labels is checked - Fixed double headers on Metric and Group by controls by removing duplicate labels - All controls now properly configured with renderTrigger where appropriate
This commit is contained in:
@@ -18,11 +18,14 @@
|
|||||||
*/
|
*/
|
||||||
import { FC } from 'react';
|
import { FC } from 'react';
|
||||||
import { t } from '@superset-ui/core';
|
import { t } from '@superset-ui/core';
|
||||||
|
import { ColorSchemeControl } from '@superset-ui/chart-controls';
|
||||||
import { DndColumnSelect } from '../../../../src/explore/components/controls/DndColumnSelectControl/DndColumnSelect';
|
import { DndColumnSelect } from '../../../../src/explore/components/controls/DndColumnSelectControl/DndColumnSelect';
|
||||||
import { DndMetricSelect } from '../../../../src/explore/components/controls/DndColumnSelectControl/DndMetricSelect';
|
import { DndMetricSelect } from '../../../../src/explore/components/controls/DndColumnSelectControl/DndMetricSelect';
|
||||||
import TextControl from '../../../../src/explore/components/controls/TextControl';
|
import TextControl from '../../../../src/explore/components/controls/TextControl';
|
||||||
import CheckboxControl from '../../../../src/explore/components/controls/CheckboxControl';
|
import CheckboxControl from '../../../../src/explore/components/controls/CheckboxControl';
|
||||||
|
import SliderControl from '../../../../src/explore/components/controls/SliderControl';
|
||||||
import ControlHeader from '../../../../src/explore/components/ControlHeader';
|
import ControlHeader from '../../../../src/explore/components/ControlHeader';
|
||||||
|
import Control from '../../../../src/explore/components/Control';
|
||||||
|
|
||||||
interface PieControlPanelProps {
|
interface PieControlPanelProps {
|
||||||
onChange?: (field: string, value: any) => void;
|
onChange?: (field: string, value: any) => void;
|
||||||
@@ -81,7 +84,7 @@ export const PieControlPanel: FC<PieControlPanelProps> = ({
|
|||||||
<div style={{ marginBottom: 24 }}>
|
<div style={{ marginBottom: 24 }}>
|
||||||
<h4>{t('Query')}</h4>
|
<h4>{t('Query')}</h4>
|
||||||
|
|
||||||
{/* Group by */}
|
{/* Group by - NO DOUBLE HEADER */}
|
||||||
<div style={{ marginBottom: 16 }}>
|
<div style={{ marginBottom: 16 }}>
|
||||||
<ControlHeader
|
<ControlHeader
|
||||||
label={t('Group by')}
|
label={t('Group by')}
|
||||||
@@ -94,7 +97,7 @@ export const PieControlPanel: FC<PieControlPanelProps> = ({
|
|||||||
onChange={handleChange('groupby')}
|
onChange={handleChange('groupby')}
|
||||||
options={safeColumns}
|
options={safeColumns}
|
||||||
name="groupby"
|
name="groupby"
|
||||||
label={t('Group by')}
|
label="" // Remove the duplicate label
|
||||||
multi
|
multi
|
||||||
canDelete
|
canDelete
|
||||||
ghostButtonText={t('Add dimension')}
|
ghostButtonText={t('Add dimension')}
|
||||||
@@ -108,7 +111,7 @@ export const PieControlPanel: FC<PieControlPanelProps> = ({
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Metric */}
|
{/* Metric - NO DOUBLE HEADER */}
|
||||||
<div style={{ marginBottom: 16 }}>
|
<div style={{ marginBottom: 16 }}>
|
||||||
<ControlHeader
|
<ControlHeader
|
||||||
label={t('Metric')}
|
label={t('Metric')}
|
||||||
@@ -121,7 +124,7 @@ export const PieControlPanel: FC<PieControlPanelProps> = ({
|
|||||||
onChange={handleChange('metric')}
|
onChange={handleChange('metric')}
|
||||||
datasource={safeDataSource}
|
datasource={safeDataSource}
|
||||||
name="metric"
|
name="metric"
|
||||||
label={t('Metric')}
|
label="" // Remove the duplicate label
|
||||||
multi={false}
|
multi={false}
|
||||||
savedMetrics={safeMetrics}
|
savedMetrics={safeMetrics}
|
||||||
/>
|
/>
|
||||||
@@ -164,6 +167,43 @@ export const PieControlPanel: FC<PieControlPanelProps> = ({
|
|||||||
<div style={{ marginBottom: 24 }}>
|
<div style={{ marginBottom: 24 }}>
|
||||||
<h4>{t('Chart Options')}</h4>
|
<h4>{t('Chart Options')}</h4>
|
||||||
|
|
||||||
|
{/* Color Scheme */}
|
||||||
|
<div style={{ marginBottom: 16 }}>
|
||||||
|
{(() => {
|
||||||
|
const colorSchemeControl = ColorSchemeControl();
|
||||||
|
const { hidden, ...cleanConfig } = colorSchemeControl.config || {};
|
||||||
|
return (
|
||||||
|
<Control
|
||||||
|
{...cleanConfig}
|
||||||
|
name="color_scheme"
|
||||||
|
value={formValues.color_scheme}
|
||||||
|
actions={{
|
||||||
|
...actions,
|
||||||
|
setControlValue: (field: string, val: any) => {
|
||||||
|
handleChange('color_scheme')(val);
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
renderTrigger
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
})()}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Outer Radius Slider */}
|
||||||
|
<div style={{ marginBottom: 16 }}>
|
||||||
|
<ControlHeader
|
||||||
|
label={t('Outer Radius')}
|
||||||
|
description={t('Outer edge of the pie/donut')}
|
||||||
|
renderTrigger
|
||||||
|
hovered
|
||||||
|
/>
|
||||||
|
<SliderControl
|
||||||
|
value={formValues.outerRadius || 70}
|
||||||
|
onChange={handleChange('outerRadius')}
|
||||||
|
{...{ min: 10, max: 100, step: 1 }}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
{/* Donut checkbox */}
|
{/* Donut checkbox */}
|
||||||
<div style={{ marginBottom: 16 }}>
|
<div style={{ marginBottom: 16 }}>
|
||||||
<CheckboxControl
|
<CheckboxControl
|
||||||
@@ -176,6 +216,23 @@ export const PieControlPanel: FC<PieControlPanelProps> = ({
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{/* Inner Radius Slider - CONDITIONAL */}
|
||||||
|
{formValues.donut && (
|
||||||
|
<div style={{ marginBottom: 16 }}>
|
||||||
|
<ControlHeader
|
||||||
|
label={t('Inner Radius')}
|
||||||
|
description={t('Inner radius of donut hole')}
|
||||||
|
renderTrigger
|
||||||
|
hovered
|
||||||
|
/>
|
||||||
|
<SliderControl
|
||||||
|
value={formValues.innerRadius || 30}
|
||||||
|
onChange={handleChange('innerRadius')}
|
||||||
|
{...{ min: 0, max: 100, step: 1 }}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
{/* Show Labels checkbox */}
|
{/* Show Labels checkbox */}
|
||||||
<div style={{ marginBottom: 16 }}>
|
<div style={{ marginBottom: 16 }}>
|
||||||
<CheckboxControl
|
<CheckboxControl
|
||||||
@@ -188,6 +245,20 @@ export const PieControlPanel: FC<PieControlPanelProps> = ({
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{/* Label Line checkbox - CONDITIONAL */}
|
||||||
|
{formValues.show_labels && (
|
||||||
|
<div style={{ marginBottom: 16 }}>
|
||||||
|
<CheckboxControl
|
||||||
|
label={t('Label Line')}
|
||||||
|
description={t('Draw a line from the label to the slice')}
|
||||||
|
value={formValues.label_line ?? false}
|
||||||
|
onChange={handleChange('label_line')}
|
||||||
|
renderTrigger
|
||||||
|
hovered
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
{/* Show Legend checkbox */}
|
{/* Show Legend checkbox */}
|
||||||
<div style={{ marginBottom: 16 }}>
|
<div style={{ marginBottom: 16 }}>
|
||||||
<CheckboxControl
|
<CheckboxControl
|
||||||
@@ -234,16 +305,36 @@ const config = {
|
|||||||
default: true,
|
default: true,
|
||||||
label: t('Sort by metric'),
|
label: t('Sort by metric'),
|
||||||
},
|
},
|
||||||
|
color_scheme: {
|
||||||
|
default: 'supersetColors',
|
||||||
|
label: t('Color scheme'),
|
||||||
|
renderTrigger: true,
|
||||||
|
},
|
||||||
|
outerRadius: {
|
||||||
|
default: 70,
|
||||||
|
label: t('Outer Radius'),
|
||||||
|
renderTrigger: true,
|
||||||
|
},
|
||||||
donut: {
|
donut: {
|
||||||
default: false,
|
default: false,
|
||||||
label: t('Donut'),
|
label: t('Donut'),
|
||||||
renderTrigger: true,
|
renderTrigger: true,
|
||||||
},
|
},
|
||||||
|
innerRadius: {
|
||||||
|
default: 30,
|
||||||
|
label: t('Inner Radius'),
|
||||||
|
renderTrigger: true,
|
||||||
|
},
|
||||||
show_labels: {
|
show_labels: {
|
||||||
default: true,
|
default: true,
|
||||||
label: t('Show labels'),
|
label: t('Show labels'),
|
||||||
renderTrigger: true,
|
renderTrigger: true,
|
||||||
},
|
},
|
||||||
|
label_line: {
|
||||||
|
default: false,
|
||||||
|
label: t('Label Line'),
|
||||||
|
renderTrigger: true,
|
||||||
|
},
|
||||||
show_legend: {
|
show_legend: {
|
||||||
default: true,
|
default: true,
|
||||||
label: t('Show legend'),
|
label: t('Show legend'),
|
||||||
|
|||||||
Reference in New Issue
Block a user