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

fix(stream_file): fix bug #348

Merged
merged 4 commits into from
Feb 2, 2024
Merged
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 CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Add reference_path to all Primitive / Elementary drawing Objects
- Remove data attr from class Arc in Python
- Light improvement of class Arc in Python
- Html stream method

## [0.21.0]
### Add
Expand Down
4 changes: 2 additions & 2 deletions plot_data/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,12 @@ def _to_html(self, debug_mode: bool = False, canvas_id: str = 'canvas', version:
def to_html_stream(self, stream, debug_mode: bool = False, canvas_id: str = 'canvas', version: str = None):
""" Export current Figure to its equivalent html stream file. """
html = self._to_html(debug_mode=debug_mode, canvas_id=canvas_id, version=version)
stream.write(html.encode('utf-8'))
stream.write(html)

def to_html(self, filepath: str = None, debug_mode: bool = False, canvas_id: str = 'canvas', version: str = None):
""" Export current Figure to an HTML file given by the filepath. """
filepath = make_filepath(filepath=filepath)
with open(filepath, 'wb') as file:
with open(filepath, 'w', encoding="utf-8") as file:
self.to_html_stream(file, debug_mode=debug_mode, canvas_id=canvas_id, version=version)
return filepath

Expand Down