score:5
Accepted answer
I think you should be using "x" instead of "dx" to place the labels. Figure you want the text at that x position and anchored on the middle. dx is meant to offset from the anchored position I think.
Similarly you probably mean to use "y" instead of "dy". Use dy to adjust the height above or below the baseline (often in "em" units) and y to actually position the text.
Try:
<svg width="650" height="400">
<g class="groups" transform="translate(25,0)">
<g class="group" transform="translate(0,0)">
<g class="bar"><rect class="subBar" x="0" y="60" width="192" height="310"/></g>
<g class="dataLabel"><text text-anchor="middle" class="subLabel" style="font-size: 14px; opacity: 1;" x="96.25" y="55">83%</text></g>
</g>
<g class="group" transform="translate(207.5,0)">
<g class="bar"><rect class="subBar" x="0" y="97.22891566265059" width="192" height="272.7710843373494"/></g>
<g class="dataLabel"><text text-anchor="middle" class="subLabel" style="font-size: 14px; opacity: 1;" x="96.25" y="92.22891566265059">73%</text></g>
</g>
<g class="group" transform="translate(415,0)">
<g class="bar"><rect class="subBar" x="0" y="93.50602409638549" width="192" height="276.4939759036145"/></g>
<g class="dataLabel"><text text-anchor="middle" class="subLabel" style="font-size: 14px; opacity: 1;" x="96px" y="88.50602409638549">74%</text></g>
</g>
</g>
</svg>
score:0
You're using dx and dy to position the text when you should be using x and y
Source: stackoverflow.com
Related Query
- SVG text element text-anchor="middle" not working in Firefox
- D3 - Positioning tooltip on SVG element not working
- svg <a> element not working
- SVG not working in Firefox 18
- SVG text path not working correctly in IE
- transitioning transform attribute of a group element not working in firefox
- D3 Not Displaying SVG Text Element
- Text element not showing on SVG
- svg filter not working in mozilla firefox after zoom
- CSS3 - Transform-origin not working on SVG element in d3.js
- d3 - problem aligning text with circle center - dominant-baseline not working on Firefox
- Text not wrapping in d3 SVG element even when using Bostock's wrap function
- D3: call() not working for appended text element (Type error)
- Assign hyperlink attribute to svg element not working
- d3 sankey svg text tspan - on click not working
- D3.js plot: SVG z-order of foreignelement not working in firefox
- Adding text in svg on mouseover not working d3.js
- SVG foreignObject contents do not display unless plain text
- d3.select("#element") not working when code above the html element
- Title Attribute not working for an SVG Rect on Safari
- d3.js - mouseover event not working properly on svg group
- Get width of d3.js SVG text element after it's created
- how to assign unique id to SVG text element in d3 javascript
- Fit Text into SVG Element (Using D3/JS)
- HTML element inside SVG not displayed
- C3.js SVG visualization to Canvas with canvg - Line charts filled with black rectangles , "ERROR: Element 'parsererror' not yet implemented"
- d3-tip offset on svgs within Leaflet, Firefox only, not working
- d3.select.style not working on firefox
- Renderer2 does not render SVG element while using d3 js - Angular 4
- D3: Zooming/Panning Line Graph in SVG is not working in Canvas
More Query from same tag
- Generate (multilevel) flare.json data format from flat json
- D3.js Tree pass node.name on click to R Shiny
- How do I rotate or scale (transform) an SVG path relative to its center point?
- d3js brush how to get values for selection
- Can't add an axis in d3.js
- How to generate D3.js circular dendrogram code from Python
- d3.js filter() not displaying expected results
- How do I use two versions of the same javascript library without bleeding functions in the same page?
- How do I create a continuous Github-like calendar with Cal-Heatmap?
- How to list node_modules folders in a json/javascript file?
- D3.js Grouped bar chart with JSON data
- Replace text value upon dataset change within an existing div using d3
- d3 js Hierarchical edge bundling Data Format
- d3.js Links between nodes not rendering as lines
- Aligning text to the left & Right of a circle depending on the data
- How to make webglcandlestick series respect the bandwidth function?
- D3.js data mapping coordinates onto a topojson map
- Set initial d3 zoom based on boundary dynamically - V4
- Crossfilter group a filtered dimension
- D3.js: Accessing the element's previous datum inside of .attrTween()
- D3 Tree Graph Modified Data Model
- Using d3.js (v5) to read a csv that has no header
- D3 v4 drag/drop tree node into new parents children
- dc.js : how to change circle color on mouseover
- How to get the data from the c3.js
- d3 js bidirectional horizontal bar chart
- How do I style a Javascript button using d3?
- d3.js Multi-series line chart interactive (tsv into literal data)
- Using D3 with Electron React app
- Assigning particular classes to particular counties via a function - D3.js