agiliq / django-graphos

Django charting made *really* easy.
http://agiliq.com/demo/graphos
BSD 2-Clause "Simplified" License
442 stars 97 forks source link

NameError: name 'LineChart' is not defined #20

Closed thecristen closed 8 years ago

thecristen commented 10 years ago

Struggling to incorporate graphos with the little documentation that is available... please help.

luzfcb commented 10 years ago

Show me the code that this error resulted

rustycar54 commented 10 years ago

Well, I'm not thecristen, but I too am having a bad time getting this to work. Here's the code:

from django.http import HttpResponse ... from django.template import RequestContext, loader from django import forms from graphos.sources.simple import SimpleDataSource from graphos.renderers import gchart

...

def do_graph(request):

get data

data = [
    ['Year', 'Sales', 'Expenses'],
    ['2004', 1000, 400],
    ['2005', 1170, 460],
    ['2006', 660, 1120],
    ['2007', 1030, 540]
    ]
chart = gchart.LineChart(SimpleDataSource(data=data), html_id="Line Chart")
context = RequestContext( request, {'chart':chart.as_html(),'data':data})
template = loader.get_template('s3_numbers/do_graph.html')
return HttpResponse(template.render(context))

my template is basically '{{chart}}' (I also dump the data so that I know the template is actually getting used).

The output? A blank page (with the data dumped below some white space).

Oh, while I'm here I should mention that the tutorial is misleading (or at least, I certainly was unable to copy and paste it - I had to go look at the test code to figure the above out). The tutorial says you can use 'LineChart(...)', which of course doesn't work unless you do something more than the tutorial gives.

akshar-raaj commented 8 years ago

@thecristen @rustycar54 We have updated README.md with proper documentation. Your issue should be resolved after following the readme file