How to display a bin count histogram 
Author Message
 How to display a bin count histogram

Hi,

I have a list of bin count from 0 to 255, I need to update the contents
of these bins as the content values change.  What would be a good way
to do this?  I tried to use for loops to add label, but 256 bin
wouldn't fit in one window, then I tried to add a scrollbar, but the
scrollbar appears to work only on listbox.  The label bin1....bin256
remains the same.  Only the content of these need to be updated.

Thanks in advance,
Ann



Thu, 18 Oct 2007 23:47:52 GMT  
 How to display a bin count histogram
Quote:

> Hi,

> I have a list of bin count from 0 to 255, I need to update the contents
> of these bins as the content values change.  What would be a good way
> to do this?  I tried to use for loops to add label, but 256 bin
> wouldn't fit in one window, then I tried to add a scrollbar, but the
> scrollbar appears to work only on listbox.  The label bin1....bin256
> remains the same.  Only the content of these need to be updated.

> Thanks in advance,
> Ann

What might work better than trying to display these values in labels
would be to use the Blt package to display a the histogram as a
graph.  It would be much easier for humans to interpret then.
Ron Fox
NSCL
Michigan State University
East Lansing, MI 48824-1321

Big Boy Caprice:  Wait a minute!  Wait.  Wait.  I'm having a thought.
Oh   yes.  Oh yes.  I'm going to have a thought.  It's coming.  It's
coming.   ...It's gone.



Fri, 19 Oct 2007 19:46:55 GMT  
 How to display a bin count histogram

Quote:

> I have a list of bin count from 0 to 255, I need to update the
> contents of these bins as the content values change.  What would be
> a good way to do this?  I tried to use for loops to add label, but
> 256 bin wouldn't fit in one window, then I tried to add a scrollbar,
> but the scrollbar appears to work only on listbox.  The label
> bin1....bin256 remains the same.  Only the content of these need to
> be updated.

Perhaps you could use one of the progress bars.  See
http://wiki.tcl.tk/2104 or search the wiki for "progress."

Bob
--

Mayo Foundation                                 (507) 538-5495
200 First St. SW                            FAX (507) 284-9171
Rochester MN, 55901  USA            http://www.mayo.edu/sppdg/



Fri, 19 Oct 2007 21:20:40 GMT  
 How to display a bin count histogram

Quote:
> Hi,

> I have a list of bin count from 0 to 255, I need to update the contents
> of these bins as the content values change.  What would be a good way
> to do this?  I tried to use for loops to add label, but 256 bin
> wouldn't fit in one window, then I tried to add a scrollbar, but the
> scrollbar appears to work only on listbox.  The label bin1....bin256
> remains the same.  Only the content of these need to be updated.

> Thanks in advance,
> Ann

The Tk canvas widget is a good fit for this sort of
task. There are some pure tcl solutions such as
http://mini.net/tcl/13680
and
http://mini.net/tcl/10878

Here is some bare Tcl code
to make horizontal bars of various
colors and update their length.
---------------------------------------------
package require Tk
destroy .c
pack [canvas .c -bd 0 -highlightthickness 0] -fill both -expand 1

set dataset {
    10 red val1
    13 green val2
    99 blue bigval
    22 brown midval

Quote:
}

set y 10
set w 20
set scale 1
set x  50
foreach {val color text} $dataset {

    # Draw the bar as a line
    .c create line $x $y [expr {$x + ($scale * $val)}] $y -width $w \
        -fill $color -tags [list $text]
    # put text over it
    .c create text 0 $y  -anchor w -text $text -fill black

    incr y [expr {$w+5}]

Quote:
}

proc changeval {text newval} {
    global scale x
    foreach {x1 y1 x2 y2} [.c coords $text] break
    .c coords $text $x1 $y1 [expr {$x + ($scale * $newval)}] $y2

Quote:
}

Roy


Sat, 20 Oct 2007 00:35:08 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. changes fixed the Histogram display but spoilt the Geometry display

2. general histogram & negative bins

3. displaying a queue count in a Browse

4. Re : Counting and Displaying char

5. Count & Display Rows in MYSQL

6. Count lines of Text on Display

7. Hex to Bin, Bin to Hex, Hex to Dec, Dec to Hex

8. Count Down to DevCon -- 7 Days and Counting

9. count counter counting mechanism

10. counting events and miss first count

11. count counts but any doesnt

12. Count = Count + 1;

 

 
Powered by phpBB® Forum Software