Enhancements:

- Added the `title` parameter to `Chart`.

Bug Fixes:
- When passing a timestamp format to `set`, `update`, or `update_from_tick`, the unit is now by default milliseconds rather than nanoseconds.
- When using `update`, if a time is passed that occurs before the current last datapoint, an error will be raised.
This commit is contained in:
louisnw
2023-11-22 17:31:35 +00:00
parent c3645ef245
commit 631afd450f
4 changed files with 18 additions and 12 deletions

View File

@ -210,7 +210,7 @@ class SeriesCommon(Pane):
def _single_datetime_format(self, arg):
if isinstance(arg, (str, int, float)) or not pd.api.types.is_datetime64_any_dtype(arg):
arg = pd.to_datetime(arg)
arg = pd.to_datetime(arg, unit='ms')
arg = self._interval * (arg.timestamp() // self._interval)+self.offset
return arg
@ -620,6 +620,11 @@ class Candlestick(SeriesCommon):
:param cumulative_volume: Adds the given volume onto the latest bar.
"""
series = self._series_datetime_format(series)
if series['time'] < self._last_bar['time']:
raise ValueError(
f'Trying to update tick of time "{pd.to_datetime(series["time"])}", '
f'which occurs before the last bar time of '
f'"{pd.to_datetime(self._last_bar["time"])}".')
bar = pd.Series()
if series['time'] == self._last_bar['time']:
bar = self._last_bar