mirror of https://github.com/buster-so/buster.git
edit pie sorting
This commit is contained in:
parent
dbd24125f7
commit
ddce1b573f
|
@ -246,7 +246,13 @@ const getBarDimensions = (context: Context) => {
|
||||||
context.dataIndex
|
context.dataIndex
|
||||||
] as BarElement;
|
] 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 };
|
return { barWidth, barHeight };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -286,8 +292,8 @@ const setGlobalRotation = (context: Context) => {
|
||||||
});
|
});
|
||||||
|
|
||||||
const labelNeedsToBeRotated = labels.some((label) => {
|
const labelNeedsToBeRotated = labels.some((label) => {
|
||||||
if (!label && !!context.chart.ctx.measureText) return false;
|
if (!label && !!context.chart.ctx?.measureText) return false;
|
||||||
const { width: textWidth } = context.chart.ctx.measureText(label);
|
const { width: textWidth } = context.chart.ctx?.measureText?.(label) || { width: 0 };
|
||||||
const { barWidth, barHeight } = getBarDimensions(context);
|
const { barWidth, barHeight } = getBarDimensions(context);
|
||||||
return textWidth > barWidth - TEXT_WIDTH_BUFFER;
|
return textWidth > barWidth - TEXT_WIDTH_BUFFER;
|
||||||
});
|
});
|
||||||
|
|
|
@ -77,7 +77,8 @@ export const MetricStylingApp: React.FC<{
|
||||||
yAxisShowAxisTitle,
|
yAxisShowAxisTitle,
|
||||||
y2AxisShowAxisTitle,
|
y2AxisShowAxisTitle,
|
||||||
scatterDotSize,
|
scatterDotSize,
|
||||||
disableTooltip
|
disableTooltip,
|
||||||
|
pieSortBy
|
||||||
} = chartConfig;
|
} = chartConfig;
|
||||||
|
|
||||||
const selectedAxis: ChartEncodes | null = getSelectedAxis(
|
const selectedAxis: ChartEncodes | null = getSelectedAxis(
|
||||||
|
@ -175,6 +176,7 @@ export const MetricStylingApp: React.FC<{
|
||||||
columnLabelFormats={columnLabelFormats}
|
columnLabelFormats={columnLabelFormats}
|
||||||
barShowTotalAtTop={barShowTotalAtTop}
|
barShowTotalAtTop={barShowTotalAtTop}
|
||||||
rowCount={rowCount}
|
rowCount={rowCount}
|
||||||
|
pieSortBy={pieSortBy}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
|
|
@ -7,16 +7,16 @@ import { SortAlphaAscending, SortNumAscending, Empty } from '@/components/ui/ico
|
||||||
import { useMemoizedFn } from '@/hooks';
|
import { useMemoizedFn } from '@/hooks';
|
||||||
|
|
||||||
const options: SegmentedItem<NonNullable<PieSortBy> | 'none'>[] = [
|
const options: SegmentedItem<NonNullable<PieSortBy> | 'none'>[] = [
|
||||||
{
|
|
||||||
value: 'key',
|
|
||||||
tooltip: 'Sort by key',
|
|
||||||
icon: <SortAlphaAscending />
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
icon: <SortNumAscending />,
|
icon: <SortNumAscending />,
|
||||||
value: 'value',
|
value: 'value',
|
||||||
tooltip: 'Sort by value'
|
tooltip: 'Sort by value'
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
value: 'key',
|
||||||
|
tooltip: 'Sort by key',
|
||||||
|
icon: <SortAlphaAscending />
|
||||||
|
},
|
||||||
{
|
{
|
||||||
icon: <Empty />,
|
icon: <Empty />,
|
||||||
value: 'none',
|
value: 'none',
|
||||||
|
|
|
@ -39,11 +39,14 @@ const UNSUPPORTED_CHART_TYPES: ChartType[] = [ChartType.Table, ChartType.Metric]
|
||||||
export const StylingAppStyling: React.FC<
|
export const StylingAppStyling: React.FC<
|
||||||
{
|
{
|
||||||
className?: string;
|
className?: string;
|
||||||
} & Parameters<typeof StylingAppStylingNotSupported>[0] &
|
} & Omit<
|
||||||
|
Parameters<typeof StylingAppStylingNotSupported>[0] &
|
||||||
Parameters<typeof GlobalSettings>[0] &
|
Parameters<typeof GlobalSettings>[0] &
|
||||||
Parameters<typeof ChartSpecificSettings>[0] &
|
Parameters<typeof ChartSpecificSettings>[0] &
|
||||||
Parameters<typeof EtcSettings>[0] &
|
Parameters<typeof EtcSettings>[0] &
|
||||||
Parameters<typeof PieSettings>[0]
|
Parameters<typeof PieSettings>[0],
|
||||||
|
'onUpdateMetricChartConfig' | 'onUpdateYAxis' | 'onUpdateDataLabel' | 'onUpdateChartConfig'
|
||||||
|
>
|
||||||
> = ({
|
> = ({
|
||||||
className = '',
|
className = '',
|
||||||
columnSettings,
|
columnSettings,
|
||||||
|
|
Loading…
Reference in New Issue