javascript - How to push data into highchart with just one decimal place? -


I am trying to create sinus and cosinus graphs. Data pushed in such a way:

  Data: (function exp () {var data1 = [], // i = 0, x = 0, y = 0; for (i = - 10; i & lt; = 10; i = i + 0.1) {// x = i.to fix (4); x = i; y = math sin (i); data1.push ({// x: Math round (i * 10000) / 10000, x: X, y: y,}); if ((y.toFixed (4) == 0) || (y.toFixed (4) == -0)) / var x = Math.sin (mathematics. I * 10000) / 10000); // var y = Math. (Math. Sin (i) * 10000) / 10000; addtext (x, y);}} return data 1;}) ()},   

Therefore the x value should be: -10; -9.9; -9.8, -9.7 and so on ... but if you look at the graph, then the x values ​​are: -10; -9.9; -9.8, and then -9.700000000000001 and all the next x values ​​have been damaged in the same way.

I have tried to use methods of .toFixed and .toPrecision , but they (for example) made point [0, Something like sin (0) should be [-0.0000, -0.0000], what's definitely bad, because it assumes x -0.000000000000187 ... does anyone help me push data with just 1 decimal place is?

Try adjusting the input x value.

To show the circular or floor numbers in the tooltip, you must drop the footer format , headerFormat , and pointFormat Take full control of the tooltip using more options. Something like this:

  formatter: function () {var s = '& lt; B & gt; + High quality. Number format (this.x, 1) + '& lt; / B & gt; '; $ .eight (this point, function (i, point) {s + = '

You should meet whatever you want.

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -