mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Ensure that tooltip and legend have same parameters to calculate and display label equally (#53176)
This commit is contained in:
@@ -25,6 +25,7 @@ import { findMidPointYPosition, pluginLog } from '../utils';
|
|||||||
interface TooltipPluginProps {
|
interface TooltipPluginProps {
|
||||||
timeZone: TimeZone;
|
timeZone: TimeZone;
|
||||||
data: DataFrame;
|
data: DataFrame;
|
||||||
|
frames?: DataFrame[];
|
||||||
config: UPlotConfigBuilder;
|
config: UPlotConfigBuilder;
|
||||||
mode?: TooltipDisplayMode;
|
mode?: TooltipDisplayMode;
|
||||||
sortOrder?: SortOrder;
|
sortOrder?: SortOrder;
|
||||||
@@ -203,7 +204,7 @@ export const TooltipPlugin: React.FC<TooltipPluginProps> = ({
|
|||||||
series={[
|
series={[
|
||||||
{
|
{
|
||||||
color: display.color || FALLBACK_COLOR,
|
color: display.color || FALLBACK_COLOR,
|
||||||
label: getFieldDisplayName(field, otherProps.data),
|
label: getFieldDisplayName(field, otherProps.data, otherProps.frames),
|
||||||
value: display ? formattedValueToString(display) : null,
|
value: display ? formattedValueToString(display) : null,
|
||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
@@ -237,7 +238,7 @@ export const TooltipPlugin: React.FC<TooltipPluginProps> = ({
|
|||||||
sortIdx.push(v);
|
sortIdx.push(v);
|
||||||
series.push({
|
series.push({
|
||||||
color: display.color || FALLBACK_COLOR,
|
color: display.color || FALLBACK_COLOR,
|
||||||
label: getFieldDisplayName(field, frame),
|
label: getFieldDisplayName(field, frame, otherProps.frames),
|
||||||
value: display ? formattedValueToString(display) : null,
|
value: display ? formattedValueToString(display) : null,
|
||||||
isActive: focusedSeriesIdx === i,
|
isActive: focusedSeriesIdx === i,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -71,6 +71,7 @@ export const TimeSeriesPanel: React.FC<TimeSeriesPanelProps> = ({
|
|||||||
<ZoomPlugin config={config} onZoom={onChangeTimeRange} />
|
<ZoomPlugin config={config} onZoom={onChangeTimeRange} />
|
||||||
{options.tooltip.mode === TooltipDisplayMode.None || (
|
{options.tooltip.mode === TooltipDisplayMode.None || (
|
||||||
<TooltipPlugin
|
<TooltipPlugin
|
||||||
|
frames={frames}
|
||||||
data={alignedDataFrame}
|
data={alignedDataFrame}
|
||||||
config={config}
|
config={config}
|
||||||
mode={options.tooltip.mode}
|
mode={options.tooltip.mode}
|
||||||
@@ -117,6 +118,7 @@ export const TimeSeriesPanel: React.FC<TimeSeriesPanelProps> = ({
|
|||||||
) : (
|
) : (
|
||||||
<ContextMenuPlugin
|
<ContextMenuPlugin
|
||||||
data={alignedDataFrame}
|
data={alignedDataFrame}
|
||||||
|
frames={frames}
|
||||||
config={config}
|
config={config}
|
||||||
timeZone={timeZone}
|
timeZone={timeZone}
|
||||||
replaceVariables={replaceVariables}
|
replaceVariables={replaceVariables}
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ export interface ContextMenuItemClickPayload {
|
|||||||
|
|
||||||
interface ContextMenuPluginProps {
|
interface ContextMenuPluginProps {
|
||||||
data: DataFrame;
|
data: DataFrame;
|
||||||
|
frames?: DataFrame[];
|
||||||
config: UPlotConfigBuilder;
|
config: UPlotConfigBuilder;
|
||||||
defaultItems?: Array<MenuItemsGroup<ContextMenuItemClickPayload>>;
|
defaultItems?: Array<MenuItemsGroup<ContextMenuItemClickPayload>>;
|
||||||
timeZone: TimeZone;
|
timeZone: TimeZone;
|
||||||
@@ -179,6 +180,7 @@ export const ContextMenuPlugin: React.FC<ContextMenuPluginProps> = ({
|
|||||||
{isOpen && coords && (
|
{isOpen && coords && (
|
||||||
<ContextMenuView
|
<ContextMenuView
|
||||||
data={data}
|
data={data}
|
||||||
|
frames={otherProps.frames}
|
||||||
defaultItems={defaultItems}
|
defaultItems={defaultItems}
|
||||||
timeZone={timeZone}
|
timeZone={timeZone}
|
||||||
selection={{ point, coords }}
|
selection={{ point, coords }}
|
||||||
@@ -196,8 +198,9 @@ export const ContextMenuPlugin: React.FC<ContextMenuPluginProps> = ({
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
interface ContextMenuProps {
|
interface ContextMenuViewProps {
|
||||||
data: DataFrame;
|
data: DataFrame;
|
||||||
|
frames?: DataFrame[];
|
||||||
defaultItems?: MenuItemsGroup[];
|
defaultItems?: MenuItemsGroup[];
|
||||||
timeZone: TimeZone;
|
timeZone: TimeZone;
|
||||||
onClose?: () => void;
|
onClose?: () => void;
|
||||||
@@ -208,7 +211,7 @@ interface ContextMenuProps {
|
|||||||
replaceVariables?: InterpolateFunction;
|
replaceVariables?: InterpolateFunction;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const ContextMenuView: React.FC<ContextMenuProps> = ({
|
export const ContextMenuView: React.FC<ContextMenuViewProps> = ({
|
||||||
selection,
|
selection,
|
||||||
timeZone,
|
timeZone,
|
||||||
defaultItems,
|
defaultItems,
|
||||||
@@ -274,7 +277,7 @@ export const ContextMenuView: React.FC<ContextMenuProps> = ({
|
|||||||
timestamp={xFieldFmt(xField.values.get(dataIdx)).text}
|
timestamp={xFieldFmt(xField.values.get(dataIdx)).text}
|
||||||
displayValue={displayValue}
|
displayValue={displayValue}
|
||||||
seriesColor={displayValue.color!}
|
seriesColor={displayValue.color!}
|
||||||
displayName={getFieldDisplayName(field, data)}
|
displayName={getFieldDisplayName(field, data, otherProps.frames)}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user