4

Although I've specified text and hoverinfo, I'm not getting any hover annotation at all.

If I comment out the "text" attribute, I get the default behavior of hoverinfo: "x+y". I've also tried hoverinfo: "text" and hoverinfo: "x+text" (which is what I really want), but these do not change the behavior.

https://jsfiddle.net/abalter/0cjprqgy/

var data =
{
    "x":["2014-02-10 00:00:00.0","2014-02-18 00:00:00.0","2014-02-24 00:00:00.0"],
  "y":[0,0,0],
  "text":["gemcitabine","gemcitabine + Abraxane","Xeloda"],
  "hoverinfo": "all",
  "name":"Treatment",
  "type":"scatter",
  "mode":"markers",
  "marker":
  {
    "size":9,
    "color":"#800000"
    },
  "uid":"c2e171"
};

var layout = 
{
    "title":"Treatments",
  "height":600,
  "width":655,
  "autosize":true,
  "yaxis":
  {
    "titlefont":
    {
        "size":12,
      "color":"#800000"
    },
    "domain":[0.85,0.9],
    "showgrid":false,
    "showline":false,
    "showticklabels":false,
    "zeroline":true,
    "type":"linear",
    "range":[0,0],
    "autorange":true
  },
  "hovermode":"closest",
  "xaxis":
  {
    "type":"date",
    "range":[1389215256994.8186,1434909143005.1814],
    "autorange":true
  }
};

Plotly.plot('graph', [data], layout);

1 Answer 1

4

First of all, thank you for having me to discover this really cool graphic platform! I checked at the documentation to get to know how the data has to be formatted (here: https://plot.ly/javascript/hover-events/#coupled-hover-events-on-single-plot)... And "played" with you fiddle.

First, I removed all the unnessessary double quotes you had there, wrapping the param names and placed your value arrays outside of the "data" array. I don't know if it is part of the problem... I just tryed to format it as the example I found.

The "x+y+text" suddenly appeared when I played with the "domain" parameter.
I don't know what it really defines.
I repeat, I have a 10 minutes experience with this thing. (lol)

Check this update I made of your fiddle : https://jsfiddle.net/0cjprqgy/6/

var dates = ["2014-02-10 00:00:00.0","2014-02-18 00:00:00.0","2014-02-24 00:00:00.0"],
  qty = ["0.2","0.5","1"],
  product = ["gemcitabine","gemcitabine + Abraxane","Xeloda"],
data =
{
  x:dates,
  y:qty,
  text:product,
  hoverinfo: "x+y+text",
  name:"Treatment",
  type:"scatter",
  mode:"markers",
  marker:
  {
    size:9,
    color:"#800000"
    },
  uid:"c2e171"
};

var layout = 
{
  title:"Treatments",
  height:600,
  width:655,
  autosize:true,
  yaxis:
  {
    titlefont:
    {
      size:12,
      color:"#800000"
    },
    domain:[0.85,1.9],
    showgrid:false,
    showline:false,
    showticklabels:false,
    zeroline:true,
    type:"linear",
    range:[0,0],
    autorange:true
  },
  hovermode:"closest",
  xaxis:
  {
    type:"date",
    range:[1389215256994.8186,1434909143005.1814],
    autorange:true
  }
};

Plotly.plot('graph', [data], layout);
Sign up to request clarification or add additional context in comments.

3 Comments

Hi @Louys. Welcome to Plotly! It's a pretty great plotting package, but is still a work in progress--has a lot of quirks. But they are planning some great improvements for the next release.
So, this is really interesting. After playing around, and using diff I was able to figure out that the crucial change to make it work was changing domain from [0.85, 0.9] to [0.85, 1.9]. The domain is a 0 to 1 coordinate for the "page," meaning 0 is the bottom of the plot and 1 is the top. I'm trying to place this line of points above another subplot as in plnkr.co/edit/vvStyutowlwubUdddY37. So, a domain to 1.9 really doesn't make any sense. Yet, it makes the over work. I'm going to call this a bug and post it.
BTW, great work for having never seen Plotly before!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.