I have a couple a functions
they’re in an array
I can make a radio switch using values 0,1… toward function number in the array and use the function by array[valuechoosen]()…and this works
I was wondering wether the function (names) could be passed straightfully as value in the radio switch, but then the viewof my radio select turns into string of the function…
I don’t think that’s supported by Jeremy’s radio input, but you can certainly do it yourself. Here’s an example with a select input, but you could adapt the code to use radio buttons instead.
wowie zowie, that’s the winner, didn’t think could access the functions in library that way…
I prefer really this solution to my array of function indexed values
You can expand that technique further to generate the available options. E.g., to create entries for every scale* function, except scaleDiverging* and scaleSequential*, use:
const options = Object.keys(d3)
.filter(k => k.match(/^scale(?!Diverging|Sequential)/))
.map(k => ({
// strip "scale" prefix and convert first character to lowercase
label: k.slice(5, 6).toLowerCase() + k.slice(6),
value: k
}));