score:1
Accepted answer
you could use a conditional return statement within the function which returns d. for example:
.text(function(d) {
if (d==="a") {
return "field1"
}else {
return "field2"
}
})
working fiddle.
let me know if this is not the solution you were looking for.
Source: stackoverflow.com
Related Query
- d3.js using a conditional return within text attribute
- Access the text within SVG object using d3js
- How to concatenate a return function into a SVG transform attribute using D3.js
- Text rotation within an arc using D3JS
- Replace text value upon dataset change within an existing div using d3
- d3js using an attribute that is updated within the same callback
- Can you insert a line break in text when using d3.js?
- How to write vertical text from bottom to top without using transform rotate?
- NVD3 chart fails to calculate legend text length in Chrome, since Window.getComputedStyle does not return font-size correctly
- How to return html in d3 text function?
- Getting text area using getBBox()
- D3: Using node attribute for links instead of index in array
- Wrap text within circle
- Display text on rect using D3.js
- Making a SVG Text draggable using d3.js
- Invalid value for <circle> attribute cx=“NaN” using D3.js
- How to right/end align text along an textPath inside an arc using d3.js?
- Align text within d3 svg
- Appended text not appearing when using D3
- How to place text on the circle when using D3.js force layout?
- How to align text vertically on a node within a Sankey diagram (D3.JS)?
- Invalid value for <circle> attribute cx="NaN" using NVD3.js
- With D3, how can I set attribute ("fill", "none") of axis path and line, but not text (without editing stylesheet)
- D3 circle pack: html in text attribute
- Using asynchronous call when setting text D3
- Changing Ticks values to text using D3
- Changing text attribute based upon event handler in d3.js
- d3 Trying to select text within a svg text element
- Simple curved text within a circle
- How to underline text within a node's label in d3 force based layouts?
More Query from same tag
- I've defined a path in d3.js, it draws correctly, but .getTotalLength() is undefined
- d3js make tooltip stay when clicked
- D3.js - line graph is not displayed
- how to create a dynamic append using d3?
- Specifying Ticks on D3 Bar chart with Time Series data and scaleBand
- D3 v4 transition or update
- nvd3: How highlight bar on click event?
- Changes in d3 (Data-Driven Documents)
- Add a concurrent transition during another transition if a condition is met
- Updating a layout.pack in d3.js
- Force-directed graph: How to add icon in the middle of an edge?
- D3 histogram is not responsive even after using preserveAspectRatio
- Why does d3 axis class name change axis format?
- Why does D3's brush start event interfere with later brush events?
- Js for loop to store values
- Can't refer to json data with D3 js if it has a whitespace
- Formatting numbers with commas in D3
- Why are events from d3 in firefox not handled
- Cubism d3 dependency with requirejs
- load d3.js and c3.js from directory dosen't work
- D3. Load SVG files and show only one at a time. Fading/Replacing issue
- Nvd3js bullet chart : Chart.update does not update the chart
- How can I add labels to my diagram with d3.js?
- How to "dump" points selected with the LinkedBrush plugin for mpld3?
- D3js: Unable to set drag behaviour to chess pieces
- Does using JOINS also have performance improvement
- D3 won't append elements after external JSON is loaded
- D3 V3 Stacked Bar Negative Values
- In Hierarchical edge bundling how to use json string instead of a json file?
- Ordering and grouping in a complex MySQL query