So I am getting the error gd.data must be an array when I am attempting to add a trace to an existing graph with addTraces. The plotly is within an ajax call. I have tried explicitly declaring an array and adding the new trace data to it, and I have tried ensuring that the x and y coordinates are an array in same way. I am still getting the error gd.data must be an array. I saw that this was asked earlier, but did not have any answers. I was wondering if there was any solution to this issue, or if there was another way that I could add traces to an existing graph.
//adding the traces
let dd = [];
let pd = [];
dd.push(dateData);
pd.push(pricingData);
Plotly.addTraces('graphing-area', [{
x: dd,
y: pd,
name: ticker,
type: 'scatter',
showlegend: true,
}]);
let trace = [{
x: [dateData],
y: [pricingData],
name: ticker,
type: 'scatter',
showlegend: true
}];
let layout = {
padding: {b:0},
title: {
text:'Bid Price vs Maturity',
font: {
family: 'Courier New, monospace',
size: 18
},
}
};
Plotly.newPlot('graphing-area', trace, layout, {displayModeBar: false});
Does anybody have a solution or a workaround?
Thanks!
Plotly.newPlot(graphDiv, null, layout)before adding the trace.