Skip to content
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

Generator for discontinuous datestamped data #43

Merged
merged 13 commits into from Jun 7, 2019

Conversation

cjohnson318
Copy link
Contributor

This generator is used when you want to plot non-continuous date-stamped data from a Django QuerySet. For example, you might have data spanning three weeks, but you're missing data for the weekends, and you want to express that those data points are missing.

In order to use this generator you would provide the start and end dates as either datetime.date objects, or strings with the format yyyy-mm-dd, the QuerySet of the model you're using, the name of the date attribute of the model, and the name of the value attribute of the model that you're interested in. If the QuerySet doesn't have a value for a particular date, then this generator yields a 'null'.

This generator is used when you want to plot non-continuous datestamped data. For
example, you might have data spanning three weeks, but you're missing data for the
weekends, and you want to express that those data points are missing. If a queryset
doesn't have a value for a particular date, then this generator yields a 'null'.
@cjohnson318 cjohnson318 requested a review from Natim as a code owner June 6, 2019 04:21
chartjs/util.py Show resolved Hide resolved
@Natim
Copy link
Collaborator

Natim commented Jun 6, 2019

Interesting work. Do you mind adding and example of how to use it as well as a couple of tests?

@cjohnson318
Copy link
Contributor Author

Thanks! Will do.

The docstring suggests that colors.next_color() should return a list,
and that the internal `step` variable should be initialized to 0,
rather than 1.
Since this feature utilizes data from a QuerySet, I needed to
generate a fixture, and then load that into the database in order
to implement a demo. To do this, I modified the Makefile with two
extra commands.
demo/demoproject/views.py Outdated Show resolved Hide resolved
demo/demoproject/tests.py Outdated Show resolved Hide resolved
Makefile Outdated Show resolved Hide resolved
Makefile Outdated
.PHONY: demo
demo-test:
test -d demo/venv || virtualenv demo/venv
demo/venv/bin/pip install -e demo
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is how you can fix your import hack.

Suggested change
demo/venv/bin/pip install -e demo
demo/venv/bin/pip install -e . demo

demo/demoproject/tests.py Outdated Show resolved Hide resolved
@Natim
Copy link
Collaborator

Natim commented Jun 7, 2019

Thank you for your work on this, I am merging.

@Natim Natim merged commit 0add51d into peopledoc:master Jun 7, 2019
@Natim
Copy link
Collaborator

Natim commented Jun 7, 2019

Released in django-chartjs 1.4.0

@cjohnson318
Copy link
Contributor Author

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants