react-plotly.js
react-plotly.js copied to clipboard
Cannot change hover text by hovertemplate/hoverinfo/text/hovertemplate
I am trying to change the hover text. However, this is no effect no matter how I set the data prop: hovertemplate / hoverinfo / text / hovertemplate. None of them work.
Here is the code:
<Plot
data={[
{
name: 'Target',
type: 'scatter3d',
mode: 'markers+text',
x: this.state.xValues,
y: this.state.yValues,
z: this.state.zValues,
marker: {color: "rgb(207, 190, 23)"},
hoverinfo: "all",
text: this.state.selectedStudentId,
hovertext: this.state.selectedStudentId,
},
]}
layout={{
autosize: true,
scene: {
height: 640,
title: 'Nearest Neighbor',
xaxis: {
title: this.state.selectedXAxis,
},
yaxis: {
title: this.state.selectedYAxis,
},
zaxis: {
title: this.state.selectedZAxis,
},
aspectratio: {
x: 1,
y: 1,
z: 1
},
camera: {
center: {
x: 0,
y: 0,
z: 0
},
eye: {
x: -2,
y: -2,
z: 1.25
},
up: {
x: 0,
y: 0,
z: 1
},
}
},
}}
/>
Maybe you can try according to these documents: https://github.com/plotly/react-plotly.js/#event-handler-props https://www.edwardbeazer.com/how-to-add-hover-events-to-any-react-component/
You have to unset hoverinfo
and set hovertemplate
instead.