This fork of Bokeh gets the bounding boxes of drawn primitives.
It is based on Bokeh version 0.12.6.
Bokeh is very easy to use and extend, and has no dependency on matplotlib.
At a high-level, here's how the library works:
-
The figure is defined in Python. Source code lives in the Bokeh Python library (bokeh/bokeh).
- Make sure you add
name
attributes to the different parts of your figure. - Use the
export_png_and_data
function from bokeh.io to get the PNG and a Python dict of the bounding box data. - See the examples in
bokeh/bokeh/example_graphs
.
- Make sure you add
-
The Bokeh Python library calls the Bokeh JavaScript library (bokeh/bokehjs) which renders the plot to a canvas using a headless browser, then exports this to a PNG.
- The Python lib generates an HTML file with JSON defining the figure.
- The JS lib takes the HTML file and renders it in a headless browser (PhantomJS).
- The JS lib renders the figure (model-view coffeescript, like Backbone.js) and performs the drawing to canvas.
- While drawing, the JS lib calculates bounding boxes, associates them with names defined in the Python figure, and saves these annotations to localStorage in PhantomJS.
- The Python lib then grabs the data from the PhantomJS webdriver's localStorage.
Note: there's no need to install the requirements from requirements.txt
if you run setup.py
.
- If on Linux, install these packages:
libfontconfig
(e.g.sudo apt-get install libfontconfig
).zlib
(e.g.sudo apt-get install zlib1g-dev
)libjpeg
(e.g.sudo apt-get install libjpeg-dev
)
- Install NodeJS LTS from here. These instructions are based on Node version 11.15.0. Note that this won't build with node > 11 because of a gulp issue.
npm install -g phantomjs-prebuilt
to install PhantomJS globally. This may have to be done insudo
orAdministrator
mode.- Make sure the PhantomJS executable is on your PATH. On Windows, I found mine in
C:\Users\<user>\AppData\Roaming\npm\node_modules\phantomjs-prebuilt\lib\phantom\bin
. - Clone this repo or unzip the source from the release page.
cd bokeh/bokehjs
.npm install
.cd ../bokeh
.python setup.py install --build-js
See the Bokeh developer guide here.
To use changes to both the Bokeh Python and JS libs, you need to run either
python setup.py develop --build-js
(to build the JS bundle fresh and include it in the Python library) orpython setup.py develop --install-js
(to use the last built JS bundle)
every time you want to use new Bokeh JS changes with the Bokeh Python library.
I.e. if you've made changes to the JS files and want to test them with the Python lib, you need to run python setup.py develop --build-js
again to package the latest JS lib into the Python lib.
If you've made changes to the Python files only, and run python setup.py develop --build-js/--install-js
once, you don't need to do anything more.
Your Bokeh Python changes will be picked up immediately.
cd bokeh/bokehjs
gulp watch
if you want to recompile on new changes, orgulp dev-build
to build an un-minified bundle.
You can run gulp watch
to rebuild the library in dev mode everytime bokeh/bokehjs/src files are modified.
To use this bundle right away, you can use a modified HTML file generated by the Python lib. This can be done with a reference to the generated bundle in the build directory using a script tag like <script type="text/javascript" src="build/js/bokeh.js"></script>
. This will pick up the latest bundle genenerated by gulp.
This lets you analyze console errors and debug faster than rebuilding the whole Bokeh library every time.
See the samples in the bokeh/bokeh/example_graphs
directory to see how you can generate one of these files.
Some examples are provided in bokeh/bokeh/example_graphs
.
Latest Release | |
License | |
Build Status | |
Conda | |
PyPI | |
Gitter | |
Bokeh, a Python interactive visualization library, enables beautiful and meaningful visual presentation of data in modern web browsers. With Bokeh, you can quickly and easily create interactive plots, dashboards, and data applications.
Bokeh helps provide elegant, concise construction of novel graphics in the style of D3.js, while also delivering high-performance interactivity over very large or streaming datasets.
Visit the Bokeh web page for information and full documentation.
To contribute to Bokeh, please review the Developer Guide.
Follow us on Twitter @bokehplots and on YouTube.