score:1
Accepted answer
You forgot to set the x
and y
positions of the text elements:
//text to show
elementGroup.append("text")
.attr("text-anchor", "middle")
.attr("x", function(d,i){return i*80+40;}
.attr("y", h/2)
.text(function(d) {
return parseInt(d);
})
.classed('tweet-number', true);
Here is your CodePen: http://codepen.io/anon/pen/mOyrMM
The <g>
element wrap its content and autosize according to the contents, but it doesn't position the contents.
That being said, an alternative is using translate
to the groups, and not setting any position for the texts or the circles:
elementGroup.attr("transform", function(d,i){
return "translate(" + (i*80+40) + "," + h/2 + ")";
});
The result is the same, check the CodePen: http://codepen.io/anon/pen/yVyVYy
Source: stackoverflow.com
Related Query
- D3.js: Text is not showing inside a circle(They are on the same level of an element-group). How do I bring the text to the front?
- Why are my images not showing up in the nodes of this D3 chart?
- In d3.js ticks are not showing in the x axis
- D3 - not all children nodes are shown at the same time
- Drawing a line using d3 is not visible when all data items are the same
- d3 axis not showing tick label if two ticks have the same value
- Why are the first two text labels of my bar chart not shown?
- Why are not all my text labels showing in my Scatterplot?
- Why are my SVG foreign object text not showing up?
- CSV File opened using JS not showing the updated version of the file when replaced by another one with the same name. d3.csv
- Why does the text not appear inside the svg rects
- d3 line chart x, y not in the same level of a data structure, how to set x, y function?
- In D3, Bar graph's text labels are not updated after the inclusion of additional data
- text and input elements appended and given attributes the same way. Text shows but not the input. Why?
- D3js how to append 2 children at the same level in .enter context
- Appended text not showing in d3 v4
- Why are .domain, tickFormat and tickValues not recognised inside dimensions variable? (d3, parallel coordinates)
- How to avoid the overlapping of text elements on the TreeMap when child elements are opened in D3.js?
- Data points and ticks in the scaleBand axis are not aligned
- Angular ng-click's inside a dynamically created d3 chart are not working
- How do I hide the text labels in d3 when the nodes are too small?
- text not showing in forcelayout d3js but present in view
- Text not displaying in the middle of circles in d3js
- Why are both of these lines coming up the same color?
- D3.js: "On the fly" added elements to array are not refreshing the svg graphic
- D3 quantize color scale not showing the right color distribution
- Multiple classes assigned via D3's .attr are not in the serialized (serializeToString) string
- My D3.js code is not showing seconds in the time axis?
- d3js text not showing on node graph
- Append two elements in svg at the same level
More Query from same tag
- Replace space with new line charcter in texts d3js
- d3.js Uncaught (in promise) TypeError: d3.forceSimulation is not a function
- Dynamic JSON not loading - D3.js Line chart
- d3.js User viewer chart
- D3 "Sunburst" Center Path Size
- dimplejs line series tooltip customisation
- How to follow a symbolic link using javascript?
- Why does `treemap.nodes` not see the update to my object?
- Looping over objects in an array in javascript
- D3 Chloropleth zoom works when only with states, but breaks when I draw it with counties
- D3 Sunburst. How to set different ring\level widths
- D3 stacked bar chart g and rect not showing
- Binding nested data to box plot / rectangles
- Convert dc.js chart to pdf
- multiple circles / lines using d3.js
- d3 + adding text labels + formatting
- How do I parse a JSON file to bind data to a d3 choropleth map
- Circles on a moving Line chart
- dc.js Percentage Histogram - Size of groups
- D3js/Javascript with Dart
- How to create multi-polygon intersecting a circle / necklace using d3.js?
- d3 - csv file header rows in console if a string type
- Accessing data values in c3js in data events
- ART and d3 barchart in react native
- D3.js pulling and embedding DataURI images with Promises
- Custom breadcrumb UI for d3.js treemap
- dc scatter plot binding onClick event
- d3.js data imported but bar chart not displayed
- How to add text to D3 js donut chart
- Graph Not Working: Stacked Bar Chart - Date versus Values