2016-12-02 69 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的图表值