1

グラフの凡例は、plotpanイベントが発生するたびにのみ発生します。これが私のupdateLegend関数で、プログラムはもちろんトレースメッセージを使用して入っていると確信しています

ただし、機能を含めてから凡例が更新されるのは、aが発生plotpanした直後だけです。plotpan何が原因なのかわからないので、問題に対処できません。次の分離されたコード セグメントよりも役立つ JSFiddle を次に示します。

var updateLegendTimeout = null;
var latestPosition = null;
 function updateLegend(){
        var series = (plot.getData())[0];
        legends.eq(0).text(series.label ="x: " + (local_x)+" y: "+ (local_y));
 }  


placeholder.bind("plothover",  function (event, pos, item) {
if (item){
    local_x = item.datapoint[0].toFixed(2);
        local_y = item.datapoint[1].toFixed(2);
    console.log("x:" + local_x + ", " + "y:" + local_y);
}

if (!updateLegendTimeout){
    updateLegendTimeout = setTimeout(updateLegend, 50);
        updateLegendTimeout = null;
}
});
4

1 に答える 1