Skip to content

Commit

Permalink
Merge branch 'master' of github.com:Kozea/pygal
Browse files Browse the repository at this point in the history
  • Loading branch information
paradoxxxzero committed May 9, 2016
2 parents 2e7689a + 0a98f33 commit f966497
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
27 changes: 26 additions & 1 deletion docs/documentation/output.rst
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ If pyquery is installed you can get the pyquery object wrapping the chart by cal
chart.render_pyquery() # Return pyquery object
Flask response
Flask App
--------------

If you are using pygal in a flask app the ``render_response`` may come in handy:
Expand All @@ -121,6 +121,31 @@ If you are using pygal in a flask app the ``render_response`` may come in handy:
...
return chart.render_response()
An other way is to use a Base 64 data URI for your flask app.

In python file:

.. code-block:: python
@app.route('/charts/')
def line_route():
chart = pygal.Line()
...
chart = chart.render_data_uri()
return render_template( 'charts.html', chart = chart)
In HTML file:

.. code-block:: html

<!-- Don't forget the "|safe"! -->
<div id="chart">
<embed type="image/svg+xml" src= {{ chart|safe }} />
</div>




Django response
---------------
Expand Down
2 changes: 1 addition & 1 deletion docs/documentation/web.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Embedding in a web page
Within an embed tag
-------------------

First setup an url entry point for you svg: ``/mysvg.svg`` don't forget to set the mime-type to ``image/svg+xml``. (If you are using flask you can use the ``render_response`` method.)
First set up an url entry point for your svg: ``/mysvg.svg`` don't forget to set the mime-type to ``image/svg+xml``. (If you are using flask you can use the ``render_response`` method.)

Then in your html put an embed tag like this:

Expand Down

0 comments on commit f966497

Please sign in to comment.