import React from 'react'; import { cloneDeep } from 'lodash'; import { DataFrame, TimeRange } from '@grafana/data'; import { GraphNG, GraphNGProps, PlotLegend, UPlotConfigBuilder, usePanelContext, useTheme2 } from '@grafana/ui'; import { LegendDisplayMode } from '@grafana/schema'; import { BarChartOptions } from './types'; import { preparePlotConfigBuilder, preparePlotFrame } from './utils'; import { PropDiffFn } from '../../../../../packages/grafana-ui/src/components/GraphNG/GraphNG'; /** * @alpha */ export interface BarChartProps extends BarChartOptions, Omit {} const propsToDiff: Array = [ 'orientation', 'barWidth', 'groupWidth', 'stacking', 'showValue', (prev: BarChartProps, next: BarChartProps) => next.text?.valueSize === prev.text?.valueSize, ]; export const BarChart: React.FC = (props) => { const theme = useTheme2(); const { eventBus } = usePanelContext(); const renderLegend = (config: UPlotConfigBuilder) => { if (!config || props.legend.displayMode === LegendDisplayMode.Hidden) { return null; } return ; }; const prepConfig = (alignedFrame: DataFrame, allFrames: DataFrame[], getTimeRange: () => TimeRange) => { const { timeZone, orientation, barWidth, showValue, groupWidth, stacking, legend, tooltip, text } = props; return preparePlotConfigBuilder({ frame: alignedFrame, getTimeRange, theme, timeZone, eventBus, orientation, barWidth, showValue, groupWidth, stacking, legend, tooltip, text, allFrames: props.frames, }); }; return ( ); }; BarChart.displayName = 'BarChart';