Skip to content
Advertisement

Is it possible to feed a Danfojs Series object to D3js data() binding method?

I created a Series object from my data, like so: enter image description here

But I don’t know how to actually implement the Series object to scale and bind the data, here is my code:

JavaScript

Any help or pointers will be much appreciated.

Advertisement

Answer

The real question here is about your data structure: how to switch to a more convenient one for D3.js purposes?

As you highlighted, we have keys in plot_data.index_arr, and data in plot_data.data.

By doing a map over index_arr we get the indexes. The second argument to the callback i is the index which we can use to get the data, by accessing plot_data.data[i].

JavaScript

Once done, we can put them however we want: here I put them in an array, but you can put them in a {key:value} object or a Map object.

JavaScript
Advertisement