Value Precision in a Bar Chart

I have a bar chart that shows the number of times a particular torque value occurred. The dataset is a comprised of a double for the torque value and an integer for the number of times the torque occurred. In the dataset everything shows correctly but when the values are shown in the bar chart, the precision is off. The information comes from a SQL query in my database. Everything shows with the correct precision except for the bar chart. I thought this only happens with float datatype. I am using Ignition 7.7

Binary literally can’t represent arbitrary decimal precision the way that you’re expecting it to. Neither the float nor double type will behave differently - this is how all computers work on the backend.

You will need to round the data before it’s displayed; either in your SQL query, in scripting before it’s displayed on the chart, or using the JFreeChart API (you will probably have the best results with the Chart component, which allows you to run a configureChart scripting function).

2 Likes

The result data in the SQL query is already in the format, #.##, that I am trying to achieve. Does that need to be converted to something else or am I misunderstanding your statement? The only place it is displayed with a lot of numbers behind the decimal is the bar chart.

The result data you see in management studio/workbench/etc does not indicate how the value is actually stored in binary. Explicitly round the results and you should get the expected output.

Thank you! I understand now and I am getting the values I expect.