react-plotly.js icon indicating copy to clipboard operation
react-plotly.js copied to clipboard

Cannot change hover text by hovertemplate/hoverinfo/text/hovertemplate

Open himgodfreyho opened this issue 5 years ago • 2 comments

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
                      },
                    }
                  },
                }}
/>

Screenshot 2019-09-03 at 00 49 29

himgodfreyho avatar Sep 02 '19 16:09 himgodfreyho

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/

ghost avatar Oct 27 '19 09:10 ghost

You have to unset hoverinfo and set hovertemplate instead.

nicolaskruchten avatar Oct 27 '19 14:10 nicolaskruchten