altair + okab = static beauty
Project description
Okab
altair + okab = static beauty
Install
Okab is available with pip but it is currently in an alpha release as the API is under active development.
Wheels are also available from the releases.
pip install okab
Usage
As an altair-saver method
To get started using okab you can directly access it's altair_saver compatible method.
Note: Okab as a python library at present still has a runtime dependency on altair_saver but this may change in future releases.
import altair as alt
from okab.saver import OkabSaver
...
chart.save("chart.png",method=OkabSaver,scale_factor=2)
As a standalone CLI
You can provide either vega-lite or vega specs, please specify the --mode to match your spec type, by default okab expects vega-lite.
okab -i bar.vl.json -o chart.png
See okab -h for a list of options.
Results
| svg | png | png (scale factor 5) |
|---|---|---|
Compiling the Wheels
Currently the wheel generation is highly dependent on make.
To get started you can bootstrap your environment.
This rule will generate a virtual environment,
install the python and node dependencies,
and the liberation sans font.
make bootstrap
In order to build the wheels we will need to compile the okab js backend into standalone executables for all supported targets.
You can do this ahead of time or as the wheels are built.
Regardless, you'll need to have installed vercel/pkg.
npm install -g pkg
If you'd just like to compile a single wheel for your platform you can specify the target to compile the backend.
TARGET=macosx_10_14_x86_64 make single-wheel
To generate all supported platform wheels:
make wheels
How does it work?
We leverage vercel/pkg and distribute self-contained platform-specific executables within the python wheels.
This takes the problems of installing and setting up the needed backends from the user and leaves it to a well crafted CI.
First we need access to the libraries that render our visualizations vega & vega-lite.
We can use the vega API to generate a view and easily convert this to svg.
Generating appropriate png is a different problem. The vega view API can return an svg or canvas object.
In the browser this uses HTML canvas, server-side they rely on node-canvas.
This works fine in a properly configured node environment,
but canvas has a number of system dependencies and caveats that make packaging it with vercel/pkg a problem.
Instead, we can take advantage of a different svg rendering library RazrFalcon/resvg and yisibl/resvg-js.
Acknowledgements
This app is made possible by these great open source projects.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file okab-22.8a1-py3-none-win_amd64.whl.
File metadata
- Download URL: okab-22.8a1-py3-none-win_amd64.whl
- Upload date:
- Size: 22.1 MB
- Tags: Python 3, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b89852a623dd61bb7e00440f50031f7f6a2522510648ae59148fd5f2789dd262
|
|
| MD5 |
2b3a3b3442be816c871c580a9da0e3f1
|
|
| BLAKE2b-256 |
c7af5cd1feecbcce1058b74f4c7c2cb5b9808e3750d2b6bebf85e2e16f7071dc
|
File details
Details for the file okab-22.8a1-py3-none-manylinux_2_17_x86_64.whl.
File metadata
- Download URL: okab-22.8a1-py3-none-manylinux_2_17_x86_64.whl
- Upload date:
- Size: 25.6 MB
- Tags: Python 3, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
64be9bf83ac31f6f54340998f7e2751b22634a166c12c00458cf6edf594bddcf
|
|
| MD5 |
6d6870a2bbf11cc154d2fd21f52f1868
|
|
| BLAKE2b-256 |
d71f56e2880858a1a7535c665fb6b3b4ef888bfec95da9e0fe39f09258ce8952
|
File details
Details for the file okab-22.8a1-py3-none-macosx_10_14_x86_64.whl.
File metadata
- Download URL: okab-22.8a1-py3-none-macosx_10_14_x86_64.whl
- Upload date:
- Size: 25.6 MB
- Tags: Python 3, macOS 10.14+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2deb52b7bc1762be9826738811ba1749925bfb4839ab0c85a553337554f67b10
|
|
| MD5 |
8c61eb955b02d54ed3c2e1e62af87a02
|
|
| BLAKE2b-256 |
ce091d4e5b22a1dcec7e72520e1dc56e6f2e1dbdd2e6f5cec440ec320aa85ac6
|