matthisk / django-jchart

📈 A Django package for plotting charts using the excellent Chart.JS library.
BSD 3-Clause "New" or "Revised" License
121 stars 23 forks source link

examples don't render properly (as advertised) #23

Open ursomniac opened 5 years ago

ursomniac commented 5 years ago

I've installed everything, and started by copying examples. At first I thought this was a miracle (because the setup is so easy and the instructions are so well-written). But then I realized: not one of the example plots (at my end) is rendering properly.

Basically for every 'line' style plot, you get the first two data points stretched out over the entire horizontal part of the plot, no axis labels. The y-axis appears correct.

Since I'm using the exact code you have (for even the 'data': [69, 30, 45, 60, 55] example which is very simple, I don't understand what's missing.

class LineChartTest1(Chart):
    chart_type = 'line'

    def get_datasets(self, **kwargs):
        return [{
            'label': "My Dataset",
            'data': [69, 30, 45, 60, 55]
        }]

screen shot 2018-12-26 at 16 05 56

View code:

class Test1View(TemplateView):
    template_name = 'analysis/test1.html'

    def get_context_data(self, **kwargs):
        context = super(Test1View, self).get_context_data(**kwargs)
        context['line_chart'] = charts.LineChartTest1()
        return context

Template code:

{% extends "base.html" %}

{% block content %}
<h1> I am a test page! </h1>
<div style="width: 600px;">
{{ line_chart.as_html }}
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.4.0/Chart.bundle.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
{% endblock content %}

Any suggestions would be greatly appreciated.