import { css } from '@emotion/css';
import { identity } from 'lodash';
import * as React from 'react';
import {
AbsoluteTimeRange,
DataQueryResponse,
LoadingState,
SplitOpen,
EventBus,
GrafanaTheme2,
DataFrame,
TimeRange,
} from '@grafana/data';
import { TimeZone } from '@grafana/schema';
import { Icon, SeriesVisibilityChangeMode, Tooltip, TooltipDisplayMode, useStyles2, useTheme2 } from '@grafana/ui';
import { getLogsVolumeDataSourceInfo, isLogsVolumeLimited } from '../../logs/utils';
import { ExploreGraph } from '../Graph/ExploreGraph';
type Props = {
logsVolumeData: DataQueryResponse;
allLogsVolumeMaximum: number;
timeRange: TimeRange;
timeZone: TimeZone;
splitOpen: SplitOpen;
width: number;
onUpdateTimeRange: (timeRange: AbsoluteTimeRange) => void;
onLoadLogsVolume: () => void;
onHiddenSeriesChanged: (hiddenSeries: string[]) => void;
eventBus: EventBus;
annotations: DataFrame[];
toggleLegendRef?: React.MutableRefObject<(name: string, mode: SeriesVisibilityChangeMode) => void> | undefined;
};
export function LogsVolumePanel(props: Props) {
const {
width,
timeZone,
splitOpen,
onUpdateTimeRange,
onHiddenSeriesChanged,
allLogsVolumeMaximum,
toggleLegendRef,
} = props;
const theme = useTheme2();
const styles = useStyles2(getStyles);
const spacing = parseInt(theme.spacing(2).slice(0, -2), 10);
const height = 150;
const logsVolumeData = props.logsVolumeData;
const logsVolumeInfo = getLogsVolumeDataSourceInfo(logsVolumeData?.data);
let extraInfo = logsVolumeInfo ? `${logsVolumeInfo.name}` : '';
if (isLogsVolumeLimited(logsVolumeData.data)) {
extraInfo = [
extraInfo,
'This datasource does not support full-range histograms. The graph below is based on the logs seen in the response.',
]
.filter(identity)
.join('. ');
}
let extraInfoComponent = {extraInfo};
if (logsVolumeData.state === LoadingState.Streaming) {
extraInfoComponent = (
<>
{extraInfoComponent}