簡體   English   中英

Plotly懸停文本不顯示

[英]Plotly hover text not displaying

雖然我已經指定了text和hoverinfo,但我根本沒有得到任何懸停注釋。

如果我注釋掉“text”屬性,我會得到hoverinfo: "x+y"的默認行為hoverinfo: "x+y" 我也嘗試了hoverinfo: "text"hoverinfo: "x+text" (這是我真正想要的),但這些並沒有改變行為。

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);

首先,感謝您讓我發現這個非常酷的圖形平台! 我查看了文檔以了解數據的格式化(例如: https//plot.ly/javascript/hover-events/#coupled-hover-events-on-single-plot )...和你玩“玩”。

首先,我刪除了你在那里的所有不必要的雙引號,包裝了param名稱並將你的值數組放在“data”數組之外。 我不知道它是否是問題的一部分......我只是試着將其格式化為我發現的例子。

當我使用“domain”參數時, 突然出現“x + y + text”
我不知道它的真正定義。
我再說一遍,我有10分鍾的經驗。 (大聲笑)

檢查我的小提琴更新: 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);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM