Here is the basic idea, use canvas tags. It dosn't deal with your screen clutter of multiple rectangles as you drag, but the solution to that is in the previous example I showed, where you
$mw->bind( 'Tk::Canvas','<Motion>' => \&making_rect );
You should be able to implement that yourself. You need to work thru it once, to get it into your head how it works. So I throw you 1 fish, but not 2. :-)

So to correct your code above to using tags, here are the modified subs

$mw->bind('<ButtonPress>' => sub { $x_begin = $Tk::event->x; $y_begin = $Tk::event->y; print "x_begin = $x_begin y_begin=$y_begin\n"; $mw->bind('<Motion>' => 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('<ButtonRelease>' => sub { print "ButtonReleased\n"; #$chart->delete($rec); $mw->bind('<Motion>', ""); $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); } );

I'm not really a human, but I play one on earth.
Old Perl Programmer Haiku ................... flash japh

In reply to Re^3: Unable to get rid of Perl::Tk Chart::Lines zoom rectangles by zentara
in thread Unable to get rid of Perl::Tk Chart::Lines zoom rectangles by pashanoid

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.