2014-10-16 3 views
4

모든 차트를 표시하고 모든 360º를 유지할 때 차트 생성에 문제가 있습니다. 차트가 안드로이드 기본 브라우저에 360 애니메이션을 종료Chartjs Donut이 사라집니다.

<!doctype html> 
 
<html> 
 
    <head> 
 
    <title>Chart Test</title> 
 
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> 
 
    <script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/1.0.1-beta.2/Chart.js"></script> 
 
    </head> 
 
    <body> 
 
    <canvas width="200" height="200"></canvas> 
 

 
    <script> 
 
    var canvas = $('canvas') 
 
     , data = [ 
 
     { 
 
      value  : 300, 
 
      color  : "#F7464A", 
 
      highlight : "#FF5A5E", 
 
      label  : "Red" 
 
     } 
 
     ] 
 
     , options = {"percentageInnerCutout":70,"showTooltips":false,"animateScale":true} 
 
     , chart = new Chart(canvas.get(0).getContext('2d')).Doughnut(data, options); 
 
    </script> 
 
    </body> 
 
</html>

그냥 후에는 disapears하지만 크롬에 발생하지 않습니다 다음은 예입니다. Sony Xperia (v4.1.2) 및 Samsung S3에서 테스트되었습니다.

내 데스크톱에서이 문제는 발생하지 않으므로 기본 Android 브라우저와 관련이있는 것으로 보입니다. 나는 또한 최신 chart.js 버전 1.0.1 - beta.4 테스트 한

...

이에 대한 GitHub의에 open issue을있다.

누구든지이 문제를 해결 했습니까?

+0

당신이 어떤 사람을 의미합니까 :

그래서 여기 내가 생각 해낸거야? 데스크톱 브라우저에서 재생할 수 있습니까? – Quince

+0

이것은 firefox 23에서 잘 작동합니다. – Quince

+0

또한 사파리 Mac에서 문제가되는 것 같습니다 –

답변

1

이 문제의 해결 방법을 찾고 며칠 전부터 지금까지 어떤 응답도 얻지 못했기 때문에 몇 가지 테스트를 통해 제대로 작동하는 데 필요한 최소 지원 값을 확인했습니다. 지금 당장은 이전에 언급 한 장치로 작업하고 있습니다.

다음 예제에서는 "데이터"배열에 대한 다양한 테스트 값이 있으므로 테스트 해보고 새 테스트 값을 사용해 모든 버그를 식별하십시오. 당신이 어떤 오래된 브라우저가 말할 때

<!doctype html> 
 
