我正在用Plotly写一个网页。问题是,当我使用Plotly_onclick事件时,似乎出现了一些问题。具体地说,当我用鼠标点击时,它没有反应。当我使用笔记本电脑的触摸板点击时,也就是按下触摸板,它也没有反应。只有当我用力触摸我的触摸板时,它才会做出反应。我处理不了这个问题。有没有人知道怎么修?
click事件的代码如下:
.on('plotly_click', function (event, eventdata) {
var point = eventdata.points[0];
var traceColor = point.fullData.marker.color,
newAnnotation = {
x: point.xaxis.d2l(point.x),
y: point.yaxis.d2l(point.y),
ax: 0,
ay: -50,
arrowhead: 6,
bgcolor: 'rgba(255,255,255,0.75)',
arrowcolor: traceColor,
font: {color: traceColor},
text: point.data.name + ':' + point.y + 'on ' + point.x
},
newIndex = (rangePlot.layout.annotations || []).length;
console.log(newIndex);
var TextFromUser = {name: point.data.name, time: point.x, value: point.y};
if(TextFromUser['time'].length==10)
{
TextFromUser['time']=TextFromUser['time']+' 00:00';
}
else if(TextFromUser['time'].length==13)
{
TextFromUser['time']=TextFromUser['time']+':00';
}
else;
if (newIndex) {
var foundCopy = false;
rangePlot.layout.annotations.forEach(function (ann, sameIndex) {
if (ann.text === newAnnotation.text) {
Plotly.relayout(rangePlot, 'annotations[' + sameIndex + ']', 'remove');
foundCopy = true;
}
});
if (foundCopy) return;
}
Plotly.relayout(rangePlot, 'annotations[' + newIndex + ']', newAnnotation);
})发布于 2016-07-15 18:16:20
示例引用:https://plot.ly/javascript/click-events/
代码:
Plotly.newPlot('myDiv', data, layout);
myPlot.on('plotly_click', function(data){
var pts = '';
for(var i=0; i < data.points.length; i++){
pts = 'x = '+data.points[i].x +'\ny = '+
data.points[i].y.toPrecision(4) + '\n\n';
}
alert('Closest point clicked:\n\n'+pts);
});它有一些泻湖,但它是一个事件的开始...
https://stackoverflow.com/questions/33205978
复制相似问题