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

The use of 'use_decimal' assumes simplejson #3

Closed wraithan closed 8 years ago

wraithan commented 12 years ago

In the template tag load_charts on line 70 there is use_decimals=True in dumps(). The library uses django's simplejson which gracefully falls back to python's built in json lib which does not have a use_decimals argument to its dumps().

pgollakota commented 12 years ago

I should really just make simplejson a requirement for django_chartit, because not using decimals makes it too complicated. I will add it to requirements.

blades commented 12 years ago

alternatively, change the import statement like this:

try: import simplejson except ImportError: try: import json as simplejson except ImportError: from django.utils import simplejson

seems to work for me to get around that particular error, although i get a new error now ("datetime.datetime(2012, 2, 17, 7, 24, 55, tzinfo=) is not JSON serializable").

amibenson commented 12 years ago

I got the same error: "datetime.date(2012, 5, 22) is not JSON serializable". I am trying to use a DateField on the x-axis instead of the "Month" integer type field used on http://chartit.shutupandship.com/demo/chart/scatter-plot/ and this is what causes the error.

Could someone please explain how can I display the chart using a DateField on the X-Axis?

pgollakota commented 12 years ago

Unfortunately Chartit still does not support datetime objects as axes.

ghost commented 11 years ago

Is there any way around the datetime issue?

atodorov commented 10 years ago

FYI chartit imports simplejson form django.utils.simplejson, not directly. And this is what latest Django says:

warnings.warn("django.utils.simplejson is deprecated; use json instead.", DeprecationWarning, stacklevel=2)

supritashankar commented 10 years ago

@pgollakota if you put simplejson in requirements. You need to change the import too. "import simplejson"