Create legend by providing a column?


#1

Is there an easier way to create legend than creating multiple traces?

For example, by providing another column that would containing the legend values?:

var trace = {
x: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
y: [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],
legend: [‘active’, ‘active’, ‘completed’, ‘completed’, ‘pending’, ‘pending’, ‘pending’,‘active’, ‘completed’, ‘active’],
};

Plotly.plot(‘chart’, [trace])