gpt4 book ai didi

javascript - 我们可以改变所选点的样式吗?

转载 作者:行者123 更新时间:2023-12-02 23:49:21 26 4
gpt4 key购买 nike

在这个由plotly.js生成的箱线图中,选择点后,未选择的点的不透明度为0.2。

是否可以更改选定点和未选定点的样式?

var trace1 = {
y: [0, 1, 2, 3, 4, 5, 6],
type: 'box',
selectedpoints : [1,2,5],
boxpoints: 'all'
};

var data = [trace1];

var layout = {};

Plotly.newPlot('myDiv', data, layout);
<head>
<!-- Plotly.js -->
<script src="https://cdn.plot.ly/plotly-latest.min.js"></script>
</head>
<body>
<!-- Plotly chart will be drawn inside this DIV -->
<div id="myDiv"></div>
<script>
/* JAVASCRIPT CODE GOES HERE */
</script>
</body>

最佳答案

如果你看reference ,您可以看到“选定”和“未选定”标记的属性允许您更改其样式:

var trace1 = {
y: [0, 1, 2, 3, 4, 5, 6],
type: 'box',
selectedpoints: [1, 2, 5],
boxpoints: 'all',
selected: {
marker: {
color: '#ff0000',
opacity: 0.8
}
},
unselected: {
marker: {
color: '#00ff00',
opacity: 0.5
}
}
};

var data = [trace1];

var layout = {};

Plotly.newPlot('myDiv', data, layout);
<head>
<!-- Plotly.js -->
<script src="https://cdn.plot.ly/plotly-latest.min.js"></script>
</head>

<body>
<!-- Plotly chart will be drawn inside this DIV -->
<div id="myDiv"></div>
<script>
/* JAVASCRIPT CODE GOES HERE */
</script>
</body>

关于javascript - 我们可以改变所选点的样式吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55707159/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com