$mw->bind('' => sub { $x_begin = $Tk::event->x; $y_begin = $Tk::event->y; print "x_begin = $x_begin y_begin=$y_begin\n"; $mw->bind('' => sub { $x_now = $Tk::event->x; $y_now = $Tk::event->y; print "x_now = $x_now y_now=$y_now\n"; $rec = $chart->createRectangle( $x_begin, $y_begin, $x_now, $y_now, -width => 2, -outline => 'yellow', ################### -tags => ['rect'] ); ################### $rec2 = $chart2->createRectangle( $x_begin, $y_begin, $x_now, $y_now, -width => 2, -outline => 'orange', ################# -tags => ['rect'] ); ################## }); } ); $mw->bind('' => sub { print "ButtonReleased\n"; #$chart->delete($rec); $mw->bind('', ""); $chart_width = $chart->width; $chart->delete($rec); $chart2->delete($rec2); ###################################### $chart->delete('rect'); $chart2->delete('rect'); ###################################### $d = $x_begin/$chart_width; $e = $x_now/$chart_width; print "draw next chart at $d percent of timeline, end at $e percent of timeline\n"; $chart->clearchart; $chart2->clearchart; &update_data($d, $e); $chart->plot(\@data); $chart2->plot(\@data2); } );