Tk Library Source Code

View Ticket
Login
Ticket UUID: 1891251
Title: Support of long ylabels in horizontal bar charts
Type: Patch Version: None
Submitter: relaxmike Created on: 2008-02-11 16:24:32
Subsystem: tklib :: plotchart Assigned To: arjenmarkus
Priority: 5 Medium Severity: Minor
Status: Open Last Modified: 2024-05-05 13:25:07
Resolution: None Closed By: nobody
    Closed on:
Description:
Hi,
The goal of this patch is to take into account for long y labels in an horizontal plotchart.
I have allread discussed that problem on comp.lang.tcl where the solution has been suggested by other Tclers :
http://groups.google.com/group/comp.lang.tcl/browse_thread/thread/ab5ee289991f81f/6821b6d40899d276?lnk=gst&q=plotchart#6821b6d40899d276
The problem is that, when long labels are to be displayed, some are hidden because there is no space left on the canvas.
The patch is fixing the problem by computing the longest y label to display : this allows to set the view accordingly.
The problem is located in the file plotchart.tcl, in the proc "::Plotchart::createHorizontalBarchart".
The following code takes into account for the size of the current default font used in the barchart and is not perfect because Plotchart does not take into account the fonts yet.

   label .invisibleLabel
   set fontname [.invisibleLabel cget -font]
   destroy .invisibleLabel
   
   set xspacemax 0
   foreach ylab $ylabels {
       set xspace [font measure $fontname $ylab]
       if {$xspace> $xspacemax} then {
           set xspacemax $xspace
       }
   }
   set text_width [expr {int ( $xspacemax / 10.) + 1}]

   foreach {pxmin pymin pxmax pymax} [MarginsRectangle $w $notext $text_width] {break}

Best regards,

Michaƫl
User Comments: arjenmarkus added on 2008-02-12 14:50:27:
Logged In: YES 
user_id=400048
Originator: NO

I will incorporate this patch in Plotchart. Unfortunately my connection to the Internet from my development PC (at home) is at this moment unreliable at the best of times and non-existent on average.

relaxmike added on 2008-02-11 23:24:32:

File Added - 265887: plotchart.tcl

Attachments: