A D3 scale is just a function translates values from a given input domain (your data values, 0 to max) to a specified output range (the width of your chart). Thus you have to apply the scale to your data, e.g.
widthScale( d ). Right now you are assigning the
widthScale function to the
width attribute of your
rect instead of the output value.
See the working fiddle: http://jsfiddle.net/S92u4/
- d3.js - Bar chart won't display with scale
- dc.js bar chart with ordinal x axis scale doesn't render correctly
- Align x-axis with zero scale d3 bar chart
- D3 Gradient Fill on Bar Chart - with colour scale
- Labels do not display with D3 v4 bar chart
- DC bar chart Y axis with integer scale (not multiplicated)
- Bar chart with negative values
- Using an ordinal scale ('d3.scale.ordinal') for the x-axis in a bar chart
- How to update d3.js bar chart with new data
- Make simple bar chart using C3 with separate columns on the x axis
- d3 bar chart with range selector in x-axis (like dygraphs)
- d3.js bar chart sorting: can't figure out how to sort x-axis labels along with bars
- Adding Error Bars to Grouped Bar Chart with D3.js
- How to use x and width in a bar chart with scaleTime?
- C3 / D3 bar chart with horizontal scroll
- DC.js bar chart with date axis
- d3.js stacked bar chart with positive and negative values
- Need help lining up x axis ticks with bars in D3.js bar chart
- How to Make a bar chart with rounded corners with extended grid in d3.js?
- Sorting the bars in a bar chart with dc.js
- NVD3.js: Stacked and grouped bar chart with two y-axis
- D3 bar chart background with dots
- D3 bar chart - how to display positive/negative values together?
- d3 show labels only for ticks with data in a bar chart
- D3 - How to loop through an object with keys for a bar chart
- d3.js Stacked bar chart with Logarithmic Scaling
- Grouped bar chart with zoom and updateable data error
- Specifying Ticks on D3 Bar chart with Time Series data and scaleBand
- nvd3 Bubble chart with log scale
- Bar Chart With View Finder d3.js
More Query from same tag
- Completed a row before a selectall
- reading d3 data in from a file rather than hard coding it into a programme
- d3.js — creating HTML table from 2 dimensional array but excluding the first inner array?
- Ploting Scales and Axes using d3.js code in Google Datastudio for scatter plot
- copy an object doesn't effect on my code
- How to nest my data by name on d3?
- How to fix the " 'd3' was used before it was defined" error
- How to zoom a chart in d3 correctly?
- Color descendant nodes and links broken after moving to d3 v5
- Select row in HTML table to update chart selection?
- d3.js is not showing icons
- SVG clipPath with USE breaking in Safari when updating linked shape
- How to select all unselected nodes ? d3/js
- d3 render polygon from points array
- d3 - attaching data to an axis for rescaling
- Trying to draw a bar chart in D3 and I am not seeing the output
- How to get coordinates(cx, cy) of circles after d3 force collision?
- Read d3 keys values
- D3: clustered force layout with fixed centers
- Assign mouse click handler to line in d3 with snapping behaviour
- Multi bar chart using NVD3.js
- Escape Characters in d3.js ticks
- d3 select elements having no id
- dc.js / crossfilter dimensions (year / week)
- getting rid of the middle line on c3.js
- crossfilter - calculating percent of all records with a property
- Nested datasets in d3, updating the right element
- D3 x-axis for each day of the week
- Calculating GEO transformation params in Vega/d3