simplecharts

SVG charts without dependencies
git clone https://git.ce9e.org/simplecharts.git

commit
0da1f1902e2a2011b08330b680510d424388e645
parent
093abd4772e7c1faa632785da32efedf6de5364f
Author
Tobias Bengfort <tobias.bengfort@posteo.de>
Date
2020-01-10 13:11
support float values

Diffstat

M simplecharts.py 7 +++----
M test.py 2 ++

2 files changed, 5 insertions, 4 deletions


diff --git a/simplecharts.py b/simplecharts.py

@@ -1,5 +1,6 @@
    1     1 import argparse
    2     2 import csv
   -1     3 import math
    3     4 import sys
    4     5 from xml.sax.saxutils import escape
    5     6 
@@ -7,10 +8,8 @@ COLORS = ['#e41a1c', '#377eb8', '#4daf4a', '#984ea3', '#ff7f00', '#ffff33']
    7     8 
    8     9 
    9    10 def round_max(value):
   10    -1     s = str(value)
   11    -1     head = int(s[0])
   12    -1     tail = 10 ** (len(s) - 1)
   13    -1     head += 1
   -1    11     tail = 10 ** math.floor(math.log(value, 10))
   -1    12     head = int(value / tail) + 1
   14    13     if head & 1:
   15    14         head += 1
   16    15     return head * tail

diff --git a/test.py b/test.py

@@ -52,3 +52,5 @@ for fn in os.listdir(DIR):
   52    52 test_round_max(10, 20)
   53    53 test_round_max(9, 10)
   54    54 test_round_max(9000, 10000)
   -1    55 test_round_max(0.01, 0.02)
   -1    56 test_round_max(0.003, 0.004)