angularjs nvd3 多条形图 xAxis 刻度未显示
angularjs nvd3 multibar chart xAxis tick not showing
- 我正在使用 angularjs nvd3 多条形图
图表 xAxis 刻度不显示如下。
我想显示所有 xAxis 刻度形成 %Y/%m/%d %H:%M
这是我的代码。
this.$scope.options = {
chart: {
type: 'multiBarChart',
height: 450,
margin : {
top: 20,
right: 20,
bottom: 60,
left: 65
},
x: function(d){ return d[0]; },
y: function(d){ return d[1]; },
color: d3.scale.category10().range(),
duration: 300,
stacked: true,
clipEdge: true,
clipVoronoi: false,
xAxis: {
axisLabel: 'Time',
tickFormat: function(d) {
let formedDate = d3.time.format('%Y/%m/%d %H:%M')(new Date(d));
return formedDate
},
showMaxMin: false,
staggerLabels: true
},
yAxis: {
axisLabel: 'Data',
axisLabelDistance: -20,
tickFormat: function(d){
return d3.format()(d);
}
}
}
};
请帮助我。
尝试在您的图表对象中添加以下优先级
chart = {
...
reduceXTicks:false,
...
xAxis : {
.tickFormat: "%Y/%m/%d %H:%M"
}
}
- 我正在使用 angularjs nvd3 多条形图
图表 xAxis 刻度不显示如下。
我想显示所有 xAxis 刻度形成 %Y/%m/%d %H:%M
这是我的代码。
this.$scope.options = {
chart: {
type: 'multiBarChart',
height: 450,
margin : {
top: 20,
right: 20,
bottom: 60,
left: 65
},
x: function(d){ return d[0]; },
y: function(d){ return d[1]; },
color: d3.scale.category10().range(),
duration: 300,
stacked: true,
clipEdge: true,
clipVoronoi: false,
xAxis: {
axisLabel: 'Time',
tickFormat: function(d) {
let formedDate = d3.time.format('%Y/%m/%d %H:%M')(new Date(d));
return formedDate
},
showMaxMin: false,
staggerLabels: true
},
yAxis: {
axisLabel: 'Data',
axisLabelDistance: -20,
tickFormat: function(d){
return d3.format()(d);
}
}
}
};
请帮助我。
尝试在您的图表对象中添加以下优先级
chart = {
...
reduceXTicks:false,
...
xAxis : {
.tickFormat: "%Y/%m/%d %H:%M"
}
}