Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function convertMeasureDefinition(definition: IMeasureDefinitionType): AFM.MeasureDefinition {
if (VisualizationObject.isMeasureDefinition(definition)) {
return convertSimpleMeasureDefinition(definition);
} else if (VisualizationObject.isPopMeasureDefinition(definition)) {
return convertPopMeasureDefinition(definition);
} else if (VisualizationObject.isPreviousPeriodMeasureDefinition(definition)) {
return convertPreviousPeriodMeasureDefinition(definition);
} else if (VisualizationObject.isArithmeticMeasureDefinition(definition)) {
return convertArithmeticMeasureDefinition(definition);
} else {
throw Error("The measure definition is not supported: " + JSON.stringify(definition));
}
}
function getFormat(measure: IMeasure): string | undefined {
const {
measure: { definition },
} = measure;
const measureFormat = get(measure.measure, "format");
if (VisualizationObject.isArithmeticMeasureDefinition(definition)) {
if (definition.arithmeticMeasure.operator === "change") {
return "#,##0.00%";
}
}
const predefinedFormat = VisualizationObject.isMeasureDefinition(definition)
? getPredefinedFormat(definition)
: undefined;
return predefinedFormat || measureFormat;
}