| 280 | _template = Template("") |
| 281 | |
| 282 | def __init__( |
| 283 | self, |
| 284 | data: Any, |
| 285 | width: Union[int, str, None] = None, |
| 286 | height: Union[int, str, None] = None, |
| 287 | left: Union[int, str] = "0%", |
| 288 | top: Union[int, str] = "0%", |
| 289 | position: str = "relative", |
| 290 | ): |
| 291 | super(self.__class__, self).__init__() |
| 292 | self._name = "VegaLite" |
| 293 | self.data = data.to_json() if hasattr(data, "to_json") else data |
| 294 | if isinstance(self.data, str): |
| 295 | self.data = json.loads(self.data) |
| 296 | |
| 297 | self.json = json.dumps(self.data) |
| 298 | |
| 299 | # Size Parameters. |
| 300 | self.width = _parse_size( |
| 301 | self.data.get("width", "100%") if width is None else width |
| 302 | ) |
| 303 | self.height = _parse_size( |
| 304 | self.data.get("height", "100%") if height is None else height |
| 305 | ) |
| 306 | self.left = _parse_size(left) |
| 307 | self.top = _parse_size(top) |
| 308 | self.position = position |
| 309 | |
| 310 | def render(self, **kwargs): |
| 311 | """Renders the HTML representation of the element.""" |