|
|
|
|
@ -1,6 +1,6 @@ |
|
|
|
|
import React, { useRef } from 'react'; |
|
|
|
|
import { cloneDeep } from 'lodash'; |
|
|
|
|
import { DataFrame, TimeRange } from '@grafana/data'; |
|
|
|
|
import { DataFrame, FieldType, TimeRange } from '@grafana/data'; |
|
|
|
|
import { GraphNG, GraphNGProps, PlotLegend, UPlotConfigBuilder, usePanelContext, useTheme2 } from '@grafana/ui'; |
|
|
|
|
import { LegendDisplayMode } from '@grafana/schema'; |
|
|
|
|
import { BarChartOptions } from './types'; |
|
|
|
|
@ -38,7 +38,12 @@ export const BarChart: React.FC<BarChartProps> = (props) => { |
|
|
|
|
return <PlotLegend data={props.frames} config={config} maxHeight="35%" maxWidth="60%" {...props.legend} />; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
const rawValue = (seriesIdx: number, valueIdx: number) => frame0Ref.current!.fields[seriesIdx].values.get(valueIdx); |
|
|
|
|
const rawValue = (seriesIdx: number, valueIdx: number) => { |
|
|
|
|
let field = frame0Ref.current!.fields.find( |
|
|
|
|
(f) => f.type === FieldType.number && f.state?.seriesIndex === seriesIdx - 1 |
|
|
|
|
); |
|
|
|
|
return field!.values.get(valueIdx); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
const prepConfig = (alignedFrame: DataFrame, allFrames: DataFrame[], getTimeRange: () => TimeRange) => { |
|
|
|
|
const { timeZone, orientation, barWidth, showValue, groupWidth, stacking, legend, tooltip, text } = props; |
|
|
|
|
|