虽然我已经指定了文字和hoverinfo,但我根本没有获得任何悬停注释。
如果我注释掉"文字"属性,我得到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);
答案 0 :(得分:3)
首先,感谢您让我发现这个非常酷的图形平台!我查看了文档以了解数据的格式化方式(这里:https://plot.ly/javascript/hover-events/#coupled-hover-events-on-single-plot)...并且“玩”了你的小提琴。
首先,我删除了你在那里的所有不必要的双引号,包装参数名称并将值数组放在“data”数组之外。我不知道它是否是问题的一部分......我只是试着将其格式化为我发现的例子。
当我使用“domain”参数播放时,“x + y + text”突然出现。
我不知道它的定义是什么
我再说一遍,我有10分钟的经验。 (LOL)
检查我的小提琴: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);