score:2
Accepted answer
d3.scaleTime
has to be treated differently on a number of fronts.
The scale doesn't take padding as an argument:
var x = d3.scaleTime()
.domain(d3.extent(data, function(d) { return d.Date; }))
.rangeRound([margin.left, width - margin.right]);
Time is continuous rather than discrete, so the widths of the bars need to be calculated manually, as a ratio of rect
and series.length
. I got this to work, but maybe you want something more elegant:
.attr("width", width/series.length - 450)
Source: stackoverflow.com
Related Query
- How to use rangeRound in scaleTime in d3 v4?
- How to use scaleTime to horizontally position a background rectangle
- how to format time on xAxis use d3.js
- How to use D3 in Node.js properly?
- How to use D3 selectAll with multiple class names
- How to properly add and use D3 Events?
- How to use an arrow marker on an SVG <line> element?
- How to use d3.min and d3.max within a d3.json command
- How do I use angularjs directives in generated d3 html?
- How to use the D3 diagonal function to draw curved lines?
- How to get maximum value from an array of objects to use in d3.scale.linear().domain()
- how to include use of node_modules in rollup compile
- How do I resolve "[ERR_REQUIRE_ESM]: Must use import to load ES Module" when using D3.js 7.0.0 with Next.js 11.0.1?
- How can I use d3 classed selection to have name as function
- How to use 'this' in Angular with D3?
- how to use svg file for image source in D3
- d3.js: how to use map function?
- How to use D3js on server side to generate SVG directly?
- How to use a JavaScript chart library like D3.js or Raphaƫl in server-side Java
- How to use `this` and `_this` (fat arrow) using coffeescript?
- How to make a color scale in D3 JS to use in fill attribute?
- How to use SVG gradients to display varying colors relative to the size of the colored region
- How can I use d3.js to create a trend/exponential regression line?
- How to use D3 zoom behavior with ViewBox instead of transform
- How can I use d3-scale-chromatic functions with a domain other than [0, 1]?
- In D3 V4, how to use .ease("bounce") propertly?
- d3 scale: How to use .copy()?
- How to use timer in d3 V3?
- Selections in D3: how to use parentNode.appendChild?
- How can I use D3 (or just javascript) to set a form option as being "selected"
More Query from same tag
- d3.js binding data array in array
- Responsive d3 area
- Y-axis created but invisible
- how to implement zoom in d3 graph of force directed layout and position the nodes
- Having trouble panning and zooming on my d3 map
- How can I get the source code from a page using javascript
- d3 drag multiple text elements inside a group SVG
- Onclick event fires, but append-code is not executed
- d3 js how to retrieve time from a x position
- Why is sankeyNetwork in R not showing different colors?
- Blazor, get Input value from Javascript created DOM Element
- DC bar chart Y axis with integer scale (not multiplicated)
- Using D3 in React without svg for table rows arn't rendering
- Control multi line spreading of x-axis tick in billboard.js
- derive array of unique property values from an array of objects
- Make d3 svg path clickable (in Google Maps Overlay)
- Label above d3 chart itself
- Draw scatter plot using d3
- How to give padding on top/bottom/left/right to text that is contained inside a rect
- d3 variable equals the string "function(d)", not the value the function returns
- Recursively map 3d.js graph nodes and links from nested structure
- d3-voronoi-map path not drawn
- d3.js v5 - Promise.all replaced d3.queue
- d3.js Indented tree with straight links
- parameter 1 is not of type 'SVGRect'
- d3.js pan and zoom jumps when using mouse after programatic zoom
- Trying to understand this d3 force example
- GeoJSON with lower precision
- JSON returned null value or undefined in jsp page
- D3.js path goes in different directions in V3 vs V4