score:2
Accepted answer
in order to have the same behavior as the original code, you need to return a function (that itself returns a function when called) from runnumber
. this should work (untested):
function runnumber(start, end, decimal) {
return function() {
var n = d3.interpolatenumber(start, end);
return function(t) {
d3.select(this).text(n(t).tofixed(decimal) + '%');
};
};
}
Source: stackoverflow.com
Related Query
- D3: replacing anonymous function with a named one
- d3 set multiple attributes with one function
- Typescript class implementing interface with anonymous function
- Enter() statement with a function from one data array to multiple arrays? (Adding multiple Gradient Paths)
- "Property does not exist on type {}" error when using anonymous function with D3 SVG Symbol
- d3.js replacing random() data function with asynchronous function
- How to set cx and cy with only one function using d3.js, force and network?
- replacing the anonymous function after embedding csv data
- trying to call a named function with async javascript then
- Replacing one d3 visualisation with another d3 visualisation in same place?
- How to set multiple attributes with one value function?
- d3 add multiple classes with function
- Third variable in D3 anonymous function
- D3: use nest function to turn flat data with parent key into a hierarchy
- How to make data() key function to work with TypeScript?
- How to create stacked row chart with one row with dc.js?
- d3js timeline chart - with one rectangle block for a scrub
- d3 append() with function argument
- d3 replacing semicolon with comma
- Getting TypeError: .selectAll(...).enter is not a function with d3.js
- Replacing chart datasets with d3.js / c3.js
- How to throttle function call on mouse event with D3.js
- How to replace a d3js nest function with group and rollup
- Leaflet overlaid with D3 Chart - Need chart to remain in one place
- Can one specify a custom force function for a force-directed layout?
- Initialize element and start dragging with just one click
- .colors function in barChart dc.js with only two options
- d3.js: Pass anonymous function as parameter to centering force?
- D3js zoom with reset function
- Javascript: Array of dictionaries, get all key value pairs from one dictionairy with condition
More Query from same tag
- Drawing a simple chart using D3 and C3
- Line chart: points over ticks
- Bar colors reverting back to original colors
- Enable mouseup / mousedown but prevent click behavior
- In D3 zoomable sunburst, how to show only one level of children
- Adding context menu to nodes
- Extract specific row of data in d3
- d3 remove text from svg
- D3 Force Layout with Image as Node but Wrong Images are Appended
- d3 tooltips not showing up
- How to parse a date string with microseconds
- I am trying to build a d3js graph but on the x-axis i am getting the timestamps instead of date and time even after i used formatting
- vanilla javascript to Reactjs component?
- d3js Multiple Stacked Bar Chart Line Cursor Appearing in Wrong Chart
- Add correct value after nesting with d3
- Import EventDrops (D3.js) into Angular 2
- d3 - How to use values in counter from php script
- what's wrong with my label update selection
- Convert text header of image appended to node in typical graph of nodes and link, to image in D3
- Add data points and text to lines on a multi-bar graph with lines
- Dynamic url as data-attribute of pseudo-element in css and D3JS
- The use of a data array in the d3.js scatter file instead of an external data file
- .timeFormat(%b %Y) not giving me the right dates
- D3 Crossfilter grouping
- Why is my .on("mouseover") event firing on page refresh and not when I 'mouseover' the event
- Drawing a SVG with d3.js while tab is in background
- Using D3.js with symfony2
- Filter/select specific type of data
- D3 circles too big after reappearing
- d3.pack Multiple hierarchies with a single JSON