-
Notifications
You must be signed in to change notification settings - Fork 124
Open
Description
# -*- coding: utf-8 -*-
from echarts import Echart, Legend, Bar, Axis
chart = Echart(u'GDP',u'This is a fake chart')
chart.use(Bar('China',[2, 3, 4, 5]))
chart.use(Legend(['GDP']))
chart.use(Axis('category', 'bottom', data=['Nov', 'Dec', 'Jan', 'Feb']))
chart.plot()
报错:
Traceback (most recent call last):
File "C:\Program Files\Python36\echats.py", line 8, in <module>
chart.plot()
File "C:\Program Files\Python36\lib\site-packages\echarts\__init__.py", line 105, in plot
fobj.write(self._html())
File "C:\Program Files\Python36\lib\site-packages\echarts\__init__.py", line 95, in _html
template = f.read()
UnicodeDecodeError: 'gbk' codec can't decode byte 0xa4 in position 250: illegal multibyte sequence
按提示改了下:~Python36\lib\site-packages\echarts_init_.py -->
def _html(self):
with open(os.path.join(os.path.dirname(__file__), u'plot.j2'),'rb') as f:
template = f.read()
return template.replace(bytes('{{ opt }}',encoding='utf-8'),bytes(json.dumps(self.json, indent=4),encoding='utf-8'))
然后正常运行;
JxSx and Eajack
Metadata
Metadata
Assignees
Labels
No labels