Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Can't use model properties in chartit #35
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...
@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 - 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.
added a commit
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.