Plotly.js: 为什么更新绘图时必须使用嵌套数组?

Plotly.js: Why do I have to use a nested array when updating a plot?

This example 表示使用

更新绘图
var newArray = []
...
newArray.splice(0, 1)
...
var data_update = {
   y: [newArray]
 };

Plotly.update('graph', data_update)

但为什么我必须将数字数组包装到另一个数组中才能使其工作?

我阅读了 plotly.restyle and plotly.update 的文档和示例,但找不到解释。

有什么想法吗?

我在 Plotly.restyle 的文档中找到了解决方案:

In restyle, arrays are assumed to be used in conjunction with the trace indices provided. Therefore, to apply an array as a value , you need to wrap it in an additional array. For example:

// update two traces with new z data
var update = {z: [[[1,2,3], [2,1,2], [1,1,1]], [[0,1,1], [0,2,1], [3,2,1]]]};
Plotly.restyle(graphDiv, update, [1, 2])