Chartjs-Input data in german data format combined with ChartsJs

0👍

Before inserting the numbers in that library, do this:
EDIT2: I misread your question, I thought you were asking how to change the floating point integers formats.

let n = "653.598,36";
let result = "";
let decimalPart = n.split(",")[1];
let decimalPartLen = decimalPart.length;
n = n.replace(".",""); //parseFloat doesn't like commas
let commaIndex = n.length - decimalPartLen;
result = parseFloat(n.substr(0,commaIndex - 1)+"."+n.substr(commaIndex, n.length));
console.log(result);

EDIT: this is client side js, but you could do this in python with minimal changes
Here it is in python:

n = "653.598,36"
result = ""
decimalPart = n.split(",")[1]
decimalPartLen = len(decimalPart)
n = n.replace(".","")
commaIndex = len(n) - decimalPartLen
result = float(n[:commaIndex-1]+"."+n[commaIndex:])
print(result)

Leave a comment