Allow plotting edge-case values
This commit is contained in:
@@ -49,6 +49,19 @@ export function toPlottableValue(value: any): number | undefined {
|
|||||||
if (isNumber && !isNaN(intVal)) {
|
if (isNumber && !isNaN(intVal)) {
|
||||||
return intVal
|
return intVal
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Convert "on" / "off" to int 1 / 0
|
||||||
|
if (typeof value === 'string') {
|
||||||
|
if (/^(on$)|(off$)/i.test(value)) {
|
||||||
|
return value.toLowerCase() === 'on' ? 1 : 0
|
||||||
|
}
|
||||||
|
if (/^[0-9]*,[0-9]+$/.test(value)) {
|
||||||
|
let parsedFloat = parseFloat(value.replace(',', '.'))
|
||||||
|
if (!isNaN(parsedFloat)) {
|
||||||
|
return parsedFloat
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isPlottable(value: any) {
|
export function isPlottable(value: any) {
|
||||||
|
|||||||
Reference in New Issue
Block a user