taipy
taipy copied to clipboard
Better way to handle time zone (charts)
Description To avoid delays in dates for chart, the user has to manually localize dataframe columns of date to 'UTC'. It is making the code heavier and less natural.
The problem comes from Plotly. We want to make sure, from time to time, that there's nothing we can do and take this issue back to the New Issues column if there's no news...
How to replicate
Run this code:
from taipy.gui import Gui
import taipy.gui.builder as tgb
import numpy as np
import pandas as pd
# create data with Dates
data = pd.DataFrame(
{
"Date": pd.date_range("2020-01-01", periods=5, freq="M", tz="Europe/Paris"),
"Value": np.random.rand(5),
}
)
with tgb.Page() as page:
tgb.chart("{data}", x="Date", y="Value", height="800px")
tgb.table("{data}")
print(data)
Gui(page).run(use_reloader=True, port=5003, title="Date issue")
You will see differences in the chart between the dates if you compare the chart and the table.
Acceptance Criteria
- [ ] Ensure new code is unit tested, and check code coverage is at least 90%
- [ ] Propagate any change on the demos and run all of them to ensure there is no breaking change
- [ ] Ensure any change is well documented
https://github.com/plotly/plotly.js/issues/1956 https://github.com/plotly/plotly.js/issues/1532
An easy workaround to this issue is to apply the string format for the Date column to avoid putting the timezone to 'UTC'.