Applies self.style_function to each feature of self.data.
(self)
| 1064 | self.add_child(Tooltip(tooltip)) |
| 1065 | |
| 1066 | def style_data(self) -> None: |
| 1067 | """Applies self.style_function to each feature of self.data.""" |
| 1068 | |
| 1069 | def recursive_get(data, keys): |
| 1070 | if len(keys): |
| 1071 | return recursive_get(data.get(keys[0]), keys[1:]) |
| 1072 | else: |
| 1073 | return data |
| 1074 | |
| 1075 | geometries = recursive_get(self.data, self.object_path.split("."))[ |
| 1076 | "geometries" |
| 1077 | ] # noqa |
| 1078 | for feature in geometries: |
| 1079 | feature.setdefault("properties", {}).setdefault("style", {}).update( |
| 1080 | self.style_function(feature) |
| 1081 | ) # noqa |
| 1082 | |
| 1083 | def render(self, **kwargs): |
| 1084 | """Renders the HTML representation of the element.""" |