I started looking at it before the OP posted the links to his db, so I just hacked up some dummy data.

I blanked out the dates and update_data routines since they didn't seem pertinent to the problem:

sub dates {} sub update_data{}

Then put in some dummy data at the top just after the @dataX arrays were declared:

@data0 = @data1 = @data2 = @data3 =([0..200], [300..500]);

That got me able to run the script to try and troubleshoot. Lots of 'uninitialized' warnings, but it ran at least. Putting "no warnings qw/uninitialized/;" at the top reduced that clutter.

UPDATE: FWIW here is the actual code I tested with:

UPDATE 2: Crap. It needs some further modifications to work correctly under Linux. Added some lines to the render{} subroutine to rebind the scroll buttons if you aren't running under Win32.

#!/usr/bin/perl use strict; use warnings; use Tk; use Tk::Chart; use Tk::Chart::Lines; use Tk::Canvas::GradientColor; use Tk::Pane; use DBI; use utf8; use Tk::DateEntry; use POSIX qw/strftime/; use Time::Local; no warnings qw/uninitialized/; my ( $mw, $pane ); my ( @data0, @data1, @data2, @data3 ); @data0 = @data1 = @data2 = @data3 = ( [ 0 .. 200 ], [ 300 .. 500 ] ); my $datemin; my $datemax; my $color_start = '#ffffff'; #my $color_end = '#DF776F'; my $color_end = '#bbbbbb'; &dates; my ( $chart0, $chart1, $chart2, $chart3, $xlabelskip ); my ( $powermax, $powermin, $poweravg ); my ( $speedmax, $speedmin, $speedavg, $powersum ); my ( $battmax, $battmin, $battavg ); my ( $powersunmax, $powersunmin, $powersunavg, $powersunsum ); my ( @timeline, @speed, @power, @v_acc, @powersun ); &update_data; &create_mw; &set_charts; &render; MainLoop(); sub draw_charts { $chart0->clearchart; $chart1->clearchart; $chart2->clearchart; $chart3->clearchart; $chart0->destroy; $chart1->destroy; $chart2->destroy; $chart3->destroy; $mw->destroy; &create_mw; &update_data; &set_charts; &render; } sub render { $chart0->plot( \@data0 ); #u akb $chart1->plot( \@data1 ); #sun p $chart2->plot( \@data2 ); #wind p $chart3->plot( \@data3 ); #wind speed unless ($^O =~ /Win32/){ for my $w ( $chart0, $chart1, $chart2, $chart3 ) { $w->CanvasBind( '<4>', sub { $pane->yview( 'scroll', -3, +'units' ); $w->yviewMoveto(0); return;} ); $w->CanvasBind( '<5>', sub { $pane->yview( 'scroll', 3, ' +units' ); $w->yviewMoveto(1); return;} ); } } } sub create_mw { $mw = MainWindow->new(); $mw->geometry("840x800"); $mw->title("SA wind generation from $datemin to $datemax"); $mw->optionAdd( "*font", "*utf-8" ); $mw->fontCreate( 'giant_rus', -family => 'nimbus sans l', -weight => 'normal', -size => int( -13 * 13 / 10 ) ); $mw->fontCreate( 'tiny_rus', -family => 'nimbus sans l', -weight => 'normal', -size => int( -12 * 12 / 10 ) ); $pane = $mw->Scrolled(qw/Pane -scrollbars e -width 990 -height 960 +/)->pack; my $dateframe = $pane->Frame()->pack( -side => 'top', -anchor => 'nw', -padx => +'15' ); my $datelabel = $dateframe->Label( -text => "\x{0414}\x{0438}\x{0430}\x{043f}\x{0430}\x{0439}\x{043e}\x{ +1085}: ", -font => 'giant_rus' )->pack( -side => 'left' ); my @daynames = (); foreach ( 0 .. 6 ) { push @daynames, strftime( "%a", 0, 0, 0, 1, 1, 1, $_ ); } my $datebegin = $dateframe->DateEntry( -font => 'giant_rus', -daynames => \@daynames, -todaybackground => 'green', -textvariable => \$datemin, -formatcmd => sub { sprintf( "%d-%02d-%02d 00:00:00", $_[0], $_[1], $_[2] +); }, -width => 18 )->pack( -side => 'left' ); my $dateend = $dateframe->DateEntry( -font => 'giant_rus', -daynames => \@daynames, -todaybackground => 'green', -textvariable => \$datemax, -formatcmd => sub { sprintf( "%d-%02d-%02d 00:00:00", $_[0], $_[1], $_[2] +); }, -width => 18 )->pack( -side => 'left' ); my $buttonok = $dateframe->Button( -text => 'Ok', -command => \&draw_charts ) ->pack( -side => 'left' ); bindmousewheel($pane); $pane->focus; for ( $datebegin, $dateend, $buttonok ) { $_->bind( '<Leave>', sub { $pane->focus } ); } } sub set_charts { $chart0 = $pane->Lines( -title => "U \x{0430}\x{043a}\x{0431} min: $battmin max: $battmax avg: $battav +g (m/s)", -titlefont => 'giant_rus', -textfont => 'tiny_rus', -titleheight => '5', -xlabelfont => 'tiny_rus', -ylabelfont => 'tiny_rus', -ylabel => 'V', -boxaxis => 1, -yticknumber => 5, -linewidth => 2, -bezier => 1, -alltickview => 1, -pointline => 0, -markers => [ 10, 9, 9 ], -xtickheight => 5, -ylongticks => 1, -ylongtickscolor => 'white', -xlongticks => 1, -xlongtickscolor => 'white', -width => 800, -height => 220, -yminvalue => $battmin, -ymaxvalue => $battmax, -xlabelskip => $xlabelskip, )->pack(); $chart0->enabled_gradientcolor(); $chart0->set_gradientcolor( -start_color => $color_start, -end_color => $color_end, -type => 'linear_vertical', ); $chart3 = $pane->Lines( -title => "\x{0421}\x{043e}\x{043b}\x{043d}\x{0446}\x{0435}\x{0433}\x{0435}\x{04 +3d}\x{0435}\x{0440}\x{0430}\x{0446}\x{0438}\x{044f} min: $powersunmin + max: $powersunmax avg: $powersunavg (Wt) sum: $powersunsum (kWt*h) +", -titlefont => 'giant_rus', -textfont => 'tiny_rus', -titleheight => '5', -xlabelfont => 'tiny_rus', -ylabelfont => 'tiny_rus', -ylabel => 'P', -boxaxis => 1, -yticknumber => 5, -linewidth => 2, -bezier => 1, -alltickview => 1, -pointline => 0, -markers => [ 10, 9, 9 ], -xtickheight => 5, -ylongticks => 1, -ylongtickscolor => 'white', -xlongticks => 1, -xlongtickscolor => 'white', -width => 800, -height => 220, -yminvalue => $powersunmin, -ymaxvalue => $powersunmax, -xlabelskip => $xlabelskip, -colordata => [qw(orange)], )->pack(); $chart3->enabled_gradientcolor(); $chart3->set_gradientcolor( -start_color => $color_start, -end_color => $color_end, -type => 'linear_vertical', ); $chart2 = $pane->Lines( -title => "\x{0412}\x{0435}\x{0442}\x{0440}\x{043e}\x{0433}\x{0435}\x{043d}\x{04 +35}\x{0440}\x{0430}\x{0446}\x{044f} min: $powermin max: $powermax a +vg: $poweravg (Wt) sum: $powersum (kWt*h)", -titlefont => 'giant_rus', -textfont => 'tiny_rus', -titleheight => '5', -xlabelfont => 'tiny_rus', -ylabelfont => 'tiny_rus', -ylabel => 'P', -boxaxis => 1, -yticknumber => 5, -linewidth => 2, -bezier => 1, -alltickview => 1, -pointline => 0, -markers => [ 10, 9, 9 ], -xtickheight => 5, -ylongticks => 1, -ylongtickscolor => 'white', -xlongticks => 1, -xlongtickscolor => 'white', -width => 800, -height => 220, -yminvalue => $powermin, -ymaxvalue => $powermax, -xlabelskip => $xlabelskip, -colordata => [qw(blue)], )->pack(); $chart2->enabled_gradientcolor(); $chart2->set_gradientcolor( -start_color => $color_start, -end_color => $color_end, -type => 'linear_vertical', ); $chart1 = $pane->Lines( -title => "\x{0421}\x{043a}\x{043e}\x{0440}\x{043e}\x{0441}\x{0442}\x{044c} \x{0 +432}\x{0435}\x{0442}\x{0440}\x{0430}min: $speedmin max: $speedmax a +vg: $speedavg (m/s)", -titlefont => 'giant_rus', -textfont => 'tiny_rus', -titleheight => '5', -xlabelfont => 'tiny_rus', -ylabelfont => 'tiny_rus', -ylabel => 'V', -boxaxis => 1, -yticknumber => 5, -linewidth => 2, -bezier => 1, -alltickview => 1, -pointline => 0, -markers => [ 10, 9, 9 ], -xtickheight => 5, -ylongticks => 1, -ylongtickscolor => 'white', -xlongticks => 1, -xlongtickscolor => 'white', -width => 800, -height => 220, -yminvalue => $speedmin, -ymaxvalue => $speedmax, -xlabelskip => $xlabelskip, -colordata => [qw(green)], )->pack(); $chart1->enabled_gradientcolor(); $chart1->set_gradientcolor( -start_color => $color_start, -end_color => $color_end, -type => 'linear_vertical', ); } sub dates { } sub update_data { } sub bindmousewheel { my ($w) = @_; if ( $^O =~ /Win32/ ) { $w->bind( '<MouseWheel>' => [ sub { $w->yview( 'scroll', -( $_[1] / 120 ) * 3, 'units' + ); }, Ev('D') ] ); } else { $w->bind( '<4>' => sub { $w->yview( 'scroll', -3, 'units' ) unless $Tk::strictM +otif; } ); $w->bind( '<5>' => sub { $w->yview( 'scroll', +3, 'units' ) unless $Tk::strictM +otif; } ); } }

In reply to Re^3: Stop mouse wheel from moving charts up/down Tk::Scrolled by thundergnat
in thread Stop mouse wheel from moving charts up/down Tk::Scrolled 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.