@grafana/data#getColumnFromDimension TypeScript Examples
The following examples show how to use
@grafana/data#getColumnFromDimension.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SingleModeGraphTooltip.tsx From grafana-chinese with Apache License 2.0 | 6 votes |
SingleModeGraphTooltip: React.FC<GraphTooltipContentProps> = ({ dimensions, activeDimensions }) => {
// not hovering over a point, skip rendering
if (
activeDimensions.yAxis === null ||
activeDimensions.yAxis[1] === undefined ||
activeDimensions.xAxis === null ||
activeDimensions.xAxis[1] === undefined
) {
return null;
}
const time = getValueFromDimension(dimensions.xAxis, activeDimensions.xAxis[0], activeDimensions.xAxis[1]);
const timeField = getColumnFromDimension(dimensions.xAxis, activeDimensions.xAxis[0]);
const processedTime = timeField.display ? formattedValueToString(timeField.display(time)) : time;
const valueField = getColumnFromDimension(dimensions.yAxis, activeDimensions.yAxis[0]);
const value = getValueFromDimension(dimensions.yAxis, activeDimensions.yAxis[0], activeDimensions.yAxis[1]);
const display = valueField.display ?? getDisplayProcessor({ field: valueField });
const disp = display(value);
return (
<SeriesTable
series={[
{
color: disp.color,
label: valueField.name,
value: formattedValueToString(disp),
},
]}
timestamp={processedTime}
/>
);
}