I’m following the instructions of feeding the funnel with array data,
supposedly in the documentation, it should be:
data: [ ['Website visits', 15654], ['Downloads', 4064], ['Requested price list', 1987], ['Invoice sent', 976], ['Finalized', 846] ]
this is how I get the array:
let url = 'url.com/api...'; fetch(url).then(res => res.json()).then((out) => { console.log(out.Data); var forFunnel = out.Data //highchart demo sample code }).catch(err => { throw err });
my array data is:
{ Value: 228230938.61, Stage: "Prospect" } { Value: 30000000, Stage: "Prospect1" } { Value: 29267484.58, Stage: "Prospect2" } { Value: 21414898.46, Stage: "Prospect3" }
Is there a type of conversion am missing?
Advertisement
Answer
It looks like you just need to map()
the returned Data
to the appropriate format (here using destructuring):
var forFunnel = out.Data.map(({ Value, Stage }) => [Stage, Value]);