使用标记符号绘制更新轨迹会重置标记大小
Plotly updating trace with marker symbol resets marker size
问题:
我正在使用 plotly.js .
当我尝试更新 marker.symbol
时,它会重置 marker.size
JSFIDDLE:
https://jsfiddle.net/bababalcksheep/sa0rbfg8/6/
代码:
var trace1 = {
x: [1, 2, 3, 4],
y: [10, 11, 12, 13],
mode: 'markers',
marker: {
size: [40, 60, 80, 100]
}
};
var data = [trace1];
var layout = {
title: 'Marker Size',
showlegend: false,
height: 400,
width: 480
};
Plotly.newPlot('myDiv', data, layout);
$('#changes').click(function() {
var data_update = {
'marker': {
symbol: 'square'
}
};
Plotly.restyle('myDiv', data_update, [0]);
});
问题是大小是标记的 属性,当您使用新的标记对象更新轨迹时,您将用不包含大小的新 json 覆盖。这样的事情就可以了。
var trace1 = {
x: [1, 2, 3, 4],
y: [10, 11, 12, 13],
mode: 'markers',
marker: {
size: [40, 60, 80, 100]
}
};
var data = [trace1];
var layout = {
title: 'Marker Size',
showlegend: false,
height: 400,
width: 480
};
Plotly.newPlot('myDiv', data, layout);
$('#changes').click(function() {
var data_update = {
'marker.symbol': 'square'
}
};
Plotly.restyle('myDiv', data_update, [0]);
});
问题:
我正在使用 plotly.js .
当我尝试更新 marker.symbol
时,它会重置 marker.size
JSFIDDLE: https://jsfiddle.net/bababalcksheep/sa0rbfg8/6/
代码:
var trace1 = {
x: [1, 2, 3, 4],
y: [10, 11, 12, 13],
mode: 'markers',
marker: {
size: [40, 60, 80, 100]
}
};
var data = [trace1];
var layout = {
title: 'Marker Size',
showlegend: false,
height: 400,
width: 480
};
Plotly.newPlot('myDiv', data, layout);
$('#changes').click(function() {
var data_update = {
'marker': {
symbol: 'square'
}
};
Plotly.restyle('myDiv', data_update, [0]);
});
问题是大小是标记的 属性,当您使用新的标记对象更新轨迹时,您将用不包含大小的新 json 覆盖。这样的事情就可以了。
var trace1 = {
x: [1, 2, 3, 4],
y: [10, 11, 12, 13],
mode: 'markers',
marker: {
size: [40, 60, 80, 100]
}
};
var data = [trace1];
var layout = {
title: 'Marker Size',
showlegend: false,
height: 400,
width: 480
};
Plotly.newPlot('myDiv', data, layout);
$('#changes').click(function() {
var data_update = {
'marker.symbol': 'square'
}
};
Plotly.restyle('myDiv', data_update, [0]);
});