views:

36

answers:

0

Hi,

I'm trying to generate some charts using django-googlecharts. This works fine for rather static data but in one case I would like to render a different number of lines, based on a variable. I tried this:

  {% chart %}
   {% for line in line_data %}
    {% chart-data line %}
   {% endfor %}
   {% chart-size "390x200" %}
   {% chart-type "line" %}
   {% chart-labels days %}
  {% endchart %}

Line data is a list containing lists. The template code fails with "Caught an exception while rendering: max() arg is an empty sequence".

I guess the problem is that I try to loop over templatetags. What approach could be used here? Or am I completely missing something? Is this doable using inclusion tags?

Thanks for your help.

@msw:

line-data looks something like this:

[
[0, 10, 10, 10, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 
[0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 
[0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
]

and I'm using render_to_response this way:

return render_to_response('chart_line.html', {'days': days, 'line_data': line_data})