问题
- I'm using angularjs nvd3 multibar chart
chart xAxis tick do not show like below.
I want to show all xAxis tick formed %Y/%m/%d %H:%M
This is my code.
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);
}
}
}
};
please help me.
回答1:
try to add the following priorities in your chart object
chart = {
...
reduceXTicks:false,
...
xAxis : {
.tickFormat: "%Y/%m/%d %H:%M"
}
}
来源:https://stackoverflow.com/questions/40882662/angularjs-nvd3-multibar-chart-xaxis-tick-not-showing