edit pie sorting

This commit is contained in:
Nate Kelley 2025-04-11 15:51:44 -06:00
parent dbd24125f7
commit ddce1b573f
No known key found for this signature in database
GPG Key ID: FD90372AB8D98B4F
4 changed files with 25 additions and 14 deletions

View File

@ -246,7 +246,13 @@ const getBarDimensions = (context: Context) => {
context.dataIndex
] as BarElement;
const { width: barWidth, height: barHeight } = barElement.getProps(['width', 'height'], true);
const { width: barWidth, height: barHeight } = barElement?.getProps?.(
['width', 'height'],
true
) || {
width: 0,
height: 0
};
return { barWidth, barHeight };
};
@ -286,8 +292,8 @@ const setGlobalRotation = (context: Context) => {
});
const labelNeedsToBeRotated = labels.some((label) => {
if (!label && !!context.chart.ctx.measureText) return false;
const { width: textWidth } = context.chart.ctx.measureText(label);
if (!label && !!context.chart.ctx?.measureText) return false;
const { width: textWidth } = context.chart.ctx?.measureText?.(label) || { width: 0 };
const { barWidth, barHeight } = getBarDimensions(context);
return textWidth > barWidth - TEXT_WIDTH_BUFFER;
});

View File

@ -77,7 +77,8 @@ export const MetricStylingApp: React.FC<{
yAxisShowAxisTitle,
y2AxisShowAxisTitle,
scatterDotSize,
disableTooltip
disableTooltip,
pieSortBy
} = chartConfig;
const selectedAxis: ChartEncodes | null = getSelectedAxis(
@ -175,6 +176,7 @@ export const MetricStylingApp: React.FC<{
columnLabelFormats={columnLabelFormats}
barShowTotalAtTop={barShowTotalAtTop}
rowCount={rowCount}
pieSortBy={pieSortBy}
/>
)}

View File

@ -7,16 +7,16 @@ import { SortAlphaAscending, SortNumAscending, Empty } from '@/components/ui/ico
import { useMemoizedFn } from '@/hooks';
const options: SegmentedItem<NonNullable<PieSortBy> | 'none'>[] = [
{
value: 'key',
tooltip: 'Sort by key',
icon: <SortAlphaAscending />
},
{
icon: <SortNumAscending />,
value: 'value',
tooltip: 'Sort by value'
},
{
value: 'key',
tooltip: 'Sort by key',
icon: <SortAlphaAscending />
},
{
icon: <Empty />,
value: 'none',

View File

@ -39,11 +39,14 @@ const UNSUPPORTED_CHART_TYPES: ChartType[] = [ChartType.Table, ChartType.Metric]
export const StylingAppStyling: React.FC<
{
className?: string;
} & Parameters<typeof StylingAppStylingNotSupported>[0] &
Parameters<typeof GlobalSettings>[0] &
Parameters<typeof ChartSpecificSettings>[0] &
Parameters<typeof EtcSettings>[0] &
Parameters<typeof PieSettings>[0]
} & Omit<
Parameters<typeof StylingAppStylingNotSupported>[0] &
Parameters<typeof GlobalSettings>[0] &
Parameters<typeof ChartSpecificSettings>[0] &
Parameters<typeof EtcSettings>[0] &
Parameters<typeof PieSettings>[0],
'onUpdateMetricChartConfig' | 'onUpdateYAxis' | 'onUpdateDataLabel' | 'onUpdateChartConfig'
>
> = ({
className = '',
columnSettings,