simplecharts

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

commit
6b09cf7618522123f19d0594dbce4c45d658f1eb
parent
14ce5dafb265f76e370567bf95ae132d690f8c01
Author
Tobias Bengfort <bengfort@mpib-berlin.mpg.de>
Date
2025-04-24 16:14
set font-size and font-family

Diffstat

M simplecharts.py 5 +++++
M tests/no-legend_ColumnRenderer.svg 2 +-
M tests/no-legend_LineRenderer.svg 2 +-
M tests/no-legend_StackedAreaRenderer.svg 2 +-
M tests/no-legend_StackedColumnRenderer.svg 2 +-
M tests/simple_ColumnRenderer.svg 2 +-
M tests/simple_LineRenderer.svg 2 +-
M tests/simple_StackedAreaRenderer.svg 2 +-
M tests/simple_StackedColumnRenderer.svg 2 +-
M tests/single_ColumnRenderer.svg 2 +-
M tests/single_LineRenderer.svg 2 +-
M tests/single_StackedAreaRenderer.svg 2 +-
M tests/single_StackedColumnRenderer.svg 2 +-

13 files changed, 17 insertions, 12 deletions


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

@@ -27,6 +27,7 @@ class BaseRenderer:
   27    27         self.colors = colors
   28    28         self.ui_color = ui_color
   29    29 
   -1    30         self.font_size = 16
   30    31         self.char_width = 10
   31    32         self.char_padding = 4
   32    33         self.x_labels = self.char_width * 5
@@ -178,6 +179,10 @@ class BaseRenderer:
  178   179             content,
  179   180             xmlns='http://www.w3.org/2000/svg',
  180   181             viewBox=self.get_view_box(),
   -1   182             **{
   -1   183                 'font-size': self.font_size,
   -1   184                 'font-family': 'sans-serif',
   -1   185             },
  181   186         )
  182   187 
  183   188 

diff --git a/tests/no-legend_ColumnRenderer.svg b/tests/no-legend_ColumnRenderer.svg

@@ -1,4 +1,4 @@
    1    -1 <svg viewBox="-55 -25 700 530" xmlns="http://www.w3.org/2000/svg">
   -1     1 <svg font-family="sans-serif" font-size="16" viewBox="-55 -25 700 530" xmlns="http://www.w3.org/2000/svg">
    2     2 	<g role="table">
    3     3 		<line stroke="#333" x1="0" x2="0" y1="0" y2="480" />
    4     4 		<line stroke="#333" x1="0" x2="640" y1="480" y2="480" />

diff --git a/tests/no-legend_LineRenderer.svg b/tests/no-legend_LineRenderer.svg

@@ -1,4 +1,4 @@
    1    -1 <svg viewBox="-55 -25 700 530" xmlns="http://www.w3.org/2000/svg">
   -1     1 <svg font-family="sans-serif" font-size="16" viewBox="-55 -25 700 530" xmlns="http://www.w3.org/2000/svg">
    2     2 	<g role="table">
    3     3 		<line stroke="#333" x1="0" x2="0" y1="0" y2="480" />
    4     4 		<line stroke="#333" x1="0" x2="640" y1="480" y2="480" />

diff --git a/tests/no-legend_StackedAreaRenderer.svg b/tests/no-legend_StackedAreaRenderer.svg

@@ -1,4 +1,4 @@
    1    -1 <svg viewBox="-55 -25 700 530" xmlns="http://www.w3.org/2000/svg">
   -1     1 <svg font-family="sans-serif" font-size="16" viewBox="-55 -25 700 530" xmlns="http://www.w3.org/2000/svg">
    2     2 	<g role="table">
    3     3 		<line stroke="#333" x1="0" x2="0" y1="0" y2="480" />
    4     4 		<line stroke="#333" x1="0" x2="640" y1="480" y2="480" />

diff --git a/tests/no-legend_StackedColumnRenderer.svg b/tests/no-legend_StackedColumnRenderer.svg

@@ -1,4 +1,4 @@
    1    -1 <svg viewBox="-55 -25 700 530" xmlns="http://www.w3.org/2000/svg">
   -1     1 <svg font-family="sans-serif" font-size="16" viewBox="-55 -25 700 530" xmlns="http://www.w3.org/2000/svg">
    2     2 	<g role="table">
    3     3 		<line stroke="#333" x1="0" x2="0" y1="0" y2="480" />
    4     4 		<line stroke="#333" x1="0" x2="640" y1="480" y2="480" />

diff --git a/tests/simple_ColumnRenderer.svg b/tests/simple_ColumnRenderer.svg

