2016-12-02 93 views
0

我想在x軸上顯示確切的日期,但它總是以範圍形式出現,如下圖所示。請建議解決方案。如何在nvd3.js的x軸上顯示確切的日期?

我在下面的參數給$scope.options

$scope.options = { 
chart: { 
type: 'historicalBarChart', 
height: 450, 
margin : { 
top: 20, 
right: 20, 
bottom: 65, 
left: 50 
}, 
x: function(d){return d[0];}, 
y: function(d){return d[1];}, 
showValues: true, 
valueFormat: function(d){ 
return d3.format(',')(d); 
}, 
duration: 1, 
xAxis: { 
axisLabel: 'Date', 
tickFormat: function(d) { 
return d3.time.format('%d-%m-%y')(new Date(d)) 
}, 
}, 
yAxis: { 
axisLabel: 'Body Weight', 
axisLabelDistance: -10, 
tickFormat: function(d){ 
return d3.format(',')(d); 
} 
}, 
tooltip: { 
keyFormatter: function(d) { 
return d3.time.format('%x')(new Date(d)); 
} 
}, 
zoom: { 
enabled: true, 
scaleExtent: [1, 10], 
useFixedDomain: false, 
useNiceScale: false, 
horizontalOff: false, 
verticalOff: true, 
unzoomEventType: 'dblclick.zoom' 
} 
} 
}; 

enter image description here

回答

0

我已經改變值scaleExtent: [1, 10]解決它。此選項將顯示比例尺x-axis的圖表值