2016-06-26 3 views
2

지금 시간 문제로 어려움을 겪고 있습니다. 내 차트를 만들 수 NVD3 라이브러리을 사용하고Nvd3 차트와 다른 시간대

, 나는 서버 측 모든 차트 데이터를 계산합니다.

문제는 그래프의 시간 범위가 내 컴퓨터 시간 (GMT + 3) 및 내 컴퓨터 (UTC)가 아닌입니다. GMT + 3이 아닌 UTC로 가져올 수있는 방법은 무엇입니까?

어떻게해야합니까?

nv.addGraph(function() { 
var chart = nv.models.lineWithFocusChart().x(function(d) {return d[0];}).y(function(d) { return d[1]; }); 
chart.yAxis 
.tickFormat(d3.format(',.2f')); 

chart.y2Axis 
.tickFormat(d3.format(',.2f')); 

chart.xAxis 
.tickFormat(function(d) { return d3.time.format('%H:%M:%Z')(new Date(d)) }); 

chart.x2Axis 
.tickFormat(function(d) { return d3.time.format('%H:%M:%Z')(new Date(d)) }); 

d3.select('#chart svg') 
.datum(data) 
.transition().duration(500) 
.call(chart); 

return chart; 
+0

서버에서 CMT + 3 또는 UTC로 그래프 데이터를 생성합니까? –

+0

서버에서 UTC와 UTC + 02 : 00 –

+0

의 클라이언트를 생성하지만 문제는 프로젝트가 다른 시간대에서 동시에 작동해야합니다. –

답변

1

해결책을 찾아 도울 수 있다면 난 내 코드를 추가 해요!

var now =new Date(); 
chart.xAxis.tickFormat(function(d) { if (d!= undefined) 
    { 
    return d3.time.format('%H:%M')(new Date(d+ now.getTimezoneOffset() *    60000 +Number(timeZoneOffset))) } 
});