Posted to tcl by jdc at Tue Oct 02 09:12:33 GMT 2007view raw

  1. package require Tk
  2. package require BLT
  3.  
  4. set gf [frame .gf]
  5. pack $gf -fill both -expand true
  6.  
  7. set g [blt::graph $gf.g]
  8. set sx [scrollbar $gf.sx -orient horizontal -command [list $g axis view x]]
  9. set sy [scrollbar $gf.sy -orient vertical -command [list $g axis view y]]
  10.  
  11. grid $g -row 0 -column 0 -sticky ewns
  12. grid $sx -row 1 -column 0 -sticky ewns
  13. grid $sy -row 0 -column 1 -sticky ewns
  14. grid columnconfigure $gf 0 -weight 1
  15. grid rowconfigure $gf 0 -weight 1
  16.  
  17. $g axis configure x -scrollcommand [list $sx set] -rotate 90.0
  18. $g axis configure y -scrollcommand [list $sy set]
  19. $g grid on
  20.  
  21. Blt_ZoomStack $g
  22. Blt_Crosshairs $g
  23. Blt_ActiveLegend $g
  24. Blt_ClosestPoint $g
  25. Blt_PrintKey $g
  26.  
  27. $g element create t1 -smooth linear -symbol "" -color red -label "t1-red"
  28.  
  29. set dx {}
  30. set dy {}
  31. for { set i 0 } { $i < 1024 } { incr i } {
  32. lappend dx $i
  33. lappend dy [expr {sin($i*3.1415/1024)}]
  34. }
  35.  
  36. $g element configure t1 -xdata $dx -ydata $dy