我试图根据值更新nvd3中的x轴标签,但是我的x轴axisLable
返回图表中的整个函数而不仅仅是字符串...我该怎么做所以它只返回字符串?
$scope.options_scn_cst_compare = {
chart: {
type: "multiBarChart",
x: function(d){ return d.x; },
y: function(d){ return d.values; },
xAxis: {
axisLabel: function(d) {
if (yAxistm.tm === 'yr') {
return "Time (Years)";
} else if (yAxistm.tm === 'qtr') {
return "Time (Quarterly)";
} else if (yAxistm.tm === 'mth') {
return "Time (Montly)";
};
}
.....
}
答案 0 :(得分:0)
如果您的目标是动态提供X轴标签,您可以执行以下操作。
// Generate chart
var chart = nv.models.multiBarChart();
// based on some value update the X-axes label.
if (yAxistm.tm === 'yr') {
chart.xAxis.axisLabel("Yearly");
} else if (yAxistm.tm === 'qtr') {
chart.xAxis.axisLabel("Quaterly");
} else if (yAxistm.tm === 'mth') {
chart.xAxis.axisLabel("Monthly");
};