Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting blank chart when trying to use ModelDataSource #21

Closed
ShiftyRat opened this issue Sep 18, 2014 · 2 comments
Closed

Getting blank chart when trying to use ModelDataSource #21

ShiftyRat opened this issue Sep 18, 2014 · 2 comments
Assignees

Comments

@ShiftyRat
Copy link

I'm getting a blank chart when I'm trying to pull data from a Django model. Here is the relevant code:

views.py:

    queryset = HisCorOsCompliance.objects.filter(facility='ALL')
    data_source = ModelDataSource(queryset, fields=['server_compliance', 'date'],)                          
    chart = morris.LineChart(data_source)      
    context = {'chart':chart}  

    return render(request, 'portal/index.html',  context)

html:

        {% if chart %}
        {{ chart.as_html }}
        {% endif %}

I'm getting a large, blank chart as a result. I can verify that the query is working correctly. if I do a "print data" within the get_field_values function within model.py, the console prints all of the values that I'm trying to display.

I've been able to get a chart working by using the SimpleDataSource. I'm sure there's something really basic that I'm overlooking, but I'm having a really hard time figuring it out. Any help is appreciated!

@akshar-raaj akshar-raaj self-assigned this Jul 19, 2016
@akshar-raaj
Copy link
Member

@prophecy0 It seems like you haven't included morris.js in your html. Can you check your javascript console? Probably, you would see "Uncaught ReferenceError: Morris is not defined" on the console.

Your html file should look like:

<link rel="stylesheet" href="http://cdn.oesmith.co.uk/morris-0.4.3.min.css">
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/raphael/2.1.0/raphael-min.js"></script>
<script src="http://cdn.oesmith.co.uk/morris-0.4.3.min.js"></script>
{% if chart %}
{{chart.as_html}}
{% endif %} 

@akshar-raaj
Copy link
Member

@prophecy0 I belive my last comment should resolve your issue, so closing this issue. Please feel free to reopen the issue if it is not resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants