通过下面的代码,我尝试创建一个简单的气泡图。我创建了一个跟踪以便稍后扩展它:
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/
慕侠2389804
相关分类