3

I am displaying a pie and a bar charts for different projects using ChartJS. When I click on the first project in the Statistics tab, it displays the charts correctly. When I click on the next projects, its not displaying the charts from there on. Instead, an exception is thrown:

Uncaught IndexSizeError: Failed to execute 'arc' on 'CanvasRenderingContext2D': The radius provided (-0.5) is negative. 

I'm trying to solve this for a long time. But I couldn't make it up. Can anyone help me with this?

Opal
  • 81,889
  • 28
  • 189
  • 210

2 Answers2

0

Not sure if this is exactly the same issue but it sounds similar to what I was experiencing here

angular-chart zero dimensions inside angular-strap panel

Community
  • 1
  • 1
Fabian
  • 3,310
  • 3
  • 26
  • 35
0

The problem is that when you load the page in some cases the chart doesn't receive the dimensions of the page (the width and height) therefore can not create the chart again. That happened to me when my app was showing a modal with AngularJS. So I did this:

In my index.html

<canvas chart-options="viewCountOptions" id="doughnut" class="chart chart-doughnut" chart-data="data" chart-labels="labels" chart-colours="colours" chart-legend="legend">

In my controllers.js

$scope.viewCountOptions = {
     responsive: false
  };