import React, { useMemo } from 'react'; import { PanelProps, buildHistogram, getHistogramFields } from '@grafana/data'; import { histogramFieldsToFrame } from '@grafana/data/src/transformations/transformers/histogram'; import { useTheme2 } from '@grafana/ui'; import { Histogram, getBucketSize } from './Histogram'; import { PanelOptions } from './models.gen'; type Props = PanelProps; export const HistogramPanel: React.FC = ({ data, options, width, height }) => { const theme = useTheme2(); const histogram = useMemo(() => { if (!data?.series?.length) { return undefined; } if (data.series.length === 1) { const info = getHistogramFields(data.series[0]); if (info) { return histogramFieldsToFrame(info); } } const hist = buildHistogram(data.series, options); if (!hist) { return undefined; } return histogramFieldsToFrame(hist, theme); }, [data.series, options, theme]); if (!histogram || !histogram.fields.length) { return (

No histogram found in response

); } const bucketSize = getBucketSize(histogram); return ( {(config, alignedFrame) => { return null; // ; }} ); };