1 回答

TA貢獻1719條經驗 獲得超6個贊
如果您使用extendTraces并想要更新屬性,例如標記大小,您需要以字符串形式提供屬性,例如,marker.size并且值必須是數組,就像新的 x 和 y 值一樣。
Plotly.extendTraces(
'plot',
{
x: [[5491]],
y: [[5]],
'marker.size':[[40*100]]
}, [0]);
您的初始數據和屬性應該是一個簡單的數組或對象,而不是數組/對象的數組。
var t9 = {
x: [100821],
y: [11],
name: 'Some text',
text: 'Some text',
mode: 'markers',
marker: {
size: [15*100],
sizeref: 1,
sizemode: 'area'
}
};
var data = [t9];
var layout = {
title: 'Chart',
showlegend: true,
xaxis: {
title: 'Some text'
},
yaxis: {
title: 'Some text',
range: [-12, 30]
}
};
var config = {responsive: true}
Plotly.newPlot('plot', data, layout, config);
Plotly.extendTraces(
'plot',
{
x: [[5491]],
y: [[5]],
'marker.size':[[40*100]]
}, [0]);
Plotly.extendTraces(
'plot',
{
x: [[60022]],
y: [[11]],
'marker.size':[[200*100]]
}, [0]);
<head>
<script src="https://cdn.plot.ly/plotly-latest.min.js"></script>
</head>
<div id='plot'>
</div>
添加回答
舉報