you need to change a lot of things in your code.
populationin the array
- scales are used to convert values to proportional pixel values
heightis the vertical size of an element. you should use
widthis the horizontal size of an element. you should use
yis the vertical position of an element. you should use
xis the vertical position of an element. you should use
selectall("rect")on a new appended
svgelement not the same
gelement that has the axises on it
fillattribute so that your rects have color
you have the population field labelled
value but you're calling
population through out the code to use it. so replace value with population in your data objects.
next you need to change the way you're setting up the rects. use selectall on the
svg element directly or append another
g to the
svg element and add the rects on that element. right now your code attempts to add the rects to the same
g element as the x axis.
make sure you are setting the attributes of the rects correctly. height is the size in pixels of the rect element not the position.
y is the position of the rects vertically from the top downwards. this means the
height attribute should use
width should use
xscale(d.population) because they are the width and length of the rectangles, or
y are the coordinate positions of the element from the top left corner of the
svg element. use them to determine the starting position of the top left pixel of your rects. you should have
- d3js: Unable to place horizontally bars within the axis
- d3js - Stacked Bar Chart in Horizontal Axis - How do I set x so the bars are seperated?
- d3js display arrow at the end of each axis
- Different tick sizes on the Y axis of a D3js line graph
- Access the text within SVG object using d3js
- d3js x axis dates display month at the end not in the front
- Unable to get drop-shadow on the bars
- How to place the bars of a bar chart in the right positions of the xAxis using d3.js?
- A few bars in the wrong place in a bar graph after sorting in ascending order
- D3js scale chart have x axis in the middle
- d3js not having the same behaviour within and outside a function
- D3js Ordinal Axis does not show all the ticks
- Using d3js, how do I use the tree layout to visually place child nodes within their parent?
- Why is the color of the bars not filling and staying white? d3js
- 404 error - unable to find JSON file when making a map but it looks like it's in the right place
- Why the axis I generated using d3js is significantly different from the example even though the code are similar?
- how to fill the area between the bars in the given example d3js
- d3js using an attribute that is updated within the same callback
- d3.js: Align text labels between ticks on the axis
- How can I get the D3.js axis ticks and positions as an array?
- D3: Is it possible to zoom+pan one axis and only pan the other?
- D3js how to append 2 children at the same level in .enter context
- D3js within Java application
- D3js v4: scaleOrdinal does not have the rangePoints()
- D3 grouped bar chart: How to rotate the text of x axis ticks?
- how to set the domain and scale on an axis on a nvd3.js multiBarChart
- nvd3.js : unable to bind onClick event with the data points in the svg
- Make simple bar chart using C3 with separate columns on the x axis
- How to change line color in d3js according to axis value?
- How to display the value for the final tick on axis in D3?
More Query from same tag
- Updating data in a simple reusable D3 chart
- Chart Drawn Incorrectly when using NVD3
- D3 lines and scope
- How to remove unwanted lines in Axis scale of a graph when using D3.js?
- Drop shadow effect on a Line Graph
- datamaps.js: Animate bubble remove after new data gets loaded
- graph.hasEdge function in dagre-d3/graphlib
- How to draw spiral bubble charts with d3.js
- unable to access a .csv file using java script in html
- Crossfilter.js: Creating Dimensions/Groups With Nested Attributes
- Change class of a D3 map's tooltip with mouse position
- D3 Json request getting XmlHttpRequest error: Origin null is not allowed by Access-Control-Allow-Origin
- Class not being applied by JQuery
- d3 typescript bindings: cannot read property 'ticks' of undefined
- Show data on map using D3
- Angular D3 not displaying line chart
- D3.js Cannot read property 'length' of undefined
- d3.js: Display x-axis value and y-axis value in tooltip with two separate arrays
- Conditional color of countries selecting word in name of Topojson
- Replicating a chropleth in D3.js using d3.tsv
- how to add y axis label(custom text) in rickshaw graph?
- d3.js not reading JSON (d3.js + dc.js + crossfilter)
- Word Cloud Generator
- Changing Data Using an Interactive Dropdown to Feed a Filter in d3.js
- c3.js bar, spline charts
- D3 Slice array with from to values
- Typescript class implementing interface with anonymous function
- D3: can create a subset of elements, but not update them
- D3 Radial Dendrogram only displaying part
- radio buttons in nvd3 charts