0
votes

I'm trying to update the x axis labels in nvd3 based on a value but my x axis axisLable returns the entire function in the chart and not just the string...how do I do it so that it just return the string?

    $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)";

                        };

                    }
           .....
           }
1

1 Answers

0
votes

if your objective is to give X-axis label dynamically, you can do following.

// 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");
};