Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Correct the use of options for the vertical subtext. Add missing procedures from previous checkin. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | subtitles-and-corrected-tests |
Files: | files | file ages | folders |
SHA1: | bb8dd0fd80eb9ea89782905a20011100820d8514 |
User & Date: | markus 2013-03-10 16:08:36 |
Context
2013-03-12
| ||
03:03 | Fix for plotchart testsuite, added proper Tcl version check. check-in: 7c69b51a2d user: aku tags: subtitles-and-corrected-tests | |
2013-03-11
| ||
20:08 | Merged latest plotchart work into the pending release. check-in: c2b933f8dd user: andreask tags: tklib-0-6-rc | |
2013-03-10
| ||
16:08 | Correct the use of options for the vertical subtext. Add missing procedures from previous checkin. check-in: bb8dd0fd80 user: markus tags: subtitles-and-corrected-tests | |
14:12 | Document the subtext subcommands. Compute the new margins based on the presence or absence of subtexts to the axes. Bumped version to 2.1.0 to reflect the addition of these subcommands and the repair of the pixelToCoords procedure. check-in: b779f23b2e user: markus tags: subtitles-and-corrected-tests | |
Changes
Changes to modules/plotchart/plotaxis.tcl.
680 681 682 683 684 685 686 687 688 689 690 691 692 693 ... 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 ... 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 |
if {$config($w,bottomaxis,render) eq "simple"} { $w create text $xt $yt -text [lindex $args 0] -fill $textcolor -anchor n -font $textfont -tags [list xtext $w] } elseif {$config($w,bottomaxis,render) eq "text"} { RenderText $w $xt $yt -text $args -anchor n -font $textfont -tags [list xtext $w] \ -fill $textcolor } } # DrawYtext -- # Draw text to the y-axis # Arguments: # w Name of the canvas # text Text to be drawn # Result: ................................................................................ if { [string match "r*" $w] == 0 } { set textcolor $config($w,leftaxis,textcolor) set textfont $config($w,leftaxis,font) set xt $scaling($w,pxmin) set anchor se } else { set textcolor $config($w,rightaxis,textcolor) set textfont $config($w,rightaxis,font) set xt $scaling($w,pxmax) set anchor sw } set yt [expr {$scaling($w,pymin)-$config($w,font,char_height)/2}] $w delete "ytext && $w" $w create text $xt $yt -text $text -fill $textcolor -anchor $anchor -font $textfont -tags [list ytext $w] } # DrawVtext -- # Draw vertical text to the y-axis # Arguments: # w Name of the canvas # text Text to be drawn # Result: ................................................................................ # This requires Tk 8.6 or later # proc ::Plotchart::DrawVtext { w text } { variable scaling variable config if { [package vsatisfies [package present Tk] 8.6] } { set yt [expr {($scaling($w,pymin) + $scaling($w,pymax)) / 2}] if { [string match "r*" $w] } { set anchor n set bbox [$w bbox raxis] set tag "rvtext" set axis "rightaxis" set xt [expr {[lindex $bbox 2] + $config($w,rightaxis,vtextoffset)}] } else { set anchor s set bbox [$w bbox yaxis] set tag "vtext" set axis "leftaxis" set xt [expr {[lindex $bbox 0] - $config($w,leftaxis,vtextoffset)}] } $w delete "$tag && $w" $w create text $xt $yt -text $text -fill black -anchor $anchor -angle 90 -tags [list $tag $w] \ -font $config($w,$axis,font) -fill $config($w,$axis,textcolor) } } # DrawPolarAxes -- # Draw thw two polar axes # Arguments: # w Name of the canvas # rad_max Maximum radius # rad_step Step in radius |
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > |
680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 ... 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 ... 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 |
if {$config($w,bottomaxis,render) eq "simple"} { $w create text $xt $yt -text [lindex $args 0] -fill $textcolor -anchor n -font $textfont -tags [list xtext $w] } elseif {$config($w,bottomaxis,render) eq "text"} { RenderText $w $xt $yt -text $args -anchor n -font $textfont -tags [list xtext $w] \ -fill $textcolor } } # DrawXsubtext -- # Draw subtext to the x-axis # Arguments: # w Name of the canvas # args Text to be drawn (more than one argument if rendering in on) # Result: # None # Side effects: # Text drawn in canvas # proc ::Plotchart::DrawXsubtext { w args } { variable scaling variable config set textcolor $config($w,bottomaxis,subtextcolor) set textfont $config($w,bottomaxis,subtextfont) set char_height [font metrics $textfont -linespace] set xt [expr {($scaling($w,pxmin)+$scaling($w,pxmax))/2}] set yt [expr {$scaling($w,pymax)+2*$char_height+4}] $w delete "xsubtext && $w" if {$config($w,bottomaxis,render) eq "simple"} { $w create text $xt $yt -text [lindex $args 0] -fill $textcolor -anchor n -font $textfont -tags [list xsubtext $w] } elseif {$config($w,bottomaxis,render) eq "text"} { RenderText $w $xt $yt -text $args -anchor n -font $textfont -tags [list xsubtext $w] \ -fill $textcolor } } # DrawYtext -- # Draw text to the y-axis # Arguments: # w Name of the canvas # text Text to be drawn # Result: ................................................................................ if { [string match "r*" $w] == 0 } { set textcolor $config($w,leftaxis,textcolor) set textfont $config($w,leftaxis,font) set xt $scaling($w,pxmin) set anchor se set usesubtext $config($w,leftaxis,usesubtext) } else { set textcolor $config($w,rightaxis,textcolor) set textfont $config($w,rightaxis,font) set xt $scaling($w,pxmax) set anchor sw set usesubtext $config($w,rightaxis,usesubtext) } if { $usesubtext } { set char_height [font metrics $textfont -linespace] set yt [expr {$scaling($w,pymin)-$config($w,font,char_height)/2 - $char_height}] } else { set yt [expr {$scaling($w,pymin)-$config($w,font,char_height)/2}] } $w delete "ytext && $w" $w create text $xt $yt -text $text -fill $textcolor -anchor $anchor -font $textfont -tags [list ytext $w] } # DrawYsubtext -- # Draw subtext to the y-axis # Arguments: # w Name of the canvas # text Text to be drawn # Result: # None # Side effects: # Text drawn in canvas # proc ::Plotchart::DrawYsubtext { w text } { variable scaling variable config if { [string match "r*" $w] == 0 } { set textcolor $config($w,leftaxis,subtextcolor) set textfont $config($w,leftaxis,subtextfont) set xt $scaling($w,pxmin) set anchor se } else { set textcolor $config($w,rightaxis,subtextcolor) set textfont $config($w,rightaxis,subtextfont) set xt $scaling($w,pxmax) set anchor sw } set char_height [font metrics $textfont -linespace] set yt [expr {$scaling($w,pymin)-$char_height/2+4}] $w delete "ysubtext && $w" $w create text $xt $yt -text $text -fill $textcolor -anchor $anchor -font $textfont -tags [list ysubtext $w] } # DrawVtext -- # Draw vertical text to the y-axis # Arguments: # w Name of the canvas # text Text to be drawn # Result: ................................................................................ # This requires Tk 8.6 or later # proc ::Plotchart::DrawVtext { w text } { variable scaling variable config if { [package vsatisfies [package present Tk] 8.6] } { set yt [expr {($scaling($w,pymin) + $scaling($w,pymax)) / 2}] if { [string match "r*" $w] } { set anchor n set bbox [$w bbox "raxis && $w"] set tag "rvtext" set axis "rightaxis" set xt [expr {[lindex $bbox 2] + $config($w,rightaxis,vtextoffset)}] } else { set anchor s set bbox [$w bbox "yaxis && $w"] set tag "vtext" set axis "leftaxis" set xt [expr {[lindex $bbox 0] - $config($w,leftaxis,vtextoffset)}] } if { $config($w,$axis,usevsubtext) } { set char_height [font metrics $config($w,$axis,font) -linespace] set xt [expr {$xt - $char_height - 4}] } $w delete "$tag && $w" $w create text $xt $yt -text $text -fill black -anchor $anchor -angle 90 -tags [list $tag $w] \ -font $config($w,$axis,font) -fill $config($w,$axis,textcolor) } } # DrawVsubtext -- # Draw vertical subtext to the y-axis # Arguments: # w Name of the canvas # text Text to be drawn # Result: # None # Side effects: # Text drawn in canvas # Note: # This requires Tk 8.6 or later # proc ::Plotchart::DrawVsubtext { w text } { variable scaling variable config if { [package vsatisfies [package present Tk] 8.6] } { set yt [expr {($scaling($w,pymin) + $scaling($w,pymax)) / 2}] if { [string match "r*" $w] } { set anchor n set bbox [$w bbox "raxis && $w"] set tag "rvsubtext" set axis "rightaxis" set xt [expr {[lindex $bbox 2] + $config($w,rightaxis,vtextoffset)}] } else { set anchor s set bbox [$w bbox "yaxis && $w"] set tag "vsubtext" set axis "leftaxis" set xt [expr {[lindex $bbox 0] - $config($w,leftaxis,vtextoffset)}] } $w delete "$tag && $w" $w create text $xt $yt -text $text -fill black -anchor $anchor -angle 90 -tags [list $tag $w] \ -font $config($w,$axis,vsubtextfont) -fill $config($w,$axis,vsubtextcolor) } } # DrawPolarAxes -- # Draw thw two polar axes # Arguments: # w Name of the canvas # rad_max Maximum radius # rad_step Step in radius |
Changes to modules/plotchart/plotchart.man.
877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 |
Specify the subtext of the (vertical) y-axis, for those plots that have a straight y-axis. This text is drawn to the [emph right] of the primary text, for both axes on the left and the right. [nl] Since this involves positioning the primary text and setting margins, you need to set the option "usesubtext" for the left or right axis via the plotstyle command. The relevant options are: usevsubtext, subvtextcolor and subvtextfont. (Note the "v" to distinguish this option from the text at the top of a vertical axis that is drawn via [term "\$anyplot ytext"] or [term "\$anyplot ysubtext"].) [list_begin arguments] [arg_def string text in] The secondary (vertical) text of the y-axis label to be drawn. |
| |
877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 |
Specify the subtext of the (vertical) y-axis, for those plots that have a straight y-axis. This text is drawn to the [emph right] of the primary text, for both axes on the left and the right. [nl] Since this involves positioning the primary text and setting margins, you need to set the option "usesubtext" for the left or right axis via the plotstyle command. The relevant options are: usevsubtext, vsubtextcolor and vsubtextfont. (Note the "v" to distinguish this option from the text at the top of a vertical axis that is drawn via [term "\$anyplot ytext"] or [term "\$anyplot ysubtext"].) [list_begin arguments] [arg_def string text in] The secondary (vertical) text of the y-axis label to be drawn. |
Changes to modules/plotchart/plotconfig.tcl.
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
...
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
|
} { set config($type,components) $components } # define implemented properties for each component: # (the '-' means that the component inherits the properties of the previous component on the list) foreach {component properties} { leftaxis {color thickness font format ticklength textcolor labeloffset minorticks shownumbers showaxle render vtextoffset subtextcolor subtextfont subvtextfont subvtextcolor usesubtext usesubvtext} rightaxis - axis {color thickness font format ticklength textcolor labeloffset minorticks shownumbers showaxle render justify subtextcolor subtextfont usesubtext} topaxis - bottomaxis - xaxis - yaxis - zaxis - ................................................................................ set config(font,char_height) $char_height # values for the 'default' style: set _color "black" set _font [.invisibleCanvas itemcget $invisibleLabel -font] set _subtextfont $_font set _subtextcolor $_color set _subvtextfont $_font set _subvtextcolor $_color set _usesubtext 0 set _usesubvtext 0 set _thickness 1 set _format "" set _ticklength 3 set _minorticks 0 set _textcolor "black" set _anchor n set _labeloffset 2 |
|
|
|
|
|
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
...
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
|
} { set config($type,components) $components } # define implemented properties for each component: # (the '-' means that the component inherits the properties of the previous component on the list) foreach {component properties} { leftaxis {color thickness font format ticklength textcolor labeloffset minorticks shownumbers showaxle render vtextoffset subtextcolor subtextfont vsubtextfont vsubtextcolor usesubtext usevsubtext} rightaxis - axis {color thickness font format ticklength textcolor labeloffset minorticks shownumbers showaxle render justify subtextcolor subtextfont usesubtext} topaxis - bottomaxis - xaxis - yaxis - zaxis - ................................................................................ set config(font,char_height) $char_height # values for the 'default' style: set _color "black" set _font [.invisibleCanvas itemcget $invisibleLabel -font] set _subtextfont $_font set _subtextcolor $_color set _vsubtextfont $_font set _vsubtextcolor $_color set _usesubtext 0 set _usevsubtext 0 set _thickness 1 set _format "" set _ticklength 3 set _minorticks 0 set _textcolor "black" set _anchor n set _labeloffset 2 |
Changes to modules/plotchart/plotpriv.tcl.
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
...
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
|
set config($w,font,char_height) $char_height foreach {char_width char_height} [FontMetrics $w] {break} set margin_right [expr {$char_width * 4}] if { $margin_right < $config($w,margin,right) } { set margin_right $config($w,margin,right) } if { $config($w,rightaxis,usesubvtext) } { set char_height [font metrics $config($w,rightaxis,subvtextfont) -linespace] set margin_right [expr {$margin_right + $char_height + 4}] } set margin_bottom [expr {$char_height * 2 + 2}] if { $margin_bottom < $config($w,margin,bottom) } { set margin_bottom $config($w,margin,bottom) } if { $config($w,bottomaxis,usesubtext) } { ................................................................................ set pxmin $config($w,margin,left) } set pymin [expr {int($char_height*$notext) + [$w cget -borderwidth]}] if { $pymin < $config($w,margin,top) } { set pymin $config($w,margin,top) } if { $config($w,leftaxis,usesubtext) || $config($w,rightaxis,usesubtext) } { set char_height [font metrics $config($w,bottomaxis,subtextfont) -linespace] set pymin [expr {$pymin + $char_height}] } if { $config($w,leftaxis,usesubvtext) } { set char_height [font metrics $config($w,bottomaxis,subvtextfont) -linespace] set pxmin [expr {$pxmin + $char_height + 4}] } array set options $argv if {[info exists options(-box)]} { foreach {offx offy width height} $options(-box) {break} if { $offy == 0 } { |
|
|
|
>
|
|
|
|
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
...
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
|
set config($w,font,char_height) $char_height foreach {char_width char_height} [FontMetrics $w] {break} set margin_right [expr {$char_width * 4}] if { $margin_right < $config($w,margin,right) } { set margin_right $config($w,margin,right) } if { $config($w,rightaxis,usevsubtext) } { set char_height [font metrics $config($w,rightaxis,vsubtextfont) -linespace] set margin_right [expr {$margin_right + $char_height + 4}] } set margin_bottom [expr {$char_height * 2 + 2}] if { $margin_bottom < $config($w,margin,bottom) } { set margin_bottom $config($w,margin,bottom) } if { $config($w,bottomaxis,usesubtext) } { ................................................................................ set pxmin $config($w,margin,left) } set pymin [expr {int($char_height*$notext) + [$w cget -borderwidth]}] if { $pymin < $config($w,margin,top) } { set pymin $config($w,margin,top) } if { $config($w,leftaxis,usesubtext) || $config($w,rightaxis,usesubtext) } { set char_height1 [font metrics $config($w,leftaxis,subtextfont) -linespace] set char_height2 [font metrics $config($w,rightaxis,subtextfont) -linespace] set pymin [expr {$pymin + max($char_height1,$char_height2)}] } if { $config($w,leftaxis,usevsubtext) } { set char_height [font metrics $config($w,leftaxis,vsubtextfont) -linespace] set pxmin [expr {$pxmin + $char_height + 4}] } array set options $argv if {[info exists options(-box)]} { foreach {offx offy width height} $options(-box) {break} if { $offy == 0 } { |