Search the Community
Showing results for tags 'decimals'.
Found 1 result
-
Hi, I found a bug in FC, when you're setting : decimals: "0" and you have negative values in your graph, the value is not well rounded. In example : -3.5 should be rounded at -4, currently it show -3. I think this is because your devs are using the Math.round integrated function of JS, but this is something wrong. Try this dataSource : const chartData = { chart: { caption: "Test decimals", theme: "fusion", decimals: "0" }, data: [ { label: "test1", value: "3.5" }, { label: "test2", value: "-3.5" }, { label: "test3", value: "-2.5" }, { label: "test4", value: "+2.4" }, { label: "test5", value: "-10.5" } ] }; I suggest to use this function I delveloped myself that I always use to have good rounding relative numbers (my variables are in french but it works) : /** * Permet d'arrondir un nombre à la décimale souhaitée * @param {number} nombre Nombre à arrondir. * @param {number} decimales Nombre de décimales à arrondir. (Par défaut 0) * @returns {number} */ function arrondi(nombre, decimales = 0) { if (decimales < -1) throw new Error("Le nombre de décimales ne peut être inférieur à -1."); var neg = nombre < 0; if (decimales == -1) return nombre; else { var nombre_abs = Math.round(Math.abs(nombre) * Math.pow(10, decimales)) / Math.pow(10, decimales); if (neg) return -nombre_abs else return nombre_abs; } }