diff options
author | Eugeniy E. Mikhailov <evgmik@gmail.com> | 2018-05-10 23:44:03 -0400 |
---|---|---|
committer | Eugeniy E. Mikhailov <evgmik@gmail.com> | 2018-05-10 23:47:40 -0400 |
commit | e9d4c779a3b9583e0e9de004df77650119e320d8 (patch) | |
tree | 6b7a1b8775fa984a581c6e89a7b4e7ed340b171a /GradeBook_lib.tcl | |
parent | 60dc2f0475ac932d72a572c039da1078bd568b6c (diff) | |
download | GradeBook-e9d4c779a3b9583e0e9de004df77650119e320d8.tar.gz GradeBook-e9d4c779a3b9583e0e9de004df77650119e320d8.zip |
offload text plotting to separate library
Diffstat (limited to 'GradeBook_lib.tcl')
-rwxr-xr-x | GradeBook_lib.tcl | 25 |
1 files changed, 1 insertions, 24 deletions
diff --git a/GradeBook_lib.tcl b/GradeBook_lib.tcl index b4035c3..89206b7 100755 --- a/GradeBook_lib.tcl +++ b/GradeBook_lib.tcl @@ -7,6 +7,7 @@ exec tclsh "$0" "$@" package require Tcl 8.5 package require math::statistics +source ./txtPlot.tcl source ./libBasicTableOperations.tcl # internal version of this code @@ -2300,30 +2301,6 @@ proc UpdateAndCreateAsNeededInfoRow { columnname inforow val } { UpdateColValue4UserNameNonWeb $columnname $inforow $val } -proc data2txtPlot { data } { - set maxVal [::math::statistics::max $data ] - set minVal [::math::statistics::min $data ] - set diffVal [expr {$maxVal-$minVal}] - set chars {▁ ▂ ▃ ▄ ▅ ▆ ▇ █}; # 8 bars - if { $diffVal == 0 } { - set diffVal 1 - set chars {▄}; # if all values are the same use mid bar - } - set barsNum [llength $chars]; - foreach x $data { - # funky 1.1 are needed to convert it to floats - set cnt [expr { round((1.0*$x-$minVal)/(1.1*$diffVal)*(1.1*($barsNum-1.0))) }] - - # safety check on counter value - set cnt [expr {min($cnt, ($barsNum-1))}] - set cnt [expr {max($cnt, 0)}] - - set bar [lrange $chars $cnt $cnt] - lappend strPlot $bar - } - return [join $strPlot ""] -} - proc UpdateColumnGradesHistogram { columnname } { # find maximum in the column with a given name among active students set hist "N/A" |