2016-07-30 1 views
2

Google에서 최근에 시작한 gantt 차트를 사용하여 차트를 통해 작업을 추적하는 데 적합합니다.Google gantt 차트의 연도가 잘못 표시되었습니다.

4 개의 작업을 만들었으므로 차트로드가 잘되었지만 예를 들어 잘못된 날짜가 표시됩니다. 2016 년 1 월, 제품 개발 및 출시 섹션 실제로 나는이 데이터를 내 데이터에서 전혀 사용하지 않았습니다. 여기에 어떤 문제가 있습니까?

enter image description here

당신은 모양 바이올린을 가지고 나에게 문제를 제발 알려 수 있습니다.

HTML :

<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script> 
<div id="chart_div"></div> 

자바 스크립트 :

google.charts.load('current', {'packages':['gantt']}); 
google.charts.setOnLoadCallback(drawChart); 

function daysToMilliseconds(days) { 
    return days * 24 * 60 * 60 * 1000; 
} 

function drawChart() { 

    var data = new google.visualization.DataTable(); 
    data.addColumn('string', 'Task ID'); 
    data.addColumn('string', 'Task Name'); 
    data.addColumn('date', 'Start Date'); 
    data.addColumn('date', 'End Date'); 
    data.addColumn('number', 'Duration'); 
    data.addColumn('number', 'Percent Complete'); 
    data.addColumn('string', 'Dependencies'); 

    data.addRows([ 
    ['Design', 'Design and analysis', 
    new Date(2015, 8, 1), new Date(2015, 8, 15), null, 25, null], 
    ['Development', 'Develop the product', 
    new Date(2015, 8, 16), new Date(2015, 10, 31), null, 20, null], 
    ['Testing', 'Product testing', 
    new Date(2015, 11, 01), new Date(2015, 11, 30), null, 10, null], 
    ['Release', 'Release the product', 
    new Date(2015, 12, 01), new Date(2015, 12, 20), null, 0, null], 
    ]); 

    var options = { 
    height: 275 
    }; 

    var chart = new google.visualization.Gantt(document.getElementById('chart_div')); 

    chart.draw(data, options); 
} 

는 도움과 감사 회신! >new Date(2015, 11, 01)

대신 12은 조각 다음을 참조하십시오 2016년 1월 1일

에 날짜를 밀어 -

답변

3

개월 번호는 자바 스크립트에서 0을 기준으로

12월 있도록 2015 년 1 것이다. ..

날짜 테스트

범위 8 월 할 필요가있는 경우 84,

차트 테스트

이 - 십이 다음이 도움 1 개

google.charts.load('current', {'packages':['gantt']}); 
 
    google.charts.setOnLoadCallback(drawChart); 
 

 
    function daysToMilliseconds(days) { 
 
     return days * 24 * 60 * 60 * 1000; 
 
    } 
 

 
    function drawChart() { 
 

 
     var data = new google.visualization.DataTable(); 
 
     data.addColumn('string', 'Task ID'); 
 
     data.addColumn('string', 'Task Name'); 
 
     data.addColumn('date', 'Start Date'); 
 
     data.addColumn('date', 'End Date'); 
 
     data.addColumn('number', 'Duration'); 
 
     data.addColumn('number', 'Percent Complete'); 
 
     data.addColumn('string', 'Dependencies'); 
 

 
     data.addRows([ 
 
     ['Design', 'Design and analysis', 
 
     new Date(2015, 7, 1), new Date(2015, 7, 15), null, 25, null], 
 
     ['Development', 'Develop the product', 
 
     new Date(2015, 7, 16), new Date(2015, 9, 31), null, 20, null], 
 
     ['Testing', 'Product testing', 
 
     new Date(2015, 10, 01), new Date(2015, 10, 30), null, 10, null], 
 
     ['Release', 'Release the product', 
 
     new Date(2015, 11, 01), new Date(2015, 11, 20), null, 0, null], 
 
     ]); 
 

 
     var options = { 
 
     height: 275 
 
     }; 
 

 
     var chart = new google.visualization.Gantt(document.getElementById('chart_div')); 
 

 
     chart.draw(data, options); 
 
    }
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script> 
 
<div id="chart_div"></div>

+0

희망에 의해 매달 번호를 줄이고, 참조 [날짜 및 시간] (https://developers.google.com/chart/interactive/docs/dates) andtimes) (Google 차트 참조) more ... – WhiteHat

+0

흥미 롭습니다! 대부분 JS PHP를 사용하기 때문에 JS에 대해 인식하지 못했습니다 :) Thanks WhiteHat! –

관련 문제