mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-08-15 12:36:07 +08:00
fix: [SIG-567]: prevented stage-&-run API on legend change (#4720)
* fix: prevented stage-&-run API on legend change * fix: code refactor --------- Co-authored-by: Sagar Rajput <sagarrajput@192.168.1.2>
This commit is contained in:
parent
63f0ae1c7c
commit
0df86454ce
@ -133,6 +133,7 @@ function WidgetGraph({
|
|||||||
softMax,
|
softMax,
|
||||||
softMin,
|
softMin,
|
||||||
panelType: selectedGraph,
|
panelType: selectedGraph,
|
||||||
|
currentQuery,
|
||||||
}),
|
}),
|
||||||
[
|
[
|
||||||
widgetId,
|
widgetId,
|
||||||
@ -148,6 +149,7 @@ function WidgetGraph({
|
|||||||
softMax,
|
softMax,
|
||||||
softMin,
|
softMin,
|
||||||
selectedGraph,
|
selectedGraph,
|
||||||
|
currentQuery,
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@ import { Dimensions } from 'hooks/useDimensions';
|
|||||||
import { convertValue } from 'lib/getConvertedValue';
|
import { convertValue } from 'lib/getConvertedValue';
|
||||||
import _noop from 'lodash-es/noop';
|
import _noop from 'lodash-es/noop';
|
||||||
import { MetricRangePayloadProps } from 'types/api/metrics/getQueryRange';
|
import { MetricRangePayloadProps } from 'types/api/metrics/getQueryRange';
|
||||||
|
import { Query } from 'types/api/queryBuilder/queryBuilderData';
|
||||||
import uPlot from 'uplot';
|
import uPlot from 'uplot';
|
||||||
|
|
||||||
import onClickPlugin, { OnClickPluginOpts } from './plugins/onClickPlugin';
|
import onClickPlugin, { OnClickPluginOpts } from './plugins/onClickPlugin';
|
||||||
@ -40,6 +41,7 @@ export interface GetUPlotChartOptions {
|
|||||||
maxTimeScale?: number;
|
maxTimeScale?: number;
|
||||||
softMin: number | null;
|
softMin: number | null;
|
||||||
softMax: number | null;
|
softMax: number | null;
|
||||||
|
currentQuery?: Query;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getUPlotChartOptions = ({
|
export const getUPlotChartOptions = ({
|
||||||
@ -59,6 +61,7 @@ export const getUPlotChartOptions = ({
|
|||||||
softMax,
|
softMax,
|
||||||
softMin,
|
softMin,
|
||||||
panelType,
|
panelType,
|
||||||
|
currentQuery,
|
||||||
}: GetUPlotChartOptions): uPlot.Options => {
|
}: GetUPlotChartOptions): uPlot.Options => {
|
||||||
const timeScaleProps = getXAxisScale(minTimeScale, maxTimeScale);
|
const timeScaleProps = getXAxisScale(minTimeScale, maxTimeScale);
|
||||||
|
|
||||||
@ -223,6 +226,7 @@ export const getUPlotChartOptions = ({
|
|||||||
widgetMetaData: apiResponse?.data.result,
|
widgetMetaData: apiResponse?.data.result,
|
||||||
graphsVisibilityStates,
|
graphsVisibilityStates,
|
||||||
panelType,
|
panelType,
|
||||||
|
currentQuery,
|
||||||
}),
|
}),
|
||||||
axes: getAxes(isDarkMode, yAxisUnit),
|
axes: getAxes(isDarkMode, yAxisUnit),
|
||||||
};
|
};
|
||||||
|
@ -3,6 +3,7 @@ import { PANEL_TYPES } from 'constants/queryBuilder';
|
|||||||
import { themeColors } from 'constants/theme';
|
import { themeColors } from 'constants/theme';
|
||||||
import getLabelName from 'lib/getLabelName';
|
import getLabelName from 'lib/getLabelName';
|
||||||
import { MetricRangePayloadProps } from 'types/api/metrics/getQueryRange';
|
import { MetricRangePayloadProps } from 'types/api/metrics/getQueryRange';
|
||||||
|
import { Query } from 'types/api/queryBuilder/queryBuilderData';
|
||||||
import { QueryData } from 'types/api/widgets/getQuery';
|
import { QueryData } from 'types/api/widgets/getQuery';
|
||||||
|
|
||||||
import { drawStyles, lineInterpolations } from './constants';
|
import { drawStyles, lineInterpolations } from './constants';
|
||||||
@ -31,6 +32,7 @@ const getSeries = ({
|
|||||||
widgetMetaData,
|
widgetMetaData,
|
||||||
graphsVisibilityStates,
|
graphsVisibilityStates,
|
||||||
panelType,
|
panelType,
|
||||||
|
currentQuery,
|
||||||
}: GetSeriesProps): uPlot.Options['series'] => {
|
}: GetSeriesProps): uPlot.Options['series'] => {
|
||||||
const configurations: uPlot.Series[] = [
|
const configurations: uPlot.Series[] = [
|
||||||
{ label: 'Timestamp', stroke: 'purple' },
|
{ label: 'Timestamp', stroke: 'purple' },
|
||||||
@ -40,13 +42,15 @@ const getSeries = ({
|
|||||||
const newGraphVisibilityStates = graphsVisibilityStates?.slice(1);
|
const newGraphVisibilityStates = graphsVisibilityStates?.slice(1);
|
||||||
|
|
||||||
for (let i = 0; i < seriesList?.length; i += 1) {
|
for (let i = 0; i < seriesList?.length; i += 1) {
|
||||||
const { metric = {}, queryName = '', legend = '' } = widgetMetaData[i] || {};
|
const { metric = {}, queryName = '', legend: lgd } = widgetMetaData[i] || {};
|
||||||
|
|
||||||
const label = getLabelName(
|
const newLegend =
|
||||||
metric,
|
currentQuery?.builder.queryData.find((item) => item.queryName === queryName)
|
||||||
queryName || '', // query
|
?.legend || '';
|
||||||
legend || '',
|
|
||||||
);
|
const legend = newLegend || lgd || '';
|
||||||
|
|
||||||
|
const label = getLabelName(metric, queryName || '', legend);
|
||||||
|
|
||||||
const color = generateColor(label, themeColors.chartcolors);
|
const color = generateColor(label, themeColors.chartcolors);
|
||||||
|
|
||||||
@ -87,6 +91,7 @@ export type GetSeriesProps = {
|
|||||||
widgetMetaData: QueryData[];
|
widgetMetaData: QueryData[];
|
||||||
graphsVisibilityStates?: boolean[];
|
graphsVisibilityStates?: boolean[];
|
||||||
panelType?: PANEL_TYPES;
|
panelType?: PANEL_TYPES;
|
||||||
|
currentQuery?: Query;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default getSeries;
|
export default getSeries;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user