Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return value => {
try {
return format !== 'none' ? getValueFormat(format)(value, decimals, scaledDecimals) : value;
} catch (err) {
console.error(err.message || err);
return value;
}
};
}
getValue = (chart, value) => {
let yAxisTickFormat = null;
if (chart.tickFormat) {
const valueFormatter = getValueFormat(chart.tickFormat);
yAxisTickFormat = (v) => `${valueFormatter(v)}`;
return yAxisTickFormat(value);
} else if (chart.tickTemplate) {
try {
const template = Handlebars.compile(chart.tickTemplate);
yAxisTickFormat = (v) => `${template({ values: v })}`;
return yAxisTickFormat(value);
} catch (err) {
console.error("Failed to compile y axis tick template", err);
}
} else {
return value.toFixed(5);
}
}
return this.defaultCellFormatter(map.text, column.style);
}
}
}
if (v === null || v === void 0) {
return '-';
}
this.setColorState(v, column.style);
return this.defaultCellFormatter(v, column.style);
};
}
if (column.style.type === 'number') {
const valueFormatter = getValueFormat(column.unit || column.style.unit);
return v => {
if (v === null || v === void 0) {
return '-';
}
if (isNaN(v) || _.isArray(v)) {
return this.defaultCellFormatter(v, column.style);
}
this.setColorState(v, column.style);
return valueFormatter(v, column.style.decimals, null);
};
}
return value => {
return this.defaultCellFormatter(map.text, column.style);
}
}
}
if (v === null || v === void 0) {
return '-';
}
this.setColorState(v, column.style);
return this.defaultCellFormatter(v, column.style);
};
}
if (column.style.type === 'number') {
const valueFormatter = getValueFormat(column.unit || column.style.unit);
return v => {
if (v === null || v === void 0) {
return '-';
}
if (isNaN(v) || _.isArray(v)) {
return this.defaultCellFormatter(v, column.style);
}
this.setColorState(v, column.style);
return valueFormatter(v, column.style.decimals, null);
};
}
if (column.style.type === 'severity') {
sensor.isBold = valueMapping.isSensorFontBold;
break;
} else {
normalizeSensor(sensor);
}
}
} else {
normalizeSensor(sensor);
}
if (metricValue === undefined) {
sensor.valueFormatted = 'Select a sensor metric';
} else {
const formatFunc = getValueFormat(sensor.unitFormat);
sensor.valueFormatted = formatFunc(metricValue, sensor.decimals);
}
}
dragEventSetup();
}