<html> 
 
    <head> 
 
    <title>Chart Test</title> 
 
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> 
 
    <script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/1.0.1-beta.2/Chart.js"></script> 
 
    </head> 
 
    <body> 
 
    <canvas width="300" height="300"></canvas> 
 
    <script> 
 
     var canvas  = $('canvas') 
 
     , lowestValue = 0.001   // Minimum supported value 
 
     , highestValue = 0 
 
     , emptySection = { 
 
       value  : lowestValue 
 
      , color  : '#e8e8e8' 
 
      , highlight : '#e8e8e8' 
 
      , label  : '' 
 
      } 
 
     , data = [] 
 
     /*, data = [ 
 
       { 
 
        value  : 0 
 
       , color  : '#F7464A' 
 
       , highlight : '#FF5A5E' 
 
       , label  : 'Red' 
 
       } 
 
      ] 
 
     , data = [ 
 
       { 
 
        value  : 1 
 
       , color  : '#F7464A' 
 
       , highlight : '#FF5A5E' 
 
       , label  : 'Red' 
 
       } 
 
      ] 
 
     , data = [ 
 
       { 
 
        value  : 0 
 
       , color  : '#F7464A' 
 
       , highlight : '#FF5A5E' 
 
       , label  : 'Red' 
 
       } 
 
      , { 
 
        value  : 0 
 
       , color  : '#15D42F' 
 
       , highlight : '#15D42F' 
 
       , label  : 'Green' 
 
       } 
 
      ] 
 
     , data = [ 
 
       { 
 
        value  : 0 
 
       , color  : '#F7464A' 
 
       , highlight : '#FF5A5E' 
 
       , label  : 'Red' 
 
       } 
 
      , { 
 
        value  : 1 
 
       , color  : '#15D42F' 
 
       , highlight : '#15D42F' 
 
       , label  : 'Green' 
 
       } 
 
      ] 
 
     , data = [ 
 
       { 
 
        value  : 1 
 
       , color  : '#F7464A' 
 
       , highlight : '#FF5A5E' 
 
       , label  : 'Red' 
 
       } 
 
      , { 
 
        value  : 0 
 
       , color  : '#15D42F' 
 
       , highlight : '#15D42F' 
 
       , label  : 'Green' 
 
       } 
 
      ] 
 
     , data = [ 
 
       { 
 
        value  : 1 
 
       , color  : '#F7464A' 
 
       , highlight : '#FF5A5E' 
 
       , label  : 'Red' 
 
       } 
 
      , { 
 
        value  : 2 
 
       , color  : '#15D42F' 
 
       , highlight : '#15D42F' 
 
       , label  : 'Green' 
 
       } 
 
      ] 
 
     , data = [ 
 
       { 
 
        value  : 0.000001 
 
       , color  : '#F7464A' 
 
       , highlight : '#FF5A5E' 
 
       , label  : 'Red' 
 
       } 
 
      , { 
 
        value  : 0.0058 
 
       , color  : '#15D42F' 
 
       , highlight : '#15D42F' 
 
       , label  : 'Green' 
 
       } 
 
      , { 
 
        value  : 1 
 
       , color  : '#FAEC23' 
 
       , highlight : '#FAEC23' 
 
       , label  : 'Yellow' 
 
       } 
 
      ] 
 
     , data = [ 
 
       { 
 
        value  : 0.00 
 
       , color  : '#F7464A' 
 
       , highlight : '#FF5A5E' 
 
       , label  : 'Red' 
 
       } 
 
      , { 
 
        value  : 0.00 
 
       , color  : '#15D42F' 
 
       , highlight : '#15D42F' 
 
       , label  : 'Green' 
 
       } 
 
      , { 
 
        value  : 0.00 
 
       , color  : '#15D42F' 
 
       , highlight : '#15D42F' 
 
       , label  : 'Green' 
 
       } 
 
      , { 
 
        value  : 0.00 
 
       , color  : '#15D42F' 
 
       , highlight : '#15D42F' 
 
       , label  : 'Green' 
 
       } 
 
      , { 
 
        value  : 0.00 
 
       , color  : '#15D42F' 
 
       , highlight : '#15D42F' 
 
       , label  : 'Green' 
 
       } 
 
      , { 
 
        value  : 0.00 
 
       , color  : '#15D42F' 
 
       , highlight : '#15D42F' 
 
       , label  : 'Green' 
 
       } 
 
      , { 
 
        value  : 0.00 
 
       , color  : '#15D42F' 
 
       , highlight : '#15D42F' 
 
       , label  : 'Green' 
 
       } 
 
      , { 
 
        value  : 0.00 
 
       , color  : '#15D42F' 
 
       , highlight : '#15D42F' 
 
       , label  : 'Green' 
 
       } 
 
      , { 
 
        value  : 0.00 
 
       , color  : '#15D42F' 
 
       , highlight : '#15D42F' 
 
       , label  : 'Green' 
 
       } 
 
      , { 
 
        value  : 1 
 
       , color  : '#FAEC23' 
 
       , highlight : '#FAEC23' 
 
       , label  : 'Yellow' 
 
       } 
 
      ]*/ 
 
     , options = { 
 
       'percentageInnerCutout': 70 
 
      , 'showTooltips'   : false 
 
      , 'animateScale'   : true 
 
      } 
 
     , chart = {}; 
 

 
     // If there are no valid segments, include two new ones an set the value of one of them to 1 
 
     // so that the chart appears. 
 
     if (data.length === 0) { 
 
     data.push($.extend(true, {}, emptySection)); 
 
     data.push($.extend(true, {}, emptySection)); 
 

 
     data[ 0 ].value = 1; 
 

 
     // Even if there are segments, we add a new one with one of the values: 
 
     // \t - 10: if the highest value of any segment is lower that the lowest allowed (0.001). 
 
     // \t - 0.001 of the highest value 
 
     } else { 
 

 
     $.each(data, function(index, el) { 
 
      el.value = el.value < lowestValue ? lowestValue : el.value; 
 
      highestValue = el.value > highestValue ? el.value : highestValue; 
 
     }); 
 

 
     data.push($.extend(true, {}, emptySection)); 
 

 
     // Set the value of the new segment. 
 
     // Get 0.001% of the highest value if it's greater that the lowest allowed. 
 
     // If it's not greater that the lowest allowed, set it to a value big enought so the other segments don't appear. 
 
     data[ data.length - 1 ].value = highestValue > lowestValue ? determinePercentage(highestValue) : 10; 
 
\t \t \t \t } 
 

 
     // Create the chart. 
 
     chart = new Chart(canvas.get(0).getContext('2d')).Doughnut(data, options); 
 

 

 
     /** 
 
     * Determines a specific percentage of a value. If no percentage is passed it assumes the lowest allowed (0.001). 
 
     */ 
 
     function determinePercentage(total, percentage) { 
 
      percentage = percentage || lowestValue; 
 

 
      return total ? (parseFloat(total) * percentage)/100 : 0; 
 
     } 
 

 
    </script> 
 
    </body> 
 
</html>