1

カーソルが移動すると、プロットされたポイントがまだない場合は、最も近い 2 つのポイントを取得します。

これら 2 つの最も近い点を点灯させ (つまり、色をオレンジ色か何かに変更)、カーソルがグラフの範囲を離れると通常に戻るようにしたいと考えています。これを実装するにはどうすればよいですか?

placeholder.bind("plothover",  function (event, pos, item) {
    if (item){
        local_x = item.datapoint[0].toFixed(2);
        local_y = item.datapoint[1].toFixed(2);                 
        if (!updateLegendTimeout){
        updateLegendTimeout = setTimeout(updateLegend(local_x,local_y), 1000);
        updateLegendTimeout = null;
        }
    }
    else{
         var closest_points_container = interpolate(plot,pos.x,pos.y);                              

         //Code to make points glow goes here, they are contained in closest_points[0]                   
           and closest_points[1].
    }
4

1 に答える 1