【发布时间】:2017-01-04 14:57:21
【问题描述】:
大家好,我已经在我的应用程序中实现了 NVD3 折线图,我在 X 轴上有“一月,二月..直到..十二月”之类的刻度,图表绘制得很完美,但是 x 轴刻度没有被渲染照原样。请帮我解决问题,这是我所做的以及我可以绘制的折线图的快照,
JSP 代码:
<nvd3 options="options" data="dataForLineChart"></nvd3>
控制器:
$scope.options = {
chart: {
type: 'lineChart',
showXAxis:true,
height: 300,
margin : {
top: 20,
right: 20,
bottom: 40,
left: 55
},
x: function(d){ return d.x; },
y: function(d){ return d.y; },
useInteractiveGuideline: false,
dispatch: {
stateChange: function(e){ console.log("stateChange"); },
changeState: function(e){ console.log("changeState"); },
tooltipShow: function(e){ console.log("tooltipShow"); },
tooltipHide: function(e){ console.log("tooltipHide"); }
},
xAxis: {
axisLabel: 'Timeline(months)',
showMaxMin: false
},
yAxis: {
axisLabel: 'Rate of aquisition',
tickFormat: function(d){
return d3.format('')(d);
},
axisLabelDistance: -8
},
callback: function(chart){
console.log("!!! lineChart callback !!!");
},
showLegend : false
}
}
我提供的数据是:
$scope.dataForLineChart =
[{
"key": "3",
"values":[{
"x": "0",
"y": "57.0"
}, {
"x": "1",
"y": "67.0"
}, {
"x": "2",
"y": "40.0"
}, {
"x": "3",
"y": "20.0"
}, {
"x": "4",
"y": "10.0",
}, {
"x": "5",
"y": "40.0"
}, {
"x": "6",
"y": "57.0",
}, {
"x": "7",
"y": "44.0"
}, {
"x": "8",
"y": "23.0"
}, {
"x": "9",
"y": "75.0"
}, {
"x": "10",
"y": "22.0"
}, {
"x": "11",
"y": "12.0"
}]
}];
【问题讨论】:
-
剩下的数字去哪儿了,???这可能是一个html问题吗?
-
您找到解决方案了吗?