javascript - I have this d3 code but Iwould like to insert lable number on the top of the yAixes here is my code -


generate array of data random values bounded between 0 , 100.
need add text objects place labels above each rect svg object shows "y" value of entry

function generate_random_ints( opts) { var num_possible_ints =  opts.max_value             - opts.min_value             +1;  var data = []; ( var = 0; < opts.num_values; i++ ) {     var value = math.random()     * num_possible_ints     + opts.min_value;     data.push( math.floor( value) ); } return data; }  var data_option = { min_value: 0, max_value:50, num_values: 30 }; // generate rect objects within svg object each entry in array of data sized , positioned create simple bar graph.     var svg = d3.select("body")     .append("svg")     .attr("width", "700px")     .attr("height", "700px") ;     //set width , height of div  var svg_width = 700; var svg_height = 700; var ytextpadding = 20;  var dataset = generate_random_ints(data_option); //console.log(dataset); var x_scale = 3;// our x scale  var y_scale = svg_height / data_option.max_value; // our y scale   var rects = svg.selectall("rect")                     .data( dataset )     .enter()     .append("rect")     .attr("x", 5)     .attr("y", 6)     .attr({ "x": function(d, i) {     return ( svg_width / dataset. length)         * + x_scale / 4;// our x scale     },  "y":  function(d, i) {     return svg_height - ( d * y_scale )     }, "width":  function(d, i) {     return ( svg_width / dataset.length )         - x_scale / 2;     },   "height":  function(d, i) {     return d * y_scale;     },     "fill": "red"     })  // our color bands     ; 


Comments

Popular posts from this blog

c++ - No viable overloaded operator for references a map -

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - Cannot secure connection using TLS -