projects/swimlane/ngx-charts/src/lib/common/label.helper.ts
/**
* Formats a label given a date, number or string.
*
* @export
*/
export function formatLabel(label: any): string {
if (label instanceof Date) {
label = label.toLocaleDateString();
} else {
label = label.toLocaleString();
}
return label;
}
/**
* Escapes a label.
*
* @export
*/
export function escapeLabel(label: any): string {
return label.toLocaleString().replace(/[&'`"<>]/g, match => {
return {
'&': '&',
// tslint:disable-next-line: quotemark
"'": ''',
'`': '`',
'"': '"',
'<': '<',
'>': '>'
}[match];
});
}