2025-01-07 02:29:29 +08:00
|
|
|
import React, { useMemo } from 'react';
|
2025-05-10 04:16:59 +08:00
|
|
|
import type {
|
2025-01-07 02:29:29 +08:00
|
|
|
BusterChartComponentProps,
|
|
|
|
BusterChartRenderComponentProps
|
|
|
|
} from './interfaces/chartComponentInterfaces';
|
|
|
|
import { BusterChartJS } from './BusterChartJS';
|
|
|
|
import { useDatasetOptions } from './chartHooks';
|
|
|
|
|
|
|
|
export const BusterChartComponent: React.FC<BusterChartRenderComponentProps> = ({
|
|
|
|
data: dataProp,
|
|
|
|
barSortBy,
|
2025-04-12 05:40:40 +08:00
|
|
|
pieSortBy,
|
2025-01-07 02:29:29 +08:00
|
|
|
pieMinimumSlicePercentage,
|
|
|
|
trendlines,
|
|
|
|
...props
|
|
|
|
}) => {
|
2025-04-12 05:40:40 +08:00
|
|
|
const {
|
|
|
|
barGroupType,
|
|
|
|
columnMetadata,
|
|
|
|
lineGroupType,
|
|
|
|
columnLabelFormats,
|
|
|
|
selectedChartType,
|
|
|
|
selectedAxis
|
|
|
|
} = props;
|
2025-04-23 06:29:00 +08:00
|
|
|
|
2025-01-07 02:29:29 +08:00
|
|
|
const {
|
2025-05-02 03:47:34 +08:00
|
|
|
numberOfDataPoints,
|
2025-01-07 02:29:29 +08:00
|
|
|
datasetOptions,
|
|
|
|
dataTrendlineOptions,
|
|
|
|
y2AxisKeys,
|
|
|
|
yAxisKeys,
|
|
|
|
tooltipKeys,
|
2025-04-23 06:29:00 +08:00
|
|
|
hasMismatchedTooltipsAndMeasures,
|
|
|
|
isDownsampled
|
2025-01-07 02:29:29 +08:00
|
|
|
} = useDatasetOptions({
|
|
|
|
data: dataProp,
|
|
|
|
selectedAxis,
|
|
|
|
barSortBy,
|
|
|
|
selectedChartType,
|
|
|
|
pieMinimumSlicePercentage,
|
|
|
|
columnLabelFormats,
|
|
|
|
barGroupType,
|
|
|
|
lineGroupType,
|
2025-04-12 05:40:40 +08:00
|
|
|
trendlines,
|
|
|
|
pieSortBy,
|
|
|
|
columnMetadata
|
2025-01-07 02:29:29 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
const chartProps: BusterChartComponentProps = useMemo(
|
|
|
|
() => ({
|
|
|
|
...props,
|
|
|
|
datasetOptions,
|
2025-01-08 05:42:00 +08:00
|
|
|
pieMinimumSlicePercentage,
|
2025-01-07 02:29:29 +08:00
|
|
|
dataTrendlineOptions,
|
|
|
|
y2AxisKeys,
|
|
|
|
yAxisKeys,
|
|
|
|
tooltipKeys,
|
2025-04-23 06:29:00 +08:00
|
|
|
hasMismatchedTooltipsAndMeasures,
|
2025-05-02 03:47:34 +08:00
|
|
|
isDownsampled,
|
|
|
|
numberOfDataPoints
|
2025-01-07 02:29:29 +08:00
|
|
|
}),
|
|
|
|
[
|
|
|
|
props,
|
2025-01-08 05:42:00 +08:00
|
|
|
pieMinimumSlicePercentage,
|
2025-01-07 02:29:29 +08:00
|
|
|
datasetOptions,
|
|
|
|
dataTrendlineOptions,
|
|
|
|
y2AxisKeys,
|
|
|
|
yAxisKeys,
|
|
|
|
hasMismatchedTooltipsAndMeasures,
|
2025-04-23 06:29:00 +08:00
|
|
|
tooltipKeys,
|
2025-05-02 03:47:34 +08:00
|
|
|
isDownsampled,
|
|
|
|
numberOfDataPoints
|
2025-01-07 02:29:29 +08:00
|
|
|
]
|
|
|
|
);
|
|
|
|
|
2025-03-04 00:40:02 +08:00
|
|
|
return <BusterChartJS {...chartProps} />;
|
2025-01-07 02:29:29 +08:00
|
|
|
};
|