kinegratii/django-echarts

前端渲染 k线图,bar图,地图,饼图,无法渲染,只有词云可以渲染

Closed this issue · 5 comments

这里时Django报错信息

[13/May/2018 16:39:03] "GET /options/simpleKLine/ HTTP/1.1" 500 17958
Internal Server Error: /options/simpleBar/
Traceback (most recent call last):
File "/home/tqw233/cycle/data/django-chartit/chart/lib/python3.5/site-packages/django/core/handlers/exception.py", line 35, in inner
response = get_response(request)
File "/home/tqw233/cycle/data/django-chartit/chart/lib/python3.5/site-packages/django/core/handlers/base.py", line 128, in _get_response
response = self.process_exception_by_middleware(e, request)
File "/home/tqw233/cycle/data/django-chartit/chart/lib/python3.5/site-packages/django/core/handlers/base.py", line 126, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/home/tqw233/cycle/data/django-chartit/chart/lib/python3.5/site-packages/django/views/generic/base.py", line 69, in view
return self.dispatch(request, *args, **kwargs)
File "/home/tqw233/cycle/data/django-chartit/chart/lib/python3.5/site-packages/django/views/generic/base.py", line 89, in dispatch
return handler(request, *args, **kwargs)
File "/home/tqw233/cycle/data/django-chartit/chart/lib/python3.5/site-packages/django_echarts/views/frontend.py", line 12, in get
return JsonResponse(data=echarts_instance.options, safe=False)
File "/home/tqw233/cycle/data/django-chartit/chart/lib/python3.5/site-packages/django/http/response.py", line 509, in init
data = json.dumps(data, cls=encoder, **json_dumps_params)
File "/usr/lib/python3.5/json/init.py", line 237, in dumps
**kw).encode(obj)
File "/usr/lib/python3.5/json/encoder.py", line 198, in encode
chunks = self.iterencode(o, _one_shot=True)
File "/usr/lib/python3.5/json/encoder.py", line 256, in iterencode
return _iterencode(o, 0)
File "/home/tqw233/cycle/data/django-chartit/chart/lib/python3.5/site-packages/django/core/serializers/json.py", line 104, in default
return super().default(o)
File "/usr/lib/python3.5/json/encoder.py", line 179, in default
raise TypeError(repr(o) + " is not JSON serializable")
TypeError: <pyecharts.echarts.label.NormalLabel object at 0x7f183e0ece10> is not JSON serializable
ERROR:django.request:Internal Server Error: /options/simpleBar/
Traceback (most recent call last):
File "/home/tqw233/cycle/data/django-chartit/chart/lib/python3.5/site-packages/django/core/handlers/exception.py", line 35, in inner
response = get_response(request)
File "/home/tqw233/cycle/data/django-chartit/chart/lib/python3.5/site-packages/django/core/handlers/base.py", line 128, in _get_response
response = self.process_exception_by_middleware(e, request)
File "/home/tqw233/cycle/data/django-chartit/chart/lib/python3.5/site-packages/django/core/handlers/base.py", line 126, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/home/tqw233/cycle/data/django-chartit/chart/lib/python3.5/site-packages/django/views/generic/base.py", line 69, in view
return self.dispatch(request, *args, **kwargs)
File "/home/tqw233/cycle/data/django-chartit/chart/lib/python3.5/site-packages/django/views/generic/base.py", line 89, in dispatch
return handler(request, *args, **kwargs)
File "/home/tqw233/cycle/data/django-chartit/chart/lib/python3.5/site-packages/django_echarts/views/frontend.py", line 12, in get
return JsonResponse(data=echarts_instance.options, safe=False)
File "/home/tqw233/cycle/data/django-chartit/chart/lib/python3.5/site-packages/django/http/response.py", line 509, in init
data = json.dumps(data, cls=encoder, **json_dumps_params)
File "/usr/lib/python3.5/json/init.py", line 237, in dumps
**kw).encode(obj)
File "/usr/lib/python3.5/json/encoder.py", line 198, in encode
chunks = self.iterencode(o, _one_shot=True)
File "/usr/lib/python3.5/json/encoder.py", line 256, in iterencode
return _iterencode(o, 0)
File "/home/tqw233/cycle/data/django-chartit/chart/lib/python3.5/site-packages/django/core/serializers/json.py", line 104, in default
return super().default(o)
File "/usr/lib/python3.5/json/encoder.py", line 179, in default
raise TypeError(repr(o) + " is not JSON serializable")
TypeError: <pyecharts.echarts.label.NormalLabel object at 0x7f183e0ece10> is not JSON serializable

chfw commented

pip freeze

请给出你的版本信息

解决了 pyecharts 的版本降级到0.4.0

astroid==1.6.3
borax==1.0.3
coverage==4.5.1
Django==2.0.4
django-chartit==0.2.9
django-echarts==0.3.5
django-markup-deprecated==0.0.3
docutils==0.14
dukpy==0.2.0
flake8==3.5.0
future==0.16.0
isort==4.3.4
javascripthon==0.10
Jinja2==2.10
jupyter-echarts-pypkg==0.1.0
lazy-object-proxy==1.3.1
lml==0.0.2
macropy3==1.1.0b2
MarkupSafe==1.0
mccabe==0.6.1
Pillow==5.1.0
pycodestyle==2.3.1
pyecharts==0.4.0
pyecharts-javascripthon==0.0.6
pyecharts-jupyter-installer==0.0.3
pyflakes==1.6.0
Pygments==2.2.0
pylint==1.8.4
pytz==2018.4
requirements==0.1
six==1.11.0
wrapt==1.10.11

chfw commented

0.5.3 应该也可以的

django-echarts 目前(最新 v0.3.x) 还不支持 pyecharts v0.5.x 。

参考: #18

chfw commented

请参照我的解决方案试试