proc scaleY {pw ax} {
#$Header: /home/cvsroot/tcldb/wisql/Tlib/scaleY,v 1.1 1998/05/17 00:54:47 de Exp $

	global Vdata Data RangeMidPt ScaleRange

#	pw is plot widget
#	ele is ele name
#	eli is element index in plot 

	set w .scaley_$ax
	toplevel $w -class Dialog
	
	set ds $Vdata($ax)
	set nam [keylget Data($ds) $ax]

	set ymin [$pw axis cget $ax -min]
	set ymax [$pw axis cget $ax -max]

	if {$ymin == ""} {
		set ymax [eval max [eval $ax range 0 end]]
		set ymin [eval min [eval $ax range 0 end]]
	}
	set ScaleRange [expr $ymax - $ymin]
	set RangeMidPt [expr $ymin + ($ScaleRange / 2.0)]
	
	label $w.lab -text "Scale $nam" -background antiquewhite
	pack $w.lab -side top

	frame $w.data -background antiquewhite
	grid columnconfigure $w.data 0 -minsize 100
	grid columnconfigure $w.data 1 -minsize 100
	label $w.data.rngl -background antiquewhite -relief groove -border 2  \
		-text "Range in Axis Units"
	entry $w.data.rnge  -background ivory -width 10 -relief sunken -border 2  \
		-textvariable ScaleRange
	label $w.data.ctrl -background antiquewhite -relief groove -border 2 \
		-text "Center Range on Value"
	entry $w.data.ctre -background ivory -width 10 -relief sunken -border 2  \
		-textvariable RangeMidPt
	grid $w.data.rngl -column 0 -row 0
	grid $w.data.rnge -column 1 -row 0
	grid $w.data.ctrl -column 0 -row 1
	grid $w.data.ctre -column 1 -row 1

	button $w.appl -text "Apply" -command "doScale $pw $ax \$RangeMidPt \$ScaleRange"  -background lavender -activebackground lavender  -activeforeground magenta2
	button $w.auto -text "Auto" -command "set RangeMidPt 0; set ScaleRange 0; $w.appl invoke"  -background lavender -activebackground lavender  -activeforeground magenta2
	button $w.quit -text "Quit" -command "destroy $w"  -background white -foreground red -activebackground black  -activeforeground yellow

	pack $w.data -side top -expand true -fill x
	pack $w.appl -side left -expand true -fill x
	pack $w.quit -side right -expand true -fill x
	pack $w.auto -side right -expand true -fill x
	
}

