2017-09-22 3 views
0

I가 매일 2 키로 지난 30 일의 배열 :나뭇 날짜 시간에서 날짜와 googlechart X 축 구현

-date (날짜)

-count (정수)

enter image description here

본인은 X- 축에 날짜와 count y 축에 있지만 최대한 빨리 나뭇 가지를 사용하여 내 배열에 루프를 시도, 내 날짜 시간 값이 변경 될 것으로 보인다와 구글 차트를 실체화하려고합니다. 나는 각 루프 반복의 날짜를 인쇄하고 나는이 결과를 얻을

function drawChart() { 

     var dataTable = new google.visualization.DataTable(); 
     dataTable.addColumn({ type: 'date', id: 'date', label: 'date'}); 
     dataTable.addColumn({ type: 'number', id: 'Nombre d OF', label: 'Nb of'}); 


    {% for value in chartData.data %} 
     console.log({{ value.date.format('Y-m-d') }}); 
     dataTable.addRow([new Date("{{ value.date.format('Y-m-d')| date("Y-m-d") }}".replace(/-/g,"/")), {{ value.count }}]); 
    {% endfor %} 

    var options = { 
     title: 'Nombre d\'ordre de fabrication crées sur les 30 derniers jours ('+{{ chartData.info }}+')', 
     hAxis: {title: 'Jours', titleTextStyle: {color: '#333'}}, 
     vAxis: {minValue: 0} 
    }; 

    var chart = new google.visualization.AreaChart(document.getElementById('chart_div')); 
    chart.draw(dataTable, options); 
    } 

:

enter image description here

을 여기

drawGraph() 기능에 내 그래프에 행을 추가 할 수있는 방법 I 루프입니다

내 질문 : 내 루프에서 날짜가 변경된 이유는 무엇입니까?

답변

1

2017 - 9 - 24는 actualy ..., 당신이 그렇지 않으면

console.log('{{ value.date.format('Y-m-d') }}');

+0

OMG가 와서 subvision으로 처리됩니다 따옴표로 문을 포장하는 데 필요한 답변을 주셔서 감사합니다 1984입니다 – Gauthier

관련 문제