Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to use d3 .ticks to show original y-axis values in bar chart
    primarykey
    data
    text
    <p>I have some number of amount (in dollar) which I am showing on y-axis and year on x-axis. now, I want to show original number on y-axis but not able to do.</p> <p>i mean on y axis i want to show number from 1 to 100000 as amount but now, with .ticks(10) i can only used between 0 to 8000 amount at y axis.</p> <p>and one more thing that if i want to show name as string at x axis then how can i show please let me know. i am stuck here and newly with d3. </p> <pre><code>function test() { var graph_data; // in graph_data it should contain value like this // [Object { letter="2011", frequency="10000"}, // Object { letter="2012", frequency="8200"}] var margin = {top: 20, right: 20, bottom: 30, left: 40}, width = 960 - margin.left - margin.right, height = 500 - margin.top - margin.bottom; var x = d3.scale.ordinal() .rangeRoundBands([0, 110], .3); var y = d3.scale.linear() .range([height, 0]); var xAxis = d3.svg.axis() .scale(x) .tickPadding(10) .orient("bottom"); var yAxis = d3.svg.axis() .scale(y) .tickPadding(3) .orient("left") .ticks(10); var svg = d3.select("#award_by_year_chart").append("svg") .attr("width", width + margin.left + margin.right) .attr("height", height + margin.top + margin.bottom) .append("g") .attr("transform", "translate(" + margin.left + "," + margin.top + ")"); x.domain(graph_data.map(function(d) { return d.letter; })); y.domain([0, d3.max(graph_data, function(d) { return d.frequency; })]); svg.append("g") .attr("class", "x axis") .attr("transform", "translate(0," + height + ")") .call(xAxis); svg.append("g") .attr("class", "y axis") .call(yAxis) .append("text") .attr("transform", "rotate(-90)") .attr("y", 6) .attr("dy", ".71em") .style("text-anchor", "end") .text("Total dollar"); svg.selectAll(".bar") .data(graph_data) .enter().append("rect") .attr("class", "bar") .attr("x", function(d) { return x(d.letter); }) .attr("width", x.rangeBand()) .attr("y", function(d) { return y(d.frequency); }) .attr("height", function(d) { return height - y(d.frequency); }); function type(d) { d.frequency = +d.frequency; return d; } } </code></pre> <p>now, this code is working as below chart image. and i want to change value of y axis according to total dollar value and it's coming from table and it can also -ve as well +ve and upper limit not fixed. then how can resolve.</p> <p><img src="https://i.stack.imgur.com/5uxET.png" alt="enter image description here"> </p> <p>please give me valuable solution.</p> <p>thanks</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload