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

Can't use model properties in chartit #35

Closed
luflow opened this Issue Feb 25, 2016 · 7 comments

Comments

Projects
None yet
4 participants
@luflow

luflow commented Feb 25, 2016

Hi everyone!

I tried to use chartit with a property in my model but then I get a "Field XYZ does not exist. Valid lookups are ..."

The main problem I wanted to solve was to format the date from the database for the x-Axis in a specific manner. Maybe there is another solution for this which I cant figure out at the moment? I already tried to use js options of chartit to reformat the date like documented here http://jsfiddle.net/gh/get/jquery/1.7.2/highslide-software/highcharts.com/tree/master/samples/highcharts/xaxis/datetimelabelformats/ but it seems as these options are only working on js date data and not with strings from the database...

@atodorov atodorov added the feature label Aug 9, 2016

@atodorov

This comment has been minimized.

Contributor

atodorov commented Aug 9, 2016

@krautnerds - formatting datetime fields should be possible on the DB level using extra(), please see the latest commits for examples.

Otherwise the possibility to chart using model properties is sounds great but it is not easy to implement at the moment. chartit relies heavily on QuerySet (in fact it uses QuerySet.values() to fetch the data) and this operates on the DB level. It may be possible to rewrite the model manager to allow for this but I'm not sure how well will that work.

@Sh4kE

This comment has been minimized.

Sh4kE commented Aug 18, 2016

In my case this would also be needed, because I want to compare two distinct querysets and show the computed diff. Or is there also another possibility to do this kind of tasks?

@ajurna

This comment has been minimized.

ajurna commented Sep 14, 2016

My problem stems from it using raw data from the DB so all my times are in utc with no good way to convert them to local time.

@atodorov

This comment has been minimized.

Contributor

atodorov commented Sep 14, 2016

@Sh4kE - can you elaborate more on your use case ? How do you imagine you will compare query sets with chartit ? Without any more info I think you can compute the diff between the two query sets and create a new one from it. Then pass the new QS to chartit for plotting on a chart.

@atodorov

This comment has been minimized.

Contributor

atodorov commented Sep 14, 2016

@ajurna datetime conversions should be now possible by using extra() or annotate() fields, see changelog and the examples in demo project. Let me know if that works for you ? Maybe we only need to update the docs to make this more visible.

@ajurna

This comment has been minimized.

ajurna commented Sep 14, 2016

timezone and strftime conversions are two very separate things...
doing both makes it look messy and makes it depend on a DB type which doesn't really suit me.

atodorov added a commit to MrSenko/django-chartit that referenced this issue Nov 24, 2016

@atodorov

This comment has been minimized.

Contributor

atodorov commented Nov 24, 2016

@krautnerds @Sh4kE @ajurna - hey guys I know I've been late to respond to this but I think I have finally managed to fix it. Following my changes related to #44 (removal of .values()) chartit now operates on objects instead of dictionaries and it was very easy to call a model property instead of a field.

Can you check out my fork + topic branch and tell me how that works for you? Note that the changes are only for DataPool, not PivotDataPool, which I'm planning to phase out.

@atodorov atodorov closed this in ef943b3 Dec 4, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment