| 203 | |
| 204 | |
| 205 | class Axes(Controls): |
| 206 | legend = param.Selector(default='bottom_right', objects=_hvConverter._legend_positions) |
| 207 | |
| 208 | logx = param.Boolean(default=False) |
| 209 | |
| 210 | logy = param.Boolean(default=False) |
| 211 | |
| 212 | height = param.Integer(default=None, bounds=(0, None)) |
| 213 | |
| 214 | width = param.Integer(default=None, bounds=(0, None)) |
| 215 | |
| 216 | responsive = param.Boolean(default=True) |
| 217 | |
| 218 | shared_axes = param.Boolean(default=True) |
| 219 | |
| 220 | xlim = param.Range() |
| 221 | |
| 222 | ylim = param.Range() |
| 223 | |
| 224 | logx = param.Boolean(default=False) |
| 225 | |
| 226 | logy = param.Boolean(default=False) |
| 227 | |
| 228 | def __init__(self, data, **params): |
| 229 | super().__init__(data, **params) |
| 230 | self._update_ranges() |
| 231 | |
| 232 | @param.depends('explorer.xlim', 'explorer.ylim', watch=True) |
| 233 | def _update_ranges(self): |
| 234 | xlim = self.explorer.xlim() |
| 235 | if xlim is not None and is_number(xlim[0]) and is_number(xlim[1]) and xlim[0] != xlim[1]: |
| 236 | xlim = self._convert_to_int(xlim) |
| 237 | self.param.xlim.precedence = 0 |
| 238 | self.param.xlim.bounds = xlim |
| 239 | else: |
| 240 | self.param.xlim.precedence = -1 |
| 241 | ylim = self.explorer.ylim() |
| 242 | if ylim is not None and is_number(ylim[0]) and is_number(ylim[1]) and ylim[0] != ylim[1]: |
| 243 | ylim = self._convert_to_int(ylim) |
| 244 | self.param.ylim.precedence = 0 |
| 245 | self.param.ylim.bounds = ylim |
| 246 | else: |
| 247 | self.param.ylim.precedence = -1 |
| 248 | |
| 249 | @staticmethod |
| 250 | def _convert_to_int(val): |
| 251 | """ |
| 252 | Converts datetime to int to avoid the error in https://github.com/holoviz/hvplot/issues/964. |
| 253 | |
| 254 | This function is a workaround and should be removed when a better solution is found. |
| 255 | |
| 256 | """ |
| 257 | |
| 258 | if isinstance(val[0], datetime_types) and isinstance(val[1], datetime_types): |
| 259 | val = (dt_to_int(val[0], 'ms'), dt_to_int(val[1], 'ms')) |
| 260 | |
| 261 | return val |
| 262 |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…