Fixed issue with graphs that are not showing series correctly (#763)
Co-authored-by: Benjamin Perez <benjamin@bexsoft.net>
This commit is contained in:
@@ -727,13 +727,27 @@ const constructLabelNames = (metrics: any, legendFormat: string) => {
|
||||
const keysToReplace = Object.keys(metrics);
|
||||
const expToReplace = new RegExp(`{{(${keysToReplace.join("|")})}}`, "g");
|
||||
|
||||
const replacedLegend = legendFormat.replace(expToReplace, (matchItem) => {
|
||||
let replacedLegend = legendFormat.replace(expToReplace, (matchItem) => {
|
||||
const nwMatchItem = matchItem.replace(/({{|}})/g, "");
|
||||
return metrics[nwMatchItem];
|
||||
});
|
||||
|
||||
const countVarsOpen = (replacedLegend.match(/{{/g) || []).length;
|
||||
const countVarsClose = (replacedLegend.match(/}}/g) || []).length;
|
||||
|
||||
let cleanLegend = replacedLegend.replace(/{{(.*?)}}/g, "");
|
||||
|
||||
if (countVarsOpen === countVarsClose && countVarsOpen !== 0 && countVarsClose !== 0) {
|
||||
|
||||
keysToReplace.forEach((element) => {
|
||||
replacedLegend = replacedLegend.replace(element, metrics[element]);
|
||||
})
|
||||
|
||||
cleanLegend = replacedLegend;
|
||||
}
|
||||
|
||||
// In case not all the legends were replaced, we remove the placeholders.
|
||||
return replacedLegend.replace(/{{(.*?)}}/g, "");
|
||||
return cleanLegend;
|
||||
};
|
||||
|
||||
export const getWidgetsWithValue = (payload: any[]) => {
|
||||
|
||||
Reference in New Issue
Block a user