Check-in [5b9ba9de4c]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:small cleanup in plotchart
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 5b9ba9de4c3f5f715aa5036fec7ff684841e3fbd
User & Date: chw 2019-06-10 17:54:48
Context
2019-06-10
17:59
add can2svg from Coccinella contrib check-in: de9706d7a1 user: chw tags: trunk
17:54
small cleanup in plotchart check-in: 5b9ba9de4c user: chw tags: trunk
17:53
add a few nanosvg upstream changes to tksvg check-in: 530070899f user: chw tags: trunk
Changes

Changes to assets/tklib0.6/plotchart/plotconfig.tcl.

95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
...
206
207
208
209
210
211
212

213
214
215
216
217
218







219
220
221
222
223
224
225
226
227
228
229
...
265
266
267
268
269
270
271
272

273

274
275
276
277
278
279
280
    #     font            (Optional) font to be used instead of the default
    #     add_line_space  (Optional) add linespacing or not
    #
    # Result:
    #     List of character width and height
    #
    proc FontMetrics {w {font {}} {add_line_space 0}} {
            if { $font != {} } {
               set item        [$w create text 0 0 -font $font -text "M"]
            } else {
               set item        [$w create text 0 0 -text "M"]
            }
        set bbox        [$w bbox $item]
        set char_width  [expr {[lindex $bbox 2] - [lindex $bbox 0]}]
        set char_height [expr {[lindex $bbox 3] - [lindex $bbox 1]}]
        if { $char_width  <  8 } { set char_width   8 }
        if { $char_height < 14 } { set char_height 14 }
        $w delete $item

            if {$add_line_space} {
               set $char_height [expr $char_height + [font metrics $font -linespace]]
            }
        return [list $char_width $char_height]
    }

    #
    # List of styles
    #
    set config(styles) [list]
................................................................................
            set properties $lastProperties
        }
        set config($component,properties) $properties
        set lastProperties $properties
    }

    # get some font properties:

    canvas .invisibleCanvas
    set invisibleLabel [.invisibleCanvas create text 0 0 -text "M"]

    foreach {char_width char_height} [FontMetrics .invisibleCanvas] {break}
    set config(font,char_width)  $char_width
    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 _sorted        0      ;# piechart and spiral pie
   #set _shownumbers   0      ;# piechart and spiral pie      - conflict with axes - see below
   #set _format        "%s (%g)"  ;# piechart and spiral pie
    set _formatright   ""         ;# piechart and spiral pie
    set _transposecoordinates 0 ;# horizontal barchart
    set _justify       "left"



    destroy .invisibleCanvas


    #
    # Define the 'default' style
    #
    foreach type $config(charttypes) {
        foreach component $config($type,components) {
            foreach property $config($component,properties) {







|
|
|
|
|







|
|
|







 







>
|
|

|
|
|
>
>
>
>
>
>
>



<







 







<
>
|
>







95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
...
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229

230
231
232
233
234
235
236
...
272
273
274
275
276
277
278

279
280
281
282
283
284
285
286
287
288
    #     font            (Optional) font to be used instead of the default
    #     add_line_space  (Optional) add linespacing or not
    #
    # Result:
    #     List of character width and height
    #
    proc FontMetrics {w {font {}} {add_line_space 0}} {
        if { $font != {} } {
            set item        [$w create text 0 0 -font $font -text "M"]
        } else {
            set item        [$w create text 0 0 -text "M"]
        }
        set bbox        [$w bbox $item]
        set char_width  [expr {[lindex $bbox 2] - [lindex $bbox 0]}]
        set char_height [expr {[lindex $bbox 3] - [lindex $bbox 1]}]
        if { $char_width  <  8 } { set char_width   8 }
        if { $char_height < 14 } { set char_height 14 }
        $w delete $item

        if {$add_line_space} {
            set $char_height [expr {$char_height + [font metrics $font -linespace]}]
        }
        return [list $char_width $char_height]
    }

    #
    # List of styles
    #
    set config(styles) [list]
................................................................................
            set properties $lastProperties
        }
        set config($component,properties) $properties
        set lastProperties $properties
    }

    # get some font properties:
    if {[info command canvas] eq "canvas"} {
        canvas .invisibleCanvas
        set invisibleLabel [.invisibleCanvas create text 0 0 -text "M"]

        foreach {char_width char_height} [FontMetrics .invisibleCanvas] {break}
        set config(font,char_width)  $char_width
        set config(font,char_height) $char_height
        set _font [.invisibleCanvas itemcget $invisibleLabel -font]
    } else {
        foreach {char_width char_height} {12 16} {break}
        set config(font,char_width)  $char_width
        set config(font,char_height) $char_height
        set _font fixed
    }

    # values for the 'default' style:
    set _color         "black"

    set _subtextfont   $_font
    set _subtextcolor  $_color
    set _vsubtextfont  $_font
    set _vsubtextcolor $_color
    set _usesubtext    0
    set _usevsubtext   0
    set _thickness     1
................................................................................
    set _sorted        0      ;# piechart and spiral pie
   #set _shownumbers   0      ;# piechart and spiral pie      - conflict with axes - see below
   #set _format        "%s (%g)"  ;# piechart and spiral pie
    set _formatright   ""         ;# piechart and spiral pie
    set _transposecoordinates 0 ;# horizontal barchart
    set _justify       "left"


    if {[info command canvas] eq "canvas"} {
        destroy .invisibleCanvas
    }

    #
    # Define the 'default' style
    #
    foreach type $config(charttypes) {
        foreach component $config($type,components) {
            foreach property $config($component,properties) {

Changes to assets/tklib0.6/plotchart/plotpriv.tcl.

28
29
30
31
32
33
34

35


36
37
38
39
40
41
42
43
..
59
60
61
62
63
64
65

66



67
68
69
70
71
72
73
....
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
    if { [string match {[0-9]*} $w] } {
        set w [string range $w [string first . $w] end]
    }

    if { [info exists scaling($ref,refwidth)] && $useref } {
        set width $scaling($ref,refwidth)
    } else {

        set width [winfo width $w]



        if { $width < 10 } {
            set width [$w cget -width]
        }
    }
    incr width -[$w cget -borderwidth]

    return $width
................................................................................
    if { [string match {[0-9]*} $w] } {
        set w [string range $w [string first . $w] end]
    }

    if { [info exists scaling($ref,refheight)] && $useref } {
        set height $scaling($ref,refheight)
    } else {

        set height [winfo height $w]



        if { $height < 10 } {
            set height [$w cget -height]
        }
    }
    incr height -[$w cget -borderwidth]
    return $height
}
................................................................................
           }
           set tmpFont $render(subFont)
           set yp1 [expr {round($fontsize/3.0)}]
           set yp2 [expr {-1 * $yp1}]
           set xp1 [expr {round($fontsize/-5.0)}]
           set xp2 [expr {round($fontsize/-5.0)}]
           set advance 1
        }
       "^" { # Superscript
             if {$render(subFont) eq ""} {
                 set render(superFont) [font create {*}[font configure $font]]
                 set fontsize [font configure $font -size]
                 set fontsize [expr {round($fontsize * 3.0/5.0)}]
                 font configure $render(superFont) -size $fontsize
             } else {
                 set fontsize [$render(superFont) configure -size]
             }
             set tmpFont $render(superFont)
             set yp1 [expr {round($fontsize/-1.5)}]
             set yp2 [expr {-1 * $yp1}]
             set xp1 [expr {round($fontsize/-5.0)}]
             set xp2 [expr {round($fontsize/-5.0)}]
             set advance 1
           }
       default {
           set tmpFont $font
       }
   }
   return [list $xp1 $yp1 $xp2 $yp2 $advance $tmpFont]
}








