2

I have the following include in a django html template file:

{% include 'categories_chart.svg' %}

However when a request is made and the page displayed, the tooltip on mouse hover has incomplete information - it only displays the value but not the title of the item. The issue is only within the requested HTML file; the actual svg file, when loaded separately, contains the proper information. Here is the tooltip within the svg file when it's opened separately:

enter image description here

And here is the incomplete tooltip in the Django browser response with that exact same svg file included:

enter image description here

Any idea what might be causing this? The tooltips seem to be messed up in more than just this one way in the Django response, but this is the most prominant and reproducible error so I'm focusing on it first.

user2390206
  • 123
  • 1
  • 9

1 Answers1

4

I managed to solve this by using a Base 64 data URI output instead of an SVG file. See the Paygal output page for information.

Just assign the output to a name, then render that name from your view to your html template, and embed the chart using context. So for example:

your_chart = pygal.Line() (chart code goes here) some_name = your_chart.render_data_uri()

then in your django view:

def charts_page(request): return render_to_response('charts_page.html', {'your_chart': some_name})

Finally, in your charts_page.html template:

<embed type="image/svg+xml" src= {{ your_chart|safe }} />

This will display all charts flawlessly and without tooltip errors.

user2390206
  • 123
  • 1
  • 9