@@ -1,4 +1,4 @@
    1    -1 <svg viewBox="-55 -25 700 530" xmlns="http://www.w3.org/2000/svg">
   -1     1 <svg font-family="sans-serif" font-size="16" viewBox="-55 -25 700 530" xmlns="http://www.w3.org/2000/svg">
    2     2 	<g role="table">
    3     3 		<line stroke="#333" x1="0" x2="0" y1="0" y2="480" />
    4     4 		<line stroke="#333" x1="0" x2="640" y1="480" y2="480" />

diff --git a/tests/simple_LineRenderer.svg b/tests/simple_LineRenderer.svg

@@ -1,4 +1,4 @@
    1    -1 <svg viewBox="-55 -25 700 530" xmlns="http://www.w3.org/2000/svg">
   -1     1 <svg font-family="sans-serif" font-size="16" viewBox="-55 -25 700 530" xmlns="http://www.w3.org/2000/svg">
    2     2 	<g role="table">
    3     3 		<line stroke="#333" x1="0" x2="0" y1="0" y2="480" />
    4     4 		<line stroke="#333" x1="0" x2="640" y1="480" y2="480" />

diff --git a/tests/simple_StackedAreaRenderer.svg b/tests/simple_StackedAreaRenderer.svg

@@ -1,4 +1,4 @@
    1    -1 <svg viewBox="-55 -25 700 530" xmlns="http://www.w3.org/2000/svg">
   -1     1 <svg font-family="sans-serif" font-size="16" viewBox="-55 -25 700 530" xmlns="http://www.w3.org/2000/svg">
    2     2 	<g role="table">
    3     3 		<line stroke="#333" x1="0" x2="0" y1="0" y2="480" />
    4     4 		<line stroke="#333" x1="0" x2="640" y1="480" y2="480" />

diff --git a/tests/simple_StackedColumnRenderer.svg b/tests/simple_StackedColumnRenderer.svg

@@ -1,4 +1,4 @@
    1    -1 <svg viewBox="-55 -25 700 530" xmlns="http://www.w3.org/2000/svg">
   -1     1 <svg font-family="sans-serif" font-size="16" viewBox="-55 -25 700 530" xmlns="http://www.w3.org/2000/svg">
    2     2 	<g role="table">
    3     3 		<line stroke="#333" x1="0" x2="0" y1="0" y2="480" />
    4     4 		<line stroke="#333" x1="0" x2="640" y1="480" y2="480" />

diff --git a/tests/single_ColumnRenderer.svg b/tests/single_ColumnRenderer.svg

@@ -1,4 +1,4 @@
    1    -1 <svg viewBox="-55 -25 700 530" xmlns="http://www.w3.org/2000/svg">
   -1     1 <svg font-family="sans-serif" font-size="16" viewBox="-55 -25 700 530" xmlns="http://www.w3.org/2000/svg">
    2     2 	<g role="table">
    3     3 		<line stroke="#333" x1="0" x2="0" y1="0" y2="480" />
    4     4 		<line stroke="#333" x1="0" x2="640" y1="480" y2="480" />

diff --git a/tests/single_LineRenderer.svg b/tests/single_LineRenderer.svg

@@ -1,4 +1,4 @@
    1    -1 <svg viewBox="-55 -25 700 530" xmlns="http://www.w3.org/2000/svg">
   -1     1 <svg font-family="sans-serif" font-size="16" viewBox="-55 -25 700 530" xmlns="http://www.w3.org/2000/svg">
    2     2 	<g role="table">
    3     3 		<line stroke="#333" x1="0" x2="0" y1="0" y2="480" />
    4     4 		<line stroke="#333" x1="0" x2="640" y1="480" y2="480" />

diff --git a/tests/single_StackedAreaRenderer.svg b/tests/single_StackedAreaRenderer.svg

@@ -1,4 +1,4 @@
    1    -1 <svg viewBox="-55 -25 700 530" xmlns="http://www.w3.org/2000/svg">
   -1     1 <svg font-family="sans-serif" font-size="16" viewBox="-55 -25 700 530" xmlns="http://www.w3.org/2000/svg">
    2     2 	<g role="table">
    3     3 		<line stroke="#333" x1="0" x2="0" y1="0" y2="480" />
    4     4 		<line stroke="#333" x1="0" x2="640" y1="480" y2="480" />

diff --git a/tests/single_StackedColumnRenderer.svg b/tests/single_StackedColumnRenderer.svg

@@ -1,4 +1,4 @@
    1    -1 <svg viewBox="-55 -25 700 530" xmlns="http://www.w3.org/2000/svg">
   -1     1 <svg font-family="sans-serif" font-size="16" viewBox="-55 -25 700 530" xmlns="http://www.w3.org/2000/svg">
    2     2 	<g role="table">
    3     3 		<line stroke="#333" x1="0" x2="0" y1="0" y2="480" />
    4     4 		<line stroke="#333" x1="0" x2="640" y1="480" y2="480" />