>
|
>
>
|







 







>
|
>
>
>







 







|

|
|
|
|
|
|
|
|
|
|
|
|
|
|
|







28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
..
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
....
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
    if { [string match {[0-9]*} $w] } {
        set w [string range $w [string first . $w] end]
    }

    if { [info exists scaling($ref,refwidth)] && $useref } {
        set width $scaling($ref,refwidth)
    } else {
        if {[info command winfo] eq "winfo" && [winfo exists $w]} {
            set width [winfo width $w]
        } elseif {[catch {$w cget -width} width]} {
            set width 640
        }
        if { $width < 10 } {
            set width [$w cget -width]
        }
    }
    incr width -[$w cget -borderwidth]

    return $width
................................................................................
    if { [string match {[0-9]*} $w] } {
        set w [string range $w [string first . $w] end]
    }

    if { [info exists scaling($ref,refheight)] && $useref } {
        set height $scaling($ref,refheight)
    } else {
        if {[info command winfo] eq "winfo" && [winfo exists $w]} {
            set height [winfo height $w]
        } elseif {[catch {$w cget -height} height]} {
            set height 480
        }
        if { $height < 10 } {
            set height [$w cget -height]
        }
    }
    incr height -[$w cget -borderwidth]
    return $height
}
................................................................................
           }
           set tmpFont $render(subFont)
           set yp1 [expr {round($fontsize/3.0)}]
           set yp2 [expr {-1 * $yp1}]
           set xp1 [expr {round($fontsize/-5.0)}]
           set xp2 [expr {round($fontsize/-5.0)}]
           set advance 1
       }
       "^" { # Superscript
           if {$render(subFont) eq ""} {
               set render(superFont) [font create {*}[font configure $font]]
               set fontsize [font configure $font -size]
               set fontsize [expr {round($fontsize * 3.0/5.0)}]
               font configure $render(superFont) -size $fontsize
           } else {
               set fontsize [$render(superFont) configure -size]
           }
           set tmpFont $render(superFont)
           set yp1 [expr {round($fontsize/-1.5)}]
           set yp2 [expr {-1 * $yp1}]
           set xp1 [expr {round($fontsize/-5.0)}]
           set xp2 [expr {round($fontsize/-5.0)}]
           set advance 1
       }
       default {
           set tmpFont $font
       }
   }
   return [list $xp1 $yp1 $xp2 $yp2 $advance $tmpFont]
}