Skip to content

Commit

Permalink
Switch from iPython HTML to IFrame
Browse files Browse the repository at this point in the history
  • Loading branch information
palewire authored Jan 28, 2024
1 parent b68e5f2 commit 2d1581e
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions datawrapper/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

import pandas as pd
import requests as r
from IPython.display import HTML, Image
from IPython.display import IFrame, Image

from .exceptions import FailedRequest, InvalidRequest

Expand Down Expand Up @@ -922,7 +922,7 @@ def delete_chart(self, chart_id: str) -> bool:
"""
return self.delete(f"{self._CHARTS_URL}/{chart_id}")

def display_chart(self, chart_id: str) -> HTML:
def display_chart(self, chart_id: str) -> IFrame:
"""Displays a datawrapper chart.
Parameters
Expand All @@ -932,12 +932,12 @@ def display_chart(self, chart_id: str) -> HTML:
Returns
-------
IPython.display.HTML
HTML displaying the chart.
IPython.display.IFrame
IFrame displaying the chart.
"""
obj = self.get_chart(chart_id)
iframe = obj["metadata"]["publish"]["embed-codes"]["embed-method-iframe"]
return HTML(iframe)
return IFrame(iframe)

def copy_chart(self, chart_id: str) -> dict:
"""Copy one of your charts, tables, or maps and create a new editable copy.
Expand Down Expand Up @@ -988,7 +988,7 @@ def move_chart(self, chart_id: int, folder_id: int) -> dict:
data={"folderId": folder_id},
)

def publish_chart(self, chart_id: str, display: bool = False) -> dict | HTML:
def publish_chart(self, chart_id: str, display: bool = False) -> dict | IFrame:
"""Publishes a chart, table or map.
Parameters
Expand All @@ -1000,8 +1000,8 @@ def publish_chart(self, chart_id: str, display: bool = False) -> dict | HTML:
Returns
-------
dict | HTML
Either a dictionary containing the published chart's information or an HTML
dict | IFrame
Either a dictionary containing the published chart's information or an IFrame
object displaying the chart.
"""
obj = self.post(f"{self._CHARTS_URL}/{chart_id}/publish")
Expand All @@ -1010,7 +1010,7 @@ def publish_chart(self, chart_id: str, display: bool = False) -> dict | HTML:
iframe = obj["data"]["metadata"]["publish"]["embed-codes"][
"embed-method-iframe"
]
return HTML(iframe)
return IFrame(iframe)
else:
return obj

Expand Down

0 comments on commit 2d1581e

Please sign in to comment.