Skip to content

pylib: add api support for grids and docs #98

Description

@sondove

As we are nearing alpha release of novem grids and docs it would make sense to add them to the python library.

I've outlined an api design below that is similar to how Mail is currently implemented and also stays close to existing paradigms and the cli.

from novem import Plot, Grid, Doc
from novem.grid import GridMap
from novem.doc import MarkdownPage as M, GridPage as G, VisPage as V

# create grid
grd = Grid("r1_g1")

# define layout using novem ascii style
grd.layout = """
+-----------+
|   {a:-}   |
+-----------+
|   {b:-}   |
+-----+-----+
|{c:-}|{d:-}|
+-----+-----+
"""

# map existing visualisations to grid elements
grd.mapping = GridMap({
    'a':Plot("r1_p1_table_1"),
    'b':Plot("r1_p1_table_2"),
    'c':Plot("r1_p1_pie_1"),
    'd':Plot("r1_p1_pie_2"),
})

# create doc
doc = Doc("r1_doc")

# insert grid and plots into page views
doc.add_page(G(grd))
doc.add_page(V(Plot("r1_p2_table")))
doc.add_page(V(Plot("r1_p3_table")))

doc.theme = 'novem'            # use novem theme
doc.orientation = 'landscape'  # make it landscape
doc.type = 'document'          # we want the document style layout

# render document to server
doc.render()

# get the url to the doc
print(doc.url)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions