Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Timezone not respected in charts #1065

Open
kihra1 opened this issue Sep 8, 2023 · 2 comments
Open

Timezone not respected in charts #1065

kihra1 opened this issue Sep 8, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@kihra1
Copy link

kihra1 commented Sep 8, 2023

Expected Behavior

Charts would plot in same timezone as the data.

Actual Behavior

Charts are plotted in UTC, even though the source data was tz-aware of the form: 2023-06-15 08:30:00-05:00

@0sahil
Copy link

0sahil commented Jan 4, 2024

Any way to get the expected behaviour?

@kernc kernc added the bug Something isn't working label Feb 2, 2025
@kernc
Copy link
Owner

kernc commented Feb 2, 2025

df['datetime'] = df.index # Save original, maybe datetime index
df = df.reset_index(drop=True)

if is_datetime_index:
fig_ohlc.xaxis.formatter = CustomJSTickFormatter(
args=dict(axis=fig_ohlc.xaxis[0],
formatter=DatetimeTickFormatter(days='%a, %d %b',
months='%m/%Y'),
source=source),
code='''
this.labels = this.labels || formatter.doFormat(ticks
.map(i => source.data.datetime[i])
.filter(t => t !== undefined));
return this.labels[index] || "";
''')

So we either need to convert df['datetime'] to real UTC, or fix DatetimeTickFormatter to additionally format "%z". 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants