Re: BLT StripChart + scrollbar
- From: DESheffer@xxxxxxxxx
- Date: Tue, 31 Jul 2007 20:54:55 -0000
On Jul 30, 1:10 pm, Bryan Oakley <oak...@xxxxxxxxxxxxxxxxxxxx> wrote:
DEShef...@xxxxxxxxx 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 Oakleyhttp://www.tclscripting.com
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!
.
- References:
- BLT StripChart + scrollbar
- From: DESheffer
- Re: BLT StripChart + scrollbar
- From: Bryan Oakley
- BLT StripChart + scrollbar
- Prev by Date: Re: Tcl script fails on some platforms
- Previous by thread: Re: BLT StripChart + scrollbar
- Next by thread: Where to find a Tcl command?
- Index(es):
Relevant Pages
|