Giter Club home page Giter Club logo

Comments (4)

GjjvdBurg avatar GjjvdBurg commented on June 18, 2024 1

Here's the patch for timeline_kit_1.py:

diff --git a/examples/timeline_kit_1.py b/examples/timeline_kit_1.py
index 8ebf35f..8efd591 100644
--- a/examples/timeline_kit_1.py
+++ b/examples/timeline_kit_1.py
@@ -14,7 +14,7 @@ def main():
         {
             "time": date(1980, 4, 17),
             "episode": 5,
-            "text": "The Empire Strikes Back",
+            "text": "\\href{https://gertjan.dev}{gertjan.dev}",
         },
         {
             "time": date(1984, 4, 25),
@@ -56,7 +56,11 @@ def main():
         "labella": {
             "nodeHeight": 12,
         },
-        "latex": {"fontsize": "12pt", "reproducible": True},
+        "latex": {
+            "fontsize": "12pt",
+            "reproducible": True,
+            "preamble": "\\usepackage[hidelinks]{hyperref}",
+        },
     }
 
     tl = TimelineSVG(items, options=options)

This will only work for the PDF output, so disable TimelineSVG when testing.

from labella.py.

GjjvdBurg avatar GjjvdBurg commented on June 18, 2024 1

That's due to having only one label, try it with more than one and it'll work.

from labella.py.

SeaDude avatar SeaDude commented on June 18, 2024

Hm...

I'm getting:

Traceback (most recent call last):
  File "E:\dataDocuments\python\timeline_test\timeline.py", line 151, in <module>
    main()
  File "E:\dataDocuments\python\timeline_test\timeline.py", line 145, in main
    tl.export("timeline_kit_1.tex")
  File "E:\dataDocuments\python\timeline_test\.venv\lib\site-packages\labella\timeline.py", line 512, in 
export
    self.nodes, self.renderer = self.compute()
  File "E:\dataDocuments\python\timeline_test\.venv\lib\site-packages\labella\timeline.py", line 243, in 
compute
    nodes = self.get_nodes()
  File "E:\dataDocuments\python\timeline_test\.venv\lib\site-packages\labella\timeline.py", line 222, in 
get_nodes
    n = Node(self.timePos(it.data), it.width, data=it)
  File "E:\dataDocuments\python\timeline_test\.venv\lib\site-packages\labella\timeline.py", line 304, in 
timePos
    return self.options["scale"](self.options["timeFn"](thedict))
  File "E:\dataDocuments\python\timeline_test\.venv\lib\site-packages\labella\scale.py", line 507, in __call__
    return self._linear(dt2milli(x))
  File "E:\dataDocuments\python\timeline_test\.venv\lib\site-packages\labella\scale.py", line 380, in __call__
    return self._output(x)
  File "E:\dataDocuments\python\timeline_test\.venv\lib\site-packages\labella\scale.py", line 31, in <lambda>
    return lambda x: i(u(x))
  File "E:\dataDocuments\python\timeline_test\.venv\lib\site-packages\labella\scale.py", line 35, in <lambda>
    return lambda x: (x - a) / (b - a)
ZeroDivisionError: float division by zero

When using:

from datetime import date
from labella.timeline import TimelineTex

def main():
    items = [
        {
            "time": date(2021, 4, 1),
            "text": "\\href{https://gertjan.dev}{gertjan.dev}"
        }
    ]

    options = {
        "margin": {"left": 70, "right": 20, "top": 20, "bottom": 20},
        "initialWidth": 1300,
        "initialHeight": 1600,
        "direction": "right",
        "dotColor": "#000000",
        "labelBgColor": "#000000",
        "linkColor": "#000000",
        "textFn": lambda x: "{\LARGE %s -- %s}" % (x["time"].date(), x["text"]),
        "labelPadding": {"left": 2, "right": 0, "top": 2, "bottom": 0},
        "labella": {
            "nodeHeight": 12,
        },
        "latex": {
            "fontsize": "12pt",
            "reproducible": True,
            "preamble": "\\usepackage[hidelinks]{hyperref}",
        }
    }

    tl = TimelineTex(items, options=options)
    tl.export("timeline_kit_1.tex")

if __name__ == "__main__":
    main()

from labella.py.

SeaDude avatar SeaDude commented on June 18, 2024

You got it! Adding a second node did the trick!

Thank you so much for all the support! Cool project!

from labella.py.

Related Issues (15)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.