peopledoc / django-chartjs

Django Class Based Views to generate Ajax charts js parameters.
Other
407 stars 112 forks source link

How to get data? #40

Closed ambigus9 closed 4 years ago

ambigus9 commented 6 years ago

I have a JSON file returned by another function in my "views.py" file and I'm trying to pass this JSON data to ChartMixin class, but I can't find a good way to do this, Any idea?

def simple_upload(request):
        ......
        return render(request, 'core/my_web.html', {'result_json' : result_json})

And this is the ChartMixin class:


class ChartMixin(object):
     def get_labels(self):
        """Return 7 labels."""
        return ["January", "February", "March", "April", "May", "June", "July"]

    def get_data(self):
        """Return 3 random dataset to plot."""
        def data():
            """Return 7 randint between 0 and 100."""
            return [randint(0, 100) for x in range(7)]