mirror of https://github.com/buster-so/buster.git
78 lines
1.7 KiB
TypeScript
78 lines
1.7 KiB
TypeScript
import type React from 'react';
|
|
import { useMemo } from 'react';
|
|
import { BusterChartJS } from './BusterChartJS';
|
|
import { useDatasetOptions } from './chartHooks';
|
|
import type {
|
|
BusterChartComponentProps,
|
|
BusterChartRenderComponentProps,
|
|
} from './interfaces/chartComponentInterfaces';
|
|
|
|
export const BusterChartComponent: React.FC<BusterChartRenderComponentProps> = ({
|
|
data: dataProp,
|
|
barSortBy,
|
|
pieSortBy,
|
|
pieMinimumSlicePercentage,
|
|
trendlines,
|
|
...props
|
|
}) => {
|
|
const {
|
|
barGroupType,
|
|
columnMetadata,
|
|
lineGroupType,
|
|
columnLabelFormats,
|
|
selectedChartType,
|
|
selectedAxis,
|
|
} = props;
|
|
|
|
const {
|
|
numberOfDataPoints,
|
|
datasetOptions,
|
|
y2AxisKeys,
|
|
yAxisKeys,
|
|
tooltipKeys,
|
|
hasMismatchedTooltipsAndMeasures,
|
|
isDownsampled,
|
|
} = useDatasetOptions({
|
|
data: dataProp,
|
|
selectedAxis,
|
|
barSortBy,
|
|
selectedChartType,
|
|
pieMinimumSlicePercentage,
|
|
columnLabelFormats,
|
|
barGroupType,
|
|
lineGroupType,
|
|
trendlines,
|
|
pieSortBy,
|
|
columnMetadata,
|
|
});
|
|
|
|
// biome-ignore lint/correctness/useExhaustiveDependencies: we are content with the current dependencies
|
|
const chartProps: BusterChartComponentProps = useMemo(
|
|
() => ({
|
|
...props,
|
|
datasetOptions,
|
|
pieMinimumSlicePercentage,
|
|
y2AxisKeys,
|
|
yAxisKeys,
|
|
tooltipKeys,
|
|
hasMismatchedTooltipsAndMeasures,
|
|
isDownsampled,
|
|
numberOfDataPoints,
|
|
trendlines,
|
|
}),
|
|
[
|
|
props.selectedAxis,
|
|
pieMinimumSlicePercentage,
|
|
datasetOptions,
|
|
y2AxisKeys,
|
|
yAxisKeys,
|
|
hasMismatchedTooltipsAndMeasures,
|
|
tooltipKeys,
|
|
isDownsampled,
|
|
numberOfDataPoints,
|
|
]
|
|
);
|
|
|
|
return <BusterChartJS {...chartProps} />;
|
|
};
|