2016-12-15 1 views
0

Ich versuche, die X-Achsen-Etiketten in nvd3 basierend auf einem Wert zu aktualisieren, aber meine X-Achse axisLable gibt die gesamte Funktion im Diagramm und nicht nur die Zeichenfolge ... wie mache ich es so, dass es nur die Zeichenfolge zurückgibt?Aktualisierung x Achse Etikett in nvd3 dynamisch

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

         }; 

        } 
      ..... 
      } 

Antwort

0

Wenn es Ihr Ziel ist, X-Achsen-Label dynamisch anzugeben, können Sie Folgendes tun.

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