【发布时间】:2021-03-17 05:47:59
【问题描述】:
通过下面的代码,我正在尝试创建一个简单的气泡图。我创建一个跟踪以稍后扩展它:
var t9 = {
x: [100821],
y: [11],
name: 'Some text',
text: ['Some text'],
mode: ['markers'],
marker: [{
size: [1531*10],
sizeref: 2,
sizemode: 'area'
}]
};
var data = [t9];
var layout = {
title: 'Chart',
showlegend: true,
xaxis: {
title: 'Some text'
},
yaxis: {
title: 'Some text'
}
};
var config = {responsive: true}
Plotly.newPlot('plot', data, layout, config);
Plotly.extendTraces(
'plot',
{
x: [[5491]],
y: [[5]],
text: [['Some text']],
mode: [['markers']],
marker: [[{
size: 123*100,
sizeref: 2,
sizemode: 'area'
}]]
}, [0]);
Plotly.extendTraces(
'plot',
{
x: [[60022]],
y: [[11]],
text: [['Some text']],
mode: [['markers']],
marker: [[{
size: 982*100,
sizeref: 2,
sizemode: 'area'
}]]
}, [0]);
<head>
<!-- Plotly.js -->
<script src="https://cdn.plot.ly/plotly-latest.min.js"></script>
</head>
<html>
<body>
<div id="plot"></div>
</body>
</html>
如您所见,标记不会占用mode: ['markers'] 属性和所有markers: 属性。
知道如何在此页面上获得类似的结果吗? https://plotly.com/javascript/bubble-charts/
【问题讨论】:
标签: javascript plotly marker extend area