【问题标题】:How to show exact date in x-axis in nvd3.js?如何在 nvd3.js 的 x 轴上显示确切的日期?
【发布时间】:2016-12-02 15:18:44
【问题描述】:

我试图在 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'
}
}
};

【问题讨论】:

    标签: javascript graph nvd3.js angular-nvd3


    【解决方案1】:

    我通过更改scaleExtent: [1, 10] 中的值解决了这个问题。此选项将制作一个图表以显示比例 x-axis

    【讨论】:

      猜你喜欢
      • 2012-12-13
      • 2014-02-14
      • 1970-01-01
      • 2013-12-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多