D3.js v5 concat dynamic arrays

For this particular task, I’m unable to parse data. So I need to hard-code some data with desired format:

var data = ["1Equity","2Equity","3Equity","4Balanced","5Balanced","6MMF","7MMF","8MMF","9MMF","10MMF"];

It is essentially an array with numerous occurrences of several different strings; the actual array will be much longer and so I am searching for a labor-saving device.

I have tried:

d3.range(3).map(function(v) { return v+"equity"}).push(d3.range(2).map(function(v) { return v+"balanced"})).push(d3.range(5).map(function(v) { return v+"mmf"}))

However, this returned:

Uncaught (in promise) d3.range(…).map(…).push(…).push is not a
function

Question

How can I concat arrays with items mapped to several different strings (occurrence of string based on my discression/user configurable) in a single line?

16 thoughts on “D3.js v5 concat dynamic arrays”

Leave a Comment