Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

BLT StripChart + scrollbar

37 views
Skip to first unread message

DESh...@gmail.com

unread,
Jul 30, 2007, 12:01:34 PM7/30/07
to
I am currently reading real time data into a BLT StripChart that has
both the -autorange and -shiftby options. As is desired, all older
data is automatically moved to the left, out of view. However, I would
also like to scroll backwards in time (x-axis) to view the older data,
with the option to later return to the -shiftby view. Has anyone done
this sort of thing with a StripChart and scrollbar and care to share
some examples?

With my current setup, it seems that once I use the scrollbar, the -
shiftby option becomes disabled and cannot be re-set. Is there any way
to get this option back so I can toggle back to the original shifted
mode?

Thank you!
Doug

Bryan Oakley

unread,
Jul 30, 2007, 1:10:19 PM7/30/07
to
DESh...@gmail.com wrote:
> I am currently reading real time data into a BLT StripChart that has
> both the -autorange and -shiftby options. As is desired, all older
> data is automatically moved to the left, out of view. However, I would
> also like to scroll backwards in time (x-axis) to view the older data,
> with the option to later return to the -shiftby view. Has anyone done
> this sort of thing with a StripChart and scrollbar and care to share
> some examples?

I've done it. I can't share any working examples right now because it's
all buried in lots of proprietary code, but I can give some advice.

> With my current setup, it seems that once I use the scrollbar, the -
> shiftby option becomes disabled and cannot be re-set. Is there any way
> to get this option back so I can toggle back to the original shifted
> mode?

The way I solved this is with a hack in the code that handles scrollbar
requests. What I have is something like this:

scrollbar $graph_h_scrollbar ... -command scrollTheGraph
...
proc scrollTheGraph {args} {
global graph

set result [eval $graph axis view x $args]
update idletasks
set viewx [lindex [$graph axis view x] end]
if {$viewx > .999} {
$graph_w axis configure x -min {} -max {}
}
return $result}
}

I don't know recall why I chose .999 (and is proof why Magic Numbers
aren't a good idea...). The idea is, if the scrollbar is sufficiently to
the right, reset the min and max to null which is what is necessary to
re-enable the autoscrolling.

(yuck! revisiting that code now after so many months, I'm chagrined by
my use of a magic number and a call to update, but I'm hoping I had a
good reason at the time!)

We also have a scale widget that lets you adjust the scale of the graph,
and it has the following comment at the top:

"If min and max are configured the autorange has no effect. So, when the
scale changes we need to re-enable auto scaling by adjusting the max
while keeping the min static"

I hope this helps. It _is_ possible to have autoscrolling and use
scrollbars, it just takes some creative coding. The BLT graph widget is
amazing, but the docs do leave a little bit to be desired. With enough
digging though, just about anything you want to do seems to be possible.


--
Bryan Oakley
http://www.tclscripting.com

DESh...@gmail.com

unread,
Jul 31, 2007, 4:54:55 PM7/31/07
to
On Jul 30, 1:10 pm, Bryan Oakley <oak...@bardo.clearlight.com> wrote:

It is good to know someone else has had some success doing this. Your
code and description sounds like what I am aiming for, and should
certainly help me. Thank you!

0 new messages