d3.js - d3JS Histogram with ordinal scale -


i trying d3js histogram working ordinal scale (in case, student grade symbols (a+, a, b ... f).

here minimum working example:

<!doctype html> <meta charset="utf-8">  <body> <script src="http://d3js.org/d3.v3.min.js"></script> <script>     var studentsymbols = ["f", "e", "d", "c", "c", "c", "c", "b", "b", "a", "a+"];      var x = d3.scale.ordinal()         .domain(["f", "e", "d", "c", "b", "a", "a+"])         .rangeroundbands([0, width]);      // generate histogram using twenty uniformly-spaced bins.     var myhistogram = d3.layout.histogram()         (studentsymbols);      console.log(myhistogram) </script> </body> 

when above run, console outputs array of 5 arrays, dx , x fields equal nan.

how should correct code?

i think may have figured out. changed declaration of myhistogram to:

    var myhistogram = d3.layout.histogram()         (studentsymbols.map(x)); 

Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -