chartit / django-chartit

A Django app to plot charts and pivot charts directly from the models. Uses HighCharts and jQuery JavaScript libraries to render the charts on the webpage.
http://django-chartit.mrsenko.com/
Other
492 stars 166 forks source link

Support for RawQuerySet #44

Closed someidiot closed 7 years ago

someidiot commented 7 years ago

Is this possible? Sometimes the ORM just can't do what I need and a raw query is the easiest way to go.

atodorov commented 7 years ago

@someidiot I will have to look a bit more into the code to verify whether or not this is possible but the straight out answer is no. chartit is very tightly coupled to QuerySet and it's API. It does use said API for validation and field lookups. This is making it very hard to add functionality that doesn't conform to QuerySet. Right now I'm thinking about refactoring quite a few pieces of the code to allow for more flexibility but haven't had the time to do so in the last month.

Let me get back to you on the RawQuerySet support in a week or so, it may turn out less trickier than I think.

someidiot commented 7 years ago

Thanks. It's no biggie, just trying to avoid having two different charting methods in my code, it would be nice to use this for everything.

atodorov commented 7 years ago

@someidiot I have good news for you. I've managed to get a working support for RawQuerySet for Chart type of charts. Haven't looked into PivotChart yet, bout should be similar. The main change was that I needed to get rid of QuerySet.values() internally and make use of objects instead of dictionaries. However this is something I've been wanting to do for a while now.

Can you checkout my fork + topic branch, give it a try and let me know how that works for you? Also see the demoproject/ for some usage examples. I'm planning to release to PyPI very soon if this works for you.