const chart = new Chart({
element: document.querySelector('#graph'),
data: d3.csv('d1.csv', function(d){
function removeNaN(e,c){
if (e>0) {return e} else {return c}
}
return { date: d3.timeParse("%Y-%m-%d")(d.Date),
aapl : d.AAPL, tsla : d.TSLA,
aapl_sma: removeNaN(+d.SMA_AAPL,d.AAPL),
tsla_sma: removeNaN(+d.SMA_TSLA,d.TSLA)
}
}).then(function(data){return data})
});
Hello- this is how I'm initializing my Chart() object. then() returns a Promise object that I would like to access. [[PromiseResult]] contains the data array I'd like to use.
How do I access the array, and should it be done from within the Chart() class, or from the chart object?
This is the constructor:
class Chart{
constructor(opts){
this.data = opts.data;
this.element = opts.element;
this.draw();
}