Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@ venv/
*.rdb
coverage.xml
htmlcov/
.idea/
5 changes: 3 additions & 2 deletions echarts/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import logging
import tempfile
import webbrowser
import codecs
from .option import Base
from .option import Axis, Legend, Series, Tooltip, Toolbox, VisualMap
from .datastructure import *
Expand Down Expand Up @@ -91,7 +92,7 @@ def json(self):
return json

def _html(self):
with open(os.path.join(os.path.dirname(__file__), 'plot.j2')) as f:
with codecs.open(os.path.join(os.path.dirname(__file__), 'plot.j2'), encoding='utf8') as f:
template = f.read()
return template.replace('{{ opt }}', json.dumps(self.json, indent=4))

Expand All @@ -102,7 +103,7 @@ def plot(self, persist=True):
:param persist: persist output html to disk
"""
with tempfile.NamedTemporaryFile(suffix='.html', delete=not persist) as fobj:
fobj.write(self._html())
fobj.write(self._html().encode('utf8'))
fobj.flush()
webbrowser.open('file://' + os.path.realpath(fobj.name))
persist or raw_input('Press enter for continue')
Expand Down