Skip to content

Rounding problems #1498

@jibaku

Description

@jibaku

On some graph (using 2.0.0-dev), I've rounding problems, where I get 103.9999999999 instead of 104 etc.

Rounding problem
Rounding problems

The code for the rounding with 103 / 104 issue

<script src="/static/js/bootstrap.min.js"></script>

<script type="text/javascript" src="/static/js/Chart.min.js"></script>
<script type="text/javascript">
  var lineChartData = {"tension": 0, "legendTemplate": "", "type": "line", "data": {"labels": ["22/09", "23/09", "24/09", "25/09", "26/09", "27/09", "28/09", "29/09"], "datasets": [{"borderColor": "rgba(220,220,220,0.5)", "pointBorderWidth": "rgba(220,220,220,0.5)", "backgroundColor": "rgba(220,220,220,0.5)", "borderDash": [5, 5], "pointBorderColor": "rgba(220,220,220,0.5)", "pointBackgroundColor": "rgba(220,220,220,0.5)", "data": [103, 103, 103, 103, 104, 104, 104, 104], "label": "Likes"}]}, "tooltipTemplate": "", "options": {"responsive": true, "scales": {"xAxes": [{"display": true}], "yAxes": [{"display": true}]}}};
  function updateLegend() {
      $legendContainer = $('#legendContainer');
      $legendContainer.empty();
      $legendContainer.append(window.myBar.generateLegend());
  }
  window.onload = function() {

      Chart.defaults.global.elements.line.tension = 0;
      var ctx2 = document.getElementById("line").getContext("2d");
      window.myBar = new Chart(ctx2, lineChartData);
  };
</script>

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions